Class DoubleMatrix

java.lang.Object
com.singularsys.extensions.matrix.doublemat.DoubleMatrix
All Implemented Interfaces:
MatrixI, Serializable

public final class DoubleMatrix extends Object implements MatrixI, Serializable
A matrix where the elements are doubles
See Also:
  • Constructor Details

    • DoubleMatrix

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

    • newInstance

      public static DoubleMatrix newInstance(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 Double getEle(int i, int j) throws EvaluationException
      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
      Throws:
      EvaluationException - if the index is out of range. Since Jep 4.1 extensions 2.2 this now throws an EvaluationException
    • getDEle

      public double getDEle(int i, int j) throws EvaluationException
      Get the element as a double value.
      Parameters:
      i - row
      j - col
      Returns:
      the double value at that position
      Throws:
      EvaluationException
    • 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 String toString()
      Overrides:
      toString in class Object
    • setEle

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

      public void setEle(int row, int col, Object val) throws EvaluationException
      Description copied from interface: MatrixI
      Set an element of a matrix
      Specified by:
      setEle in interface MatrixI
      Parameters:
      row -
      col -
      val - value to set
      Throws:
      EvaluationException
    • toArray

      public Object[][] toArray(Object[][] mat) throws EvaluationException
      Description copied from interface: MatrixI
      Copies the data to an array
      Specified by:
      toArray in interface MatrixI
      Parameters:
      mat -
      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 Object
    • equals

      public boolean equals(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 Object
    • eq

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