public double determinant ( ) throws MatrixException { decompose ( ) ; // Each row exchange during forward elimination flips the sign // of the determinant, so check for an odd number of exchanges. double determinant = ( ( exchangeCount & 1 ) == 0 ) ? 1 : - 1 ; // Form the product of the diagonal elements of matrix U. for ( int i = 0 ; i < nRows ; ++ i ) { int pi = permutation [ i ] ; // permuted index determinant *= LU . at ( pi , i ) ; } return determinant ; }
Compute the determinant .