Interface FieldVector<T extends FieldElement<T>>

Type Parameters:
T - the type of the field elements
All Known Implementing Classes:
ArrayFieldVector, SparseFieldVector

public interface FieldVector<T extends FieldElement<T>>
Interface defining a field-valued vector with basic algebraic operations.

vector element indexing is 0-based -- e.g., getEntry(0) returns the first element of the vector.

The various mapXxx and mapXxxToSelf methods operate on vectors element-wise, i.e. they perform the same operation (adding a scalar, applying a function ...) on each element in turn. The mapXxx versions create a new vector to hold the result and do not change the instance. The mapXxxToSelf versions use the instance itself to store the results, so the instance is changed by these methods. In both cases, the result vector is returned by the methods, this allows to use the fluent API style, like this:

   RealVector result = v.mapAddToSelf(3.0).mapTanToSelf().mapSquareToSelf();
 
Since:
2.0
  • Method Details

    • getField

      Field<T> getField()
      Get the type of field elements of the vector.
      Returns:
      type of field elements of the vector
    • copy

      FieldVector<T> copy()
      Returns a (deep) copy of this.
      Returns:
      vector copy
    • add

      Compute the sum of this and v.
      Parameters:
      v - vector to be added
      Returns:
      this + v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • add

      Compute the sum of this and v.
      Parameters:
      v - vector to be added
      Returns:
      this + v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • subtract

      Compute this minus v.
      Parameters:
      v - vector to be subtracted
      Returns:
      this + v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • subtract

      FieldVector<T> subtract(T[] v) throws IllegalArgumentException
      Compute this minus v.
      Parameters:
      v - vector to be subtracted
      Returns:
      this + v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • mapAdd

      FieldVector<T> mapAdd(T d)
      Map an addition operation to each entry.
      Parameters:
      d - value to be added to each entry
      Returns:
      this + d
    • mapAddToSelf

      FieldVector<T> mapAddToSelf(T d)
      Map an addition operation to each entry.

      The instance is changed by this method.

      Parameters:
      d - value to be added to each entry
      Returns:
      for convenience, return this
    • mapSubtract

      FieldVector<T> mapSubtract(T d)
      Map a subtraction operation to each entry.
      Parameters:
      d - value to be subtracted to each entry
      Returns:
      this - d
    • mapSubtractToSelf

      FieldVector<T> mapSubtractToSelf(T d)
      Map a subtraction operation to each entry.

      The instance is changed by this method.

      Parameters:
      d - value to be subtracted to each entry
      Returns:
      for convenience, return this
    • mapMultiply

      FieldVector<T> mapMultiply(T d)
      Map a multiplication operation to each entry.
      Parameters:
      d - value to multiply all entries by
      Returns:
      this * d
    • mapMultiplyToSelf

      FieldVector<T> mapMultiplyToSelf(T d)
      Map a multiplication operation to each entry.

      The instance is changed by this method.

      Parameters:
      d - value to multiply all entries by
      Returns:
      for convenience, return this
    • mapDivide

      FieldVector<T> mapDivide(T d)
      Map a division operation to each entry.
      Parameters:
      d - value to divide all entries by
      Returns:
      this / d
    • mapDivideToSelf

      FieldVector<T> mapDivideToSelf(T d)
      Map a division operation to each entry.

      The instance is changed by this method.

      Parameters:
      d - value to divide all entries by
      Returns:
      for convenience, return this
    • mapInv

      FieldVector<T> mapInv()
      Map the 1/x function to each entry.
      Returns:
      a vector containing the result of applying the function to each entry
    • mapInvToSelf

      FieldVector<T> mapInvToSelf()
      Map the 1/x function to each entry.

      The instance is changed by this method.

      Returns:
      for convenience, return this
    • ebeMultiply

      Element-by-element multiplication.
      Parameters:
      v - vector by which instance elements must be multiplied
      Returns:
      a vector containing this[i] * v[i] for all i
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • ebeMultiply

      FieldVector<T> ebeMultiply(T[] v) throws IllegalArgumentException
      Element-by-element multiplication.
      Parameters:
      v - vector by which instance elements must be multiplied
      Returns:
      a vector containing this[i] * v[i] for all i
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • ebeDivide

      Element-by-element division.
      Parameters:
      v - vector by which instance elements must be divided
      Returns:
      a vector containing this[i] / v[i] for all i
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • ebeDivide

      FieldVector<T> ebeDivide(T[] v) throws IllegalArgumentException
      Element-by-element division.
      Parameters:
      v - vector by which instance elements must be divided
      Returns:
      a vector containing this[i] / v[i] for all i
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • getData

      T[] getData()
      Returns vector entries as a T array.
      Returns:
      T array of entries
    • dotProduct

      T dotProduct(FieldVector<T> v) throws IllegalArgumentException
      Compute the dot product.
      Parameters:
      v - vector with which dot product should be computed
      Returns:
      the scalar dot product between instance and v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • dotProduct

      T dotProduct(T[] v) throws IllegalArgumentException
      Compute the dot product.
      Parameters:
      v - vector with which dot product should be computed
      Returns:
      the scalar dot product between instance and v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • projection

      Find the orthogonal projection of this vector onto another vector.
      Parameters:
      v - vector onto which instance must be projected
      Returns:
      projection of the instance onto v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • projection

      FieldVector<T> projection(T[] v) throws IllegalArgumentException
      Find the orthogonal projection of this vector onto another vector.
      Parameters:
      v - vector onto which instance must be projected
      Returns:
      projection of the instance onto v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • outerProduct

      Compute the outer product.
      Parameters:
      v - vector with which outer product should be computed
      Returns:
      the square matrix outer product between instance and v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • outerProduct

      FieldMatrix<T> outerProduct(T[] v) throws IllegalArgumentException
      Compute the outer product.
      Parameters:
      v - vector with which outer product should be computed
      Returns:
      the square matrix outer product between instance and v
      Throws:
      IllegalArgumentException - if v is not the same size as this
    • getEntry

      T getEntry(int index) throws MatrixIndexException
      Returns the entry in the specified index.

      The index start at 0 and must be lesser than the size, otherwise a MatrixIndexException is thrown.

      Parameters:
      index - index location of entry to be fetched
      Returns:
      vector entry at index
      Throws:
      MatrixIndexException - if the index is not valid
      See Also:
    • setEntry

      void setEntry(int index, T value) throws MatrixIndexException
      Set a single element.
      Parameters:
      index - element index.
      value - new value for the element.
      Throws:
      MatrixIndexException - if the index is inconsistent with vector size
      See Also:
    • getDimension

      int getDimension()
      Returns the size of the vector.
      Returns:
      size
    • append

      FieldVector<T> append(FieldVector<T> v)
      Construct a vector by appending a vector to this vector.
      Parameters:
      v - vector to append to this one.
      Returns:
      a new vector
    • append

      FieldVector<T> append(T d)
      Construct a vector by appending a T to this vector.
      Parameters:
      d - T to append.
      Returns:
      a new vector
    • append

      FieldVector<T> append(T[] a)
      Construct a vector by appending a T array to this vector.
      Parameters:
      a - T array to append.
      Returns:
      a new vector
    • getSubVector

      FieldVector<T> getSubVector(int index, int n) throws MatrixIndexException
      Get a subvector from consecutive elements.
      Parameters:
      index - index of first element.
      n - number of elements to be retrieved.
      Returns:
      a vector containing n elements.
      Throws:
      MatrixIndexException - if the index is inconsistent with vector size
    • setSubVector

      void setSubVector(int index, FieldVector<T> v) throws MatrixIndexException
      Set a set of consecutive elements.
      Parameters:
      index - index of first element to be set.
      v - vector containing the values to set.
      Throws:
      MatrixIndexException - if the index is inconsistent with vector size
      See Also:
    • setSubVector

      void setSubVector(int index, T[] v) throws MatrixIndexException
      Set a set of consecutive elements.
      Parameters:
      index - index of first element to be set.
      v - vector containing the values to set.
      Throws:
      MatrixIndexException - if the index is inconsistent with vector size
      See Also:
    • set

      void set(T value)
      Set all elements to a single value.
      Parameters:
      value - single value to set for all elements
    • toArray

      T[] toArray()
      Convert the vector to a T array.

      The array is independent from vector data, it's elements are copied.

      Returns:
      array containing a copy of vector elements