Class DoubleMatrix

  • All Implemented Interfaces:
    MatrixI, java.io.Serializable

    public final class DoubleMatrix
    extends java.lang.Object
    implements MatrixI, java.io.Serializable
    A matrix where the elements are doubles
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      DoubleMatrix​(double[][] data)
      Create matrix from a rectangular array of data
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean eq​(DoubleMatrix mat)
      Test equality with another double matrix using == for doubles.
      boolean equals​(java.lang.Object obj)
      Uses the Double.equals() rather than == for compatibility with hashcode.
      double getDEle​(int i, int j)
      Get the element as a double value.
      Dimensions getDimensions()
      Gets the dimensions of the Vector or Matrix
      java.lang.Double getEle​(int i, int j)
      Gets an element of a matrix
      int getNCols()
      The number of columns
      int getNRows()
      The number of rows
      int hashCode()  
      static DoubleMatrix newInstance​(DoubleVector[] rows)
      Create a matrix from an array of Doubles
      static DoubleMatrix newInstance​(java.lang.Double[][] in)
      Create a matrix from an array of Doubles
      void setEle​(int row, int col, double val)
      Sets an element
      void setEle​(int row, int col, java.lang.Object val)
      Set an element of a matrix
      java.lang.Object[][] toArray​(java.lang.Object[][] mat)
      Copies the data to an array
      double[][] toArrayMat()
      Return a cloned copy of the data
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • DoubleMatrix

        public DoubleMatrix​(double[][] data)
        Create matrix from a rectangular array of data
        Parameters:
        data - must be rectangular
    • Method Detail

      • newInstance

        public static DoubleMatrix newInstance​(java.lang.Double[][] in)
        Create a matrix from an array of Doubles
        Parameters:
        in - rectangular array of Doubles
        Returns:
        a new DoubleMatrix
      • newInstance

        public static DoubleMatrix newInstance​(DoubleVector[] rows)
        Create a matrix from an array of Doubles
        Parameters:
        rows - array of DoubleVector's, one per row, must all be the same length
        Returns:
        a new DoubleMatrix
      • getEle

        public java.lang.Double getEle​(int i,
                                       int j)
        Description copied from interface: MatrixI
        Gets an element of a matrix
        Specified by:
        getEle in interface MatrixI
        Parameters:
        i - the row
        j - the column
        Returns:
        the element
      • getDEle

        public double getDEle​(int i,
                              int j)
        Get the element as a double value.
        Parameters:
        i - row
        j - col
        Returns:
        the double value at that position
      • getNRows

        public int getNRows()
        Description copied from interface: MatrixI
        The number of rows
        Specified by:
        getNRows in interface MatrixI
        Returns:
        number of rows
      • getNCols

        public int getNCols()
        Description copied from interface: MatrixI
        The number of columns
        Specified by:
        getNCols in interface MatrixI
        Returns:
        number of columns
      • getDimensions

        public Dimensions getDimensions()
        Description copied from interface: MatrixI
        Gets the dimensions of the Vector or Matrix
        Specified by:
        getDimensions in interface MatrixI
        Returns:
        the dimensions
      • toArrayMat

        public double[][] toArrayMat()
        Return a cloned copy of the data
        Returns:
        data.clone()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setEle

        public void setEle​(int row,
                           int col,
                           double val)
        Sets an element
        Parameters:
        row - the row
        col - the column
        val - value to set
      • toArray

        public java.lang.Object[][] toArray​(java.lang.Object[][] mat)
                                     throws EvaluationException
        Description copied from interface: MatrixI
        Copies the data to an array
        Specified by:
        toArray in interface MatrixI
        Returns:
        mat with the elements filled in
        Throws:
        EvaluationException - if mat is not a matrix of the correct size
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Uses the Double.equals() rather than == for compatibility with hashcode. Hence NaN equals NaN and -0.0 equals 0.0. Use eq(DoubleMatrix) for comparison using ==.
        Overrides:
        equals in class java.lang.Object
      • eq

        public boolean eq​(DoubleMatrix mat)
        Test equality with another double matrix using == for doubles.
        Parameters:
        mat -
        Returns: