Interface RingTensorMixin<T extends RingTensorMixin<T,U,V>,U extends RingTensorMixin<U,U,V>,V extends Ring<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. Satisfiesring
axioms.
- All Superinterfaces:
SemiringTensorMixin<T,
,U, V> TensorOverRing<T,
,U, V[], V> TensorOverSemiring<T,
U, V[], V>
- All Known Subinterfaces:
FieldTensorMixin<T,
U, V>
- All Known Implementing Classes:
AbstractCooFieldMatrix
,AbstractCooFieldTensor
,AbstractCooFieldVector
,AbstractCooRingMatrix
,AbstractCooRingTensor
,AbstractCooRingVector
,AbstractCsrFieldMatrix
,AbstractCsrRingMatrix
,AbstractDenseFieldMatrix
,AbstractDenseFieldTensor
,AbstractDenseFieldVector
,AbstractDenseRingMatrix
,AbstractDenseRingTensor
,AbstractDenseRingVector
,CMatrix
,CooCMatrix
,CooCTensor
,CooCVector
,CooFieldMatrix
,CooFieldTensor
,CooFieldVector
,CooRingMatrix
,CooRingTensor
,CooRingVector
,CsrCMatrix
,CsrFieldMatrix
,CsrRingMatrix
,CTensor
,CVector
,FieldMatrix
,FieldTensor
,FieldVector
,RingMatrix
,RingTensor
,RingVector
public interface RingTensorMixin<T extends RingTensorMixin<T,U,V>,U extends RingTensorMixin<U,U,V>,V extends Ring<V>>
extends TensorOverRing<T,U,V[],V>, SemiringTensorMixin<T,U,V>
This interface provides default functionality for all tensors whose data are elements of a Ring
. 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
Adds a scalar value to each entry of 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 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
Multiplies a scalar value to each entry of 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
Subtracts a scalar value from each entry of 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.
-
Method Details
-
makeEmptyDataArray
Creates an empty array of the same type as the data array of this tensor.- Specified by:
makeEmptyDataArray
in interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<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. -
subEq
Subtracts a scalar value from each entry of this tensor and stores the result in this tensor. -
conj
-
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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
min
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
max
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
argmin
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, 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.
-
argmax
default int[] argmax()Finds the indices of the maximum value in this tensor.- Specified by:
argmax
in interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
argmax
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, 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.
-
argminAbs
default int[] argminAbs()Finds the indices of the minimum absolute value in this tensor.- Specified by:
argminAbs
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, 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
default int[] argmaxAbs()Finds the indices of the maximum absolute value in this tensor.- Specified by:
argmaxAbs
in interfaceTensorOverRing<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, 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
default double minAbs()Finds the minimum value, in absolute value, in this tensor. -
maxAbs
-
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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
add
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
addEq
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b
- Scalar field value in sum.
-
mult
Multiplies a scalar value to each entry of this tensor.- Specified by:
mult
in interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
mult
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
multEq
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Parameters:
b
- Scalar value in product.
-
isZeros
default boolean isZeros()Checks if this tensor only contains zeros.- Specified by:
isZeros
in interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
isZeros
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
isOnes
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
sum
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<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 interfaceSemiringTensorMixin<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>> - Specified by:
prod
in interfaceTensorOverSemiring<T extends RingTensorMixin<T,
U, V>, U extends RingTensorMixin<U, U, V>, V extends Ring<V>[], V extends Ring<V>> - Returns:
- The product of all values (or non-zero values if sparse) in this tensor.
-
norm
default double norm()Computes the Euclidean norm of this vector.- Returns:
- The Euclidean norm of this vector.
-
norm
default double norm(double p) Computes the p-norm of this vector.- Parameters:
p
-p
value in the p-norm.- Returns:
- The Euclidean norm of this vector.
-