MatrixHelper<T>
Helpers & Utilities · AiDotNet.Helpers
Provides helper methods for matrix operations used in AI and machine learning algorithms.
For Beginners
A matrix is a rectangular array of numbers arranged in rows and columns. Matrices are fundamental in machine learning for representing data, transformations, and mathematical operations.
Methods
| Method | Summary |
|---|---|
Matrix<T> ApplyHouseholderTransformation(Matrix<T> matrix, Vector<T> vector, int k) |
Applies a Householder transformation to a matrix. |
Matrix<T> CalculateHatMatrix(Matrix<T> features) |
Calculates the Hat Matrix (also known as the projection matrix) used in regression analysis. |
Matrix<T> InvertUsingDecomposition(IMatrixDecomposition<T> decomposition) |
Inverts a matrix using a provided matrix decomposition. |
Matrix<T> OrthogonalizeColumns(Matrix<T> matrix) |
Orthogonalizes the columns of a matrix using the Gram-Schmidt process. |
Matrix<T> OuterProduct(Vector<T> v1, Vector<T> v2) |
Computes the outer product of two vectors. |
Matrix<T> ReduceToHessenbergFormat(Matrix<T> matrix) |
Reduces a matrix to Hessenberg form, which is useful for eigenvalue calculations. |
T CalculateDeterminantRecursive(Matrix<T> matrix) |
Calculates the determinant of a matrix using a recursive algorithm. |
T Hypotenuse(T x, T y) |
Calculates the hypotenuse of a right triangle given the lengths of the other two sides. |
T Hypotenuse(T[] values) |
Calculates the Euclidean norm (magnitude) of a vector of values. |
T SpectralNorm(Matrix<T> matrix) |
Calculates the spectral norm of a matrix, which is the largest singular value. |
ValueTuple<T, T> ComputeGivensRotation(T a, T b) |
Computes the cosine and sine components of a Givens rotation. |
ValueTuple<T, Vector<T>> PowerIteration(Matrix<T> aMatrix, int maxIterations, T tolerance) |
Implements the power iteration algorithm to find the dominant eigenvalue and eigenvector of a matrix. |
Vector<T> CreateHouseholderVector(Vector<T> xVector) |
Creates a Householder vector from a given vector. |
Vector<T> ExtractDiagonal(Matrix<T> matrix) |
Extracts the diagonal elements of a matrix into a vector. |
bool IsInvertible(Matrix<T> matrix) |
Determines if a matrix is invertible (non-singular). |
bool IsUpperHessenberg(Matrix<T> matrix, T tolerance) |
Determines if a matrix is in upper Hessenberg form within a specified tolerance. |
void ApplyGivensRotation(Matrix<T> H, T c, T s, int i, int j, int kStart, int kEnd) |
Applies a Givens rotation to specific rows of a matrix. |
void BandDiagonalMultiply(int leftSide, int rightSide, Matrix<T> matrix, Vector<T> solutionVector, Vector<T> actualVector) |
Multiplies a band diagonal matrix by a vector. |
void TridiagonalSolve(Vector<T> vector1, Vector<T> vector2, Vector<T> vector3, Vector<T> solutionVector, Vector<T> actualVector) |
Solves a tridiagonal system of linear equations. |