Class CooSemiringTensorOps
java.lang.Object
org.flag4j.linalg.ops.sparse.coo.semiring_ops.CooSemiringTensorOps
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V extends Semiring<V>>
SparseTensorData<V> add
(Shape shape1, V[] src1Entries, int[][] src1Indices, Shape shape2, V[] src2Entries, int[][] src2Indices) Sums two complex sparse COO tensors and stores result in a new COO tensor.static <V extends Semiring<V>>
SparseTensorData<V> elemMult
(Shape shape1, V[] src1Entries, int[][] src1Indices, Shape shape2, V[] src2Entries, int[][] src2Indices) Computes the element-wise multiplication between two complex sparse COO tensors.static <T extends Semiring<T>>
SparseTensorData<T> Computes the generalized trace of a tensor along the specified axes.
-
Method Details
-
add
public static <V extends Semiring<V>> SparseTensorData<V> add(Shape shape1, V[] src1Entries, int[][] src1Indices, Shape shape2, V[] src2Entries, int[][] src2Indices) Sums two complex sparse COO tensors and stores result in a new COO tensor.- Parameters:
shape1
- Shape of the first tensor.src1Entries
- Non-zero data of the first tensor.src1Indices
- Non-zero indices of the first tensor.shape2
- Shape of the second tensor.src2Entries
- Non-zero data of the second tensor.src2Indices
- Non-zero indices of the second tensor.- Returns:
- The element-wise tensor sum of the two tensors.
- Throws:
LinearAlgebraException
- If the tensorssrc1
andsrc2
do not have the same shape.
-
elemMult
public static <V extends Semiring<V>> SparseTensorData<V> elemMult(Shape shape1, V[] src1Entries, int[][] src1Indices, Shape shape2, V[] src2Entries, int[][] src2Indices) Computes the element-wise multiplication between two complex sparse COO tensors.
Assumes indices of both tensors are sorted lexicographically by their indices.
- Parameters:
shape1
- Shape of the first tensor.src1Entries
- Non-zero data of the first tensor.src1Indices
- Non-zero indices of the first tensor.shape2
- Shape of the second tensor.src2Entries
- Non-zero data of the second tensor.src2Indices
- Non-zero indices of the second tensor.- Returns:
- The element-wise product of the two specified tensors.
- Throws:
TensorShapeException
- If!shape1.equals(shape2)
.
-
tensorTr
public static <T extends Semiring<T>> SparseTensorData<T> tensorTr(Shape shape, T[] entries, int[][] indices, int axis1, int axis2) Computes the generalized trace of a tensor along the specified axes.
The generalized tensor trace is the sum along the diagonal values of the 2D sub-arrays of the
src
tensor specified byaxis1
andaxis2
. The shape of the resulting tensor is equal to thesrc
tensor with theaxis1
andaxis2
removed.- Parameters:
axis1
- First axis for 2D sub-array.axis2
- Second axis for 2D sub-array.shape1
- Shape of the tensor.src1Entries
- Non-zero data of the tensor.src1Indices
- Non-zero indices of the tensor.- Returns:
- The generalized trace of the
src
tensor alongaxis1
andaxis2
. - Throws:
IndexOutOfBoundsException
- If the two axes are not both larger than zero and less than thesrc
tensors rank.IllegalArgumentException
- Ifaxis1 == axis2
orsrc.shape.get(axis1) != src.shape.get(axis1)
(i.e. the axes are equal or the tensor does not have the same length along the two axes.)
-