Cholesky Decomposition : Matrix Decomposition | Java program to decompose a matrix using Cholesky Decomposition ; Decomposing a matrix into Lower Triangular ; summation for diagonals ; Evaluating L ( i , j ) using L ( j , j ) ; Displaying Lower Triangular and its Transpose ; Lower Triangular ; Transpose of Lower Triangular ; Driver Code
class GFG { static void Cholesky_Decomposition ( int [ ] [ ] matrix , int n ) { int [ ] [ ] lower = new int [ n ] [ n ] ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) { int sum = 0 ; if ( j == i ) { for ( int k = 0 ; k < j ; k ++ ) sum += ( int ) Math . pow ( lower [ j ] [ k ] , 2 ) ; lower [ j ] [ j ] = ( int ) Math . sqrt ( matrix [ j ] [ j ] - sum ) ; } else { for ( int k = 0 ; k < j ; k ++ ) sum += ( lower [ i ] [ k ] * lower [ j ] [ k ] ) ; lower [ i ] [ j ] = ( matrix [ i ] [ j ] - sum ) / lower [ j ] [ j ] ; } } } System . out . println ( " ▁ Lower ▁ Triangular TABSYMBOL ▁ Transpose " ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < n ; j ++ ) System . out . print ( lower [ i ] [ j ] + " TABSYMBOL " ) ; System . out . print ( " " ) ; for ( int j = 0 ; j < n ; j ++ ) System . out . print ( lower [ j ] [ i ] + " TABSYMBOL " ) ; System . out . println ( ) ; } } public static void main ( String [ ] args ) { int n = 3 ; int [ ] [ ] matrix = new int [ ] [ ] { { 4 , 12 , - 16 } , { 12 , 37 , - 43 } , { - 16 , - 43 , 98 } } ; Cholesky_Decomposition ( matrix , n ) ; } }