Interface VectorMixin<T extends VectorMixin<T,U,V,W>,U extends MatrixMixin<U,V,T,W>,V extends MatrixMixin<V,V,?,W>,W>

Type Parameters:
T - Type of this vector.
U - Type of matrix which is similar to T.
V - Type of dense matrix which is similar to U. If T is dense, then U and T should be the same type.
W - Type (or wrapper of) an individual element of the vector.
All Known Implementing Classes:
AbstractCooFieldVector, AbstractCooRingVector, AbstractCooSemiringVector, AbstractDenseFieldVector, AbstractDenseRingVector, AbstractDenseSemiringVector, CooCVector, CooFieldVector, CooRingVector, CooSemiringVector, CooVector, CVector, FieldVector, RingVector, SemiringVector, Vector

public interface VectorMixin<T extends VectorMixin<T,U,V,W>,U extends MatrixMixin<U,V,T,W>,V extends MatrixMixin<V,V,?,W>,W>
This interface specifies methods which all vectors should implement.
  • Method Summary

    Modifier and Type
    Method
    Description
    dot(T b)
    Computes the dot product between two vectors.
    get(int idx)
    Gets the element of this vector at the specified index.
    inner(T b)
    Computes the inner product between two vectors.
    join(T b)
    Joints specified vector with this vector.
    int
    Gets the length of a vector.
    mag()
    Computes the magnitude of this vector.
    Normalizes this vector to a unit length vector.
    outer(T b)
    Computes the outer product of two vectors.
    repeat(int n, int axis)
    Repeats a vector n times along a certain axis to create a matrix.
    default int
    Gets the size/length of a vector.
    default U
    stack(T b)
    Stacks two vectors vertically as if they were row vectors to form a matrix with two rows.
    stack(T b, int axis)
    Stacks two vectors along specified axis.
    default U
    Converts a vector to an equivalent matrix representing the vector as a column vector.
    toMatrix(boolean columVector)
    Converts a vector to an equivalent matrix representing either a row or column vector.
  • Method Details

    • join

      T join(T b)
      Joints specified vector with this vector. That is, creates a vector of length this.length() + b.length() containing first the elements of this vector followed by the elements of b.
      Parameters:
      b - Vector to join with this vector.
      Returns:
      A vector resulting from joining the specified vector with this vector.
    • inner

      W inner(T b)

      Computes the inner product between two vectors.

      Note: this method is distinct from dot(VectorMixin). The inner product is equivalent to the dot product of this tensor with the conjugation of b.

      Parameters:
      b - Second vector in the inner product.
      Returns:
      The inner product between this vector and the vector b.
      Throws:
      IllegalArgumentException - If this vector and vector b do not have the same number of data.
      See Also:
    • dot

      W dot(T b)

      Computes the dot product between two vectors.

      Note: this method is distinct from inner(VectorMixin). The inner product is equivalent to the dot product of this tensor with the conjugation of b.

      Parameters:
      b - Second vector in the dot product.
      Returns:
      The dot product between this vector and the vector b.
      Throws:
      IllegalArgumentException - If this vector and vector b do not have the same number of data.
      See Also:
    • length

      int length()
      Gets the length of a vector. Same as size().
      Returns:
      The length, i.e. the number of data, in this vector.
    • size

      default int size()
      Gets the size/length of a vector. Same as length().
      Returns:
      The length, i.e. the number of data, in this vector.
    • repeat

      U repeat(int n, int axis)
      Repeats a vector n times along a certain axis to create a matrix.
      Parameters:
      n - Number of times to repeat vector.
      axis - Axis along which to repeat vector:
      • If axis=0, then the vector will be treated as a row vector and stacked vertically n times.
      • If axis=1 then the vector will be treated as a column vector and stacked horizontally n times.
      Returns:
      A matrix whose rows/columns are this vector repeated.
    • stack

      default U stack(T b)
      Stacks two vectors vertically as if they were row vectors to form a matrix with two rows.
      Parameters:
      b - Vector to stack below this vector.
      Returns:
      The result of stacking this vector and vector b.
      Throws:
      IllegalArgumentException - If the number of data in this vector is different from the number of data in the vector b.
    • stack

      U stack(T b, int axis)

      Stacks two vectors along specified axis.

      Stacking two vectors of length n along axis 0 stacks the vectors as if they were row vectors resulting in a 2&times;n matrix.

      Stacking two vectors of length n along axis 1 stacks the vectors as if they were column vectors resulting in a n&times;2 matrix.

      Parameters:
      b - Vector to stack with this vector.
      axis - Axis along which to stack vectors. If axis=0, then vectors are stacked as if they are row vectors. If axis=1, then vectors are stacked as if they are column vectors.
      Returns:
      The result of stacking this vector and the vector b.
      Throws:
      IllegalArgumentException - If the number of data in this vector is different from the number of data in the vector b.
      IllegalArgumentException - If axis is not either 0 or 1.
    • outer

      V outer(T b)
      Computes the outer product of two vectors.
      Parameters:
      b - Second vector in the outer product.
      Returns:
      The result of the vector outer product between this vector and b.
      Throws:
      IllegalArgumentException - If the two vectors do not have the same number of data.
    • toMatrix

      default U toMatrix()
      Converts a vector to an equivalent matrix representing the vector as a column vector.
      Returns:
      A matrix equivalent to this vector as if it were a column vector.
    • toMatrix

      U toMatrix(boolean columVector)
      Converts a vector to an equivalent matrix representing either a row or column vector.
      Parameters:
      columVector - Flag indicating whether to convert this vector to a matrix representing a row or column vector:

      If true, the vector will be converted to a matrix representing a column vector.

      If false, The vector will be converted to a matrix representing a row vector.

      Returns:
      A matrix equivalent to this vector.
    • normalize

      T normalize()
      Normalizes this vector to a unit length vector.
      Returns:
      This vector normalized to a unit length.
    • mag

      W mag()
      Computes the magnitude of this vector.
      Returns:
      The magnitude of this vector.
    • get

      W get(int idx)
      Gets the element of this vector at the specified index.
      Parameters:
      idx - Index of the element to get within this vector.
      Returns:
      The element of this vector at index idx.