Skip to main content
`Ctrl`+`K`

# scipy.linalg.diagsvd

scipy.linalg.diagsvd(s, M, N)

  Construct the sigma matrix in SVD from singular values and size M, N.

  Parameters:
    s(M,) or (N,) array_like

      Singular values

    M int

      Size of the matrix whose singular values are s.

    N int

      Size of the matrix whose singular values are s.

  Returns:
    S(M, N) ndarray

      The S-matrix in the singular value decomposition

  See also

  `svd`

    Singular value decomposition of a matrix

  `svdvals`

    Compute singular values of a matrix.

  Examples

      >>> import numpy as np
      >>> from scipy.linalg import diagsvd
      >>> vals = np.array([1, 2, 3])  # The array representing the computed svd
      >>> diagsvd(vals, 3, 4)
      array([[1, 0, 0, 0],
             [0, 2, 0, 0],
             [0, 0, 3, 0]])
      >>> diagsvd(vals, 4, 3)
      array([[1, 0, 0],
             [0, 2, 0],
             [0, 0, 3],
             [0, 0, 0]])