Class SemiringVector<T extends Semiring<T>>

Type Parameters:
T - Type of the semiring element for the matrix.
All Implemented Interfaces:
Serializable, SemiringTensorMixin<SemiringVector<T>,SemiringVector<T>,T>, TensorOverSemiring<SemiringVector<T>,SemiringVector<T>,T[],T>, VectorMixin<SemiringVector<T>,SemiringMatrix<T>,SemiringMatrix<T>,T>

public class SemiringVector<T extends Semiring<T>> extends AbstractDenseSemiringVector<SemiringVector<T>,SemiringMatrix<T>,T>

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

A SemiringVector 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 SemiringMatrix, SemiringTensor, 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
 BoolSemiring[] data = {
     new BoolSemiring(true), new BoolSemiring(false),
     new BoolSemiring(true), new BoolSemiring(true)
 };
 SemiringVector<BoolSemiring> vector = new SemiringVector(data);

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

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

    • SemiringVector

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

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