Class AbstractDenseRingTensor<T extends AbstractDenseRingTensor<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.ring_arrays.AbstractDenseRingTensor<T,V>
- Type Parameters:
T
- The type of this dense tensor.V
- The type of theRing
which this tensor's data belong to.U
- Type of sparse tensor equivalent toT
. This type parameter is required because some ops (e.g.AbstractDenseSemiringTensor.toCoo()
) may result in a sparse tensor.
- All Implemented Interfaces:
Serializable
,RingTensorMixin<T,
,T, V> TensorOverRing<T,
,T, V[], V> SemiringTensorMixin<T,
,T, V> TensorOverSemiring<T,
T, V[], V>
- Direct Known Subclasses:
AbstractDenseFieldTensor
,RingTensor
public abstract class AbstractDenseRingTensor<T extends AbstractDenseRingTensor<T,V>,V extends Ring<V>>
extends AbstractDenseSemiringTensor<T,V>
implements RingTensorMixin<T,T,V>
The base class for all dense Ring
tensors.
The AbstractTensor.data
of an AbstractDenseRingTensor are mutable but the AbstractTensor.shape
is fixed.
- See Also:
-
Field Summary
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
AbstractDenseRingTensor
(Shape shape, V[] data) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionint[]
Finds the indices of the maximum absolute value in this tensor.int[]
Finds the indices of the minimum absolute value in this tensor.H
(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
maxAbs()
Finds the maximum absolute value in this tensor.double
minAbs()
Finds the minimum value, in absolute value, in this tensor.Computes the element-wise difference between two tensors of the same shape.void
Computes the element-wise difference between two tensors of the same shape and stores the result in this tensor.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, argmin, conj, isOnes, isZeros, makeEmptyDataArray, max, min, mult, multEq, norm, norm, prod, sub, subEq, sum
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
abs, H
-
Constructor Details
-
AbstractDenseRingTensor
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
-
sub
Computes the element-wise difference between two tensors of the same shape.- Specified by:
sub
in interfaceTensorOverRing<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, 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 tensors of the same shape and stores the result in this tensor.- Parameters:
b
- Second tensor in the element-wise difference.- Throws:
TensorShapeException
- If this tensor 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 AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, 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 AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, 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:
-
argminAbs
public int[] argminAbs()Finds the indices of the minimum absolute value in this tensor.- Specified by:
argminAbs
in interfaceRingTensorMixin<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>> - Specified by:
argminAbs
in interfaceTensorOverRing<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the minimum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
argmaxAbs
public int[] argmaxAbs()Finds the indices of the maximum absolute value in this tensor.- Specified by:
argmaxAbs
in interfaceRingTensorMixin<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>> - Specified by:
argmaxAbs
in interfaceTensorOverRing<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The indices of the maximum value in this tensor. If this value occurs multiple times, the indices of the first entry (in row-major ordering) are returned.
-
minAbs
public double minAbs()Finds the minimum value, in absolute value, in this tensor.- Specified by:
minAbs
in interfaceRingTensorMixin<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>> - Specified by:
minAbs
in interfaceTensorOverRing<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The minimum value, in absolute value, in this tensor.
-
maxAbs
public double maxAbs()Finds the maximum absolute value in this tensor.- Specified by:
maxAbs
in interfaceRingTensorMixin<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>> - Specified by:
maxAbs
in interfaceTensorOverRing<T extends AbstractDenseRingTensor<T,
V>, T extends AbstractDenseRingTensor<T, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The maximum absolute value in this tensor.
-