Singular Value Decomposition

The Singular-Value Decomposition is a matrix decomposition method for reducing a matrix to its constituent parts to make specific subsequent matrix calculations simpler. It is calculated using scipy.linalg.svd.

Syntax: scipy.linalg.svd(a , full_matrices , compute_uv , overwrite_a , check_finite , lapack_driver)

Parameters:

  • a: The input matrix.
  • full_matrices (Optional): If True, the two decomposed unitary matrices of the input matrix are of shape (M, M), (N, N).
  • compute_uv (Optional): The default value is True.
  • overwrite_a (Optional): It grants permission to overwrite data in a.
  • check_finite (Optional): It checks if the input matrix consists of only finite numbers.
  • lapack_driver (Optional): It takes either the divide-and-conquer approach (‘gesdd’) or general rectangular approach (‘gesvd’).

The function scipy.linalg.svd takes a matrix M to decompose and returns:

  1. A Unitary matrix having left singular vectors as columns.
  2. The singular values sorted in non-increasing order.
  3. A unitary matrix having right singular vectors as rows.

Example:

Python




# Importing the required libraries
from scipy import linalg
import numpy as np
  
# Initializing the matrix M
M = np.array([[1 , 5] , [6 , 10]]) 
  
# Passing the values to the 
# eigen function
x , y , z = linalg.svd(M)
print(x , y , z)


Output:

SciPy Linear Algebra – SciPy Linalg

The SciPy package includes the features of the NumPy package in Python. It uses NumPy arrays as the fundamental data structure. It has all the features included in the linear algebra of the NumPy module and some extended functionality. It consists of a linalg submodule, and there is an overlap in the functionality provided by the SciPy and NumPy submodules.

Let’s discuss some methods provided by the module and its functionality with some examples.

Similar Reads

Solving the linear equations

The linalg.solve function is used to solve the given linear equations. It is used to evaluate the equations automatically and find the values of the unknown variables....

Calculating the Inverse of a Matrix

...

Calculating the Pseudo Inverse of a Matrix

The scipy.linalg.inv is used to find the inverse of a matrix....

Finding the Determinant of a Matrix

...

Singular Value Decomposition

To evaluate the (Moore-Penrose) pseudo-inverse of a matrix, scipy.linalg.pinv is used....

Eigenvalues and EigenVectors

...

Calculating the norm

The determinant of a square matrix is a value derived arithmetically from the coefficients of the matrix. In the linalg module, we use the linalg.det() function to find the determinant of a matrix....

More Matrix Functions

...