public static void mult( BlockMatrix64F A , BlockMatrix64F B , BlockMatrix64F C ) { if( A.numCols != B.numRows ) throw new IllegalArgumentException("Columns in A are incompatible with rows in B"); if( A.numRows != C.numRows ) throw new IllegalArgumentException("Rows in A are incompatible with rows in C"); if( B.numCols != C.numCols ) throw new IllegalArgumentException("Columns in B are incompatible with columns in C"); if( A.blockLength != B.blockLength || A.blockLength != C.blockLength ) throw new IllegalArgumentException("Block lengths are not all the same."); final int blockLength = A.blockLength; D1Submatrix64F Asub = new D1Submatrix64F(A,0, A.numRows, 0, A.numCols); D1Submatrix64F Bsub = new D1Submatrix64F(B,0, B.numRows, 0, B.numCols); D1Submatrix64F Csub = new D1Submatrix64F(C,0, C.numRows, 0, C.numCols); BlockMultiplication.mult(blockLength,Asub,Bsub,Csub); }
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 static void checkInput( int blockLength , D1Submatrix64F A , D1Submatrix64F B , D1Submatrix64F C ) { int Arow = A.getRows();int Acol = A.getCols(); int Brow = B.getRows();int Bcol = B.getCols(); int Crow = C.getRows();int Ccol = C.getCols(); if( Arow != Crow ) throw new RuntimeException("Mismatch A and C rows"); if( Bcol != Ccol ) throw new RuntimeException("Mismatch B and C columns"); if( Acol != Brow ) throw new RuntimeException("Mismatch A columns and B rows"); if( !BlockMatrixOps.blockAligned(blockLength,A)) throw new RuntimeException("Sub-Matrix A is not block aligned"); if( !BlockMatrixOps.blockAligned(blockLength,B)) throw new RuntimeException("Sub-Matrix B is not block aligned"); if( !BlockMatrixOps.blockAligned(blockLength,C)) throw new RuntimeException("Sub-Matrix C is not block aligned"); }
D1Submatrix64F subA = new D1Submatrix64F(A); D1Submatrix64F subV = new D1Submatrix64F(V); D1Submatrix64F subU = new D1Submatrix64F(A); double before = subU.get(A.blockLength-1,A.blockLength); subU.set(A.blockLength-1,A.blockLength,1); multPlusTransA(A.blockLength,subV,subU,subA); subU.set(A.blockLength-1,A.blockLength,before);
if( R.getCols() != lengthR ) { throw new IllegalArgumentException("Number of columns in R must be equal to the number of rows in B"); } else if( R.getRows() != lengthR ) { throw new IllegalArgumentException("Number of rows in R must be equal to the number of rows in B"); D1Submatrix64F Y = new D1Submatrix64F(B.original); D1Submatrix64F Rinner = new D1Submatrix64F(R.original); D1Submatrix64F Binner = new D1Submatrix64F(B.original);
public D1Submatrix64F(D1Matrix64F original, int row0, int row1, int col0, int col1) { set(original,row0,row1,col0,col1); }
/** * <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; }
D1Submatrix64F subA = new D1Submatrix64F(A); D1Submatrix64F subV = new D1Submatrix64F(V); D1Submatrix64F subU = new D1Submatrix64F(A); double before = subU.get(A.blockLength-1,A.blockLength); subU.set(A.blockLength-1,A.blockLength,1); multPlusTransA(A.blockLength,subV,subU,subA); subU.set(A.blockLength-1,A.blockLength,before);
if( R.getCols() != lengthR ) { throw new IllegalArgumentException("Number of columns in R must be equal to the number of rows in B"); } else if( R.getRows() != lengthR ) { throw new IllegalArgumentException("Number of rows in R must be equal to the number of rows in B"); D1Submatrix64F Y = new D1Submatrix64F(B.original); D1Submatrix64F Rinner = new D1Submatrix64F(R.original); D1Submatrix64F Binner = new D1Submatrix64F(B.original);
public D1Submatrix64F(D1Matrix64F original, int row0, int row1, int col0, int col1) { set(original,row0,row1,col0,col1); }
/** * <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); }
public static void multTransA( BlockMatrix64F A , BlockMatrix64F B , BlockMatrix64F C ) { if( A.numRows != B.numRows ) throw new IllegalArgumentException("Rows in A are incompatible with rows in B"); if( A.numCols != C.numRows ) throw new IllegalArgumentException("Columns in A are incompatible with rows in C"); if( B.numCols != C.numCols ) throw new IllegalArgumentException("Columns in B are incompatible with columns in C"); if( A.blockLength != B.blockLength || A.blockLength != C.blockLength ) throw new IllegalArgumentException("Block lengths are not all the same."); final int blockLength = A.blockLength; D1Submatrix64F Asub = new D1Submatrix64F(A,0, A.numRows, 0, A.numCols); D1Submatrix64F Bsub = new D1Submatrix64F(B,0, B.numRows, 0, B.numCols); D1Submatrix64F Csub = new D1Submatrix64F(C,0, C.numRows, 0, C.numCols); BlockMultiplication.multTransA(blockLength,Asub,Bsub,Csub); }
D1Submatrix64F subA = new D1Submatrix64F(A); D1Submatrix64F subV = new D1Submatrix64F(V); D1Submatrix64F subU = new D1Submatrix64F(A); double before = subU.get(A.blockLength-1,A.blockLength); subU.set(A.blockLength-1,A.blockLength,1); multPlusTransA(A.blockLength,subV,subU,subA); subU.set(A.blockLength-1,A.blockLength,before);
if( R.getCols() != lengthR ) { throw new IllegalArgumentException("Number of columns in R must be equal to the number of rows in B"); } else if( R.getRows() != lengthR ) { throw new IllegalArgumentException("Number of rows in R must be equal to the number of rows in B"); D1Submatrix64F Y = new D1Submatrix64F(B.original); D1Submatrix64F Rinner = new D1Submatrix64F(R.original); D1Submatrix64F Binner = new D1Submatrix64F(B.original);
public D1Submatrix64F(D1Matrix64F original) { set(original); }
private static void checkInput( int blockLength , D1Submatrix64F A , D1Submatrix64F B , D1Submatrix64F C ) { int Arow = A.getRows();int Acol = A.getCols(); int Brow = B.getRows();int Bcol = B.getCols(); int Crow = C.getRows();int Ccol = C.getCols(); if( Arow != Crow ) throw new RuntimeException("Mismatch A and C rows"); if( Bcol != Ccol ) throw new RuntimeException("Mismatch B and C columns"); if( Acol != Brow ) throw new RuntimeException("Mismatch A columns and B rows"); if( !BlockMatrixOps.blockAligned(blockLength,A)) throw new RuntimeException("Sub-Matrix A is not block aligned"); if( !BlockMatrixOps.blockAligned(blockLength,B)) throw new RuntimeException("Sub-Matrix B is not block aligned"); if( !BlockMatrixOps.blockAligned(blockLength,C)) throw new RuntimeException("Sub-Matrix C is not block aligned"); }
/** * <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); }
public static void multTransA( BlockMatrix64F A , BlockMatrix64F B , BlockMatrix64F C ) { if( A.numRows != B.numRows ) throw new IllegalArgumentException("Rows in A are incompatible with rows in B"); if( A.numCols != C.numRows ) throw new IllegalArgumentException("Columns in A are incompatible with rows in C"); if( B.numCols != C.numCols ) throw new IllegalArgumentException("Columns in B are incompatible with columns in C"); if( A.blockLength != B.blockLength || A.blockLength != C.blockLength ) throw new IllegalArgumentException("Block lengths are not all the same."); final int blockLength = A.blockLength; D1Submatrix64F Asub = new D1Submatrix64F(A,0, A.numRows, 0, A.numCols); D1Submatrix64F Bsub = new D1Submatrix64F(B,0, B.numRows, 0, B.numCols); D1Submatrix64F Csub = new D1Submatrix64F(C,0, C.numRows, 0, C.numCols); BlockMultiplication.multTransA(blockLength,Asub,Bsub,Csub); }