Class DictLibMatrixMult


  • public class DictLibMatrixMult
    extends Object
    Utility interface for dictionary matrix multiplication
    • 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 res
        row - the row to add to
        col - the col to add to
        res - the double array to add to
        val - 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 dictionary
        right - Right side dictionary
        leftRows - Left side row offsets
        rightColumns - Right side column offsets
        result - The result matrix
        counts - 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 tsmm
        counts - The frequency of each dictionary entry
        rows - The rows of the dictionary
        cols - The cols of the dictionary
        ret - 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 dictionary
        right - The right side dictionary
        rowsLeft - The row indexes on the left hand side
        colsRight - The column indexes on the right hand side
        result - 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 multiply
        right - Right dictionary to multiply
        rowsLeft - rows for the left dictionary
        colsRight - cols for the right dictionary
        result - 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 multiply
        right - Right dictionary to multiply
        rowsLeft - Rows for the left dictionary
        colsRight - Cols for the right dictionary
        scale - A multiplier to each dictionary entry
        result - The result