list_of_arrays = [a,[split[12]]]
a = np.array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2000, 0 ,0])
resultnew = []
output = a
for i in list_of_arrays[1:]:
output = output@i
resultnew.append(output)
I need help I am trying to multiply a by an array list containing 50 16x16 matrices.Example starting from split[12] (the 13th matrix in the list) , multiplied by a, and then taking the result and multiplying it by split[13], continuing until split[50] is reached.I need the output appended for each iterration.
CodePudding user response:
Maybe you are using an older version of numpy
that doesn't support the @
(matmul
) operator, which leads to the error. Or maybe your arrays are somehow python objects, not numbers (you don't show enough code for me to guess why).
If your numpy
versions supports @
, the following should work:
output = a
for arr in split[12:51]:
output = output@arr
resultnew.append(output)
If not, you could explicitly use matmul
:
output = np.matmul(output, arr)