Class AbstractDenseFieldVector<T extends AbstractDenseFieldVector<T,U,V>,U extends AbstractDenseFieldMatrix<U,T,V>,V extends Field<V>>
java.lang.Object
org.flag4j.arrays.backend.AbstractTensor<T,V[],V>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor<T,V>
org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector<T,U,V>
org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingVector<T,U,V>
org.flag4j.arrays.backend.field_arrays.AbstractDenseFieldVector<T,U,V>
- Type Parameters:
T
- Type of the vector.U
- Type of matrix equivalent to this vector.V
- Type of thefield
element of this vector.
- All Implemented Interfaces:
Serializable
,FieldTensorMixin<T,
,T, V> TensorOverField<T,
,T, V[], V> RingTensorMixin<T,
,T, V> TensorOverRing<T,
,T, V[], V> SemiringTensorMixin<T,
,T, V> TensorOverSemiring<T,
,T, V[], V> VectorMixin<T,
U, U, V>
- Direct Known Subclasses:
CVector
,FieldVector
public abstract class AbstractDenseFieldVector<T extends AbstractDenseFieldVector<T,U,V>,U extends AbstractDenseFieldMatrix<U,T,V>,V extends Field<V>>
extends AbstractDenseRingVector<T,U,V>
implements VectorMixin<T,U,U,V>, FieldTensorMixin<T,T,V>
The base class for all dense vectors whose data are Field
elements.
Vectors are 1D tensors (i.e. rank 1 tensor).
AbstractDenseFieldVectors have mutable AbstractTensor.data
but a fixed AbstractTensor.shape
.
- 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
ConstructorsModifierConstructorDescriptionprotected
AbstractDenseFieldVector
(Shape shape, V[] entries) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionabs()
Computes the element-wise absolute value of this tensor.boolean
Checks if all data of this matrix are 'close' as defined below.boolean
Checks if all data of this matrix are 'close' as defined below.Computes the element-wise quotient of two matrices.H
(int axis1, int axis2) Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.Computes the inner product between two vectors.boolean
isFinite()
Checks if this tensor only contains finite values.boolean
Checks if this tensor contains at least one infinite value.boolean
isNaN()
Checks if this tensor contains at least one NaN value.mag()
Computes the magnitude of this vector.double
norm()
Computes the Euclidean norm of this vector.double
norm
(double p) Computes the p-norm of this vector.Normalizes this vector to a unit length vector.Computes the outer product of two vectors.sqrt()
Computes the element-wise square root of this tensor.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, makeLikeMatrix, makeLikeTensor, repeat, stack, toMatrix
Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
add, addEq, argmax, argmin, copy, elemMult, flatten, flatten, get, getZeroElement, makeLikeCooTensor, max, min, reshape, set, setZeroElement, T, T, tensorDot, tensorTr, toCoo, toCoo
Methods inherited from class org.flag4j.arrays.backend.AbstractTensor
getData, getRank, getShape, makeLikeTensor, reshape, sameShape, T, totalEntries
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, 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
-
AbstractDenseFieldVector
Creates a tensor with the specified data and shape.- Parameters:
shape
- Shape of this tensor.entries
- Entries of this tensor. If this tensor is dense, this specifies all data within the tensor. If this tensor is sparse, this specifies only the non-zero data of the tensor.
-
-
Method Details
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.- Specified by:
H
in interfaceTensorOverRing<T extends AbstractDenseFieldVector<T,
U, V>, T extends AbstractDenseFieldVector<T, U, V>, V extends Field<V>[], V extends Field<V>> - Overrides:
H
in classAbstractDenseRingVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - 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 eitheraxis1
oraxis2
are out of bounds for the rank of this tensor.- See Also:
-
inner
Computes the inner product between two vectors.
- Specified by:
inner
in interfaceVectorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
inner
in classAbstractDenseSemiringVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Parameters:
b
- Second vector in the inner product.- Returns:
- The inner product between this vector and the vector
b
. - Throws:
IllegalArgumentException
- If this vector and vectorb
do not have the same number of data.- See Also:
-
outer
Computes the outer product of two vectors.- Specified by:
outer
in interfaceVectorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
outer
in classAbstractDenseSemiringVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Parameters:
b
- Second vector in the outer product.- Returns:
- The result of the vector outer product between this vector and
b
. - Throws:
IllegalArgumentException
- If the two vectors do not have the same number of data.
-
abs
Computes the element-wise absolute value of this tensor. -
normalize
Normalizes this vector to a unit length vector.- Specified by:
normalize
in interfaceVectorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
normalize
in classAbstractDenseRingVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Returns:
- This vector normalized to a unit length.
-
mag
Computes the magnitude of this vector.- Specified by:
mag
in interfaceVectorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
mag
in classAbstractDenseSemiringVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Returns:
- The magnitude of this vector.
-
norm
public double norm()Computes the Euclidean norm of this vector.- Specified by:
norm
in interfaceFieldTensorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Specified by:
norm
in interfaceRingTensorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
norm
in classAbstractDenseRingVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Returns:
- The Euclidean norm of this vector.
-
norm
public double norm(double p) Computes the p-norm of this vector.- Specified by:
norm
in interfaceFieldTensorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Specified by:
norm
in interfaceRingTensorMixin<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
norm
in classAbstractDenseRingVector<T extends AbstractDenseFieldVector<T,
U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Parameters:
p
-p
value in the p-norm.- Returns:
- The Euclidean norm of this vector.
-
div
Computes the element-wise quotient of two matrices. -
sqrt
-
isFinite
public boolean isFinite()Checks if this tensor only contains finite values. -
isInfinite
public boolean isInfinite()Checks if this tensor contains at least one infinite value.- Specified by:
isInfinite
in interfaceTensorOverField<T extends AbstractDenseFieldVector<T,
U, V>, T extends AbstractDenseFieldVector<T, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
true
if this tensor contains at least one infinite value;false
otherwise.- See Also:
-
isNaN
public boolean isNaN()Checks if this tensor contains at least one NaN value. -
allClose
Checks if all data of this matrix are 'close' as defined below. Custom tolerances may be specified usingallClose(AbstractDenseFieldVector, double, double)
.- Parameters:
b
- Second tensor in the comparison.- Returns:
- True if both tensors have the same shape and all data are 'close' element-wise, i.e.
elements
x
andy
at the same positions in the two tensors respectively and satisfy|x-y| <= (1E-08 + 1E-05*|y|)
. Otherwise, returns false. - See Also:
-
allClose
Checks if all data of this matrix are 'close' as defined below.- Parameters:
b
- Second tensor in the comparison.- Returns:
- True if both tensors have the same length and all data are 'close' element-wise, i.e.
elements
x
andy
at the same positions in the two tensors respectively and satisfy|x-y| <= (absTol + relTol*|y|)
. Otherwise, returns false. - See Also:
-