- Main Page
- Tutorials
- Functions
- Release Notes
- Examples

Functions
cholesky
Complete List of ArrayFire Functions ArrayFire Functions by Category » Linear Algebra » | Matrix factorizations and decompositions

Perform Cholesky decomposition. More...

## Functions
AFAPI int | cholesky (array &out, const array &in, const bool is_upper=true)
| C++ Interface for cholesky decomposition. More...
AFAPI int | choleskyInPlace (array &in, const bool is_upper=true)
| C++ Interface for in place cholesky decomposition. More...
AFAPI af_err | af_cholesky (af_array *out, int *info, const af_array in, const bool is_upper)
| C++ Interface for cholesky decomposition. More...
AFAPI af_err | af_cholesky_inplace (int *info, af_array in, const bool is_upper)
| C Interface for in place cholesky decomposition. More...

## Detailed Description

Perform Cholesky decomposition.

This function decomposes a positive definite matrix A into two triangular matrices such that

\(A = L * U\)

\(L = U^T\)

Only one of L and U is stored to conserve space when solving linear equations.

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

af::array out;
cholesky(out, in, is_upper);

When memory is a concern, users can perform Cholesky decomposition in place as shown below.

af::array in2 = in.copy();
choleskyInPlace(in2, is_upper);

## Function Documentation

AFAPI af_err af_cholesky | ( | af_array * | out,
|  | int * | info,
|  | const af_array | in,
|  | const bool | is_upper
| ) |  |

C++ Interface for cholesky decomposition.

Parameters

  [out] | out | contains the triangular matrix. Multiply `out` with it conjugate transpose reproduces the input `in`.
  [out] | info | is `0` if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.
  [in] | in | is the input matrix
  [in] | is_upper | a boolean determining if `out` is upper or lower triangular

Note
  The input matrix has to be a positive definite matrix, if it is not zero, the cholesky decomposition functions return a non zero output.

AFAPI af_err af_cholesky_inplace | ( | int * | info,
|  | af_array | in,
|  | const bool | is_upper
| ) |  |

C Interface for in place cholesky decomposition.

Parameters

  [out] | info | is `0` if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.
  [in,out] | in | is the input matrix on entry. It contains the triangular matrix on exit.
  [in] | is_upper | a boolean determining if `in` is upper or lower triangular

Note
  The input matrix has to be a positive definite matrix, if it is not zero, the cholesky decomposition functions return a non zero output.

AFAPI int af::cholesky | ( | array & | out,
|  | const array & | in,
|  | const bool | is_upper = `true`
| ) |  |

C++ Interface for cholesky decomposition.

Parameters

  [out] | out | contains the triangular matrix. Multiply `out` with its conjugate transpose reproduces the input `in`.
  [in] | in | is the input matrix
  [in] | is_upper | a boolean determining if `out` is upper or lower triangular

Returns
  `0` if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.

Note
  The input matrix has to be a positive definite matrix, if it is not zero, the cholesky decomposition functions return a non-zero output.
  This function is not supported in GFOR

Examples:
  cholesky.cpp.

AFAPI int af::choleskyInPlace | ( | array & | in,
|  | const bool | is_upper = `true`
| ) |  |

C++ Interface for in place cholesky decomposition.

Parameters

  [in,out] | in | is the input matrix on entry. It contains the triangular matrix on exit.
  [in] | is_upper | a boolean determining if `in` is upper or lower triangular

Returns
  `0` if cholesky decomposition passes, if not it returns the rank at which the decomposition failed.

Note
  The input matrix has to be a positive definite matrix, if it is not zero, the cholesky decomposition functions return a non-zero output.
  This function is not supported in GFOR