Class AbstractDenseRingVector<T extends AbstractDenseRingVector<T,U,V>,U extends AbstractDenseRingMatrix<U,T,V>,V extends Ring<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>
- Type Parameters:
T
- Type of the vector.U
- Type of matrix equivalent to this vector.V
- Type of theRing
element of this vector.
- All Implemented Interfaces:
Serializable
,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:
AbstractDenseFieldVector
,RingVector
public abstract class AbstractDenseRingVector<T extends AbstractDenseRingVector<T,U,V>,U extends AbstractDenseRingMatrix<U,T,V>,V extends Ring<V>>
extends AbstractDenseSemiringVector<T,U,V>
implements RingTensorMixin<T,T,V>, VectorMixin<T,U,U,V>
The base class for all dense vectors whose data are Ring
elements.
Vectors are 1D tensors (i.e. rank 1 tensor).
AbstractDenseSemiringVectors 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
AbstractDenseRingVector
(Shape shape, V[] data) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionH
(int... axes) Computes the conjugate transpose of this tensor.H
(int axis1, int axis2) Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.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 element-wise difference between two tensors of the same shape.void
Computes the element-wise difference between two vectors of the same shape and stores the result in this vectors.Methods inherited from class org.flag4j.arrays.backend.semiring_arrays.AbstractDenseSemiringVector
dot, get, inner, join, length, mag, makeLikeMatrix, makeLikeTensor, 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, 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.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
abs, H
-
Constructor Details
-
AbstractDenseRingVector
Creates a tensor with the specified data and shape.- Parameters:
shape
- Shape of this tensor.data
- 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
-
normalize
Normalizes this vector to a unit length vector.- Specified by:
normalize
in interfaceVectorMixin<T extends AbstractDenseRingVector<T,
U, V>, U extends AbstractDenseRingMatrix<U, T, V>, U extends AbstractDenseRingMatrix<U, T, V>, V extends Ring<V>> - Overrides:
normalize
in classAbstractDenseSemiringVector<T extends AbstractDenseRingVector<T,
U, V>, U extends AbstractDenseRingMatrix<U, T, V>, V extends Ring<V>> - Returns:
- This vector normalized to a unit length.
-
norm
public double norm()Computes the Euclidean norm of this vector.- Specified by:
norm
in interfaceRingTensorMixin<T extends AbstractDenseRingVector<T,
U, V>, U extends AbstractDenseRingMatrix<U, T, V>, V extends Ring<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 interfaceRingTensorMixin<T extends AbstractDenseRingVector<T,
U, V>, U extends AbstractDenseRingMatrix<U, T, V>, V extends Ring<V>> - Parameters:
p
-p
value in the p-norm.- Returns:
- The Euclidean norm of this vector.
-
sub
Computes the element-wise difference between two tensors of the same shape.- Specified by:
sub
in interfaceTensorOverRing<T extends AbstractDenseRingVector<T,
U, V>, T extends AbstractDenseRingVector<T, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b
- Second tensor in the element-wise difference.- Returns:
- The difference of this tensor with
b
. - Throws:
TensorShapeException
- If this tensor andb
do not have the same shape.
-
subEq
Computes the element-wise difference between two vectors of the same shape and stores the result in this vectors.- Parameters:
b
- Second vectors in the element-wise difference.- Throws:
TensorShapeException
- If this vectors andb
do not have the same shape.
-
H
Computes the conjugate transpose of a tensor by conjugating and exchangingaxis1
andaxis2
.- Specified by:
H
in interfaceTensorOverRing<T extends AbstractDenseRingVector<T,
U, V>, T extends AbstractDenseRingVector<T, U, V>, V extends Ring<V>[], V extends Ring<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:
-
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:
H
in interfaceTensorOverRing<T extends AbstractDenseRingVector<T,
U, V>, T extends AbstractDenseRingVector<T, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
axes
- Permutation of tensor axis. If the tensor has rankN
, then this must be an array of lengthN
which is a permutation of{0, 1, 2, ..., N-1}
.- Returns:
- The conjugate transpose of this tensor with its axes permuted by the
axes
array. - Throws:
IndexOutOfBoundsException
- If any element ofaxes
is out of bounds for the rank of this tensor.IllegalArgumentException
- Ifaxes
is not a permutation of{1, 2, 3, ... N-1}
.- See Also:
-