numpy Linear algebra with np.linalg

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Remarks

As of version 1.8, several of the routines in np.linalg can operate on a 'stack' of matrices. That is, the routine can calculate results for multiple matrices if they're stacked together. For example, A here is interpreted as two stacked 3-by-3 matrices:

np.random.seed(123)
A = np.random.rand(2,3,3)
b = np.random.rand(2,3)
x = np.linalg.solve(A, b)

print np.dot(A[0,:,:], x[0,:])
# array([ 0.53155137,  0.53182759,  0.63440096])

print b[0,:]
# array([ 0.53155137,  0.53182759,  0.63440096])

The official np docs specify this via parameter specifications like a : (..., M, M) array_like.



Got any numpy Question?