May-06-2021, 03:07 PM
Hi all
I am new of Python and I need some help in the development of a tensor through these lines:
How could I obtain it? I also tried something like that but with no success:
the error is:
I am new of Python and I need some help in the development of a tensor through these lines:
index_0=0#i index_1=0#j index_2=0#k index_3=0#w DD = np.zeros((100,100,100,100)) for i in Lunghezza_m: for j in Larghezza_m: for k in Parameter2: for w in Velocità_nodi: DD[index_0][index_1][index_2][index_3]=round(1.025*i*j*Immersa_m[index_1][index_2]*Cb[index_0][index_3],2) index_3+=1 index_3=0 index_2+=1 index_3=0 index_2=0 index_1+=1 index_3=0 index_2=0 index_1=0 index_0+=1Where Immersa_m and Cb are two rectangular matrices, instead Lunghezza_m, Larghezza_m, Parameter2 and Velocità_nodi are arrays. Obviously DD will be a tensor.
How could I obtain it? I also tried something like that but with no success:
the error is:
IndexError Traceback (most recent call last) <ipython-input-39-71f7f1b76435> in <module> 60 for k in Parameter2: 61 for w in Velocità_nodi: ---> 62 DD[index_0][index_1][index_2][index_3]=round(1.025*i*j*Immersa_m[index_1][index_2]*Cb[index_0][index_3],2) 63 index_3+=1 64 index_3=0 IndexError: invalid index to scalar variable.Thank you for the help!!