Class DoubleMatrix
java.lang.Object
com.singularsys.extensions.matrix.doublemat.DoubleMatrix
- All Implemented Interfaces:
MatrixI,Serializable
A matrix where the elements are doubles
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDoubleMatrix(double[][] data) Create matrix from a rectangular array of data -
Method Summary
Modifier and TypeMethodDescriptionbooleaneq(DoubleMatrix mat) Test equality with another double matrix using == for doubles.booleanUses the Double.equals() rather than == for compatibility with hashcode.doublegetDEle(int i, int j) Get the element as a double value.Gets the dimensions of the Vector or MatrixgetEle(int i, int j) Gets an element of a matrixintgetNCols()The number of columnsintgetNRows()The number of rowsinthashCode()static DoubleMatrixnewInstance(DoubleVector[] rows) Create a matrix from an array of Doublesstatic DoubleMatrixnewInstance(Double[][] in) Create a matrix from an array of DoublesvoidsetEle(int row, int col, double val) Sets an elementvoidSet an element of a matrixObject[][]Copies the data to an arraydouble[][]Return a cloned copy of the datatoString()
-
Constructor Details
-
DoubleMatrix
public DoubleMatrix(double[][] data) Create matrix from a rectangular array of data- Parameters:
data- must be rectangular
-
-
Method Details
-
newInstance
Create a matrix from an array of Doubles- Parameters:
in- rectangular array of Doubles- Returns:
- a new DoubleMatrix
-
newInstance
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
Description copied from interface:MatrixIGets an element of a matrix- Specified by:
getElein interfaceMatrixI- Parameters:
i- the rowj- 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
Get the element as a double value.- Parameters:
i- rowj- col- Returns:
- the double value at that position
- Throws:
EvaluationException
-
getNRows
public int getNRows()Description copied from interface:MatrixIThe number of rows -
getNCols
public int getNCols()Description copied from interface:MatrixIThe number of columns -
getDimensions
Description copied from interface:MatrixIGets the dimensions of the Vector or Matrix- Specified by:
getDimensionsin interfaceMatrixI- Returns:
- the dimensions
-
toArrayMat
public double[][] toArrayMat()Return a cloned copy of the data- Returns:
- data.clone()
-
toString
-
setEle
Sets an element- Parameters:
row- the rowcol- the columnval- value to set- Throws:
EvaluationException
-
setEle
Description copied from interface:MatrixISet an element of a matrix- Specified by:
setElein interfaceMatrixI- Parameters:
row-col-val- value to set- Throws:
EvaluationException
-
toArray
Description copied from interface:MatrixICopies the data to an array- Specified by:
toArrayin interfaceMatrixI- 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() -
equals
Uses the Double.equals() rather than == for compatibility with hashcode. Hence, NaN equals NaN and -0.0 equals 0.0. Useeq(DoubleMatrix)for comparison using ==. -
eq
Test equality with another double matrix using == for doubles.- Parameters:
mat-- Returns:
-