Class RingVector<T extends Ring<T>>
java.lang.Object
org.flag4j.arrays.backend.AbstractTensor<RingVector<T>,T[],T>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor<RingVector<T>,T>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector<RingVector<T>,RingMatrix<T>,T>
org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingVector<RingVector<T>,RingMatrix<T>,T>
org.flag4j.arrays.dense.RingVector<T>
- Type Parameters:
T
- Type of thering
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:
-
Field Summary
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector
size
Fields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
zeroElement
Fields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape
-
Constructor Summary
ConstructorsConstructorDescriptionRingVector
(Shape shape, T[] data) Creates a ring vector with the specified data and shape.RingVector
(T[] data) Creates a ring vector with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Computes the element-wise absolute value of this tensor.boolean
Checks if an object is equal to this vector object.int
hashCode()
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.protected RingMatrix
<T> makeLikeMatrix
(Shape shape, T[] entries) Constructs a matrix of similar type to this vector with the specifiedshape
anddata
.makeLikeTensor
(Shape shape, T[] entries) Constructs a tensor of the same type as this tensor with the given theshape
anddata
.makeLikeTensor
(T[] entries) Constructs a dense vector with the specifieddata
of the same type as the vector.toString()
Converts this vector to a human-readable string format.Methods inherited from class org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingVector
H, H, norm, norm, normalize, sub, subEq
Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector
dot, get, inner, join, length, mag, outer, repeat, stack, toMatrix
Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
add, addEq, argmax, argmin, copy, elemMult, flatten, flatten, get, getZeroElement, max, min, reshape, set, setZeroElement, T, T, tensorDot, tensorTr, toCoo, toCoo
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, reshape, sameShape, T, totalEntries
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.RingTensorMixin
add, addEq, argmax, argmaxAbs, argmin, argminAbs, conj, isOnes, isZeros, makeEmptyDataArray, max, maxAbs, min, minAbs, mult, multEq, prod, sub, subEq, sum
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
H
-
Constructor Details
-
RingVector
Creates a ring vector with the specified data and shape.- Parameters:
data
- Entries of the vector.
-
RingVector
-
-
Method Details
-
makeLikeTensor
Constructs a dense vector with the specifieddata
of the same type as the vector.- Specified by:
makeLikeTensor
in classAbstractDenseSemiringVector<RingVector<T extends Ring<T>>,
RingMatrix<T extends Ring<T>>, T extends Ring<T>> - Parameters:
entries
- Entries of the dense vector to construct.
-
makeLikeTensor
Constructs a tensor of the same type as this tensor with the given theshape
anddata
. The resulting tensor will also have the same non-zero indices as this tensor.- Specified by:
makeLikeTensor
in interfaceTensorOverSemiring<RingVector<T extends Ring<T>>,
RingVector<T extends Ring<T>>, T extends Ring<T>[], T extends Ring<T>> - Specified by:
makeLikeTensor
in classAbstractTensor<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
anddata
.
-
makeLikeMatrix
Constructs a matrix of similar type to this vector with the specifiedshape
anddata
.- Specified by:
makeLikeMatrix
in classAbstractDenseSemiringVector<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
anddata
.
-
makeLikeCooTensor
Constructs a sparse COO tensor which is of a similar type as this dense tensor.- Specified by:
makeLikeCooTensor
in classAbstractDenseSemiringTensor<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
Computes the element-wise absolute value of this tensor.- Returns:
- The element-wise absolute value of this tensor.
-
equals
Checks if an object is equal to this vector object.- Overrides:
equals
in classObject
- 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 typeRingVector
.false
otherwise.
-
hashCode
-
toString
Converts this vector to a human-readable string format. To specify the maximum number of data to print, usePrintOptions.setMaxColumns(int)
.
-