Module flag4j
Interface SemiringTensorMixin<T extends SemiringTensorMixin<T,U,V>,U extends SemiringTensorMixin<U,U,V>,V extends Semiring<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. Satisfiessemiring
axioms.
- All Superinterfaces:
TensorOverSemiRing<T,
U, Semiring<V>[], V>
- All Known Implementing Classes:
AbstractCooSemiringMatrix
,AbstractCooSemiringTensor
,AbstractCooSemiringVector
,AbstractDenseSemiringMatrix
,AbstractDenseSemiringTensor
,AbstractDenseSemiringVector
,CsrSemiRingMatrixBase
public interface SemiringTensorMixin<T extends SemiringTensorMixin<T,U,V>,U extends SemiringTensorMixin<U,U,V>,V extends Semiring<V>>
extends TensorOverSemiRing<T,U,Semiring<V>[],V>
This interface provides default functionality for all tensors whose entries are elements of a
Semiring
. This includes both
sparse and dense tensors.-
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[]
argmin()
Finds the indices of the minimum value 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
max()
Finds the maximum value in this tensor.default V
min()
Finds the minimum 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 V
prod()
Computes the product of all values in this tensor (or non-zero values if this tensor is sparse).default V
sum()
Computes the sum of all values in this tensor.Methods inherited from interface org.flag4j.arrays.backend.semiring.TensorOverSemiRing
add, elemMult, getEntries, getRank, getShape, makeLikeTensor, tensorDot, tensorDot, tensorDot, tensorDot, tensorTr, tensorTr
-
Method Details
-
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 entries of the tensor. -
addEq
Adds a scalar value to each entry of this tensor and stores the result in this tensor. -
mult
Multiplies a scalar value to each entry of this tensor. -
multEq
Multiplies a scalar value to each entry of this tensor and stores the result in this tensor. -
isZeros
default boolean isZeros()Checks if this tensor only contains zeros. -
isOnes
default boolean isOnes()Checks if this tensor only contains ones. If this tensor is sparse, only the non-zero entries are considered. -
sum
-
prod
Computes the product of all values in this tensor (or non-zero values if this tensor is sparse). -
min
Finds the minimum value in this tensor. If this tensor is complex, then this method finds the smallest value in magnitude.- 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.- 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.- 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.- 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.
-