
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Return the Cholesky decomposition in Linear Algebra in Python
To return the Cholesky decomposition, use the numpy.linalg.cholesky() method. Return the Cholesky decomposition, L * L.H, of the square matrix a, where L is lower-triangular and .H is the conjugate transpose operator. The a must be Hermitian and positive-definite. No checking is performed to verify whether a is Hermitian or not. In addition, only the lower-triangular and diagonal elements of a are used. Only L is actually returned.
Then parameter a, is the Hermitian (symmetric if all elements are real), positive-definite input matrix. The method returns the Upper or lower-triangular Cholesky factor of a. Returns a matrix object if a is a matrix object.
Steps
At first, import the required libraries -
import numpy as np
Creating a 2D numpy array using the numpy.array() method −
arr = np.array([[1,-2j],[2j,5]])
Display the array −
print("Our Array...\n",arr)
Check the Dimensions −
print("\nDimensions of our Array...\n",arr.ndim)
Get the Datatype −
print("\nDatatype of our Array object...\n",arr.dtype)
Get the Shape −
print("\nShape of our Array object...\n",arr.shape)
To return the Cholesky decomposition, use the numpy.linalg.cholesky() method −
print("\nCholesky decomposition in Linear Algebra...\n",np.linalg.cholesky(arr))
Example
import numpy as np # Creating a 2D numpy array using the numpy.array() method arr = np.array([[1,-2j],[2j,5]]) # Display the array print("Our Array...\n",arr) # Check the Dimensions print("\nDimensions of our Array...\n",arr.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",arr.dtype) # Get the Shape print("\nShape of our Array object...\n",arr.shape) # To return the Cholesky decomposition, use the numpy.linalg.cholesky() method. print("\nCholesky decomposition in Linear Algebra...\n",np.linalg.cholesky(arr))
Output
Our Array... [[ 1.+0.j -0.-2.j] [ 0.+2.j 5.+0.j]] Dimensions of our Array... 2 Datatype of our Array object... complex128 Shape of our Array object... (2, 2) Cholesky decomposition in Linear Algebra... [[1.+0.j 0.+0.j] [0.+2.j 1.+0.j]]
- Related Articles
- Return the infinity Norm of the matrix in Linear Algebra in Python
- Return the Frobenius Norm of the matrix in Linear Algebra in Python
- Return the Nuclear Norm of the matrix in Linear Algebra in Python
- Return the Norm of the matrix or vector in Linear Algebra in Python
- Return the negative infinity Norm of the matrix in Linear Algebra in Python
- Return the Norm of the matrix over axis in Linear Algebra in Python
- Return the Norm of the vector over given axis in Linear Algebra in Python
- Return the Norm of the vector over axis 1 in Linear Algebra in Python
- Return the Norm of the vector over axis 0 in Linear Algebra in Python
- Matrix and linear Algebra calculations in Python
- Return the Norm of the matrix or vector in Linear Algebra and also set the order in Python
- Compute the determinant of an array in linear algebra in Python
- Compute the condition number of a matrix in linear algebra in Python
- Compute the determinant of a Two-Dimensional array in linear algebra in Python
- Compute the determinant for a stack of matrices in linear algebra in Python
