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 boolean
equals(java.lang.Object obj)
Tests equality using the Arrays.equals method.Dimensions
getDimensions()
Gets the dimensions of the Vector or MatrixE
getEle(int i)
Gets the i-th element of a vectorint
getNEles()
Gets the number of elements of a vectorint
hashCode()
void
setEle(int i, java.lang.Object val)
Sets an element of a vector.void
setEleG(int i, E val)
java.lang.Object[]
toArray(java.lang.Object[] vec)
java.lang.String
toString()
-
-
-
Method Detail
-
getEle
public E getEle(int i)
Description copied from interface:VectorI
Gets 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 EvaluationException
Description copied from interface:VectorI
Sets an element of a vector.- Specified by:
setEle
in interfaceVectorI
- Throws:
EvaluationException
-
getNEles
public int getNEles()
Description copied from interface:VectorI
Gets the number of elements of a vector
-
getDimensions
public Dimensions getDimensions()
Description copied from interface:VectorI
Gets the dimensions of the Vector or Matrix- Specified by:
getDimensions
in interfaceVectorI
- Returns:
- the dimensions
-
equals
public boolean equals(java.lang.Object obj)
Tests equality using the Arrays.equals method.- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] vec) throws EvaluationException
- Specified by:
toArray
in interfaceVectorI
- Throws:
EvaluationException
-
-