|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Number
org.ujmp.core.matrix.AbstractMatrix
org.ujmp.core.genericmatrix.stub.AbstractGenericMatrix<Double>
org.ujmp.core.doublematrix.stub.AbstractDoubleMatrix
org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix
org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D
org.ujmp.core.doublematrix.impl.BlockDenseDoubleMatrix2D
public class BlockDenseDoubleMatrix2D
A dense 2D matrix with square block layout. The data in the matrix is re-organised as a block, tiled layout, which on modern CPUs with multiple caches reduces the number of cache misses, by providing better cache locality and cache temporality.
Example: a 4x4 matrix with block size 2x2 is internally re-organised into 4 separate blocks :
|(0,0) , (0, 1) | (0, 2) , (0, 3) |
|(1,0) , (1, 1) | (1, 2) , (1, 3) |
|----------------------------------
|(2,0) , (2, 1) | (2, 2) , (2, 3) |
|(3,0) , (3, 1) | (3, 2) , (3, 3) |
This can be described as a matrix of the following blocks:
| A | B |
| C | D |
Each block is mapped to a separate one-dimensional array. For example block A:
[ (0,0), (1,0), (0, 1), (1, 1)]
This layout is similar to what's described in [ref: II fig. 4b].
The blocks may be square and can be configured by the user at runtime. However, matrix multiplication performance will be sensitive to the choice of block size, depending on the amount of CPU cache available on the system.
'Efficient Matrix Multiplication Using Cache Conscious Data Layouts';
Neungsoo Park, Wenheng Liuy, Viktor K. Prasanna, Cauligi Raghavendra;
Department of Electrical Engineering{Systems), University of Southern
California
,
'Tiling, Block Data Layout, and Memory Hierarchy Performance';
Neungsoo Park, Bo Hong, and Viktor K. Prasanna
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from interface org.ujmp.core.Matrix |
---|
Matrix.StorageType |
Field Summary | |
---|---|
protected BlockMatrixLayout |
layout
Layout of matrix and blocks. |
Fields inherited from class org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D |
---|
factory |
Fields inherited from interface org.ujmp.core.doublematrix.DenseDoubleMatrix2D |
---|
chol, divideMatrix, divideScalar, eig, inv, invSPD, invSymm, lu, minusMatrix, minusScalar, mtimes, plusMatrix, plusScalar, qr, solve, solveSPD, solveSymm, svd, timesMatrix, timesScalar, transpose |
Fields inherited from interface org.ujmp.core.Matrix |
---|
ALL, COLUMN, LINK, NEW, NONE, ORIG, ROW, X, Y, Z |
Constructor Summary | |
---|---|
BlockDenseDoubleMatrix2D(BlockDenseDoubleMatrix2D m)
Constructor which takes an existing BlockMatrix to copy data and structure from. |
|
BlockDenseDoubleMatrix2D(double[][] values)
|
|
BlockDenseDoubleMatrix2D(double[][] values,
int blockStripeSize,
BlockMatrixLayout.BlockOrder blockOrder)
Create a block matrix from a jagged array. |
|
BlockDenseDoubleMatrix2D(int rows,
int cols)
Create a new matrix with the specified size, and specified block stripe size. |
|
BlockDenseDoubleMatrix2D(int rows,
int cols,
int blockStripeSize,
BlockMatrixLayout.BlockOrder blockOrder)
Create a new matrix with the specified size, and specified block stripe size. |
|
BlockDenseDoubleMatrix2D(long... size)
Create a new matrix with the given size (rows, cols) and default block layout. |
|
BlockDenseDoubleMatrix2D(long rows,
long cols,
BlockMatrixLayout.BlockOrder blockOrder)
Create a new matrix with the given size (rows, cols) and block layout. |
|
BlockDenseDoubleMatrix2D(Matrix m)
Constructor which takes an existing Matrix to copy data and structure from. |
|
BlockDenseDoubleMatrix2D(Matrix m,
int blockStripeSize)
Constructor which takes a Matrix and a proposed default block stripe size. |
|
BlockDenseDoubleMatrix2D(Matrix m,
int blockStripeSize,
BlockMatrixLayout.BlockOrder blockOrder)
Constructor which takes a Matrix and a proposed default block stripe size. |
Method Summary | |
---|---|
protected void |
addBlockData(int row,
int column,
double[] newData)
|
BlockDenseDoubleMatrix2D |
clone()
|
Matrix |
divide(double value)
Divides every entry in the matrix by a scalar. |
Matrix |
divide(Matrix value)
Calculates an entrywise division of the two matrices. |
void |
fill(double[][] data)
|
void |
fill(double[][] data,
int startRow,
int startCol)
Populate matrix with given data. |
double[][] |
getBlockDoubleArray2D()
|
BlockMatrixLayout |
getBlockLayout()
|
int |
getBlockStripeSize()
|
double |
getDouble(int row,
int col)
|
double |
getDouble(long row,
long column)
|
long[] |
getSize()
|
Matrix |
minus(double value)
Subtracts a specified value from all entries in the matrix. |
Matrix |
minus(Matrix value)
Calculates the difference of the entries in both matrices |
Matrix |
mtimes(Matrix m2)
Shortcut to create a BlockMatrix for target |
Matrix |
plus(double value)
Adds a specified value to all entries in the matrix. |
Matrix |
plus(Matrix value)
Calculates the sum of the entries in both matrices |
BlockMatrixLayout.BlockOrder |
setBlockOrder(BlockMatrixLayout.BlockOrder order)
Change layout of blocks in this matrix (e.g. switch form rowmajor to columnmajor). |
void |
setDouble(double value,
int row,
int column)
|
void |
setDouble(double value,
long row,
long column)
|
Matrix |
times(double value)
Multiplies every entry in the matrix with a scalar. |
Matrix |
times(Matrix value)
Calculates the entrywise product of the two matrices. |
Matrix |
transpose()
Returns the transpose of the current matrix. |
Matrix |
transpose(Calculation.Ret returnType)
Returns the transpose of the Matrix, where rows and columns are exchanged. |
Methods inherited from class org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix2D |
---|
allCoordinates, getAsDouble, getAsDouble, getDouble, getFactory, getObject, getObject, setAsDouble, setAsDouble, setDouble, setObject, setObject |
Methods inherited from class org.ujmp.core.doublematrix.stub.AbstractDenseDoubleMatrix |
---|
contains, getStorageType |
Methods inherited from class org.ujmp.core.doublematrix.stub.AbstractDoubleMatrix |
---|
getAsDouble, getObject, getValueType, setAsDouble, setObject |
Methods inherited from class org.ujmp.core.genericmatrix.stub.AbstractGenericMatrix |
---|
getAsObject, setAsObject |
Methods inherited from class java.lang.Number |
---|
byteValue, shortValue |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.ujmp.core.genericmatrix.GenericMatrix |
---|
getObject, setObject |
Methods inherited from interface org.ujmp.core.interfaces.CoreObject |
---|
getCoreObjectId |
Methods inherited from interface org.ujmp.core.interfaces.Clearable |
---|
clear |
Methods inherited from interface org.ujmp.core.interfaces.HasGUIObject |
---|
getGUIObject, notifyGUIObject, showGUI |
Methods inherited from interface org.ujmp.core.interfaces.HasLabel |
---|
getLabel, setLabel |
Methods inherited from interface org.ujmp.core.io.ExportMatrixInterface |
---|
exportToClipboard, exportToFile, exportToFile, exportToFile, exportToFile, exportToStream, exportToString, exportToWriter |
Methods inherited from interface org.ujmp.core.interfaces.CoordinateFunctions |
---|
availableCoordinates, contains, getCoordinatesOfMaximum, getCoordinatesOfMinimum, nonZeroCoordinates, selectedCoordinates, selectedCoordinates |
Methods inherited from interface org.ujmp.core.interfaces.GettersAndSetters |
---|
getAsBigDecimal, getAsBigInteger, getAsBoolean, getAsByte, getAsChar, getAsDate, getAsDouble, getAsFloat, getAsInt, getAsLong, getAsMatrix, getAsObject, getAsShort, getAsString, getPreferredObject, setAsBigDecimal, setAsBigInteger, setAsBoolean, setAsByte, setAsChar, setAsDate, setAsDouble, setAsFloat, setAsInt, setAsLong, setAsMatrix, setAsObject, setAsShort, setAsString, toBigDecimalArray, toBigIntegerArray, toBooleanArray, toByteArray, toCharArray, toDateArray, toDoubleArray, toFloatArray, toIntArray, toLongArray, toObjectArray, toShortArray, toStringArray |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.basic.BasicDoubleCalculations |
---|
atimes, divide, divide, minus, minus, mtimes, mtimes, mtimes, plus, plus, times, times |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.entrywise.basic.BasicEntrywiseDoubleCalculations |
---|
abs, exp, log, log10, log2, power, power, sign, sqrt |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.entrywise.rounding.RoundingDoubleCalculations |
---|
ceil, floor, round |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.entrywise.hyperbolic.HyperbolicDoubleCalculations |
---|
cosh, sinh, tanh |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.entrywise.trigonometric.TrigonometricDoubleCalculations |
---|
cos, sin, tan |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.entrywise.creators.CreatorDoubleCalculations |
---|
eye, ones, rand, randn, zeros |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.general.statistical.StatisticalDoubleCalculations |
---|
corrcoef, cov, cumprod, cumsum, diff, indexOfMax, indexOfMin, max, mean, min, mutualInf, pairedTTest, prod, std, sum, var |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.general.decomposition.DecompositionDoubleCalculations |
---|
chol, eig, eigSymm, ginv, inv, invSPD, invSymm, lu, pinv, princomp, qr, solve, solveSPD, solveSymm, svd |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.general.missingvalues.MissingValueDoubleCalculations |
---|
addMissing, countMissing, deleteColumnsWithMissingValues, deleteRowsWithMissingValues, impute |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.general.misc.MiscGeneralDoubleCalculations |
---|
append, appendHorizontally, appendVertically, center, fadeIn, fadeOut, normalize, replaceMissingBy, standardize |
Methods inherited from interface org.ujmp.core.doublematrix.calculation.general.discretize.DiscretizeCalculations |
---|
discretizeToColumns |
Methods inherited from interface org.ujmp.core.booleanmatrix.calculation.BooleanCalculations |
---|
and, and, eq, eq, ge, ge, gt, gt, le, le, lt, lt, ne, ne, not, or, or, xor, xor |
Methods inherited from interface org.ujmp.core.intmatrix.calculation.IntCalculations |
---|
discretize |
Methods inherited from interface org.ujmp.core.stringmatrix.calculation.StringCalculations |
---|
lowerCase, removePunctuation, removeWords, replaceRegex, replaceRegex, stem, tfIdf, upperCase |
Methods inherited from interface org.ujmp.core.objectmatrix.calculation.ObjectCalculations |
---|
bootstrap, bootstrap, convert, copy, delete, delete, delete, deleteColumns, deleteColumns, deleteRows, deleteRows, extractAnnotation, fill, flipdim, includeAnnotation, replace, reshape, select, select, select, selectColumns, selectColumns, selectRows, selectRows, shuffle, sortrows, squeeze, subMatrix, swap, toColumnVector, toRowVector, transpose, tril, triu, unique, uniqueValueCount |
Methods inherited from interface org.ujmp.core.interfaces.DistanceMeasures |
---|
chebyshevDistanceTo, euklideanDistanceTo, manhattenDistanceTo, minkowskiDistanceTo |
Methods inherited from interface java.lang.Comparable |
---|
compareTo |
Methods inherited from interface org.ujmp.core.annotation.HasAnnotation |
---|
getAnnotation, getAxisAnnotation, getAxisAnnotation, getColumnForLabel, getColumnLabel, getColumnObject, getMatrixAnnotation, getPositionForLabel, getRowForLabel, getRowLabel, getRowObject, setAnnotation, setAxisAnnotation, setAxisAnnotation, setColumnLabel, setColumnObject, setMatrixAnnotation, setRowLabel, setRowObject |
Methods inherited from interface org.ujmp.core.interfaces.Conversions |
---|
toBigDecimalMatrix, toBigIntegerMatrix, toBooleanMatrix, toByteMatrix, toCharMatrix, toDateMatrix, toDoubleMatrix, toFloatMatrix, toIntMatrix, toListMatrix, toLongMatrix, toMapMatrix, toObjectMatrix, toSetMatrix, toShortMatrix, toStringMatrix |
Field Detail |
---|
protected BlockMatrixLayout layout
Constructor Detail |
---|
public BlockDenseDoubleMatrix2D(double[][] values)
public BlockDenseDoubleMatrix2D(double[][] values, int blockStripeSize, BlockMatrixLayout.BlockOrder blockOrder)
values
- - the data to populate the matrix with.blockStripeSize
- - length of one side of a blockblockOrder
- - see BlockMatrixLayout.BlockOrder
.
NullPointerException
- if values is null, or values[0] is null.
ArrayIndexOutOfBoundsException
- if any row is shorter than the first row.public BlockDenseDoubleMatrix2D(int rows, int cols, int blockStripeSize, BlockMatrixLayout.BlockOrder blockOrder)
rows
- - number of rows of the matrix.cols
- - number of columns of the matrix.blockStripeSize
- - length of one side of a square block.
IllegalArgumentException
- if rows, cols or blockStripeSize are 0 or less, or blockOrder
is null.public BlockDenseDoubleMatrix2D(long rows, long cols, BlockMatrixLayout.BlockOrder blockOrder)
#BlockMatrix(int, int)
public BlockDenseDoubleMatrix2D(int rows, int cols)
rows
- - number of rows of the matrix.cols
- - number of columns of the matrix.
IllegalArgumentException
- if rows, cols are 0 or less.public BlockDenseDoubleMatrix2D(long... size)
public BlockDenseDoubleMatrix2D(Matrix m)
m
- - matrix to copy data from.public BlockDenseDoubleMatrix2D(BlockDenseDoubleMatrix2D m)
public BlockDenseDoubleMatrix2D(Matrix m, int blockStripeSize)
m
- - matrix containing existing values.blockStripeSize
- - proposed default block size.public BlockDenseDoubleMatrix2D(Matrix m, int blockStripeSize, BlockMatrixLayout.BlockOrder blockOrder)
m
- - matrix containing existing values.blockStripeSize
- - proposed default block size.blockOrder
- row major or column majorMethod Detail |
---|
protected void addBlockData(int row, int column, double[] newData)
public void fill(double[][] data)
fill(double[][], int, int)
public void fill(double[][] data, int startRow, int startCol)
data
- - to fill into matrixstartRow
- - row to start filling in data atstartCol
- - col to start atpublic final BlockMatrixLayout getBlockLayout()
BlockMatrixLayout
of this matrix.public final int getBlockStripeSize()
public double getDouble(int row, int col)
getDouble
in interface DoubleMatrix2D
public double getDouble(long row, long column)
getDouble
in interface DoubleMatrix2D
public long[] getSize()
getSize
in interface BasicMatrixProperties
public Matrix mtimes(Matrix m2)
mtimes
in interface BasicDoubleCalculations
mtimes
in class AbstractDenseDoubleMatrix2D
m2
- the second matrix
public void setDouble(double value, int row, int column)
setDouble
in interface DoubleMatrix2D
public void setDouble(double value, long row, long column)
setDouble
in interface DoubleMatrix2D
public Matrix transpose() throws MatrixException
transpose
in interface ObjectCalculations
transpose
in class AbstractDenseDoubleMatrix2D
MatrixException
public BlockDenseDoubleMatrix2D clone()
clone
in interface CoreObject
clone
in interface Matrix
clone
in class AbstractMatrix
public Matrix transpose(Calculation.Ret returnType)
ObjectCalculations
transpose
in interface ObjectCalculations
transpose
in class AbstractMatrix
returnType
- Defines if a new Matrix or a link should be returned.
public final double[][] getBlockDoubleArray2D()
getBlockDoubleArray2D
in interface HasBlockDoubleArray2D
public Matrix plus(double value)
BasicDoubleCalculations
plus
in interface BasicDoubleCalculations
plus
in class AbstractDenseDoubleMatrix2D
value
- the value to add
public Matrix plus(Matrix value)
BasicDoubleCalculations
plus
in interface BasicDoubleCalculations
plus
in class AbstractDenseDoubleMatrix2D
value
- The matrix to add
public Matrix minus(Matrix value)
BasicDoubleCalculations
minus
in interface BasicDoubleCalculations
minus
in class AbstractDenseDoubleMatrix2D
value
- The matrix to subtract
public Matrix times(Matrix value)
BasicDoubleCalculations
times
in interface BasicDoubleCalculations
times
in class AbstractDenseDoubleMatrix2D
value
- the second matrix
public Matrix divide(Matrix value)
BasicDoubleCalculations
divide
in interface BasicDoubleCalculations
divide
in class AbstractDenseDoubleMatrix2D
value
- the second matrix
public Matrix minus(double value)
BasicDoubleCalculations
minus
in interface BasicDoubleCalculations
minus
in class AbstractDenseDoubleMatrix2D
value
- the value to subtract
public Matrix times(double value)
BasicDoubleCalculations
times
in interface BasicDoubleCalculations
times
in class AbstractDenseDoubleMatrix2D
value
- factor to multiply with
public Matrix divide(double value)
BasicDoubleCalculations
divide
in interface BasicDoubleCalculations
divide
in class AbstractDenseDoubleMatrix2D
value
- factor by which to divide
public BlockMatrixLayout.BlockOrder setBlockOrder(BlockMatrixLayout.BlockOrder order)
order
- - new block layout order.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |