Package org.ujmp.core.doublematrix.impl
Class BlockMultiply
java.lang.Object
org.ujmp.core.doublematrix.impl.BlockMultiply
Multiply blocks of A and B in the specified range(fromM->toM, fromN->toN,
fromK->toK),
and add to matrix C.
and add to matrix C.
C(fromM->toM, fromK->toK) +=
     
A(fromM->toM, fromN->toN) x B(fromN->toN, fromK->toK)
All blocks must be square blocks of the same size, with length of one side =
blockStripeSize
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final int
Length of one side of a block of data.private final int
range of data in matrix to be processed by this instance.private final int
range of data in matrix to be processed by this instance.private final int
range of data in matrix to be processed by this instance.private final BlockDenseDoubleMatrix2D
Source matrices to be processed.private final BlockDenseDoubleMatrix2D
Source matrices to be processed.private final BlockDenseDoubleMatrix2D
Source matrices to be processed.private final int
range of data in matrix to be processed by this instance.private final int
range of data in matrix to be processed by this instance.private final int
range of data in matrix to be processed by this instance. -
Constructor Summary
ConstructorsConstructorDescriptionBlockMultiply
(BlockDenseDoubleMatrix2D a, BlockDenseDoubleMatrix2D b, BlockDenseDoubleMatrix2D c, int fromM, int toM, int fromN, int toN, int fromK, int toK) Constructor taking the two matrices being multiplied, the target matrix C and the range of rows and columns to multiply. -
Method Summary
Modifier and TypeMethodDescriptioncall()
protected final void
multiply()
Multiply blocks of two matrices A,B and add to C.private static void
multiplyAxB
(double[] aBlock, double[] bBlock, double[] cBlock, int step) Multiply row-major block (a) x column-major block (b), and add to block c.void
multiplyRowMajorTimesColumnMajorBlocks
(double[] aBlock, double[] bBlock, double[] cBlock, int aRows, int bRows, int bCols) private static void
verifyInput
(BlockDenseDoubleMatrix2D a, BlockDenseDoubleMatrix2D b, BlockDenseDoubleMatrix2D c, int fromM, int toM, int fromN, int toN, int fromK, int toK)
-
Field Details
-
blockStripeSize
private final int blockStripeSizeLength of one side of a block of data. -
fromM
private final int fromMrange of data in matrix to be processed by this instance. -
toM
private final int toMrange of data in matrix to be processed by this instance. -
fromN
private final int fromNrange of data in matrix to be processed by this instance. -
toN
private final int toNrange of data in matrix to be processed by this instance. -
fromK
private final int fromKrange of data in matrix to be processed by this instance. -
toK
private final int toKrange of data in matrix to be processed by this instance. -
matrixA
Source matrices to be processed. -
matrixB
Source matrices to be processed. -
matrixC
Source matrices to be processed.
-
-
Constructor Details
-
BlockMultiply
public BlockMultiply(BlockDenseDoubleMatrix2D a, BlockDenseDoubleMatrix2D b, BlockDenseDoubleMatrix2D c, int fromM, int toM, int fromN, int toN, int fromK, int toK) Constructor taking the two matrices being multiplied, the target matrix C and the range of rows and columns to multiply.- Parameters:
a
- - matrix A, size (M, N)b
- - matrix B, size (N, K)c
- - result matrix C, size (M, K)fromM
- - start row M in matrix AtoM
- - end row M in AfromN
- - start column N in A (or start row N in B)toN
- - end row NfromK
- - start column K in BtoK
- - end column K in B
-
-
Method Details
-
call
-
multiply
protected final void multiply()Multiply blocks of two matrices A,B and add to C.Blocks of Matrix B are transformed to column-major layout (if not already) to facilitate multiplication.
(If matrices have been created optimally, B should already be column-major) -
multiplyAxB
private static void multiplyAxB(double[] aBlock, double[] bBlock, double[] cBlock, int step) Multiply row-major block (a) x column-major block (b), and add to block c. -
multiplyRowMajorTimesColumnMajorBlocks
public void multiplyRowMajorTimesColumnMajorBlocks(double[] aBlock, double[] bBlock, double[] cBlock, int aRows, int bRows, int bCols) -
verifyInput
private static void verifyInput(BlockDenseDoubleMatrix2D a, BlockDenseDoubleMatrix2D b, BlockDenseDoubleMatrix2D c, int fromM, int toM, int fromN, int toN, int fromK, int toK)
-