Class 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 the setEle(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 Matrix
      E getEle​(int i)
      Gets the i-th element of a vector
      int getNEles()
      Gets the number of elements of a vector
      int 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()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • data

        protected final java.lang.Object[] data
    • Constructor Detail

      • GenericVector

        public GenericVector​(java.lang.Object[] data)
        Parameters:
        data -
    • Method Detail

      • getEle

        public E getEle​(int i)
        Description copied from interface: VectorI
        Gets the i-th element of a vector
        Specified by:
        getEle in interface VectorI
        Parameters:
        i - index (starts from 0)
        Returns:
        the i-th element
      • getNEles

        public int getNEles()
        Description copied from interface: VectorI
        Gets the number of elements of a vector
        Specified by:
        getNEles in interface VectorI
        Returns:
        the number of elements
      • getDimensions

        public Dimensions getDimensions()
        Description copied from interface: VectorI
        Gets the dimensions of the Vector or Matrix
        Specified by:
        getDimensions in interface VectorI
        Returns:
        the dimensions
      • equals

        public boolean equals​(java.lang.Object obj)
        Tests equality using the Arrays.equals method.
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object