Solve a system of equations. More...
Functions | |
AFAPI array | solve (const array &a, const array &b, const matProp options=AF_MAT_NONE) |
C++ Interface to solve a system of equations. More... | |
AFAPI af_err | af_solve (af_array *x, const af_array a, const af_array b, const af_mat_prop options) |
C Interface to solve a system of equations. More... | |
Solve a system of equations.
This function takes a co-efficient matrix \(A\) and an output matrix \(B\) as inputs to solve the following equation for \(X\), \(A * X = B\).
This operation can be done in ArrayFire using the following code snippet.
The results can be verified by reconstructing the output matrix using af::matmul in the following manner,
The sample output can be seen below.
If the coefficient matrix is known to be a triangular matrix, AF_MAT_LOWER or AF_MAT_UPPER can be passed to make solve faster.
The sample code snippets for solving a lower triangular matrix can be seen below.
Similarily, the code snippet for solving an upper triangular matrix can be seen below.
See also: af::solveLU
AFAPI af_err af_solve | ( | af_array * | x, |
const af_array | a, | ||
const af_array | b, | ||
const af_mat_prop | options | ||
) |
C Interface to solve a system of equations.
The options
parameter must be one of AF_MAT_NONE, AF_MAT_LOWER or AF_MAT_UPPER.
This function is not supported in GFOR.
[out] | x | matrix of unknown variables |
[in] | a | coefficient matrix |
[in] | b | measured values |
[in] | options | determines various properties of matrix a |
C++ Interface to solve a system of equations.
The options
parameter must be one of AF_MAT_NONE, AF_MAT_LOWER or AF_MAT_UPPER.
This function is not supported in GFOR.
[in] | a | coefficient matrix |
[in] | b | measured values |
[in] | options | determines various properties of matrix a |
x
, the matrix of unknown variables