CenterSpace Software .NET Numerics
NMath Matrix User's Guide Version 2.3
 


4.2 Creating Factorizations

You can create an instance of a factorization class by supplying the constructor with a matrix to factor. This code creates a 12 x 12 FloatBandMatrix, with upper bandwidth of 1 and lower bandwidth of 2 and values generated randomly from the interval -1 to 1, then factors the matrix using the FloatBandFact class constructor:


int rows = 12, cols = 12, ub = 1, lb = 2;

FloatVector data =

   new FloatVector( cols*(ub+lb+1), new RandGenUniform(-1, 1) );

FloatBandMatrix A =

   new FloatBandMatrix( data, rows, cols, lb, ub );



FloatBandFact F = new FloatBandFact( A );

You can also use an existing instance to factor other matrices with the provided Factor() method. Thus, if B is another FloatBandMatrix:


F.Factor( B );

The read-only IsGood property gets a boolean value that is true if the matrix factorization succeeded and the factorization may be used to solve equations, compute determinants, inverses, and so on. Otherwise, it returns false. For example:


if ( F.IsGood )

{

   // Do something here...

}

Other read-only properties provide information about the matrix used to construct an factorization:

  • Cols gets the number of columns of the factored matrix.

  • Rows gets the number of rows of the factored matrix.

  • On indefinite factorization classes, IsSingular returns true if the matrix was singular; otherwise, false.

  • On positive definite factorization classes, IsPositiveDefinite returns true if the matrix was positive definite; otherwise, false.



 

Copyright © 2003-2008 CenterSpace Software, LLC. All rights reserved.