if( orig.numCols != orig.numRows )
throw new IllegalArgumentException("Input matrix must be square.");
init(orig);
D1Submatrix64F subA = new D1Submatrix64F(A);
D1Submatrix64F subV = new D1Submatrix64F(V);
D1Submatrix64F subU = new D1Submatrix64F(A);
int N = orig.numCols;
for( int i = 0; i < N; i += A.blockLength ) {
// System.out.println("-------- triag i "+i);
int height = Math.min(A.blockLength,A.numRows-i);
subA.col0 = subU.col0 = i;
subA.row0 = subU.row0 = i;
subU.row1 = subU.row0 + height;
subV.col0 = i;
subV.row1 = height;
subV.original.reshape(subV.row1,subV.col1,false);
// bidiagonalize the top row
TridiagonalBlockHelper.tridiagUpperRow(A.blockLength,subA,gammas,subV);
// apply Householder reflectors to the lower portion using block multiplication
if( subU.row1 < orig.numCols) {
// take in account the 1 in the last row. The others are skipped over.
double before = subU.get(A.blockLength-1,A.blockLength);
subU.set(A.blockLength-1,A.blockLength,1);
// A = A + U*V^T + V*U^T
multPlusTransA(A.blockLength,subU,subV,subA);
multPlusTransA(A.blockLength,subV,subU,subA);
subU.set(A.blockLength-1,A.blockLength,before);
}
}
return true;
}