Overview:
- The function linalg.svdvals() calculates the singular values of one or more matrices and returns the results as an ndarray.
- The returned ndarray excludes the orthogonal matrices U, V obtained from the factorization the array A using Singular Value Decomposition.
Example:
# Example Python program that finds the singular values of # Create an upper triangular matrix upperTriangular[1][0] = 0 print("Matrix 1:") # Create a lower triangular matrix lowerTriangular[0][1] = 0 print("Matrix 2:") svdValues = numpy.linalg.svdvals([upperTriangular, lowerTriangular]) print("Singular values of matrix 1:") print("Singular values of matrix 2:") |
Output:
Matrix 1: [[ 1 3 5] [ 0 9 11] [ 0 0 17]] Matrix 2: [[ 2 0 0] [ 8 10 0] [14 16 18]] Singular values of matrix 1: [21.66412661 7.46801882 0.94568139] Singular values of matrix 2: [29.67443546 7.81125888 1.55309851] |