I want to multiply a 1x1 matrix by an 8x8 matrix. Obviously I know that you cannot multiply matrices of these two shapes. My question is how to I "extract" the value from the 1x1 matrix so that it's equivalent to multiplying the 8x8 matrix by a scalar. In other words is there a way to turn the 1x1 matrix into a scalar?
Here's my code so far, where n
is my 1x1 matrix and flux
is my 8x8 matrix:
n=0
for i in range(delta_E.shape[0]):
n+= 100/(210*(Sig_f_cell[i])*flux[i]*delta_E[i]*(1.6022e-13)*V_core)
flux = (np.linalg.inv(L))*G
Goal: to multiply flux by the value of n
It appears that n is a scalar but when I multiply them I get this error:
ValueError Traceback (most recent call last)
<ipython-input-26-0df98fb5a138> in <module>()
----> 1 Design_Data (1.34,.037,90)
<ipython-input-25-5ef77d3433bc> in Design_Data(pitch, Pu_fraction, FE_length)
201 print('Number of fuel elements : ',N_FE)
202
--> 203 return n*flux
204
C:\Users\Katey\Anaconda3\lib\site-packages\numpy\matrixlib\defmatrix.py in __mul__(self, other)
341 if isinstance(other, (N.ndarray, list, tuple)) :
342 # This promotes 1-D vectors to row vectors
--> 343 return N.dot(self, asmatrix(other))
344 if isscalar(other) or not hasattr(other, '__rmul__') :
345 return N.dot(self, other)
ValueError: shapes (1,1) and (8,1) not aligned: 1 (dim 1) != 8 (dim 0)
I have also tried just multiplying n[0]*flux
and I get the same error .