protected void updateNorms ( int j ) { boolean foundNegative = false ; for ( int col = j ; col < numCols ; col ++ ) { double e = dataQR [ col ] [ j - 1 ] ; double v = normsCol [ col ] -= e * e ; if ( v < 0 ) { foundNegative = true ; break ; } } // if a negative sum has been found then clearly too much precision has been lost // and it should recompute the column norms from scratch if ( foundNegative ) { for ( int col = j ; col < numCols ; col ++ ) { double u [ ] = dataQR [ col ] ; double actual = 0 ; for ( int i = j ; i < numRows ; i ++ ) { double v = u [ i ] ; actual += v * v ; } normsCol [ col ] = actual ; } } }
Performs an efficient update of each columns norm