Interface FieldTensorMixin<T extends FieldTensorMixin<T,U,V>,U extends FieldTensorMixin<U,U,V>,V extends Field<V>>
- Type Parameters:
T
- Type of this tensor.U
- Dense equivalent of this tensor. If this tensor is dense, this should be the same type asT
V
- Type of an element of this tensor. Satisfiesfield
axioms.
- All Superinterfaces:
RingTensorMixin<T,
,U, V> SemiringTensorMixin<T,
,U, V> TensorOverField<T,
,U, V[], V> TensorOverRing<T,
,U, V[], V> TensorOverSemiring<T,
U, V[], V>
- All Known Implementing Classes:
AbstractCooFieldMatrix
,AbstractCooFieldTensor
,AbstractCooFieldVector
,AbstractCsrFieldMatrix
,AbstractDenseFieldMatrix
,AbstractDenseFieldTensor
,AbstractDenseFieldVector
,CMatrix
,CooCMatrix
,CooCTensor
,CooCVector
,CooFieldMatrix
,CooFieldTensor
,CooFieldVector
,CsrCMatrix
,CsrFieldMatrix
,CTensor
,CVector
,FieldMatrix
,FieldTensor
,FieldVector
public interface FieldTensorMixin<T extends FieldTensorMixin<T,U,V>,U extends FieldTensorMixin<U,U,V>,V extends Field<V>>
extends TensorOverField<T,U,V[],V>, RingTensorMixin<T,U,V>
This interface provides default functionality for all tensors whose data are elements of a
Field
. This includes both sparse and dense tensors.
The default methods in this interface can be overridden if desired, but it is generally recommended to use them as is.
-
Method Summary
Modifier and TypeMethodDescriptiondefault T
add
(double b) Adds a primitive scalar value to each entry of this tensor.default T
Adds a scalar value to each entry of this tensor.default void
addEq
(double b) Adds a primitive scalar value to each entry of this tensor and stores the result in this tensor.default void
Adds a scalar value to each entry of this tensor and stores the result in this tensor.default int[]
argmax()
Finds the indices of the maximum value in this tensor.default int[]
Finds the indices of the maximum absolute value in this tensor.default int[]
argmin()
Finds the indices of the minimum value in this tensor.default int[]
Finds the indices of the minimum absolute value in this tensor.default T
conj()
Computes the element-wise conjugation of this tensor.default T
div
(double b) Divides each element of this tensor by a primitive scalar value.default T
Divides each element of this tensor by a scalar value.default void
divEq
(double b) Divides each element of this tensor by a primitive scalar value and stores the result in this tensor.default void
Divides each element of this tensor by a scalar value and stores the result in this tensor.default boolean
isOnes()
Checks if this tensor only contains ones.default boolean
isZeros()
Checks if this tensor only contains zeros.default V[]
makeEmptyDataArray
(int length) Creates an empty array of the same type as the data array of this tensor.default V
max()
Finds the maximum value in this tensor.default double
maxAbs()
Finds the maximum absolute value in this tensor.default V
min()
Finds the minimum value in this tensor.default double
minAbs()
Finds the minimum value, in absolute value, in this tensor.default T
mult
(double b) Multiplies a primitive scalar value to each entry of this tensor.default T
Multiplies a scalar value to each entry of this tensor.default void
multEq
(double b) Multiplies a primitive scalar value to each entry of this tensor and stores the result in this tensor.default void
Multiplies a scalar value to each entry of this tensor and stores the result in this tensor.default double
norm()
Computes the Euclidean norm of this vector.default double
norm
(double p) Computes the p-norm of this vector.default V
prod()
Computes the product of all values in this tensor (or non-zero values if this tensor is sparse).default T
recip()
Computes the element-wise reciprocals of this tensor.default T
sub
(double b) Subtracts a primitive scalar value from each entry of this tensor.default T
Subtracts a scalar value from each entry of this tensor.default void
subEq
(double b) Subtracts a scalar primitive value from each entry of this tensor and stores the result in this tensor.default void
Subtracts a scalar value from each entry of this tensor and stores the result in this tensor.default V
sum()
Computes the sum of all values in this tensor.Methods inherited from interface org.flag4j.arrays.backend.field_arrays.TensorOverField
div, isFinite, isInfinite, isNaN, sqrt
-
Method Details
-
makeEmptyDataArray
Creates an empty array of the same type as the data array of this tensor.- Specified by:
makeEmptyDataArray
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
makeEmptyDataArray
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Parameters:
length
- The length of the array to construct.- Returns:
- An empty array of the same type as the data array of this tensor.
-
sub
Subtracts a scalar value from each entry of this tensor.- Specified by:
sub
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
sub
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar value in difference.- Returns:
- The difference of this tensor and the scalar
b
.
-
subEq
Subtracts a scalar value from each entry of this tensor and stores the result in this tensor.- Specified by:
subEq
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
subEq
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar value in difference.
-
conj
Computes the element-wise conjugation of this tensor.- Specified by:
conj
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
conj
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The element-wise conjugation of this tensor.
-
recip
-
min
Finds the minimum value in this tensor. If this tensor is complex, then this method finds the smallest value in magnitude.- Specified by:
min
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
min
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
min
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The minimum value (smallest in magnitude for a complex valued tensor) in this tensor.
-
max
Finds the maximum value in this tensor. If this tensor is complex, then this method finds the largest value in magnitude.- Specified by:
max
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
max
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
max
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The maximum value (largest in magnitude for a complex valued tensor) in this tensor.
-
argmin
default int[] argmin()Finds the indices of the minimum value in this tensor.- Specified by:
argmin
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmin
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmin
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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.
-
argmax
default int[] argmax()Finds the indices of the maximum value in this tensor.- Specified by:
argmax
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmax
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmax
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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.
-
argminAbs
default int[] argminAbs()Finds the indices of the minimum absolute value in this tensor.- Specified by:
argminAbs
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argminAbs
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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
default int[] argmaxAbs()Finds the indices of the maximum absolute value in this tensor.- Specified by:
argmaxAbs
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
argmaxAbs
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<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
default double minAbs()Finds the minimum value, in absolute value, in this tensor.- Specified by:
minAbs
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
minAbs
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The minimum value, in absolute value, in this tensor.
-
maxAbs
default double maxAbs()Finds the maximum absolute value in this tensor.- Specified by:
maxAbs
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
maxAbs
in interfaceTensorOverRing<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The maximum absolute value in this tensor.
-
add
Adds a scalar value to each entry of this tensor. If the tensor is sparse, the scalar will only be added to the non-zero data of the tensor.- Specified by:
add
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
add
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
add
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar field value in sum.- Returns:
- The sum of this tensor with the scalar
b
.
-
addEq
Adds a scalar value to each entry of this tensor and stores the result in this tensor.- Specified by:
addEq
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addEq
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
addEq
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar field value in sum.
-
mult
Multiplies a scalar value to each entry of this tensor.- Specified by:
mult
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
mult
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
mult
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar value in product.- Returns:
- The product of this tensor with
b
.
-
multEq
Multiplies a scalar value to each entry of this tensor and stores the result in this tensor.- Specified by:
multEq
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multEq
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
multEq
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Parameters:
b
- Scalar value in product.
-
isZeros
default boolean isZeros()Checks if this tensor only contains zeros.- Specified by:
isZeros
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isZeros
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isZeros
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
true
if this tensor only contains zeros;false
otherwise.
-
isOnes
default boolean isOnes()Checks if this tensor only contains ones. If this tensor is sparse, only the non-zero data are considered.- Specified by:
isOnes
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isOnes
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
isOnes
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
true
if this tensor only contains ones;false
otherwise.
-
sum
Computes the sum of all values in this tensor.- Specified by:
sum
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
sum
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
sum
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The sum of all values in this tensor.
-
prod
Computes the product of all values in this tensor (or non-zero values if this tensor is sparse).- Specified by:
prod
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
prod
in interfaceSemiringTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Specified by:
prod
in interfaceTensorOverSemiring<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>[], V extends Field<V>> - Returns:
- The product of all values (or non-zero values if sparse) in this tensor.
-
add
Adds a primitive scalar value to each entry of this tensor. If the tensor is sparse, the scalar will only be added to the non-zero data of the tensor. -
addEq
default void addEq(double b) Adds a primitive scalar value to each entry of this tensor and stores the result in this tensor. -
mult
Multiplies a primitive scalar value to each entry of this tensor. -
multEq
default void multEq(double b) Multiplies a primitive scalar value to each entry of this tensor and stores the result in this tensor. -
sub
Subtracts a primitive scalar value from each entry of this tensor. -
subEq
default void subEq(double b) Subtracts a scalar primitive value from each entry of this tensor and stores the result in this tensor. -
div
Divides each element of this tensor by a scalar value. -
divEq
Divides each element of this tensor by a scalar value and stores the result in this tensor. -
div
Divides each element of this tensor by a primitive scalar value. -
divEq
default void divEq(double b) Divides each element of this tensor by a primitive scalar value and stores the result in this tensor. -
norm
default double norm()Computes the Euclidean norm of this vector.- Specified by:
norm
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Returns:
- The Euclidean norm of this vector.
-
norm
default double norm(double p) Computes the p-norm of this vector.- Specified by:
norm
in interfaceRingTensorMixin<T extends FieldTensorMixin<T,
U, V>, U extends FieldTensorMixin<U, U, V>, V extends Field<V>> - Parameters:
p
-p
value in the p-norm.- Returns:
- The Euclidean norm of this vector.
-