/** * <p> * Performs a matrix multiplication on {@link DMatrixRBlock} submatrices.<br> * <br> * c = c + a * b <br> * <br> * </p> * * <p> * It is assumed that all submatrices start at the beginning of a block and end at the end of a block. * </p> * * @param blockLength Size of the blocks in the submatrix. * @param A A submatrix. Not modified. * @param B A submatrix. Not modified. * @param C Result of the operation. Modified, */ public static void multPlus(int blockLength, DSubmatrixD1 A, DSubmatrixD1 B, DSubmatrixD1 C) { // checkShapeMult( blockLength,A,B,C); //CONCURRENT_BELOW EjmlConcurrency.loopFor(A.row0,A.row1,blockLength,i->{ for (int i = A.row0; i < A.row1; i += blockLength) { int heightA = Math.Min(blockLength, A.row1 - i); for (int j = B.col0; j < B.col1; j += blockLength) { int widthB = Math.Min(blockLength, B.col1 - j); int indexC = (i - A.row0 + C.row0) * C.original.numCols + (j - B.col0 + C.col0) * heightA; for (int k = A.col0; k < A.col1; k += blockLength) { int widthA = Math.Min(blockLength, A.col1 - k); int indexA = i * A.original.numCols + k * heightA; int indexB = (k - A.col0 + B.row0) * B.original.numCols + j * widthA; InnerMultiplication_DDRB.blockMultPlus(A.original.data, B.original.data, C.original.data, indexA, indexB, indexC, heightA, widthA, widthB); } } } //CONCURRENT_ABOVE }); }
/** * Special multiplication that takes in account the zeros and one in Y, which * is the matrix that stores the householder vectors. */ public static void multAdd_zeros(int blockLength, DSubmatrixD1 Y, DSubmatrixD1 B, DSubmatrixD1 C) { int widthY = Y.col1 - Y.col0; //CONCURRENT_BELOW EjmlConcurrency.loopFor(Y.row0, Y.row1, blockLength, i -> { for (int i = Y.row0; i < Y.row1; i += blockLength) { int heightY = Math.Min(blockLength, Y.row1 - i); for (int j = B.col0; j < B.col1; j += blockLength) { int widthB = Math.Min(blockLength, B.col1 - j); int indexC = (i - Y.row0 + C.row0) * C.original.numCols + (j - B.col0 + C.col0) * heightY; for (int k = Y.col0; k < Y.col1; k += blockLength) { int indexY = i * Y.original.numCols + k * heightY; int indexB = (k - Y.col0 + B.row0) * B.original.numCols + j * widthY; if (i == Y.row0) { multBlockAdd_zerosone(Y.original.data, B.original.data, C.original.data, indexY, indexB, indexC, heightY, widthY, widthB); } else { InnerMultiplication_DDRB.blockMultPlus(Y.original.data, B.original.data, C.original.data, indexY, indexB, indexC, heightY, widthY, widthB); } } } } //CONCURRENT_ABOVE }); }