public ColumnVector solve ( ColumnVector b , boolean improve ) throws MatrixException { // Validate b's size. if ( b . nRows != nRows ) { throw new MatrixException ( MatrixException . INVALID_DIMENSIONS ) ; } decompose ( ) ; // Solve Ly = b for y by forward substitution. // Solve Ux = y for x by back substitution. ColumnVector y = forwardSubstitution ( b ) ; ColumnVector x = backSubstitution ( y ) ; // Improve and return x. if ( improve ) improve ( b , x ) ; return x ; }
Solve Ax = b for x using the Gaussian elimination algorithm .