Class DictLibMatrixMult
- java.lang.Object
-
- org.apache.sysds.runtime.compress.colgroup.dictionary.DictLibMatrixMult
-
public class DictLibMatrixMult extends Object
Utility interface for dictionary matrix multiplication
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addToUpperTriangle(int nCols, int row, int col, double[] res, double val)
Add to the upper triangle, but twice if on the diagonalstatic void
MMDicts(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, MatrixBlock result)
Matrix Multiply the two dictionaries, note that the left side is considered transposed but not allocated transposed making the multiplication a: t(left) %*% rightstatic void
MMDictsWithScaling(IDictionary left, IDictionary right, IColIndex leftRows, IColIndex rightColumns, MatrixBlock result, int[] counts)
Matrix multiply with scaling (left side transposed)static void
TSMMDictionaryWithScaling(IDictionary dict, int[] counts, IColIndex rows, IColIndex cols, MatrixBlock ret)
Perform the full tsmm with the dictionary (allocating into the entire output matrix.)static void
TSMMToUpperTriangle(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, MatrixBlock result)
Does two matrix multiplications in one go but only add to the upper triangle.static void
TSMMToUpperTriangleScaling(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, int[] scale, MatrixBlock result)
Does two matrix multiplications in one go but only add to the upper triangle with scaling.
-
-
-
Method Detail
-
addToUpperTriangle
public static void addToUpperTriangle(int nCols, int row, int col, double[] res, double val)
Add to the upper triangle, but twice if on the diagonal- Parameters:
nCols
- number cols in resrow
- the row to add tocol
- the col to add tores
- the double array to add toval
- the value to add
-
MMDictsWithScaling
public static void MMDictsWithScaling(IDictionary left, IDictionary right, IColIndex leftRows, IColIndex rightColumns, MatrixBlock result, int[] counts)
Matrix multiply with scaling (left side transposed)- Parameters:
left
- Left side dictionaryright
- Right side dictionaryleftRows
- Left side row offsetsrightColumns
- Right side column offsetsresult
- The result matrixcounts
- The scaling factors
-
TSMMDictionaryWithScaling
public static void TSMMDictionaryWithScaling(IDictionary dict, int[] counts, IColIndex rows, IColIndex cols, MatrixBlock ret)
Perform the full tsmm with the dictionary (allocating into the entire output matrix.)- Parameters:
dict
- The dictionary to tsmmcounts
- The frequency of each dictionary entryrows
- The rows of the dictionarycols
- The cols of the dictionaryret
- The output to add the results to
-
MMDicts
public static void MMDicts(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, MatrixBlock result)
Matrix Multiply the two dictionaries, note that the left side is considered transposed but not allocated transposed making the multiplication a: t(left) %*% right- Parameters:
left
- The left side dictionaryright
- The right side dictionaryrowsLeft
- The row indexes on the left hand sidecolsRight
- The column indexes on the right hand sideresult
- The result matrix to put the results into.
-
TSMMToUpperTriangle
public static void TSMMToUpperTriangle(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, MatrixBlock result)
Does two matrix multiplications in one go but only add to the upper triangle. the two multiplications are: t(left) %*% right t(right) %*% left In practice this operation then only does one of these multiplications but all results that would end up in the lower triangle is transposed and added to the upper triangle. Furthermore all results that would end up on the diagonal is added twice to adhere with the two multiplications- Parameters:
left
- Left dictionary to multiplyright
- Right dictionary to multiplyrowsLeft
- rows for the left dictionarycolsRight
- cols for the right dictionaryresult
- the result
-
TSMMToUpperTriangleScaling
public static void TSMMToUpperTriangleScaling(IDictionary left, IDictionary right, IColIndex rowsLeft, IColIndex colsRight, int[] scale, MatrixBlock result)
Does two matrix multiplications in one go but only add to the upper triangle with scaling. the two multiplications are: t(left) %*% right t(right) %*% left In practice this operation then only does one of these multiplications but all results that would end up in the lower triangle is transposed and added to the upper triangle. Furthermore all results that would end up on the diagonal is added twice to adhere with the two multiplications- Parameters:
left
- Left dictionary to multiplyright
- Right dictionary to multiplyrowsLeft
- Rows for the left dictionarycolsRight
- Cols for the right dictionaryscale
- A multiplier to each dictionary entryresult
- The result
-
-