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 thefieldelement 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
sizeFields inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
zeroElementFields inherited from class org.flag4j.arrays.backend.AbstractTensor
data, rank, shape -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractDenseFieldVector(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.booleanChecks if all data of this matrix are 'close' as defined below.booleanChecks 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 exchangingaxis1andaxis2.Computes the inner product between two vectors.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.doublenorm()Computes the Euclidean norm of this vector.doublenorm(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, subEqMethods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector
dot, get, join, length, makeLikeMatrix, makeLikeTensor, repeat, stack, toMatrixMethods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringTensor
add, addEq, argmax, argmin, copy, dataLength, elemMult, flatten, flatten, get, getZeroElement, makeLikeCooTensor, max, min, reshape, set, setZeroElement, T, T, tensorDot, tensorTr, toCoo, toCooMethods 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, prod, recip, sub, sub, subEq, subEq, sumMethods 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 exchangingaxis1andaxis2.- Specified by:
Hin interfaceTensorOverRing<T extends AbstractDenseFieldVector<T,U, V>, T extends AbstractDenseFieldVector<T, U, V>, V extends Field<V>[], V extends Field<V>> - Overrides:
Hin 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 eitheraxis1oraxis2are out of bounds for the rank of this tensor.- See Also:
-
inner
Computes the inner product between two vectors.
- Specified by:
innerin interfaceVectorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
innerin 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 vectorbdo not have the same number of data.- See Also:
-
outer
Computes the outer product of two vectors.- Specified by:
outerin interfaceVectorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
outerin 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:
normalizein interfaceVectorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
normalizein 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:
magin interfaceVectorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
magin 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:
normin interfaceFieldTensorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Specified by:
normin interfaceRingTensorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
normin 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:
normin interfaceFieldTensorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Specified by:
normin interfaceRingTensorMixin<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Overrides:
normin classAbstractDenseRingVector<T extends AbstractDenseFieldVector<T,U, V>, U extends AbstractDenseFieldMatrix<U, T, V>, V extends Field<V>> - Parameters:
p-pvalue 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:
isInfinitein interfaceTensorOverField<T extends AbstractDenseFieldVector<T,U, V>, T extends AbstractDenseFieldVector<T, U, V>, V extends Field<V>[], V extends Field<V>> - 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. -
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
xandyat 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
xandyat the same positions in the two tensors respectively and satisfy|x-y| <= (absTol + relTol*|y|). Otherwise, returns false. - See Also:
-