Class AbstractDenseFieldTensor<T extends AbstractDenseFieldTensor<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.ring_arrays.AbstractDenseRingTensor<T,V>
org.flag4j.arrays.backend.field_arrays.AbstractDenseFieldTensor<T,V>
- Type Parameters:
T
- The type of this dense field tensor.V
- The type of theField
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
,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>
- Direct Known Subclasses:
CTensor
,FieldTensor
public abstract class AbstractDenseFieldTensor<T extends AbstractDenseFieldTensor<T,V>,V extends Field<V>>
extends AbstractDenseRingTensor<T,V>
implements FieldTensorMixin<T,T,V>
The base class for all dense Field
tensors.
The AbstractTensor.data
of an AbstractDenseFieldTensor 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
AbstractDenseFieldTensor
(Shape shape, V[] entries) Creates a tensor with the specified data and shape. -
Method Summary
Modifier and TypeMethodDescriptionboolean
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 between two tensors.H
(int... axes) Computes the conjugate transpose of this tensor.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.sqrt()
Computes the element-wise square root of this tensor.Methods inherited from class org.flag4j.arrays.backend.ring_arrays.AbstractDenseRingTensor
argmaxAbs, argminAbs, H, maxAbs, minAbs, sub, subEq
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, norm, norm, prod, recip, sub, sub, subEq, subEq, sum
Methods inherited from interface org.flag4j.arrays.backend.ring_arrays.TensorOverRing
abs, H, H, sub
-
Constructor Details
-
AbstractDenseFieldTensor
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 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 AbstractDenseFieldTensor<T,
V>, T extends AbstractDenseFieldTensor<T, V>, V extends Field<V>[], V extends Field<V>> - Overrides:
H
in classAbstractDenseRingTensor<T extends AbstractDenseFieldTensor<T,
V>, V extends Field<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:
-
div
Computes the element-wise quotient between two tensors. -
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 AbstractDenseFieldTensor<T,
V>, T extends AbstractDenseFieldTensor<T, 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(AbstractDenseFieldTensor, 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:
-