Documentation of 'mikera.matrixx.impl.SparseRowMatrix' Java class
SparseRowMatrix
mikera.matrixx.impl

Class SparseRowMatrix

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<INDArray>, java.lang.Iterable<AVector>, INDArray, ISparse, IMatrix, IFastRows


    public class SparseRowMatrix
    extends ASparseRCMatrix
    implements ISparse, IFastRows
    Matrix stored as a collection of normally sparse row vectors. This format is especially efficient for: - innerProduct() with another matrix, especially one with efficient column access like SparseColumnMatrix - access via getRow() operation - transpose into SparseColumnMatrix
    See Also:
    Serialized Form
    • Method Detail

      • create

        public static INDArray create(java.util.ArrayList<INDArray> slices,
                                      int rows,
                                      int cols)
      • componentCount

        public int componentCount()
        Description copied from interface: INDArray
        Returns the number of components of this array. May return 0 if components are not supported
        Specified by:
        componentCount in interface INDArray
        Specified by:
        componentCount in class ASparseRCMatrix
        Returns:
      • getComponent

        public AVector getComponent(int k)
        Description copied from interface: INDArray
        Gets a component from the array at the specified index Will throw an error if components are not supported, or if the component is out of bounds as defined by 0 <= k
        Specified by:
        getComponent in interface INDArray
        Specified by:
        getComponent in class ASparseRCMatrix
        Returns:
      • get

        public double get(int i,
                          int j)
        Description copied from interface: INDArray
        Returns the double value at the specified position in a 2D matrix
        Specified by:
        get in interface INDArray
        Specified by:
        get in interface IMatrix
        Specified by:
        get in class AMatrix
      • set

        public void set(int i,
                        int j,
                        double value)
        Description copied from interface: INDArray
        Sets a value at a given position in a mutable 2D array
        Specified by:
        set in interface INDArray
        Specified by:
        set in interface IMatrix
        Overrides:
        set in class ARectangularMatrix
      • unsafeGet

        public double unsafeGet(int row,
                                int column)
        Description copied from class: AMatrix
        Gets an element in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
        Overrides:
        unsafeGet in class AMatrix
        Returns:
      • unsafeSet

        public void unsafeSet(int i,
                              int j,
                              double value)
        Description copied from class: AMatrix
        Sets an element value in the matrix in an unsafe fashion, without performing bound checks The result is undefined if the row and column are out of bounds.
        Overrides:
        unsafeSet in class AMatrix
      • set

        public void set(AMatrix a)
        Description copied from class: AMatrix
        Sets this matrix with the element values from another matrix. Source matrix must have the same shape.
        Overrides:
        set in class AMatrix
      • setRow

        public void setRow(int i,
                           AVector v)
        Description copied from class: AMatrix
        Sets a row in a matrix to the value specified by the given vector
        Overrides:
        setRow in class AMatrix
      • addAt

        public void addAt(int i,
                          int j,
                          double d)
        Description copied from interface: IMatrix
        Adds a value at a specific position in the matrix, mutating the matrix Does not perform bounds checking - this in an unsafe operation
        Specified by:
        addAt in interface IMatrix
        Overrides:
        addAt in class AMatrix
      • addToArray

        public void addToArray(double[] targetData,
                               int offset)
        Description copied from interface: INDArray
        Adds all the elements of this array to a double array at the specified offset, in row-major order
        Specified by:
        addToArray in interface INDArray
        Overrides:
        addToArray in class AMatrix
      • getColumns

        public java.util.List<AVector> getColumns()
        Description copied from interface: IMatrix
        Gets a List of columns of a matrix. May return either copies or views, depending on the specific matrix type.
        Specified by:
        getColumns in interface IMatrix
        Overrides:
        getColumns in class AMatrix
        Returns:
      • getRow

        public AVector getRow(int i)
        Description copied from interface: IMatrix
        Returns a row of the matrix. May or may not be a view, depending on matrix type. Intended for the fastest possible read access of the row. This often means a view, but might not be (e.g. getRow on a Matrix33 returns a Vector3).
        Specified by:
        getRow in interface IMatrix
        Specified by:
        getRow in interface IFastRows
        Overrides:
        getRow in class AMatrix
      • getRows

        public java.util.List<AVector> getRows()
        Description copied from interface: IMatrix
        Gets a List of rows of a matrix. May return either copies or views, depending on the specific matrix type.
        Specified by:
        getRows in interface IMatrix
        Overrides:
        getRows in class AMatrix
        Returns:
      • getRowView

        public AVector getRowView(int i)
        Description copied from interface: IMatrix
        Returns a row of the matrix as a vector view. May be used to modify the original matrix.
        Specified by:
        getRowView in interface IMatrix
        Overrides:
        getRowView in class AMatrix
      • isUpperTriangular

        public boolean isUpperTriangular()
        Description copied from class: AMatrix
        Returns true if a matrix is upper triangular An upper triangular matrix is defined as having all elements equal to 0.0 where i > j
        Overrides:
        isUpperTriangular in class AMatrix
      • swapRows

        public void swapRows(int i,
                             int j)
        Description copied from class: AMatrix
        Swaps two rows of the matrix in place This is an elementary row operation
        Overrides:
        swapRows in class AMatrix
      • replaceRow

        public void replaceRow(int i,
                               AVector vec)
        Description copied from class: AMatrix
        Replaces a row in a matrix, adding the row to the internal structure of the matrix. Will throw UnsupportedOperationException if not possible for the given matrix type.
        Overrides:
        replaceRow in class AMatrix
      • add

        public void add(AMatrix a)
        Description copied from class: AMatrix
        Adds another matrix to this matrix. Matrices must be the same size.
        Overrides:
        add in class AMatrix
      • copyRowTo

        public void copyRowTo(int i,
                              double[] data,
                              int offset)
        Description copied from class: AMatrix
        Copies the elements in a selected row of this matrix to a double array
        Overrides:
        copyRowTo in class ASparseRCMatrix
        Parameters:
        i - The index of the selected row
        data - Destination double[] array
        offset - Offset into destination array
      • copyColumnTo

        public void copyColumnTo(int col,
                                 double[] targetData,
                                 int offset)
        Description copied from class: AMatrix
        Copies the elements in a selected row of this matrix to a double array
        Overrides:
        copyColumnTo in class ASparseRCMatrix
        targetData - Destination double[] array
      • multiplyCopy

        public AMatrix multiplyCopy(double a)
        Description copied from interface: INDArray
        Returns a copy of the array with all elements multiplied by a single constant value
        Specified by:
        multiplyCopy in interface INDArray
        Overrides:
        multiplyCopy in class AMatrix
        Parameters:
        a - A scalar factor
        Returns:
        A new array, with all element values scaled by the given factor
      • multiplyRow

        public void multiplyRow(int i,
                                double value)
        Description copied from class: AMatrix
        Multiplies a row by a constant factor This is an elementary row operation
        Overrides:
        multiplyRow in class AMatrix
      • rowDotProduct

        public double rowDotProduct(int i,
                                    AVector a)
        Description copied from class: AMatrix
        Returns the dot product of a specific row with a vector. Unsafe operation: performs no bounds checking
        Overrides:
        rowDotProduct in class AMatrix
        Returns:
      • innerProduct

        public AMatrix innerProduct(AMatrix a)
        Description copied from interface: IMatrix
        Computes the inner product of this matrix with another. Equivalent to matrix x matrix multiplication
        Specified by:
        innerProduct in interface IMatrix
        Overrides:
        innerProduct in class AMatrix
        Returns:
      • innerProduct

        public SparseRowMatrix innerProduct(SparseColumnMatrix a)
        Specialised inner product for sparse row matrix multiplied by sparse column matrix.
        Parameters:
        a -
        Returns:
      • exactClone

        public SparseRowMatrix exactClone()
        Description copied from interface: INDArray
        Creates a deep clone of an array, using the same class implementation as the original array
        Specified by:
        exactClone in interface INDArray
        Specified by:
        exactClone in class AMatrix
        Returns:
        A clone of the original array
      • clone

        public AMatrix clone()
        Description copied from interface: INDArray
        Returns a clone of the array data, as a new array which will be fully mutable and may be of a different class to the original. Clone should attempt to return the most efficient possible array type. Clone should preserve sparsity property where possible, but this is not guaranteed.
        Specified by:
        clone in interface INDArray
        Overrides:
        clone in class AMatrix
      • sparse

        public AMatrix sparse()
        Description copied from interface: INDArray
        Coerces this INDArray to a sparse format, without changing its element values. May return the same INDArray if already sparse. May also mutate the internal structure of the original NDArray, or create a view over parts of the original INDArray. You should take a defensive copy of the original NDArray if any of this concerns you. The returned sparse array may not be fully mutable in all elements.
        Specified by:
        sparse in interface INDArray
        Overrides:
        sparse in class ASparseRCMatrix
      • validate

        public void validate()
        Description copied from interface: INDArray
        Validates the internal data structure of the INDArray. Throws an exception on failure. Failure indicates a serious bug and/or data corruption.
        Specified by:
        validate in interface INDArray
        Overrides:
        validate in class ASparseRCMatrix
      • equals

        public boolean equals(AMatrix m)
        Description copied from class: AMatrix
        Returns true if this matrix is exactly equal to another matrix
        Overrides:
        equals in class AMatrix
      • equals

        public boolean equals(IFastRows m)
        Compares this matrix to another matrix implementing IFastColumns This can be much faster than the default equals
        Parameters:
        m -
        Returns:

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.