Linux Assemblycollection of fast libraries

Matrix libraryMatrix.h

In mathematics, a matrix is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns, that is treated in certain prescribed ways. The individual items in a matrix are called its elements or entries. A major application of matrices is to represent linear transformations. For example, the rotation of vectors in three dimensional space is a linear transformation which can be represented by a rotation matrix. Another application of matrices is in the solution of systems of linear equations. If the matrix is square, it is possible to deduce some of its properties by computing its determinant. For example, a square matrix has an inverse if and only if its determinant is not zero. Insight into the geometry of a linear transformation is obtainable (along with other information) from the matrix's eigenvalues and eigenvectors.

Applications of matrices are found in most scientific fields. In every branch of physics, including classical mechanics, optics, electromagnetism they are used to study physical phenomena, such as the motion of rigid bodies. In computer graphics, they are used to project a 3-dimensional image onto a 2-dimensional screen. In probability theory and statistics, stochastic matrices are used to describe sets of probabilities. Matrix calculus generalizes classical analytical notions such as derivatives and exponentials to higher dimensions.

Contents

Function list

C function nameFunctionsC++ function nameFunctions
Add4 functionsAdd4 functions
CholeskyLow2 functionsCholeskyLow2 functions
CholeskyUp2 functionsCholeskyUp2 functions
Copy4 functionsCopy4 functions
DeterminantDiagonal4 functionsDeterminantDiagonal4 functions
DeterminantSquareLow4 functionsDeterminantSquareLow4 functions
DeterminantSquareUp4 functionsDeterminantSquareUp4 functions
DeterminantTriangular4 functionsDeterminantTriangular4 functions
Div4 functionsDiv4 functions
GaussLow4 functionsGaussLow4 functions
GaussUp4 functionsGaussUp4 functions
InitDiagonal4 functionsInitDiagonal4 functions
InitRectangle4 functionsInitRectangle4 functions
InverseLow4 functionsInverseLow4 functions
InverseUp4 functionsInverseUp4 functions
Mul4 functionsMul4 functions
MulMatrix4 functionsMulMatrix4 functions
Neg4 functionsNeg4 functions
Sub4 functionsSub4 functions
Transpose4 functionsTranspose4 functions
C function nameFunctionsC++ function nameFunctions

Initialization

Init functions set matrix elements by the specified value. They may be used for fast creating zero and identity matrices.

Initialization of rectangle matrix

