Table of Contents

Class MatrixSolutionHelper

Namespace
AiDotNet.Helpers
Assembly
AiDotNet.dll

Provides methods for solving linear systems of equations using various matrix decomposition techniques.

public static class MatrixSolutionHelper
Inheritance
MatrixSolutionHelper
Inherited Members

Remarks

For Beginners: A linear system is a collection of linear equations with the same variables. For example: 2x + 3y = 5 and 4x - y = 1 form a linear system. In matrix form, this is written as Ax = b, where A is the coefficient matrix, x is the vector of variables we're solving for, and b is the vector of constants. This helper class provides different ways to solve for x given A and b.

Methods

SolveLinearSystem<T>(Matrix<T>, Vector<T>, MatrixDecompositionType)

Solves a linear system of equations Ax = b using the specified decomposition method.

public static Vector<T> SolveLinearSystem<T>(Matrix<T> A, Vector<T> b, MatrixDecompositionType decompositionType)

Parameters

A Matrix<T>

The coefficient matrix of the linear system.

b Vector<T>

The constant vector of the linear system.

decompositionType MatrixDecompositionType

The matrix decomposition method to use for solving the system.

Returns

Vector<T>

The solution vector x that satisfies Ax = b.

Type Parameters

T

The numeric type used in the matrices and vectors.

Remarks

For Beginners: This method solves equations of the form Ax = b, where A is a matrix, and b is a vector. Think of it like solving multiple equations at once. The "decomposition type" is just the mathematical approach used to solve the system. Different approaches work better for different types of problems. For example: - LU works well for general square matrices - Cholesky is faster but only works for symmetric, positive-definite matrices - SVD is more robust but slower, and works even for non-square matrices

Exceptions

NotSupportedException

Thrown when an unsupported decomposition type is used.

ArgumentException

Thrown when the decomposition type is not recognized.

SolveLinearSystem<T>(Vector<T>, IMatrixDecomposition<T>)

Solves a linear system using a pre-computed matrix decomposition.

public static Vector<T> SolveLinearSystem<T>(Vector<T> b, IMatrixDecomposition<T> decompositionMethod)

Parameters

b Vector<T>

The constant vector of the linear system.

decompositionMethod IMatrixDecomposition<T>

The pre-computed matrix decomposition to use.

Returns

Vector<T>

The solution vector x that satisfies Ax = b.

Type Parameters

T

The numeric type used in the matrices and vectors.

Remarks

For Beginners: This method is useful when you've already decomposed your matrix A and want to solve for multiple different b vectors without repeating the decomposition. This is more efficient because matrix decomposition is usually the most time-consuming part of solving a linear system.