I am Stuggling with using the numpy.linalg.inv() function in Python. I populate 4 matrices by fetching certain elements in a nested for loop from a larger ZMatrix. As follows
#populating arrays for Zp
for k1 in range(3):
for m1 in range(3):
Za[k1][m1] = ZMatrix[k1][m1]
for k1 in range(3,4):
for m1 in range(0,2):
Zb[k1-3][m1] = ZMatrix[k1][m1]
for k1 in range(0,2):
for m1 in range(3,4):
Zc[k1][m1-3] = ZMatrix[k1][m1]
for k1 in range(3,4):
for m1 in range(3,4):
Zd[k1-3][m1-3] = ZMatrix[k1][m1]
Then I want to do the following calculation
ZpMatrix = Za-(Zb*np.linalg.inv(Zd)*Zc)
And it throws the error:
LinAlgError: Singular matrix
How can I go about doing the calculations that I would like to, without this error.
Thank you very much