Cvoid Matrix_InitRectangle_flt32 (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix_InitRectangle_flt64 (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix_InitRectangle_cmplx32 (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix_InitRectangle_cmplx64 (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);
C++void Matrix::InitRectangle (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix::InitRectangle (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix::InitRectangle (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix::InitRectangle (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);

Description: Init all matrix elements with specified value.

Parameters:

  • matrix - pointer to the matrix
  • rows - count of matrix rows
  • cols - count of matrix columns
  • value - initialization value for all elements

Return value: None.

Initialization of diagonal matrix

Cvoid Matrix_InitDiagonal_flt32 (flt32_t matrix[], size_t order, flt32_t value);
void Matrix_InitDiagonal_flt64 (flt64_t matrix[], size_t order, flt64_t value);
void Matrix_InitDiagonal_cmplx32 (cmplx32_t matrix[], size_t order, cmplx32_t value);
void Matrix_InitDiagonal_cmplx64 (cmplx64_t matrix[], size_t order, cmplx64_t value);
C++void Matrix::InitDiagonal (flt32_t matrix[], size_t order, flt32_t value);
void Matrix::InitDiagonal (flt64_t matrix[], size_t order, flt64_t value);
void Matrix::InitDiagonal (cmplx32_t matrix[], size_t order, cmplx32_t value);
void Matrix::InitDiagonal (cmplx64_t matrix[], size_t order, cmplx64_t value);

Description: Set diagonal matrix elements to specified value and all other elements to zero.

Parameters:

  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)
  • value - initialization value for diagonal elements

Return value: None.

Copying

Cvoid Matrix_Copy_flt32 (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix_Copy_flt64 (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix_Copy_cmplx32 (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix_Copy_cmplx64 (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);
C++void Matrix::Copy (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix::Copy (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix::Copy (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix::Copy (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);

Description: Copy all elements from source matrix to target matrix.

Parameters:

  • target - pointer to target matrix
  • source - pointer to source matrix
  • rows - count of matrix rows
  • cols - count of matrix columns

Return value: None.

Warning:If matrices are overlapped in memory, then content of source matrix will be unexpectedly modified, and content of target matrix will be also undefined.

Arithmetic operations

Algorithms of arithmetic operations with matrices do standard math operations to matrices. They are divided onto two groups: unary and binary. Both operations change elements of target matrix and store the result into the same matrix. I.e. they modify original matrix (unary operations) and change target matrix (binary operations).

Unary operations

Unary operations change matrix elements and store the result into the same matrix.

Negative matrix

Cvoid Matrix_Neg_flt32 (flt32_t matrix[], size_t rows, size_t cols);
void Matrix_Neg_flt64 (flt64_t matrix[], size_t rows, size_t cols);
void Matrix_Neg_cmplx32 (cmplx32_t matrix[], size_t rows, size_t cols);
void Matrix_Neg_cmplx64 (cmplx64_t matrix[], size_t rows, size_t cols);
C++void Matrix::Neg (flt32_t matrix[], size_t rows, size_t cols);
void Matrix::Neg (flt64_t matrix[], size_t rows, size_t cols);
void Matrix::Neg (cmplx32_t matrix[], size_t rows, size_t cols);
void Matrix::Neg (cmplx64_t matrix[], size_t rows, size_t cols);

Description: Change sign of each matrix element.

Parameters:

  • matrix - pointer to the matrix
  • rows - count of matrix rows
  • cols - count of matrix columns

Return value: None.

Binary operations

Binary operations with matrices take two operands, which called target and source. Then they apply arithmetic operations to target matrix, using source matrix as second operand, and then store the result into target operand.

Addition

Cvoid Matrix_Add_flt32 (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix_Add_flt64 (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix_Add_cmplx32 (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix_Add_cmplx64 (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);
C++void Matrix::Add (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix::Add (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix::Add (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix::Add (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);

Description: Add source matrix to target matrix and store the result into the same place (into target matrix).

Parameters:

  • target - pointer to target matrix
  • source - pointer to source matrix
  • rows - count of matrix rows
  • cols - count of matrix columns

Return value: None.

Subtraction

Cvoid Matrix_Sub_flt32 (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix_Sub_flt64 (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix_Sub_cmplx32 (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix_Sub_cmplx64 (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);
C++void Matrix::Sub (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix::Sub (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix::Sub (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix::Sub (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);

Description: Subtract source matrix from target matrix and store the result into the same place (into target matrix).

Parameters:

  • target - pointer to target matrix
  • source - pointer to source matrix
  • rows - count of matrix rows
  • cols - count of matrix columns

Return value: None.

Multiplication by scalar value

Cvoid Matrix_Mul_flt32 (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix_Mul_flt64 (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix_Mul_cmplx32 (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix_Mul_cmplx64 (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);
C++void Matrix::Mul (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix::Mul (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix::Mul (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix::Mul (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);

Description: Multiply matrix by scalar value and store the result into the same place (into target matrix).

Parameters:

  • matrix - pointer to the matrix
  • rows - count of matrix rows
  • cols - count of matrix columns
  • value - value to multiply

Return value: None.

Division by scalar value

Cvoid Matrix_Div_flt32 (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix_Div_flt64 (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix_Div_cmplx32 (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix_Div_cmplx64 (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);
C++void Matrix::Div (flt32_t matrix[], size_t rows, size_t cols, flt32_t value);
void Matrix::Div (flt64_t matrix[], size_t rows, size_t cols, flt64_t value);
void Matrix::Div (cmplx32_t matrix[], size_t rows, size_t cols, cmplx32_t value);
void Matrix::Div (cmplx64_t matrix[], size_t rows, size_t cols, cmplx64_t value);

Description: Divide matrix by scalar value and store the result into the same place (into target matrix).

Parameters:

  • matrix - pointer to the matrix
  • rows - count of matrix rows
  • cols - count of matrix columns
  • value - value to divide

Return value: None.

Multiplication by matrix

Cvoid Matrix_MulMatrix_flt32 (flt32_t target[], const flt32_t source1[], const flt32_t source2[], size_t rows, size_t cols, size_t k);
void Matrix_MulMatrix_flt64 (flt64_t target[], const flt64_t source1[], const flt64_t source2[], size_t rows, size_t cols, size_t k);
void Matrix_MulMatrix_cmplx32 (cmplx32_t target[], const cmplx32_t source1[], const cmplx32_t source2[], size_t rows, size_t cols, size_t k);
void Matrix_MulMatrix_cmplx64 (cmplx64_t target[], const cmplx64_t source1[], const cmplx64_t source2[], size_t rows, size_t cols, size_t k);
C++void Matrix::MulMatrix (flt32_t target[], const flt32_t source1[], const flt32_t source2[], size_t rows, size_t cols, size_t k);
void Matrix::MulMatrix (flt64_t target[], const flt64_t source1[], const flt64_t source2[], size_t rows, size_t cols, size_t k);
void Matrix::MulMatrix (cmplx32_t target[], const cmplx32_t source1[], const cmplx32_t source2[], size_t rows, size_t cols, size_t k);
void Matrix::MulMatrix (cmplx64_t target[], const cmplx64_t source1[], const cmplx64_t source2[], size_t rows, size_t cols, size_t k);

Description: Multiply source matrices and store result into target matrix.

Parameters:

  • target - pointer to target matrix (a place for result matrix which should be able to hold at least rows * cols elements)
  • source1 - pointer to first source matrix
  • source2 - pointer to second source matrix
  • rows - rows count of first source matrix
  • cols - columns count of second source matrix
  • k - columns count of first source matrix or rows count of second source matrix

Return value: None.

Transposition

Cvoid Matrix_Transpose_flt32 (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix_Transpose_flt64 (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix_Transpose_cmplx32 (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix_Transpose_cmplx64 (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);
C++void Matrix::Transpose (flt32_t target[], const flt32_t source[], size_t rows, size_t cols);
void Matrix::Transpose (flt64_t target[], const flt64_t source[], size_t rows, size_t cols);
void Matrix::Transpose (cmplx32_t target[], const cmplx32_t source[], size_t rows, size_t cols);
void Matrix::Transpose (cmplx64_t target[], const cmplx64_t source[], size_t rows, size_t cols);

Description: Transpose source matrix and store the result into target matrix. New matrix will have cols count or rows and rows count of columns.

Parameters:

  • target - pointer to target matrix (should be able to hold at least rows * cols elements)
  • source - pointer to source matrix
  • rows - count of source matrix rows
  • cols - count of source matrix columns

Return value: None.

Inverse matrix

Following functions find inverse matrix for source matrix transforming it to upper/lower matrix, and then to identity matrix. In the same time target matrix is transformed from identity matrix to inverse matrix.

Inverse matrix through upper triangular matrix

Cbool Matrix_InverseUp_flt32 (flt32_t target[], flt32_t source[], size_t order);
bool Matrix_InverseUp_flt64 (flt64_t target[], flt64_t source[], size_t order);
bool Matrix_InverseUp_cmplx32 (cmplx32_t target[], cmplx32_t source[], size_t order);
bool Matrix_InverseUp_cmplx64 (cmplx64_t target[], cmplx64_t source[], size_t order);
C++bool Matrix::InverseUp (flt32_t target[], flt32_t source[], size_t order);
bool Matrix::InverseUp (flt64_t target[], flt64_t source[], size_t order);
bool Matrix::InverseUp (cmplx32_t target[], cmplx32_t source[], size_t order);
bool Matrix::InverseUp (cmplx64_t target[], cmplx64_t source[], size_t order);

Description: Find inverse matrix for source matrix and store the result into target matrix. Source matrix is transformed to upper triangular matrix, then it is transformed to identity matrix, while target matrix is transformed to inverse matrix.

Parameters:

  • target - pointer to target matrix (should be able to hold at least order * order elements)
  • source - pointer to source matrix
  • order - source matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if determinant of source matrix exists.
  • FALSE (0) if determinant of source matrix does not exist.

Note:These functions also change source matrix. If you still need source matrix elements, just make a copy before calling these functions.

Inverse matrix through lower triangular matrix

Cbool Matrix_InverseLow_flt32 (flt32_t target[], flt32_t source[], size_t order);
bool Matrix_InverseLow_flt64 (flt64_t target[], flt64_t source[], size_t order);
bool Matrix_InverseLow_cmplx32 (cmplx32_t target[], cmplx32_t source[], size_t order);
bool Matrix_InverseLow_cmplx64 (cmplx64_t target[], cmplx64_t source[], size_t order);
C++bool Matrix::InverseLow (flt32_t target[], flt32_t source[], size_t order);
bool Matrix::InverseLow (flt64_t target[], flt64_t source[], size_t order);
bool Matrix::InverseLow (cmplx32_t target[], cmplx32_t source[], size_t order);
bool Matrix::InverseLow (cmplx64_t target[], cmplx64_t source[], size_t order);

Description: Find inverse matrix for source matrix and store the result into target matrix. Source matrix is transformed to lower triangular matrix, then it is transformed to identity matrix, while target matrix is transformed to inverse matrix.

Parameters:

  • target - pointer to target matrix (should be able to hold at least order * order elements)
  • source - pointer to source matrix
  • order - source matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if determinant of source matrix exists.
  • FALSE (0) if determinant of source matrix does not exist.

Note:These functions also change source matrix. If you still need source matrix elements, just make a copy before calling these functions.

Determinant

Determinant functions find matrix determinant by changing original matrix to triangular view and multiplying all diagonal elements.

Determinant of diagonal matrix

Cflt32_t Matrix_DeterminantDiagonal_flt32 (const flt32_t matrix[], size_t order);
flt64_t Matrix_DeterminantDiagonal_flt64 (const flt64_t matrix[], size_t order);
cmplx32_t Matrix_DeterminantDiagonal_cmplx32 (const cmplx32_t matrix[], size_t order);
cmplx64_t Matrix_DeterminantDiagonal_cmplx64 (const cmplx64_t matrix[], size_t order);
C++flt32_t Matrix::DeterminantDiagonal (const flt32_t matrix[], size_t order);
flt64_t Matrix::DeterminantDiagonal (const flt64_t matrix[], size_t order);
cmplx32_t Matrix::DeterminantDiagonal (const cmplx32_t matrix[], size_t order);
cmplx64_t Matrix::DeterminantDiagonal (const cmplx64_t matrix[], size_t order);

Description: Compute determinant value of diagonal matrix.

Parameters:

  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value: Matrix determinant.

Determinant of triangular matrix

Cflt32_t Matrix_DeterminantTriangular_flt32 (const flt32_t matrix[], size_t order);
flt64_t Matrix_DeterminantTriangular_flt64 (const flt64_t matrix[], size_t order);
cmplx32_t Matrix_DeterminantTriangular_cmplx32 (const cmplx32_t matrix[], size_t order);
cmplx64_t Matrix_DeterminantTriangular_cmplx64 (const cmplx64_t matrix[], size_t order);
C++flt32_t Matrix::DeterminantTriangular (const flt32_t matrix[], size_t order);
flt64_t Matrix::DeterminantTriangular (const flt64_t matrix[], size_t order);
cmplx32_t Matrix::DeterminantTriangular (const cmplx32_t matrix[], size_t order);
cmplx64_t Matrix::DeterminantTriangular (const cmplx64_t matrix[], size_t order);

Description: Compute determinant value of triangular matrix.

Parameters:

  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value: Matrix determinant.

Determinant of square matrix

Following functions find determinant of square matrix by transforming it to upper/lower triangular matrix. Then they multiply diagonal elements to find matrix determinant.

Determinant of square matrix through upper triangular matrix

Cflt32_t Matrix_DeterminantSquareUp_flt32 (flt32_t matrix[], size_t order);
flt64_t Matrix_DeterminantSquareUp_flt64 (flt64_t matrix[], size_t order);
cmplx32_t Matrix_DeterminantSquareUp_cmplx32 (cmplx32_t matrix[], size_t order);
cmplx64_t Matrix_DeterminantSquareUp_cmplx64 (cmplx64_t matrix[], size_t order);
C++flt32_t Matrix::DeterminantSquareUp (flt32_t matrix[], size_t order);
flt64_t Matrix::DeterminantSquareUp (flt64_t matrix[], size_t order);
cmplx32_t Matrix::DeterminantSquareUp (cmplx32_t matrix[], size_t order);
cmplx64_t Matrix::DeterminantSquareUp (cmplx64_t matrix[], size_t order);

Description: Compute determinant value of square matrix by transforming it to upper triangular matrix.

Parameters:

  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value: Matrix determinant.

Note:These functions change original matrix during determinant calculation. If you still need matrix elements, just make a copy before calling these functions.

Determinant of square matrix through lower triangular matrix

Cflt32_t Matrix_DeterminantSquareLow_flt32 (flt32_t matrix[], size_t order);
flt64_t Matrix_DeterminantSquareLow_flt64 (flt64_t matrix[], size_t order);
cmplx32_t Matrix_DeterminantSquareLow_cmplx32 (cmplx32_t matrix[], size_t order);
cmplx64_t Matrix_DeterminantSquareLow_cmplx64 (cmplx64_t matrix[], size_t order);
C++flt32_t Matrix::DeterminantSquareLow (flt32_t matrix[], size_t order);
flt64_t Matrix::DeterminantSquareLow (flt64_t matrix[], size_t order);
cmplx32_t Matrix::DeterminantSquareLow (cmplx32_t matrix[], size_t order);
cmplx64_t Matrix::DeterminantSquareLow (cmplx64_t matrix[], size_t order);

Description: Compute determinant value of square matrix by transforming it to lower triangular matrix.

Parameters:

  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value: Matrix determinant.

Note:These functions change original matrix during determinant calculation. If you still need matrix elements, just make a copy before calling these functions.

Solving of linear system

Following functions provide different solution algorithms for linear systems, which find unique solution. These algorithms transform original matrix to upper/lower triangular matrix and then use appropriate algorithm to find all the coefficients that solve the linear system. Then they store found coefficients into the same place (into original coefficients array).

Gauss elimination

Gaussian elimination (also known as row reduction) is an algorithm for solving systems of linear equations. To perform row reduction on a matrix, it uses a sequence of elementary row operations to modify the matrix until the upper/lower left-hand corner of the matrix is filled with zeros, as much as possible. There are three types of elementary row operations: Swapping two rows; multiplying a row by a non-zero number; adding a multiple of one row to another row. Using these operations, a matrix can always be transformed into an upper/lower triangular matrix, and then simply solved.

Gauss elimination to upper triangular matrix

Cbool Matrix_GaussUp_flt32 (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix_GaussUp_flt64 (flt64_t coefficients[], flt64_t matrix[], size_t order);
bool Matrix_GaussUp_cmplx32 (cmplx32_t coefficients[], cmplx32_t matrix[], size_t order);
bool Matrix_GaussUp_cmplx64 (cmplx64_t coefficients[], cmplx64_t matrix[], size_t order);
C++bool Matrix::GaussUp (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix::GaussUp (flt64_t coefficients[], flt64_t matrix[], size_t order);
bool Matrix::GaussUp (cmplx32_t coefficients[], cmplx32_t matrix[], size_t order);
bool Matrix::GaussUp (cmplx64_t coefficients[], cmplx64_t matrix[], size_t order);

Description: Find solution of linear system using Gauss elimination algorithm. Original matrix is transformed to upper triangular matrix. Then functions find all coefficients that solve the linear system and store them into coefficients array, replacing original coefficient values.

Parameters:

  • coefficients - pointer to coefficients array
  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if linear system has unique solution.
  • FALSE (0) if can not find unique solution for linear system.

Note:These functions change original matrix during solution process. If you still need matrix elements, just make a copy before calling these functions.

Gauss elimination to lower triangular matrix

Cbool Matrix_GaussLow_flt32 (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix_GaussLow_flt64 (flt64_t coefficients[], flt64_t matrix[], size_t order);
bool Matrix_GaussLow_cmplx32 (cmplx32_t coefficients[], cmplx32_t matrix[], size_t order);
bool Matrix_GaussLow_cmplx64 (cmplx64_t coefficients[], cmplx64_t matrix[], size_t order);
C++bool Matrix::GaussLow (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix::GaussLow (flt64_t coefficients[], flt64_t matrix[], size_t order);
bool Matrix::GaussLow (cmplx32_t coefficients[], cmplx32_t matrix[], size_t order);
bool Matrix::GaussLow (cmplx64_t coefficients[], cmplx64_t matrix[], size_t order);

Description: Find solution of linear system using Gauss elimination algorithm. Original matrix is transformed to lower triangular matrix. Then functions find all coefficients that solve the linear system and store them into coefficients array, replacing original coefficient values.

Parameters:

  • coefficients - pointer to coefficients array
  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if linear system has unique solution.
  • FALSE (0) if can not find unique solution for linear system.

Note:These functions change original matrix during solution process. If you still need matrix elements, just make a copy before calling these functions.

Cholesky decomposition

In linear algebra, the Cholesky decomposition or Cholesky factorization is a decomposition of a Hermitian, positive-definite matrix into the product of a upper/lower triangular matrix and its conjugate transpose, useful for efficient numerical solutions and Monte Carlo simulations. When it is applicable, the Cholesky decomposition is roughly twice as efficient as the LU decomposition for solving systems of linear equations.

Cholesky decomposition to upper triangular matrix

Cbool Matrix_CholeskyUp_flt32 (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix_CholeskyUp_flt64 (flt64_t coefficients[], flt64_t matrix[], size_t order);
C++bool Matrix::CholeskyUp (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix::CholeskyUp (flt64_t coefficients[], flt64_t matrix[], size_t order);

Description: Find solution of linear system using Cholesky decomposition algorithm. Original matrix is transformed to upper triangular matrix. Then functions find all coefficients that solve the linear system and store them into coefficients array, replacing original coefficient values.

Parameters:

  • coefficients - pointer to coefficients array
  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if linear system has unique solution.
  • FALSE (0) if can not find unique solution for linear system.

Note:These functions change original matrix during solution process. If you still need matrix elements, just make a copy before calling these functions.

Cholesky decomposition to lower triangular matrix

Cbool Matrix_CholeskyLow_flt32 (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix_CholeskyLow_flt64 (flt64_t coefficients[], flt64_t matrix[], size_t order);
C++bool Matrix::CholeskyLow (flt32_t coefficients[], flt32_t matrix[], size_t order);
bool Matrix::CholeskyLow (flt64_t coefficients[], flt64_t matrix[], size_t order);

Description: Find solution of linear system using Cholesky decomposition algorithm. Original matrix is transformed to lower triangular matrix. Then functions find all coefficients that solve the linear system and store them into coefficients array, replacing original coefficient values.

Parameters:

  • coefficients - pointer to coefficients array
  • matrix - pointer to the matrix
  • order - matrix order (count of matrix rows and columns)

Return value:

  • TRUE (1) if linear system has unique solution.
  • FALSE (0) if can not find unique solution for linear system.

Note:These functions change original matrix during solution process. If you still need matrix elements, just make a copy before calling these functions.

Copyright 2012-2018 Jack Black. All rights reserved.