 A high-performance general-purpose compute library

Solve a system of equations. More...

## Functions

AFAPI array solve (const array &a, const array &b, const matProp options=AF_MAT_NONE)
C++ Interface for solving a system of equations.

AFAPI af_err af_solve (af_array *x, const af_array a, const af_array b, const af_mat_prop options)
C Interface for solving a system of equations.

## Detailed Description

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

 \f$A * X = B\f$


This operation can be done in ArrayFire using the following code snippet.

af::array X1 = af::solve(A, B0);
A multi dimensional data container.
Definition: array.h:37
AFAPI array solve(const array &a, const array &b, const matProp options=AF_MAT_NONE)
C++ Interface for solving a system of equations.

The results can be verified by reconstructing the output matrix using af::matmul in the following manner.

af::array B1 = af::matmul(A, X1);
AFAPI array matmul(const array &lhs, const array &rhs, const matProp optLhs=AF_MAT_NONE, const matProp optRhs=AF_MAT_NONE)
Matrix multiply of two arrays.

The sample output can be seen below

A [3 3 1 1]
0.1000 3.1000 6.1000
1.1000 4.1000 7.0000
2.0000 5.0000 8.0000
B0 [3 1 1 1]
21.9000
30.7000
39.0000
X1 [3 1 1 1]
4.0000
3.0000
2.0000
B1 [3 1 1 1]
21.9000
30.7000
39.0000

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.

@ AF_MAT_LOWER
Matrix is lower triangular.
Definition: defines.h:354

Similarily, the code snippet for solving an upper triangular matrix can be seen below.

@ AF_MAT_UPPER
Matrix is upper triangular.
Definition: defines.h:353

## ◆ af_solve()

 AFAPI af_err af_solve ( af_array * x, const af_array a, const af_array b, const af_mat_prop options )

C Interface for solving a system of equations.

Parameters
 [out] x is the matrix of unknown variables [in] a is the coefficient matrix [in] b is the measured values [in] options determining various properties of matrix a
Note
options needs to be one of AF_MAT_NONE, AF_MAT_LOWER or AF_MAT_UPPER

## ◆ solve()

 AFAPI array solve ( const array & a, const array & b, const matProp options = AF_MAT_NONE )

C++ Interface for solving a system of equations.

Parameters
 [in] a is the coefficient matrix [in] b is the measured values [in] options determining various properties of matrix a
Returns
x, the matrix of unknown variables
Note
options needs to be one of AF_MAT_NONE, AF_MAT_LOWER or AF_MAT_UPPER
This function is not supported in GFOR