Class GenericVector<E>
- java.lang.Object
-
- com.singularsys.extensions.matrix.genericmat.GenericVector<E>
-
- Type Parameters:
E- Base type for elements of the matrix.
- All Implemented Interfaces:
VectorI,java.io.Serializable
- Direct Known Subclasses:
ComplexVector,ObjectVector,RationalMatrixFactory.RationalVector
public class GenericVector<E> extends java.lang.Object implements VectorI, java.io.Serializable
Generic implementation of a matrix when all elements are of the base type E. Subclasses just need to provide a constructor and thesetEle(int, Object)method. Both of these take a standard form.class ComplexVector extends GenericVector<Complex> { protected ComplexVector(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 Vector setEle: element should Complex. It was "+val.toString()); } }- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.Object[]data
-
Constructor Summary
Constructors Constructor Description GenericVector(java.lang.Object[] data)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)Tests equality using the Arrays.equals method.DimensionsgetDimensions()Gets the dimensions of the Vector or MatrixEgetEle(int i)Gets the i-th element of a vectorintgetNEles()Gets the number of elements of a vectorinthashCode()voidsetEle(int i, java.lang.Object val)Sets an element of a vector.voidsetEleG(int i, E val)java.lang.Object[]toArray(java.lang.Object[] vec)java.lang.StringtoString()
-
-
-
Method Detail
-
getEle
public E getEle(int i)
Description copied from interface:VectorIGets the i-th element of a vector
-
setEleG
public void setEleG(int i, E val) throws EvaluationException- Throws:
EvaluationException
-
setEle
public void setEle(int i, java.lang.Object val) throws EvaluationExceptionDescription copied from interface:VectorISets an element of a vector.- Specified by:
setElein interfaceVectorI- Throws:
EvaluationException
-
getNEles
public int getNEles()
Description copied from interface:VectorIGets the number of elements of a vector
-
getDimensions
public Dimensions getDimensions()
Description copied from interface:VectorIGets the dimensions of the Vector or Matrix- Specified by:
getDimensionsin interfaceVectorI- Returns:
- the dimensions
-
equals
public boolean equals(java.lang.Object obj)
Tests equality using the Arrays.equals method.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] vec) throws EvaluationException- Specified by:
toArrayin interfaceVectorI- Throws:
EvaluationException
-
-