package com.imsl.test.example.math; import com.imsl.math.*; /** *
* Computes the SVD factorization of a matrix.
* The singular value decomposition of a matrix is performed. The rank of the * matrix is also computed. * * @see Code * @see Output */ public class SVDEx1 { public static void main(String args[]) throws SVD.DidNotConvergeException { double a[][] = { {1, 2, 1, 4}, {3, 2, 1, 3}, {4, 3, 1, 4}, {2, 1, 3, 1}, {1, 5, 2, 2}, {1, 2, 2, 3} }; // Compute the SVD factorization of A SVD svd = new SVD(a); // Print U, S and V. new PrintMatrix("U").print(svd.getU()); new PrintMatrix("S").print(svd.getS()); new PrintMatrix("V").print(svd.getV()); // Find the rank of A. int rank = svd.getRank(); System.out.println("rank = " + rank); } }