private double selectDivisor ( double v [ ] , double param [ ] ) { double maxValue = 0 ; int maxIndex = 0 ; for ( int i = 0 ; i < v . length ; i ++ ) { if ( Math . abs ( v [ i ] ) > maxValue ) { maxValue = Math . abs ( v [ i ] ) ; maxIndex = i ; } } double divisor = v [ maxIndex ] ; int index = 0 ; for ( int i = 0 ; i < v . length ; i ++ ) { v [ i ] /= divisor ; if ( i != maxIndex ) { // save first 5 parameters param [ index ] = v [ i ] ; // save indexes in the matrix int col = i < 3 ? col0 : col1 ; indexes [ index ++ ] = 3 * ( i % 3 ) + col ; } } // index of 1 int col = maxIndex >= 3 ? col1 : col0 ; indexes [ 5 ] = 3 * ( maxIndex % 3 ) + col ; return divisor ; }
The divisor is the element in the first two columns that has the largest absolute value . Finds this element sets col0 to be the row which contains it and specifies which elements in that column are to be used .