# NMath User's Guide

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

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:

NMathFunctions.Solve() solves linear systems for single or multiple right-hand sides.

NMathFunctions.Inverse() computes the inverse of a given matrix.

NMathFunctions.Determinant() computes the determinant of a given matrix.

NMathFunctions.EstimateConditionNumber() estimates the condition number of a given matrix in the specified norm type.

NMathFunctions.ConditionNumber() directly computes the condition number of a given matrix in the specified norm type.

For instance:

Code Example – C# LU factorization

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

var b = new DoubleVector( "[8 11 3]" );
DoubleVector x = NMathFunctions.Solve( A, b );

var 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 );
```

Code Example – VB LU factorization

```Dim A As New DoubleMatrix("3x3 [2 1 1  4 1 0 -2 2 1]")

Dim B As New DoubleVector("[8 11 3]")
Dim X As DoubleVector = NMathFunctions.Solve(A, B)

Dim B As New DoubleMatrix("3x2[8 3  11 11  3 8]")
Dim X As DoubleMatrix = NMathFunctions.Solve(A, B)

Dim AInv As DoubleMatrix = NMathFunctions.Inverse(A)
Dim ADet As Double = NMathFunctions.Determinant(A)
Dim ACond As Double =
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:

Code Example – C# LU factorization

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

Code Example – VB LU factorization

```Dim Fact As New DoubleLUFact(A, False)
...
Fact.Solve(B)

```

Top

Top