Class AbstractCooFieldVector<T extends AbstractCooFieldVector<T,U,V,W,Y>,U extends AbstractDenseFieldVector<U,W,Y>,V extends AbstractCooFieldMatrix<V,W,T,Y>,W extends AbstractDenseFieldMatrix<W,U,Y>,Y extends Field<Y>>
- Type Parameters:
T- Type of this vector.U- Type of equivalent dense vector.V- Type of matrix equivalent toT.W- Type of dense matrix equivalent toU.Y- Type of the field element in this vector.
- All Implemented Interfaces:
Serializable,FieldTensorMixin<T,,U, Y> TensorOverField<T,,U, Y[], Y> RingTensorMixin<T,,U, Y> TensorOverRing<T,,U, Y[], Y> SemiringTensorMixin<T,,U, Y> TensorOverSemiring<T,,U, Y[], Y> VectorMixin<T,V, W, Y>
- Direct Known Subclasses:
CooCVector,CooFieldVector
A sparse vector stored in coordinate list (COO) format. The AbstractTensor.data of this COO vector are
elements of a Field.
The non-zero data and non-zero indices of a COO vector are mutable but the AbstractTensor.shape
and total number of non-zero data is fixed.
Sparse vectors allow for the efficient storage of and ops on large vectors that contain many zero values.
COO vectors are optimized for large hyper-sparse vectors (i.e. vectors which contain almost all zeros relative to the size of the vector).
A sparse COO vector is stored as:
- The full
AbstractTensor.shape/VectorMixin.size()of the vector. - The non-zero
AbstractTensor.dataof the vector. All other data in the vector are assumed to be zero. Zero values can also explicitly be stored inAbstractTensor.data. - The
AbstractCooSemiringVector.indicesof the non-zero values in the sparse vector.
Note: many ops assume that the data of the COO vector are sorted lexicographically. However, this is not explicitly verified. Every operation implemented in this class will preserve the lexicographical sorting.
If indices need to be sorted for any reason, call AbstractCooSemiringVector.sortIndices().
- See Also:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringVector
indices, nnz, size, sparsityFields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractCooFieldVector(Shape shape, Y[] data, int[] indices) Creates a tensor with the specified data and shape.protectedAbstractCooFieldVector(Shape shape, Y[] data, int[] indices, Object dummy) Creates a tensor with the specified data and shape without performing any validation on the parameters. -
Method Summary
Modifier and TypeMethodDescriptionabs()Computes the element-wise absolute value of this tensor.Computes the element-wise quotient between two tensors.H(int... axes) Computes the conjugate transpose of this tensor.H(int axis1, int axis2) Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.booleanisFinite()Checks if this tensor only contains finite values.booleanChecks if this tensor contains at least one infinite value.booleanisNaN()Checks if this tensor contains at least one NaN value.mag()Computes the magnitude of this vector.Normalizes this vector to a unit length vector.sqrt()Computes the element-wise square root of this tensor.Methods inherited from class org.flag4j.arrays.backend.ring_arrays.AbstractCooRingVector
inner, subMethods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractCooSemiringVector
add, coalesce, coalesce, copy, dataLength, density, dot, dropZeros, elemMult, flatten, flatten, get, get, getZeroElement, join, length, makeLikeDenseMatrix, makeLikeDenseTensor, makeLikeMatrix, makeLikeTensor, makeLikeTensor, outer, repeat, reshape, set, setZeroElement, sortIndices, sparsity, stack, T, T, tensorDot, tensorTr, toDense, toMatrix, toTensor, toTensorMethods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, T, totalEntriesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flag4j.arrays.backend.field_arrays.FieldTensorMixin
add, add, addEq, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, div, div, divEq, divEq, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, mult, multEq, multEq, norm, norm, prod, recip, sub, sub, subEq, subEq, sumMethods inherited from interface org.flag4j.arrays.backend.semiring_arrays.SemiringTensorMixin
argmax, argmin, max, minMethods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
H, sub
-
Constructor Details
-
AbstractCooFieldVector
-
AbstractCooFieldVector
Creates a tensor with the specified data and shape without performing any validation on the parameters.- Parameters:
shape- Shape of this tensor.data- Non-zero entries of the tensor.indices- Non-zero entries of the tensor.dummy- Dummy object to distinguish this constructor from the safe variant.
-
-
Method Details
-
abs
Computes the element-wise absolute value of this tensor.- Specified by:
absin interfaceTensorOverRing<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Returns:
- The element-wise absolute value of this tensor.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1andaxis2.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Overrides:
Hin classAbstractCooRingVector<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>, Y extends Field<Y>> - Parameters:
axis1- First axis to exchange and conjugate.axis2- Second axis to exchange and conjugate.- Returns:
- The conjugate transpose of this tensor according to the specified axes.
- Throws:
IndexOutOfBoundsException- If eitheraxis1oraxis2are out of bounds for the rank of this tensor.- See Also:
-
H
Computes the conjugate transpose of this tensor. That is, conjugates and permutes the axes of this tensor so that it matches the permutation specified byaxes.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Overrides:
Hin classAbstractCooRingVector<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>, Y extends Field<Y>> - Parameters:
axes- Permutation of tensor axis. If the tensor has rankN, then this must be an array of lengthNwhich is a permutation of{0, 1, 2, ..., N-1}.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axesarray. - Throws:
IndexOutOfBoundsException- If any element ofaxesis out of bounds for the rank of this tensor.IllegalArgumentException- Ifaxesis not a permutation of{1, 2, 3, ... N-1}.- See Also:
-
div
Computes the element-wise quotient between two tensors.
WARNING: This method is not supported for sparse tensors. If called on a sparse tensor, an
UnsupportedOperationExceptionwill be thrown. Element-wise division is undefined for sparse matrices as it would almost certainly result in a division by zero.- Specified by:
divin interfaceTensorOverField<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Parameters:
b- Second tensor in the element-wise quotient.- Returns:
- The element-wise quotient of this tensor with
b. - Throws:
UnsupportedOperationException- if this method is ever invoked on a sparse tensor.
-
sqrt
Computes the element-wise square root of this tensor.- Specified by:
sqrtin interfaceTensorOverField<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Returns:
- The element-wise square root of this tensor.
-
isFinite
public boolean isFinite()Checks if this tensor only contains finite values.- Specified by:
isFinitein interfaceTensorOverField<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Returns:
trueif this tensor only contains finite values;falseotherwise.- See Also:
-
isInfinite
public boolean isInfinite()Checks if this tensor contains at least one infinite value.- Specified by:
isInfinitein interfaceTensorOverField<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Returns:
trueif this tensor contains at least one infinite value;falseotherwise.- See Also:
-
isNaN
public boolean isNaN()Checks if this tensor contains at least one NaN value.- Specified by:
isNaNin interfaceTensorOverField<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Returns:
trueif this tensor contains at least one NaN value;falseotherwise.- See Also:
-
normalize
Normalizes this vector to a unit length vector.- Specified by:
normalizein interfaceVectorMixin<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Overrides:
normalizein classAbstractCooSemiringVector<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>, Y extends Field<Y>> - Returns:
- This vector normalized to a unit length.
-
mag
Computes the magnitude of this vector.- Specified by:
magin interfaceVectorMixin<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>> - Overrides:
magin classAbstractCooSemiringVector<T extends AbstractCooFieldVector<T,U, V, W, Y>, U extends AbstractDenseFieldVector<U, W, Y>, V extends AbstractCooFieldMatrix<V, W, T, Y>, W extends AbstractDenseFieldMatrix<W, U, Y>, Y extends Field<Y>> - Returns:
- The magnitude of this vector.
-