/** * <p> * Computes the inner product of row vector 'rowA' against row vector 'rowB' while taking account leading zeros and one.<br> * <br> * ret = a<sup>T</sup>*b * </p> * * <p> * Row A is assumed to be a householder vector. Element at 'colStartA' is one and previous elements are zero. * </p> * * @param blockLength * @param A block aligned submatrix. * @param rowA Row index inside the sub-matrix of first row vector has zeros and ones.. * @param rowB Row index inside the sub-matrix of second row vector. * @return dot product of the two vectors. */ public static double innerProdRow(int blockLength, D1Submatrix64F A, int rowA, D1Submatrix64F B, int rowB, int zeroOffset ) { int offset = rowA + zeroOffset; if( offset + B.col0 >= B.col1 ) return 0; // take in account the one in 'A' double total = B.get(rowB,offset); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,offset+1,A.col1-A.col0); return total; }
public static void add_row( final int blockLength , D1Submatrix64F A , int rowA , double alpha , D1Submatrix64F B , int rowB , double beta , D1Submatrix64F C , int rowC , int zeroOffset , int end ) { int offset = rowA+zeroOffset; if( C.col0 + offset >= C.col1 ) return; // handle leading one C.set(rowC,offset,alpha+B.get(rowB,offset)*beta); BlockVectorOps.add_row(blockLength,A,rowA,alpha,B,rowB,beta,C,rowC,offset+1,end); }
/** * <p> * Computes the inner product of row vector 'rowA' against row vector 'rowB' while taking account leading zeros and one.<br> * <br> * ret = a<sup>T</sup>*b * </p> * * <p> * Row A is assumed to be a householder vector. Element at 'colStartA' is one and previous elements are zero. * </p> * * @param blockLength * @param A block aligned submatrix. * @param rowA Row index inside the sub-matrix of first row vector has zeros and ones.. * @param rowB Row index inside the sub-matrix of second row vector. * @return dot product of the two vectors. */ public static double innerProdRow(int blockLength, D1Submatrix64F A, int rowA, D1Submatrix64F B, int rowB, int zeroOffset ) { int offset = rowA + zeroOffset; if( offset + B.col0 >= B.col1 ) return 0; // take in account the one in 'A' double total = B.get(rowB,offset); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,offset+1,A.col1-A.col0); return total; }
public static void add_row( final int blockLength , D1Submatrix64F A , int rowA , double alpha , D1Submatrix64F B , int rowB , double beta , D1Submatrix64F C , int rowC , int zeroOffset , int end ) { int offset = rowA+zeroOffset; if( C.col0 + offset >= C.col1 ) return; // handle leading one C.set(rowC,offset,alpha+B.get(rowB,offset)*beta); BlockVectorOps.add_row(blockLength,A,rowA,alpha,B,rowB,beta,C,rowC,offset+1,end); }
private void copyZeros( D1Submatrix64F subU ) { int N = Math.min(A.blockLength,subU.col1-subU.col0); for( int i = 0; i < N; i++ ) { // save the zeros for( int j = 0; j <= i; j++ ) { zerosM.unsafe_set(i,j,subU.get(i,j)); subU.set(i,j,0); } // save the one if( subU.col0 + i + 1 < subU.original.numCols ) { zerosM.unsafe_set(i,i+1,subU.get(i,i+1)); subU.set(i,i+1,1); } } }
private void copyZeros( D1Submatrix64F subU ) { int N = Math.min(A.blockLength,subU.col1-subU.col0); for( int i = 0; i < N; i++ ) { // save the zeros for( int j = 0; j <= i; j++ ) { zerosM.unsafe_set(i,j,subU.get(i,j)); subU.set(i,j,0); } // save the one if( subU.col0 + i + 1 < subU.original.numCols ) { zerosM.unsafe_set(i,i+1,subU.get(i,i+1)); subU.set(i,i+1,1); } } }
private void copyZeros( D1Submatrix64F subU ) { int N = Math.min(A.blockLength,subU.col1-subU.col0); for( int i = 0; i < N; i++ ) { // save the zeros for( int j = 0; j <= i; j++ ) { zerosM.unsafe_set(i,j,subU.get(i,j)); subU.set(i,j,0); } // save the one if( subU.col0 + i + 1 < subU.original.numCols ) { zerosM.unsafe_set(i,i+1,subU.get(i,i+1)); subU.set(i,i+1,1); } } }
public static void add_row( final int blockLength , D1Submatrix64F A , int rowA , double alpha , D1Submatrix64F B , int rowB , double beta , D1Submatrix64F C , int rowC , int zeroOffset , int end ) { int offset = rowA+zeroOffset; if( C.col0 + offset >= C.col1 ) return; // handle leading one C.set(rowC,offset,alpha+B.get(rowB,offset)*beta); BlockVectorOps.add_row(blockLength,A,rowA,alpha,B,rowB,beta,C,rowC,offset+1,end); }
public static double innerProdRowSymm(int blockLength, D1Submatrix64F A, int rowA, D1Submatrix64F B, int rowB, int zeroOffset ) { int offset = rowA + zeroOffset; if( offset + B.col0 >= B.col1 ) return 0; if( offset < rowB ) { // take in account the one in 'A' double total = B.get(offset,rowB); total += BlockVectorOps.dot_row_col(blockLength,A,rowA,B,rowB,offset+1,rowB); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,rowB,A.col1-A.col0); return total; } else { // take in account the one in 'A' double total = B.get(rowB,offset); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,offset+1,A.col1-A.col0); return total; } }
public static double innerProdRowSymm(int blockLength, D1Submatrix64F A, int rowA, D1Submatrix64F B, int rowB, int zeroOffset ) { int offset = rowA + zeroOffset; if( offset + B.col0 >= B.col1 ) return 0; if( offset < rowB ) { // take in account the one in 'A' double total = B.get(offset,rowB); total += BlockVectorOps.dot_row_col(blockLength,A,rowA,B,rowB,offset+1,rowB); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,rowB,A.col1-A.col0); return total; } else { // take in account the one in 'A' double total = B.get(rowB,offset); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,offset+1,A.col1-A.col0); return total; } }
public static double innerProdRowSymm(int blockLength, D1Submatrix64F A, int rowA, D1Submatrix64F B, int rowB, int zeroOffset ) { int offset = rowA + zeroOffset; if( offset + B.col0 >= B.col1 ) return 0; if( offset < rowB ) { // take in account the one in 'A' double total = B.get(offset,rowB); total += BlockVectorOps.dot_row_col(blockLength,A,rowA,B,rowB,offset+1,rowB); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,rowB,A.col1-A.col0); return total; } else { // take in account the one in 'A' double total = B.get(rowB,offset); total += BlockVectorOps.dot_row(blockLength,A,rowA,B,rowB,offset+1,A.col1-A.col0); return total; } }
public SimpleMatrix extract() { SimpleMatrix ret = new SimpleMatrix(row1-row0,col1-col0); for( int i = 0; i < ret.numRows(); i++ ) { for( int j = 0; j < ret.numCols(); j++ ) { ret.set(i,j,get(i,j)); } } return ret; }
public SimpleMatrix extract() { SimpleMatrix ret = new SimpleMatrix(row1-row0,col1-col0); for( int i = 0; i < ret.numRows(); i++ ) { for( int j = 0; j < ret.numCols(); j++ ) { ret.set(i,j,get(i,j)); } } return ret; }
double before = A.get(row,row+1); A.set(row,row+1,1);
double before = A.get(row,row+1); A.set(row,row+1,1);
double before = A.get(row,row+1); A.set(row,row+1,1);
double u_0 = Y.get(i,i+1) + tau; BlockVectorOps.div_row(blockLength,Y,i,u_0,Y,i,i+1,Y.col1-Y.col0);
double u_0 = Y.get(i,i+1) + tau; BlockVectorOps.div_row(blockLength,Y,i,u_0,Y,i,i+1,Y.col1-Y.col0);
double u_0 = Y.get(i,i+1) + tau; BlockVectorOps.div_row(blockLength,Y,i,u_0,Y,i,i+1,Y.col1-Y.col0);
double before = subU.get(A.blockLength-1,A.blockLength); subU.set(A.blockLength-1,A.blockLength,1);