Function Repository Resource:

# NumPyCholeskyDecomposition

Compute the Cholesky decomposition of an array in Python using the NumPy linear algebra package

Contributed by: Wolfram Staff
 ResourceFunction["NumPyCholeskyDecomposition"][array] computes the Cholesky decomposition of an array in Python using the package NumPy. ResourceFunction["NumPyCholeskyDecomposition"][array,session] uses the specified running ExternalSessionObject session.

## Details and Options

ResourceFunction["NumPyCholeskyDecomposition"] is a wrapper function that calls the Python function numpy.linalg.cholesky().
array must be a numeric Hermitian positive definite matrix or a tensor object representing a list of such matrices.
For a matrix array, ResourceFunction["NumPyCholeskyDecomposition"][array] yields an upper or lower-triangular matrix l such that l.ConjugateTranspose[l]==array.
For a real matrix array, ConjugateTranspose[array] can be replaced with Transpose[array].
ResourceFunction["NumPyCholeskyDecomposition"] accepts array in the form of a NumericArray object or an expression that can be converted to NumericArray.
ResourceFunction["NumPyCholeskyDecomposition"][array,session] avoids the overhead of opening a new Python session for every successive call.

## Examples

### Basic Examples (3)

Compute the Cholesky decomposition of a symmetric positive-definite matrix in NumPy:

 In[1]:=
 In[2]:=
 Out[2]=
 In[3]:=
 Out[3]=

The original matrix:

 In[4]:=
 Out[4]=

In contrast, CholeskyDecomposition always returns an upper-triangular matrix:

 In[5]:=
 Out[5]=
 In[6]:=
 Out[6]=

### Scope (6)

Compute the Cholesky decomposition of a real-valued matrix:

 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=
 In[9]:=
 Out[9]=
 In[10]:=
 Out[10]=

Complex matrix:

 In[11]:=
 Out[11]=
 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=
 In[14]:=
 Out[14]=

Sparse array:

 In[15]:=
 Out[15]=
 In[16]:=
 Out[16]=
 In[17]:=
 Out[17]=

NumericArray object:

 In[18]:=
 Out[18]=

A tensor representing a list of matrices:

 In[19]:=
 Out[19]=
 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=

Make several calls to NumPyCholeskyDecomposition in the same external session:

 In[22]:=
 Out[22]=
 In[23]:=
 Out[23]=
 In[24]:=
 Out[24]=

End the session:

 In[25]:=

### Possible Issues (1)

NumPyCholeskyDecomposition returns a Failure object if the input matrix is not positive definite:

 In[26]:=
 Out[26]=
 In[27]:=
 Out[27]=

## Version History

• 1.0.0 – 07 December 2020