A high-performance general-purpose compute library

- Main Page
- Tutorials
- Release Notes
- Examples

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

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

## Detailed Description

Perform Cholesky decomposition.

This function decomposes a positive definite matrix \(A\) into two triangular matrices such that, \(A = L * U\) and \(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.

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

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

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

## Function Documentation

## ◆ af_cholesky()

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

C Interface to perform Cholesky decomposition.

Multiplying `out` with its conjugate transpose reproduces the input `in`.

The input must be positive definite.

Parameters

  [out] | out | triangular matrix;
  [out] | info | `0` if cholesky decomposition passes; if not, it returns the rank at which the decomposition fails
  [in] | in | input matrix
  [in] | is_upper | boolean determining if `out` is upper or lower triangular

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ af_cholesky_inplace()

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

C Interface to perform in-place Cholesky decomposition.

The input must be positive definite.

Parameters

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

Returns
  AF_SUCCESS, if function returns successfully, else an af_err code is given

## ◆ cholesky()

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

C++ Interface to perform Cholesky decomposition.

Multiplying `out` with its conjugate transpose reproduces the input `in`.

The input must be positive definite.

This function is not supported in GFOR.

Parameters

  [out] | out | triangular matrix;
  [in] | in | input matrix
  [in] | is_upper | 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 fails

## ◆ choleskyInPlace()

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

C++ Interface to perform in-place Cholesky decomposition.

The input must be positive definite.

This function is not supported in GFOR.

Parameters

  [in,out] | in | input matrix on entry; triangular matrix on exit
  [in] | is_upper | 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 fails