Class FieldVector<T extends Field<T>>
java.lang.Object
org.flag4j.arrays.backend.AbstractTensor<FieldVector<T>,T[],T>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor<FieldVector<T>,T>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector<FieldVector<T>,FieldMatrix<T>,T>
org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingVector<FieldVector<T>,FieldMatrix<T>,T>
org.flag4j.arrays.backend.field_arrays.AbstractDenseFieldVector<FieldVector<T>,FieldMatrix<T>,T>
org.flag4j.arrays.dense.FieldVector<T>
- Type Parameters:
T
- Type of thefield
element for the matrix.
- All Implemented Interfaces:
Serializable
,FieldTensorMixin<FieldVector<T>,
,FieldVector<T>, T> TensorOverField<FieldVector<T>,
,FieldVector<T>, T[], T> RingTensorMixin<FieldVector<T>,
,FieldVector<T>, T> TensorOverRing<FieldVector<T>,
,FieldVector<T>, T[], T> SemiringTensorMixin<FieldVector<T>,
,FieldVector<T>, T> TensorOverSemiring<FieldVector<T>,
,FieldVector<T>, T[], T> VectorMixin<FieldVector<T>,
FieldMatrix<T>, FieldMatrix<T>, T>
public class FieldVector<T extends Field<T>>
extends AbstractDenseFieldVector<FieldVector<T>,FieldMatrix<T>,T>
Instances of this class represents a dense vector backed by a Field
array. The FieldVector
class
provides functionality for matrix operations whose elements are members of a field, supporting mutable data with a fixed shape.
A FieldVector
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
FieldMatrix
,FieldTensor
, 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
Complex128[] complexData = {
new Complex128(1, 2), new Complex128(3, 4),
new Complex128(5, 6), new Complex128(7, 8)
};
FieldVector<Complex128> vector = new FieldVector(complexData);
// Performing vector inner/outer product.
Complex128 inner = vector.inner(vector);
FieldMatrix<Complex128> 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
ConstructorsConstructorDescriptionFieldVector
(int size, T fillValue) Creates a vector with the specified size filled with thefillValue
.FieldVector
(Shape shape, T[] entries) Constructs a dense complex vector with the given shape and entries.FieldVector
(T... entries) Creates a vector with the specified data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if an object is equal to this vector object.int
hashCode()
protected CooFieldVector
<T> makeLikeCooTensor
(Shape shape, T[] entries, int[][] indices) Constructs a sparse COO tensor which is of a similar type as this dense tensor.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 the shape and data.makeLikeTensor
(T... entries) Creates a vector with the specifieddata
.toString()
Converts this vector to a human-readable string format.Methods inherited from class org.flag4j.arrays.backend.field_arrays.AbstractDenseFieldVector
abs, allClose, allClose, div, H, inner, isFinite, isInfinite, isNaN, mag, norm, norm, normalize, outer, sqrt
Methods inherited from class org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingVector
H, sub, subEq
Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector
dot, get, join, length, 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.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, prod, recip, sub, sub, subEq, subEq, sum
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
H, H, sub
-
Constructor Details
-
FieldVector
Creates a vector with the specified data.- Parameters:
entries
- Entries of this vector.
-
FieldVector
Creates a vector with the specified size filled with thefillValue
.- Parameters:
size
-fillValue
- Value to fill this vector with.
-
FieldVector
Constructs a dense complex vector with the given shape and entries.- Parameters:
shape
- The shape of the vector. Must be rank-1 and satisfyshape.totalEntriesIntValueExact() == data.length
.data
- The entries of the vector.- Throws:
LinearAlgebraException
- Ifshape.getRank() != 1
IllegalArgumentException
- Ifshape.totalEntriesIntValueExact() != data.length
-
-
Method Details
-
makeLikeTensor
Creates a vector with the specifieddata
.- Specified by:
makeLikeTensor
in classAbstractDenseSemiringVector<FieldVector<T extends Field<T>>,
FieldMatrix<T extends Field<T>>, T extends Field<T>> - Parameters:
entries
- Entries of this vector.
-
makeLikeMatrix
Constructs a matrix of similar type to this vector with the specifiedshape
anddata
.- Specified by:
makeLikeMatrix
in classAbstractDenseSemiringVector<FieldVector<T extends Field<T>>,
FieldMatrix<T extends Field<T>>, T extends Field<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
.
-
makeLikeTensor
Constructs a tensor of the same type as this tensor with the given the shape and data.- Specified by:
makeLikeTensor
in interfaceTensorOverSemiring<FieldVector<T extends Field<T>>,
FieldVector<T extends Field<T>>, T extends Field<T>[], T extends Field<T>> - Specified by:
makeLikeTensor
in classAbstractTensor<FieldVector<T extends Field<T>>,
T extends Field<T>[], T extends Field<T>> - Parameters:
shape
- Shape of the tensor to construct.entries
- Entries of the tensor to construct.- Returns:
- A tensor of the same type as this tensor with the given the shape and data.
-
makeLikeCooTensor
Constructs a sparse COO tensor which is of a similar type as this dense tensor.- Specified by:
makeLikeCooTensor
in classAbstractDenseSemiringTensor<FieldVector<T extends Field<T>>,
T extends Field<T>> - Parameters:
shape
- Shape of the COO tensor.entries
- Non-zero data of the COO tensor.indices
-- Returns:
- A sparse COO tensor which is of a similar type as this dense 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 type
FieldVector
. 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)
.
-