Cholesky Decomposition : Matrix Decomposition | javascript program to decompose a matrix using Cholesky Decomposition function MAX = 100 ; ; 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
function Cholesky_Decomposition ( matrix , n ) { var lower = Array ( n ) . fill ( 0 ) . map ( x => Array ( n ) . fill ( 0 ) ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j <= i ; j ++ ) { var sum = 0 ; if ( j == i ) { for ( var k = 0 ; k < j ; k ++ ) sum += parseInt ( Math . pow ( lower [ j ] [ k ] , 2 ) ) ; lower [ j ] [ j ] = parseInt ( Math . sqrt ( matrix [ j ] [ j ] - sum ) ) ; } else { for ( var k = 0 ; k < j ; k ++ ) sum += ( lower [ i ] [ k ] * lower [ j ] [ k ] ) ; lower [ i ] [ j ] = ( matrix [ i ] [ j ] - sum ) / lower [ j ] [ j ] ; } } } document . write ( " " ) ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = 0 ; j < n ; j ++ ) document . write ( lower [ i ] [ j ] + " " ) ; for ( var j = 0 ; j < n ; j ++ ) document . write ( lower [ j ] [ i ] + " " ) ; document . write ( ' ' ) ; } } var n = 3 ; var matrix = [ [ 4 , 12 , - 16 ] , [ 12 , 37 , - 43 ] , [ - 16 , - 43 , 98 ] ] ; Cholesky_Decomposition ( matrix , n ) ;