org.apache.sysml.runtime.matrix.data

Class MatrixBlock

    • Field Detail

      • ULTRA_SPARSITY_TURN_POINT

        public static final double ULTRA_SPARSITY_TURN_POINT
        See Also:
        Constant Field Values
      • DEFAULT_INPLACE_SPARSEBLOCK

        public static final SparseBlock.Type DEFAULT_INPLACE_SPARSEBLOCK
      • rlen

        protected int rlen
      • clen

        protected int clen
      • sparse

        protected boolean sparse
      • nonZeros

        protected long nonZeros
      • denseBlock

        protected double[] denseBlock
      • estimatedNNzsPerRow

        protected int estimatedNNzsPerRow
      • numGroups

        protected int numGroups
      • diag

        protected boolean diag
    • Constructor Detail

      • MatrixBlock

        public MatrixBlock()
      • MatrixBlock

        public MatrixBlock(int rl,
                           int cl,
                           boolean sp)
      • MatrixBlock

        public MatrixBlock(int rl,
                           int cl,
                           long estnnz)
      • MatrixBlock

        public MatrixBlock(int rl,
                           int cl,
                           boolean sp,
                           long estnnz)
      • MatrixBlock

        public MatrixBlock(int rl,
                           int cl,
                           long nnz,
                           SparseBlock sblock)
        Constructs a sparse MatrixBlock with a given instance of a SparseBlock
        Parameters:
        rl - number of rows
        cl - number of columns
        nnz - number of non zeroes
        sblock - sparse block
    • Method Detail

      • reset

        public void reset(int rl,
                          int cl)
        Specified by:
        reset in class MatrixValue
      • reset

        public void reset(int rl,
                          int cl,
                          long estnnz)
      • reset

        public void reset(int rl,
                          int cl,
                          boolean sp)
        Specified by:
        reset in class MatrixValue
      • reset

        public void reset(int rl,
                          int cl,
                          boolean sp,
                          long estnnz)
        Specified by:
        reset in class MatrixValue
      • reset

        public void reset(int rl,
                          int cl,
                          double val)
        Specified by:
        reset in class MatrixValue
      • init

        public void init(double[][] arr,
                         int r,
                         int c)
                  throws DMLRuntimeException
        NOTE: This method is designed only for dense representation.
        Parameters:
        arr - 2d double array matrix
        r - number of rows
        c - number of columns
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • init

        public void init(double[] arr,
                         int r,
                         int c)
                  throws DMLRuntimeException
        NOTE: This method is designed only for dense representation.
        Parameters:
        arr - double array matrix
        r - number of rows
        c - number of columns
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • isAllocated

        public boolean isAllocated()
      • allocateDenseOrSparseBlock

        public void allocateDenseOrSparseBlock()
      • allocateSparseRowsBlock

        public void allocateSparseRowsBlock()
      • allocateSparseRowsBlock

        public void allocateSparseRowsBlock(boolean clearNNZ)
      • allocateDenseBlockUnsafe

        public void allocateDenseBlockUnsafe(int rl,
                                             int cl)
                                      throws DMLRuntimeException
        This should be called only in the read and write functions for CP This function should be called before calling any setValueDenseUnsafe()
        Parameters:
        rl - number of rows
        cl - number of columns
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • cleanupBlock

        public void cleanupBlock(boolean dense,
                                 boolean sparse)
        Allows to cleanup all previously allocated sparserows or denseblocks. This is for example required in reading a matrix with many empty blocks via distributed cache into in-memory list of blocks - not cleaning blocks from non-empty blocks would significantly increase the total memory consumption.
        Parameters:
        dense - if true, set dense block to null
        sparse - if true, set sparse block to null
      • getNumRows

        public int getNumRows()
        Specified by:
        getNumRows in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Specified by:
        getNumRows in class MatrixValue
      • setNumRows

        public void setNumRows(int r)
        NOTE: setNumRows() and setNumColumns() are used only in tertiaryInstruction (for contingency tables) and pmm for meta corrections.
        Parameters:
        r - number of rows
      • getNumColumns

        public int getNumColumns()
        Specified by:
        getNumColumns in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Specified by:
        getNumColumns in class MatrixValue
      • setNumColumns

        public void setNumColumns(int c)
      • setNonZeros

        public void setNonZeros(long nnz)
      • isVector

        public boolean isVector()
      • isEmptyBlock

        public boolean isEmptyBlock()
      • isEmptyBlock

        public boolean isEmptyBlock(boolean safe)
      • setDiag

        public void setDiag()
      • isDiag

        public boolean isDiag()
      • getDenseBlock

        public double[] getDenseBlock()
      • getSparseBlockIterator

        public Iterator<IJV> getSparseBlockIterator()
      • getSparseBlockIterator

        public Iterator<IJV> getSparseBlockIterator(int rl,
                                                    int ru)
      • getValue

        public double getValue(int r,
                               int c)
        Specified by:
        getValue in class MatrixValue
      • setValue

        public void setValue(int r,
                             int c,
                             double v)
        Specified by:
        setValue in class MatrixValue
      • quickGetValue

        public double quickGetValue(int r,
                                    int c)
      • quickSetValue

        public void quickSetValue(int r,
                                  int c,
                                  double v)
      • getValueDenseUnsafe

        public double getValueDenseUnsafe(int r,
                                          int c)
      • setValueDenseUnsafe

        public void setValueDenseUnsafe(int r,
                                        int c,
                                        double v)
        This can be only called when you know you have properly allocated spaces for a dense representation and r and c are in the the range of the dimension Note: this function won't keep track of the nozeros
        Parameters:
        r - row
        c - column
        v - value
      • getValueSparseUnsafe

        public double getValueSparseUnsafe(int r,
                                           int c)
      • appendValue

        public void appendValue(int r,
                                int c,
                                double v)
        Append value is only used when values are appended at the end of each row for the sparse representation This can only be called, when the caller knows the access pattern of the block
        Parameters:
        r - row
        c - column
        v - value
      • appendRow

        public void appendRow(int r,
                              SparseRow row)
      • appendToSparse

        public void appendToSparse(MatrixBlock that,
                                   int rowoffset,
                                   int coloffset)
      • appendToSparse

        public void appendToSparse(MatrixBlock that,
                                   int rowoffset,
                                   int coloffset,
                                   boolean deep)
      • sortSparseRows

        public void sortSparseRows()
        Sorts all existing sparse rows by column indexes.
      • sortSparseRows

        public void sortSparseRows(int rl,
                                   int ru)
        Sorts all existing sparse rows in range [rl,ru) by column indexes.
        Parameters:
        rl - row lower bound, inclusive
        ru - row upper bound, exclusive
      • minNonZero

        public double minNonZero()
                          throws DMLRuntimeException
        Utility function for computing the min non-zero value.
        Returns:
        minimum non-zero value
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • sum

        public double sum()
                   throws DMLRuntimeException
        Wrapper method for reduceall-sum of a matrix.
        Returns:
        Sum of the values in the matrix.
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • sumSq

        public double sumSq()
                     throws DMLRuntimeException
        Wrapper method for reduceall-sumSq of a matrix.
        Returns:
        Sum of the squared values in the matrix.
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • isInSparseFormat

        public boolean isInSparseFormat()
        Returns the current representation (true for sparse).
        Specified by:
        isInSparseFormat in class MatrixValue
        Returns:
        true if sparse
      • isUltraSparse

        public boolean isUltraSparse()
      • evalSparseFormatInMemory

        public boolean evalSparseFormatInMemory()
        Evaluates if this matrix block should be in sparse format in memory. Note that this call does not change the representation - for this please call examSparsity.
        Returns:
        true if matrix block should be in sparse format in memory
      • evalSparseFormatOnDisk

        public boolean evalSparseFormatOnDisk()
        Evaluates if this matrix block should be in sparse format on disk. This applies to any serialized matrix representation, i.e., when writing to in-memory buffer pool pages or writing to local fs or hdfs.
        Returns:
        true if matrix block should be in sparse format on disk
      • examSparsity

        public void examSparsity()
                          throws DMLRuntimeException
        Evaluates if this matrix block should be in sparse format in memory. Depending on the current representation, the state of the matrix block is changed to the right representation if necessary. Note that this consumes for the time of execution memory for both representations.
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • evalSparseFormatInMemory

        public static boolean evalSparseFormatInMemory(long nrows,
                                                       long ncols,
                                                       long nnz)
        Evaluates if a matrix block with the given characteristics should be in sparse format in memory.
        Parameters:
        nrows - number of rows
        ncols - number of columns
        nnz - number of non-zeros
        Returns:
        true if matrix block shold be in sparse format in memory
      • evalSparseFormatOnDisk

        public static boolean evalSparseFormatOnDisk(long nrows,
                                                     long ncols,
                                                     long nnz)
        Evaluates if a matrix block with the given characteristics should be in sparse format on disk (or in any other serialized representation).
        Parameters:
        nrows - number of rows
        ncols - number of columns
        nnz - number of non-zeros
        Returns:
        true if matrix block shold be in sparse format on disk
      • recomputeNonZeros

        public void recomputeNonZeros()
        Recomputes and materializes the number of non-zero values of the entire matrix block.
      • recomputeNonZeros

        public long recomputeNonZeros(int rl,
                                      int ru,
                                      int cl,
                                      int cu)
        Recomputes the number of non-zero values of a specified range of the matrix block. NOTE: This call does not materialize the compute result in any form.
        Parameters:
        rl - row lower index, 0-based, inclusive
        ru - row upper index, 0-based, inclusive
        cl - column lower index, 0-based, inclusive
        cu - column upper index, 0-based, inclusive
        Returns:
        the number of non-zero values
      • checkNonZeros

        public void checkNonZeros()
        Basic debugging primitive to check correctness of nnz. This method is not intended for production use.
      • checkSparseRows

        public void checkSparseRows()
        Basic debugging primitive to check sparse block column ordering. This method is not intended for production use.
      • copy

        public void copy(int rl,
                         int ru,
                         int cl,
                         int cu,
                         MatrixBlock src,
                         boolean awareDestNZ)
                  throws DMLRuntimeException
        In-place copy of matrix src into the index range of the existing current matrix. Note that removal of existing nnz in the index range and nnz maintenance is only done if 'awareDestNZ=true',
        Parameters:
        rl - row lower index, 0-based
        ru - row upper index, 0-based
        cl - column lower index, 0-based
        cu - column upper index, 0-based
        src - matrix block
        awareDestNZ - true, forces (1) to remove existing non-zeros in the index range of the destination if not present in src and (2) to internally maintain nnz false, assume empty index range in destination and do not maintain nnz (the invoker is responsible to recompute nnz after all copies are done)
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • merge

        public void merge(org.apache.sysml.runtime.controlprogram.caching.CacheBlock that,
                          boolean appendOnly)
                   throws DMLRuntimeException
        Description copied from interface: org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Merge the given block into the current block. Both blocks needs to be of equal dimensions and contain disjoint non-zero cells.
        Specified by:
        merge in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Parameters:
        that - cache block
        appendOnly - ?
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • merge

        public void merge(MatrixBlock that,
                          boolean appendOnly)
                   throws DMLRuntimeException
        Merge disjoint: merges all non-zero values of the given input into the current matrix block. Note that this method does NOT check for overlapping entries; it's the callers reponsibility of ensuring disjoint matrix blocks. The appendOnly parameter is only relevant for sparse target blocks; if true, we only append values and do not sort sparse rows for each call; this is useful whenever we merge iterators of matrix blocks into one target block.
        Parameters:
        that - matrix block
        appendOnly - ?
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • readFields

        public void readFields(DataInput in)
                        throws IOException
        Specified by:
        readFields in interface org.apache.hadoop.io.Writable
        Throws:
        IOException
      • readExternal

        public void readExternal(ObjectInput is)
                          throws IOException
        Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd deserialization.
        Specified by:
        readExternal in interface Externalizable
        Parameters:
        is - object input
        Throws:
        IOException - if IOException occurs
      • writeExternal

        public void writeExternal(ObjectOutput os)
                           throws IOException
        Redirects the default java serialization via externalizable to our default hadoop writable serialization for efficient broadcast/rdd serialization.
        Specified by:
        writeExternal in interface Externalizable
        Parameters:
        os - object output
        Throws:
        IOException - if IOException occurs
      • getExactSizeOnDisk

        public long getExactSizeOnDisk()
        NOTE: The used estimates must be kept consistent with the respective write functions.
        Returns:
        exact size on disk
      • estimateSizeInMemory

        public long estimateSizeInMemory()
      • estimateSizeInMemory

        public static long estimateSizeInMemory(long nrows,
                                                long ncols,
                                                double sparsity)
      • estimateSizeDenseInMemory

        public static long estimateSizeDenseInMemory(long nrows,
                                                     long ncols)
      • estimateSizeSparseInMemory

        public static long estimateSizeSparseInMemory(long nrows,
                                                      long ncols,
                                                      double sparsity)
      • estimateSizeOnDisk

        public long estimateSizeOnDisk()
      • estimateSizeOnDisk

        public static long estimateSizeOnDisk(long nrows,
                                              long ncols,
                                              long nnz)
      • getInMemorySize

        public long getInMemorySize()
        Description copied from interface: org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Get the in-memory size in bytes of the cache block.
        Specified by:
        getInMemorySize in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Returns:
        in-memory size in bytes of cache block
      • getExactSerializedSize

        public long getExactSerializedSize()
        Description copied from interface: org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Get the exact serialized size in bytes of the cache block.
        Specified by:
        getExactSerializedSize in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Returns:
        exact serialized size in bytes of cache block
      • isShallowSerialize

        public boolean isShallowSerialize()
        Description copied from interface: org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Indicates if the cache block is subject to shallow serialized, which is generally true if in-memory size and serialized size are almost identical allowing to avoid unnecessary deep serialize.
        Specified by:
        isShallowSerialize in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Returns:
        true if shallow serialized
      • compactEmptyBlock

        public void compactEmptyBlock()
        Description copied from interface: org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Free unnecessarily allocated empty block.
        Specified by:
        compactEmptyBlock in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
      • leftIndexingOperations

        public MatrixBlock leftIndexingOperations(MatrixBlock rhsMatrix,
                                                  int rl,
                                                  int ru,
                                                  int cl,
                                                  int cu,
                                                  MatrixBlock ret,
                                                  org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
                                           throws DMLRuntimeException
        Method to perform leftIndexing operation for a given lower and upper bounds in row and column dimensions. Updated matrix is returned as the output. Operations to be performed: 1) result=this; 2) result[rowLower:rowUpper, colLower:colUpper] = rhsMatrix;
        Parameters:
        rhsMatrix - matrix
        rl - row lower
        ru - row upper
        cl - column lower
        cu - column upper
        ret - ?
        update - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • leftIndexingOperations

        public MatrixBlock leftIndexingOperations(org.apache.sysml.runtime.instructions.cp.ScalarObject scalar,
                                                  int rl,
                                                  int cl,
                                                  MatrixBlock ret,
                                                  org.apache.sysml.runtime.controlprogram.caching.MatrixObject.UpdateType update)
                                           throws DMLRuntimeException
        Explicitly allow left indexing for scalars. Note: This operation is now 0-based. * Operations to be performed: 1) result=this; 2) result[row,column] = scalar.getDoubleValue();
        Parameters:
        scalar - scalar object
        rl - row lower
        cl - column lower
        ret - ?
        update - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • sliceOperations

        public MatrixBlock sliceOperations(int rl,
                                           int ru,
                                           int cl,
                                           int cu,
                                           org.apache.sysml.runtime.controlprogram.caching.CacheBlock ret)
                                    throws DMLRuntimeException
        Method to perform rangeReIndex operation for a given lower and upper bounds in row and column dimensions. Extracted submatrix is returned as "result". Note: This operation is now 0-based.
        Specified by:
        sliceOperations in interface org.apache.sysml.runtime.controlprogram.caching.CacheBlock
        Parameters:
        rl - row lower
        ru - row upper
        cl - column lower
        cu - column upper
        ret - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • sliceOperations

        public void sliceOperations(ArrayList<org.apache.sysml.runtime.matrix.mapred.IndexedMatrixValue> outlist,
                                    org.apache.sysml.runtime.util.IndexRange range,
                                    int rowCut,
                                    int colCut,
                                    int normalBlockRowFactor,
                                    int normalBlockColFactor,
                                    int boundaryRlen,
                                    int boundaryClen)
        Specified by:
        sliceOperations in class MatrixValue
      • dropLastRowsOrColums

        public void dropLastRowsOrColums(org.apache.sysml.lops.PartialAggregate.CorrectionLocationType correctionLocation)
      • cmOperations

        public org.apache.sysml.runtime.instructions.cp.CM_COV_Object cmOperations(org.apache.sysml.runtime.matrix.operators.CMOperator op)
                                                                            throws DMLRuntimeException
        Throws:
        DMLRuntimeException
      • interQuartileMeanOLD

        public double interQuartileMeanOLD()
                                    throws DMLRuntimeException
        Computes the weighted interQuartileMean. The matrix block ("this" pointer) has two columns, in which the first column refers to the data and second column denotes corresponding weights.
        Returns:
        InterQuartileMean
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • groupedAggOperations

        public MatrixBlock groupedAggOperations(MatrixValue tgt,
                                                MatrixValue wghts,
                                                MatrixValue ret,
                                                int ngroups,
                                                org.apache.sysml.runtime.matrix.operators.Operator op)
                                         throws DMLRuntimeException
        Invocation from CP instructions. The aggregate is computed on the groups object against target and weights. Notes: * The computed number of groups is reused for multiple invocations with different target. * This implementation supports that the target is passed as column or row vector, in case of row vectors we also use sparse-safe implementations for sparse safe aggregation operators.
        Parameters:
        tgt - ?
        wghts - ?
        ret - ?
        ngroups - ?
        op - operator
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • ternaryOperations

        public void ternaryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
                                      double scalarThat,
                                      double scalarThat2,
                                      CTableMap resultMap,
                                      MatrixBlock resultBlock)
                               throws DMLRuntimeException
        D = ctable(A,v2,w) this <- A; scalar_that <- v2; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (v2) from sclar_input2 (scalarThat) (w) from scalar_input3 (scalarThat2)
        Specified by:
        ternaryOperations in class MatrixValue
        Throws:
        DMLRuntimeException
      • ternaryOperations

        public void ternaryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
                                      MatrixIndexes ix1,
                                      double scalarThat,
                                      boolean left,
                                      int brlen,
                                      CTableMap resultMap,
                                      MatrixBlock resultBlock)
                               throws DMLRuntimeException
        Specific ctable case of ctable(seq(...),X), where X is the only matrix input. The 'left' input parameter specifies if the seq appeared on the left, otherwise it appeared on the right.
        Specified by:
        ternaryOperations in class MatrixValue
        Throws:
        DMLRuntimeException
      • ternaryOperations

        public void ternaryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
                                      MatrixValue thatVal,
                                      double scalarThat2,
                                      boolean ignoreZeros,
                                      CTableMap resultMap,
                                      MatrixBlock resultBlock)
                               throws DMLRuntimeException
        D = ctable(A,B,w) this <- A; that <- B; scalar_that2 <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2) NOTE: This method supports both vectors and matrices. In case of matrices and ignoreZeros=true we can also use a sparse-safe implementation
        Specified by:
        ternaryOperations in class MatrixValue
        Throws:
        DMLRuntimeException
      • ternaryOperations

        public void ternaryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
                                      MatrixValue thatMatrix,
                                      double thatScalar,
                                      MatrixBlock resultBlock)
                               throws DMLRuntimeException
        D = ctable(seq,A,w) this <- seq; thatMatrix <- A; thatScalar <- w; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (w) from scalar_input3 (scalarThat2)
        Parameters:
        op - operator
        thatMatrix - matrix value
        thatScalar - scalar double
        resultBlock - result matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • ternaryOperations

        public void ternaryOperations(org.apache.sysml.runtime.matrix.operators.Operator op,
                                      MatrixValue thatVal,
                                      MatrixValue that2Val,
                                      CTableMap resultMap)
                               throws DMLRuntimeException
        D = ctable(A,B,W) this <- A; that <- B; that2 <- W; result <- D (i1,j1,v1) from input1 (this) (i1,j1,v2) from input2 (that) (i1,j1,w) from input3 (that2)
        Parameters:
        op - operator
        thatVal - matrix value 1
        that2Val - matrix value 2
        resultMap - table map
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperations

        public static MatrixBlock randOperations(int rows,
                                                 int cols,
                                                 double sparsity,
                                                 double min,
                                                 double max,
                                                 String pdf,
                                                 long seed)
                                          throws DMLRuntimeException
        Function to generate the random matrix with specified dimensions (block sizes are not specified).
        Parameters:
        rows - number of rows
        cols - number of columns
        sparsity - sparsity as a percentage
        min - minimum value
        max - maximum value
        pdf - pdf
        seed - random seed
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperations

        public static MatrixBlock randOperations(int rows,
                                                 int cols,
                                                 double sparsity,
                                                 double min,
                                                 double max,
                                                 String pdf,
                                                 long seed,
                                                 int k)
                                          throws DMLRuntimeException
        Function to generate the random matrix with specified dimensions (block sizes are not specified).
        Parameters:
        rows - number of rows
        cols - number of columns
        sparsity - sparsity as a percentage
        min - minimum value
        max - maximum value
        pdf - pdf
        seed - random seed
        k - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperations

        public static MatrixBlock randOperations(RandomMatrixGenerator rgen,
                                                 long seed)
                                          throws DMLRuntimeException
        Function to generate the random matrix with specified dimensions and block dimensions.
        Parameters:
        rgen - random matrix generator
        seed - seed value
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperations

        public static MatrixBlock randOperations(RandomMatrixGenerator rgen,
                                                 long seed,
                                                 int k)
                                          throws DMLRuntimeException
        Function to generate the random matrix with specified dimensions and block dimensions.
        Parameters:
        rgen - random matrix generator
        seed - seed value
        k - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperationsInPlace

        public MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen,
                                                 LongStream nnzInBlock,
                                                 org.apache.commons.math3.random.Well1024a bigrand,
                                                 long bSeed)
                                          throws DMLRuntimeException
        Function to generate a matrix of random numbers. This is invoked both from CP as well as from MR. In case of CP, it generates an entire matrix block-by-block. A bigrand is passed so that block-level seeds are generated internally. In case of MR, it generates a single block for given block-level seed bSeed. When pdf="uniform", cell values are drawn from uniform distribution in range [min,max]. When pdf="normal", cell values are drawn from standard normal distribution N(0,1). The range of generated values will always be (-Inf,+Inf).
        Parameters:
        rgen - random matrix generator
        nnzInBlock - number of nonzeros in block
        bigrand - ?
        bSeed - seed value
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • randOperationsInPlace

        public MatrixBlock randOperationsInPlace(RandomMatrixGenerator rgen,
                                                 LongStream nnzInBlock,
                                                 org.apache.commons.math3.random.Well1024a bigrand,
                                                 long bSeed,
                                                 int k)
                                          throws DMLRuntimeException
        Function to generate a matrix of random numbers. This is invoked both from CP as well as from MR. In case of CP, it generates an entire matrix block-by-block. A bigrand is passed so that block-level seeds are generated internally. In case of MR, it generates a single block for given block-level seed bSeed. When pdf="uniform", cell values are drawn from uniform distribution in range [min,max]. When pdf="normal", cell values are drawn from standard normal distribution N(0,1). The range of generated values will always be (-Inf,+Inf).
        Parameters:
        rgen - random matrix generator
        nnzInBlock - number of nonzeros in block
        bigrand - ?
        bSeed - seed value
        k - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • seqOperations

        public static MatrixBlock seqOperations(double from,
                                                double to,
                                                double incr)
                                         throws DMLRuntimeException
        Method to generate a sequence according to the given parameters. The generated sequence is always in dense format. Both end points specified from and to must be included in the generated sequence i.e., [from,to] both inclusive. Note that, to is included only if (to-from) is perfectly divisible by incr. For example, seq(0,1,0.5) generates (0.0 0.5 1.0) whereas seq(0,1,0.6) generates (0.0 0.6) but not (0.0 0.6 1.0)
        Parameters:
        from - ?
        to - ?
        incr - ?
        Returns:
        matrix block
        Throws:
        DMLRuntimeException - if DMLRuntimeException occurs
      • isThreadSafe

        public boolean isThreadSafe()
        Indicates if concurrent modifications of disjoint rows are thread-safe.
        Returns:
        true if thread-safe
      • isThreadSafe

        public static boolean isThreadSafe(boolean sparse)
        Indicates if concurrent modifications of disjoint rows are thread-safe.
        Parameters:
        sparse - true if sparse
        Returns:
        true if ?
      • print

        public void print()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object

Copyright © 2017 The Apache Software Foundation. All rights reserved.