Home
Products
Support
Blog
Resources
Company
NMath Matrix User's Guide
TOC |  Previous |  Next |  Index

6.2 Creating Least Squares Objects

NMath Matrix provides least squares classes for four datatypes: single- and double-precision floating point numbers, and single- and double-precision complex numbers. The classnames are shown in Table 6.

Table 6 - Least squares classes
Least Squares Method
Classes
Cholesky
QR Decomposition
SVD

Instances of the least squares classes are constructed from general matrices of the appropriate datatype. For example, this code creates a FloatCholeskyLeastSq from a FloatMatrix:

FloatMatrix A = new FloatMatrix( "4x2[ 1 0  0 1  0 0  0 0 ]" );
FloatCholeskyLeastSq lsq = new FloatCholeskyLeastSq( A );

QR and SVD least squares classes also provide constructor overloads that accept a tolerance value. The specified tolerance is used in computing the numerical rank of the matrix. For example, if is the QR factorization of a matrix A, then elements on the main diagonal of R are considered to be zero if their absolute value is less than or equal to the tolerance. Similarly, in singular value decomposition, all singular values of the matrix A less than the tolerance are set to zero. Thus, this code sets all singular values less than 10-13 to zero:

DoubleMatrix A = new DoubleMatrix( "4x2[ 1 0  0 1  0 0  0 0 ]" );
DoubleSVDLeastSq lsq = new DoubleSVDLeastSq( A, 1e-13 );

TOC |  Previous |  Next |  Index

Copyright © 2008 CenterSpace Software, LLC. All rights reserved.
All trademarks and registered trademarks mentioned on this web site are the property of their respective owners.
Contact Webmaster