Class CooFieldVector<T extends Field<T>>

Type Parameters:
T - The type of elements stored in this vector, constrained by the Field interface.
All Implemented Interfaces:
Serializable, FieldTensorMixin<CooFieldVector<T>,FieldVector<T>,T>, TensorOverField<CooFieldVector<T>,FieldVector<T>,T[],T>, RingTensorMixin<CooFieldVector<T>,FieldVector<T>,T>, TensorOverRing<CooFieldVector<T>,FieldVector<T>,T[],T>, SemiringTensorMixin<CooFieldVector<T>,FieldVector<T>,T>, TensorOverSemiring<CooFieldVector<T>,FieldVector<T>,T[],T>, VectorMixin<CooFieldVector<T>,CooFieldMatrix<T>,FieldMatrix<T>,T>

public class CooFieldVector<T extends Field<T>> extends AbstractCooFieldVector<CooFieldVector<T>,FieldVector<T>,CooFieldMatrix<T>,FieldMatrix<T>,T>
Represents a sparse vector whose non-zero elements are stored in Coordinate List (COO) format, with all data elements belonging to a specified Field type.

The COO format stores sparse vector data as a list of coordinates (indices) coupled with their corresponding non-zero values, rather than allocating memory for every element in the full vector shape. This allows efficient representation and manipulation of large vector containing a substantial number of zeros.

A sparse COO vector is stored as:

The total number of non-zero elements (AbstractCooSemiringVector.nnz) and the shape/size is fixed for a given instance, but the values in AbstractTensor.data and their corresponding AbstractCooSemiringVector.indices may be updated. Many operations assume that the indices are sorted lexicographically, but this is not strictly enforced. All provided operations preserve the lexicographical sorting of indices. If there is any doubt about the ordering of indices, use AbstractCooSemiringVector.sortIndices() to ensure they are sorted. COO tensors may also store multiple entries for the same index (referred to as an uncoalesced tensor). To combine all duplicated entries use AbstractCooSemiringVector.coalesce() or AbstractCooSemiringVector.coalesce(BinaryOperator).

COO vectors are optimized for "hyper-sparse" scenarios where the proportion of non-zero elements is extremely low, offering significant memory savings and potentially more efficient computational operations than equivalent dense representations.

Example Usage:


 // shape, data, and indices for COO vector.
 Shape shape = new Shape(512);
 Complex128[] data = {
      new Complex128(1, 2), new Complex128(3, 4), new Complex128(5, 6)
      new Complex128(7, 8), new Complex128(9, 10), new Complex128(11, 12)
 };
 int[] indices = {0, 4, 128, 128, 128, 256};

 // Create COO vector.
 CooFieldVector<Complex128> vector = new CooFieldVector(shape, data, indices);

 // Sum vectors.
 CooFieldVector<Complex128> sum = vector.add(vector);

 // Compute vector inner product.
 Complex128 prod = vector.inner(vector);

 // Compute vector outer product.
 FieldMatrix<Complex128> prod = vector.outer(vector);
 
See Also:
  • Constructor Details

    • CooFieldVector

      public CooFieldVector(int size, T[] entries, int[] indices)
      Creates sparse COO vector with the specified size, non-zero data, and non-zero indices.
      Parameters:
      size - The size of this vector.
      entries - The non-zero data of this vector.
      indices - The indices of the non-zero values.
    • CooFieldVector

      public CooFieldVector(Shape shape, T[] entries, int[] indices)
      Creates sparse COO vector with the specified size, non-zero data, and non-zero indices.
      Parameters:
      entries - The non-zero data of this vector.
      indices - The indices of the non-zero values.
      Shape - The full shape of the vector.
    • CooFieldVector

      public CooFieldVector(int size, List<T> entries, List<Integer> indices)
      Creates sparse COO vector with the specified size, non-zero data, and non-zero indices.
      Parameters:
      size - The size of this vector.
      entries - The non-zero data of this vector.
      indices - The indices of the non-zero values.
    • CooFieldVector

      public CooFieldVector(int size)
      Creates a zero vector of the specified size.
  • Method Details