Overview:
-
The function svd() from the linalg module of NumPy library calculates the singular values of an input array A and returns the results contained in an SVDResult instance.
-
The first ndarray in the SVDResult instance contains the left singular vector.
-
The second ndarray in the SVDResult instance contains the singular values of the given array A.
-
The third ndarray in the SVDResult instance contains the right singular vector.
Singular Value Decomposition:
-
Using singular value decomposition the matrix A of size mxn is factorized into
-
An orthogonal matrix U of dimension mxm.
-
A complex conjugate(also known as Hermitian transpose) of orthogonal matrix V of dimension nxn
-
A diagonal matrix Σ of dimension mxn, containing singular values on its diagonal
-
as given by
A = UΣV*
-
Unlike eigenvalues which are defined only for square matrices, singular values can be found for both square matrices and rectangular matrices.
-
The singular values are non-negative real numbers.
-
V*- Complex conjugate of V.
Note:
Orthogonal matrix: An orthogonal matrix is a matrix when multiplied by its transpose results in an identity matrix.
Identity matrix: An identity matrix is a matrix whose diagonal elements are with the value one. An identity matrix is a diagonal matrix.
Diagonal matrix: A diagonal matrix is a matrix whose elements are all ones or zeroes on its diagonal.
Example:
# Example Python program that obtains the singular values of # Create a 2x2 square matrix a1[0][0] = 2 # Obtain the singular values of the matrix print("Left singular vector:") print("Right singular vector:") print("Singular values of the matrix:") |
Output:
<class 'numpy.linalg._linalg.SVDResult'> |
Applications of Singular Value Decomposition:
-
Image processing
-
Text analysis