public static double extractColumnAndMax ( ZMatrixRMaj A , int row0 , int row1 , int col , double u [ ] , int offsetU ) { int indexU = ( offsetU + row0 ) * 2 ; // find the largest value in this column // this is used to normalize the column and mitigate overflow/underflow double max = 0 ; int indexA = A . getIndex ( row0 , col ) ; double h [ ] = A . data ; for ( int i = row0 ; i < row1 ; i ++ , indexA += A . numCols * 2 ) { // copy the householder vector to an array to reduce cache misses // big improvement on larger matrices and a relatively small performance hit on small matrices. double realVal = u [ indexU ++ ] = h [ indexA ] ; double imagVal = u [ indexU ++ ] = h [ indexA + 1 ] ; double magVal = realVal * realVal + imagVal * imagVal ; if ( max < magVal ) { max = magVal ; } } return Math . sqrt ( max ) ; }
Extracts the column of A and copies it into u while computing the magnitude of the largest element and returning it .