Class Basic1DMatrix

  • All Implemented Interfaces:
    java.lang.Iterable<java.lang.Double>

    public class Basic1DMatrix
    extends DenseMatrix
    • Field Detail

      • self

        private double[] self
    • Constructor Detail

      • Basic1DMatrix

        public Basic1DMatrix()
      • Basic1DMatrix

        public Basic1DMatrix​(int rows,
                             int columns)
      • Basic1DMatrix

        public Basic1DMatrix​(int rows,
                             int columns,
                             double[] array)
    • Method Detail

      • zero

        public static Basic1DMatrix zero​(int rows,
                                         int columns)
        Creates a zero Basic1DMatrix of the given shape: rows x columns.
      • constant

        public static Basic1DMatrix constant​(int rows,
                                             int columns,
                                             double constant)
        Creates a constant Basic1DMatrix of the given shape and value.
      • diagonal

        public static Basic1DMatrix diagonal​(int size,
                                             double diagonal)
        Creates a diagonal Basic1DMatrix of the given size whose diagonal elements are equal to diagonal.
      • unit

        public static Basic1DMatrix unit​(int rows,
                                         int columns)
        Creates an unit Basic1DMatrix of the given shape: rows x columns.
      • random

        public static Basic1DMatrix random​(int rows,
                                           int columns,
                                           java.util.Random random)
        Creates a random Basic1DMatrix of the given shape: rows x columns.
      • randomSymmetric

        public static Basic1DMatrix randomSymmetric​(int size,
                                                    java.util.Random random)
        Creates a random symmetric Basic1DMatrix of the given size.
      • from1DArray

        public static Basic1DMatrix from1DArray​(int rows,
                                                int columns,
                                                double[] array)
        Creates a Basic1DMatrix of the given 1D array w/o copying the underlying array.
      • from2DArray

        public static Basic1DMatrix from2DArray​(double[][] array)
        Creates a Basic1DMatrix of the given 2D array with copying the underlying array.
      • fromBinary

        public static Basic1DMatrix fromBinary​(byte[] array)
        Decodes Basic1DMatrix from the given byte array.
        Parameters:
        array - the byte array representing a matrix
        Returns:
        a decoded matrix
      • fromCSV

        public static Basic1DMatrix fromCSV​(java.lang.String csv)
        Parses Basic1DMatrix from the given CSV string.
        Parameters:
        csv - the CSV string representing a matrix
        Returns:
        a parsed matrix
      • fromMatrixMarket

        public static Basic1DMatrix fromMatrixMarket​(java.lang.String mm)
        Parses Basic1DMatrix from the given Matrix Market string.
        Parameters:
        mm - the string in Matrix Market format
        Returns:
        a parsed matrix
      • get

        public double get​(int i,
                          int j)
        Description copied from class: Matrix
        Gets the specified element of this matrix.
        Specified by:
        get in class Matrix
        Parameters:
        i - element's row index
        j - element's column index
        Returns:
        the element of this matrix
      • set

        public void set​(int i,
                        int j,
                        double value)
        Description copied from class: Matrix
        Sets the specified element of this matrix to given value.
        Specified by:
        set in class Matrix
        Parameters:
        i - element's row index
        j - element's column index
        value - element's new value
      • setAll

        public void setAll​(double value)
        Description copied from class: Matrix
        Sets all elements of this matrix to the given value.
        Overrides:
        setAll in class Matrix
        Parameters:
        value - the element's new value
      • swapRows

        public void swapRows​(int i,
                             int j)
        Description copied from class: Matrix
        Swaps the specified rows of this matrix.
        Overrides:
        swapRows in class Matrix
        Parameters:
        i - the row index
        j - the row index
      • swapColumns

        public void swapColumns​(int i,
                                int j)
        Description copied from class: Matrix
        Swaps the specified columns of this matrix.
        Overrides:
        swapColumns in class Matrix
        Parameters:
        i - the column index
        j - the column index
      • getRow

        public Vector getRow​(int i)
        Description copied from class: Matrix
        Copies the specified row of this matrix into the vector.
        Overrides:
        getRow in class DenseMatrix
        Parameters:
        i - the row index
        Returns:
        the row represented as vector
      • copyOfShape

        public Matrix copyOfShape​(int rows,
                                  int columns)
        Description copied from class: Matrix
        Copies this matrix into the new matrix with specified dimensions: rows and columns.
        Specified by:
        copyOfShape in class Matrix
        Parameters:
        rows - the number of rows in new matrix
        columns - the number of columns in new matrix
        Returns:
        the copy of this matrix with new size
      • toArray

        public double[][] toArray()
        Description copied from class: DenseMatrix
        Converts this dense matrix to double array.
        Specified by:
        toArray in class DenseMatrix
        Returns:
        an array representation of this matrix
      • to

        public <T extends Matrix> T to​(MatrixFactory<T> factory)
        Description copied from class: Matrix
        Converts this matrix using the given factory.
        Overrides:
        to in class Matrix
        Type Parameters:
        T - type of the result matrix
        Parameters:
        factory - the factory that creates an output matrix
        Returns:
        converted matrix
      • blankOfShape

        public Matrix blankOfShape​(int rows,
                                   int columns)
        Description copied from class: Matrix
        Creates the blank matrix (a zero matrix with same size) of this matrix of the given shape: rows x columns.
        Specified by:
        blankOfShape in class Matrix
        Returns:
        blank matrix
      • toBinary

        public byte[] toBinary()
        Description copied from class: Matrix
        Encodes this matrix into a byte array.
        Specified by:
        toBinary in class Matrix
        Returns:
        a byte array representing this matrix