Class RingVector<T extends Ring<T>>

Type Parameters:
T - Type of the ring element for the matrix.
All Implemented Interfaces:
Serializable, RingTensorMixin<RingVector<T>,RingVector<T>,T>, TensorOverRing<RingVector<T>,RingVector<T>,T[],T>, SemiringTensorMixin<RingVector<T>,RingVector<T>,T>, TensorOverSemiring<RingVector<T>,RingVector<T>,T[],T>, VectorMixin<RingVector<T>,RingMatrix<T>,RingMatrix<T>,T>

public class RingVector<T extends Ring<T>> extends AbstractDenseRingVector<RingVector<T>,RingMatrix<T>,T>

Instances of this class represents a dense vector backed by a Ring array. The RingVector class provides functionality for matrix operations whose elements are members of a ring, supporting mutable data with a fixed shape.

A RingVector is essentially equivalent to a rank-1 tensor but includes extended functionality and may offer improved performance for certain operations compared to general rank-n tensors.

Key Features:

  • Support for standard vector operations like addition, subtraction, and inner/outer products.
  • Conversion methods to other representations, such as RingMatrix, RingTensor, or COO (Coordinate).
  • Utility methods for checking properties like being the zero vector.

Example Usage:


 // Constructing a complex matrix from an array of complex numbers
 RealInt32[] data = {
     new RealInt32(1), new RealInt32(2),
     new RealInt32(3), new RealInt32(4)
 };
 RingVector<RealInt32> vector = new RingVector(data);

 // Performing vector inner/outer product.
 RealInt32 inner = vector.inner(vector);
 RingMatrix<RealInt32> outer = vector.outer(vector);

 // Checking if the vector only contains zeros.
 boolean isZero = vector.isZeros();
 
See Also:
  • Constructor Details

    • RingVector

      public RingVector(T[] data)
      Creates a ring vector with the specified data and shape.
      Parameters:
      data - Entries of the vector.
    • RingVector

      public RingVector(Shape shape, T[] data)
      Creates a ring vector with the specified data and shape.
      Parameters:
      shape - Shape of the vector to construct.
      data - Entries of the vector.
  • Method Details

    • makeLikeTensor

      public RingVector<T> makeLikeTensor(T[] entries)
      Constructs a dense vector with the specified data of the same type as the vector.
      Specified by:
      makeLikeTensor in class AbstractDenseSemiringVector<RingVector<T extends Ring<T>>,RingMatrix<T extends Ring<T>>,T extends Ring<T>>
      Parameters:
      entries - Entries of the dense vector to construct.
    • makeLikeTensor

      public RingVector<T> makeLikeTensor(Shape shape, T[] entries)
      Constructs a tensor of the same type as this tensor with the given the shape and data. The resulting tensor will also have the same non-zero indices as this tensor.
      Specified by:
      makeLikeTensor in interface TensorOverSemiring<RingVector<T extends Ring<T>>,RingVector<T extends Ring<T>>,T extends Ring<T>[],T extends Ring<T>>
      Specified by:
      makeLikeTensor in class AbstractTensor<RingVector<T extends Ring<T>>,T extends Ring<T>[],T extends Ring<T>>
      Parameters:
      shape - Shape of the tensor to construct.
      entries - Entries of the tensor to construct.
      Returns:
      A tensor of the same type and with the same non-zero indices as this tensor with the given the shape and data.
    • makeLikeMatrix

      protected RingMatrix<T> makeLikeMatrix(Shape shape, T[] entries)
      Constructs a matrix of similar type to this vector with the specified shape and data.
      Specified by:
      makeLikeMatrix in class AbstractDenseSemiringVector<RingVector<T extends Ring<T>>,RingMatrix<T extends Ring<T>>,T extends Ring<T>>
      Parameters:
      shape - Shape of the matrix to construct.
      entries - Entries of the matrix to construct.
      Returns:
      A matrix of similar type to this vector with the specified shape and data.
    • makeLikeCooTensor

      protected CooRingVector<T> makeLikeCooTensor(Shape shape, T[] data, int[][] indices)
      Constructs a sparse COO tensor which is of a similar type as this dense tensor.
      Specified by:
      makeLikeCooTensor in class AbstractDenseSemiringTensor<RingVector<T extends Ring<T>>,T extends Ring<T>>
      Parameters:
      shape - Shape of the COO tensor.
      data - Non-zero data of the COO tensor.
      indices -
      Returns:
      A sparse COO tensor which is of a similar type as this dense tensor.
    • abs

      public Vector abs()
      Computes the element-wise absolute value of this tensor.
      Returns:
      The element-wise absolute value of this tensor.
    • equals

      public boolean equals(Object object)
      Checks if an object is equal to this vector object.
      Overrides:
      equals in class Object
      Parameters:
      object - Object to check equality with this vector.
      Returns:
      true if the two vectors have the same shape, are numerically equivalent, and are of type RingVector. false otherwise.
    • hashCode

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

      public String toString()
      Converts this vector to a human-readable string format. To specify the maximum number of data to print, use PrintOptions.setMaxColumns(int).
      Overrides:
      toString in class Object
      Returns:
      A human-readable string representation of this vector.