private void pivotOperation ( int k ) { double pivot = coeff [ row [ k ] ] [ col [ k ] ] ; // pivot row: set pivot to 1 coeff [ row [ k ] ] [ col [ k ] ] = 1 ; for ( int i = k + 1 ; i < coeff [ k ] . length ; i ++ ) { coeff [ row [ k ] ] [ col [ i ] ] /= pivot ; } rhs [ row [ k ] ] /= pivot ; if ( LOG . isDebugging ( ) ) { StringBuilder msg = new StringBuilder ( ) ; msg . append ( "set pivot element to 1 " ) . append ( equationsToString ( 4 ) ) ; LOG . debugFine ( msg . toString ( ) ) ; } // for (int i = k + 1; i < coeff.length; i++) { for ( int i = 0 ; i < coeff . length ; i ++ ) { if ( i == k ) { continue ; } // compute factor double q = coeff [ row [ i ] ] [ col [ k ] ] ; // modify entry a[i,k], i <> k coeff [ row [ i ] ] [ col [ k ] ] = 0 ; // modify entries a[i,j], i > k fixed, j = k+1...n-1 for ( int j = k + 1 ; j < coeff [ 0 ] . length ; j ++ ) { coeff [ row [ i ] ] [ col [ j ] ] = coeff [ row [ i ] ] [ col [ j ] ] - coeff [ row [ k ] ] [ col [ j ] ] * q ; } // end for j // modify right-hand-side rhs [ row [ i ] ] = rhs [ row [ i ] ] - rhs [ row [ k ] ] * q ; } // end for k if ( LOG . isDebugging ( ) ) { StringBuilder msg = new StringBuilder ( ) ; msg . append ( "after pivot operation " ) . append ( equationsToString ( 4 ) ) ; LOG . debugFine ( msg . toString ( ) ) ; } }
performs a pivot operation