Class GenericMatrix<E>
java.lang.Object
com.singularsys.extensions.matrix.genericmat.GenericMatrix<E>
- Type Parameters:
E- Base type for elements of the matrix.
- All Implemented Interfaces:
MatrixI,Serializable
- Direct Known Subclasses:
ComplexMatrix,ObjectMatrix,RationalMatrixFactory.RationalMatrix
Generic implementation of a matrix when all elements are of the base type E.
Subclasses just need to provide a constructor and
the
setEle(int, int, Object) method. Both of these take a standard form.
class ComplexMatrix extends GenericMatrix<Complex> {
protected ComplexMatrix(Complex[][] data) {
super(data);
}
@Override
public void setEle(int row, int col, Object val) throws EvaluationException {
if(val instanceof Complex)
this.setEleG(row, col, (Complex) val);
else
throw new EvaluationException("Complex matrix setEle: element at "+row+", "+col+" should be Complex. It was "+val.toString());
}
}
Since Jep 4.0/Extensions 2.1 fix bug with equals(Object) which did not uses Arrays.deepEquals.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanGets the dimensions of the Vector or Matrixfinal EgetEle(int i, int j) Gets an element of a matrixfinal intgetNCols()The number of columnsfinal intgetNRows()The number of rowsinthashCode()voidSet an element of a matrixfinal voidSet an element of a known type E.Object[][]Copies the data to an arraytoString()
-
Field Details
-
data
-
-
Constructor Details
-
GenericMatrix
- Parameters:
data-
-
-
Method Details
-
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
-
setEleG
Set an element of a known type E. Subclasses should call this method from theirsetEle(int, int, Object)method.- Parameters:
i- index for the row (starting at 0)j- index for the column (starting at 0)val- matrix element- 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
-
getNCols
public final int getNCols()Description copied from interface:MatrixIThe number of columns -
getNRows
public final int getNRows()Description copied from interface:MatrixIThe number of rows -
getDimensions
Description copied from interface:MatrixIGets the dimensions of the Vector or Matrix- Specified by:
getDimensionsin interfaceMatrixI- Returns:
- the dimensions
-
equals
-
hashCode
public int hashCode() -
toString
-
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
-