NMath User's Guide

TOC |  Previous |  Next |  Index

7.4 Static Methods (.NET, C#, CSharp, Visual Basic, VB.NET)

As a convenience, NMath provides static methods on class NMathFunctions for solving linear systems, and for computing determinants, inverses, and condition numbers. All methods accept a matrix.

The following static methods are provided:

For instance:

DoubleMatrix A = new DoubleMatrix( "3x3 [2 1 1  4 1 0 -2 2 1]" );

DoubleVector b = new DoubleVector( "[8 11 3]" );
DoubleVector x = NMathFunctions.Solve( A, b );
     
DoubleMatrix B = new DoubleMatrix( "3x2[8 3  11 11  3 8]" );
DoubleMatrix X = NMathFunctions.Solve( A, B );

DoubleMatrix AInv = NMathFunctions.Inverse( A );
double ADet = NMathFunctions.Determinant( A );
double ACond =
   NMathFunctions.ConditionNumber( A, NormType.InfinityNorm );

Note that an an LU factorization instance is created with each call to NMathFunctions.Solve(). If you are calling Solve() repeatedly (inside a loop, for example), and the coefficient matrix is not changing between calls, this is more efficient:

DoubleLUFact fact = new DoubleLUFact( A, false );
...
fact.Solve( B );

TOC |  Previous |  Next |  Index