In numpyTypes and
Type, the former is an array type, and the latter is a matrix type. Multiplication of array type is multiplication by element, while multiplication of matrix type is matrix multiplication.
Use the followingType to solve linear algebra problems.
Transposition of matrix:
import numpy as np A = ([[1, 2], [3, 4]]) A_T = print(A_T)
Matrix multiplication:
(A, B)
OrA @ B
import numpy as np A = ([[1, 2], [3, 4]]) B = ([[5, 6], [7, 8]]) C = (A, B) print(C) D = A @ B print(D)
Inverse matrix:
(A)
import numpy as np A = ([[1, 2], [3, 4]]) inv_A = (A) print(inv_A)
Solve the determinant:
(A)
import numpy as np A = ([[1, 2], [3, 4]]) det_A = (A) print(det_A)
The rank sum trace of the matrix:
The rank of the matrixis the maximum number of rows (or columns) linearly independent of the matrix, which reflects the "non-zero" of the matrix.Matrix tracesIt is the sum of elements on its main diagonal.
Solve the rank of the matrix:.matrix_rank(A)
Solve the traces of the matrix:(A)
Solving the traces of the matrix is used to calculate the sum of elements on the main diagonal of the matrix, which is more general. So there is no module in the linalg.
import numpy as np A = ([[1, 2], [3, 4]]) rank_A = .matrix_rank(A) print(rank_A) tr_A = (A) print(tr_A)
Solve linear equation systems:
(A, b)
import numpy as np A = ([[1, 2], [3, 4]]) b = ([1, 2]) # A x = b x = (A, b) print(x)
Calculate eigenvalues and eigenvectors:
Eigenvalue, eigenvector = (A)
import numpy as np A = ([[1, 2], [3, 4]]) eigenvalues, eigenvectors = (A) print(eigenvalues) print(eigenvectors)
Singular value decomposition:
Singular Value Decomposition (SVD) is an important matrix decomposition method in linear algebra. It decomposes a matrix into three specific products of matrices that have clear geometric and algebraic significance. For any real matrix A of m∗n, its singular value decomposition can be expressed as:
A = USVT
U, S, Vt = (A)
import numpy as np A = ([[1, 2], [3, 4]]) U, S, Vt = (A) print(U,S,Vt)
This is the end of this article about numpy solving linear algebra related problems. For more related content on numpy to solve linear algebra, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!