Package org.flag4j.linalg
Class TensorInvert
java.lang.Object
org.flag4j.linalg.TensorInvert
This class provides methods for computing the 'inverse' of a tensor with respect to some tensor dot product operation.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static Shape
getInvShape
(Shape originalShape, int numIndices) Computes the shape of the 'inverse' tensor given the original shape and the number of indices.private static int
getProduct
(int[] dims, int numIndices) Computes the total number of entries in the lastnumIndices
dimensions of a tensor with dimensions specified bydims
.static CTensor
Computes the 'inverse' of this tensor.static Tensor
Computes the 'inverse' of this tensor.
-
Constructor Details
-
TensorInvert
private TensorInvert()
-
-
Method Details
-
inv
Computes the 'inverse' of this tensor. That is, computes the tensor
X=this.tensorInv()
such thatsrc.tensorDot(X, numIndices)
is the 'identity' tensor for the tensor dot product operation.A tensor
I
is the identity for a tensor dot product ifsrc.tensorDot(I, numIndices).equals(this)
.- Parameters:
src
- Tensor to compute inverse of.numIndices
- The number of first numIndices which are involved in the inverse sum.- Returns:
- The 'inverse' of this tensor as defined in the above sense.
- Throws:
IllegalArgumentException
- IfnumIndices
is not positive.
-
inv
Computes the 'inverse' of this tensor. That is, computes the tensor
X=this.tensorInv()
such thatsrc.tensorDot(X, numIndices)
is the 'identity' tensor for the tensor dot product operation.A tensor
I
is the identity for a tensor dot product ifsrc.tensorDot(I, numIndices).equals(this)
.- Parameters:
src
- Tensor to compute inverse of.numIndices
- The number of first numIndices which are involved in the inverse sum.- Returns:
- The 'inverse' of this tensor as defined in the above sense.
- Throws:
IllegalArgumentException
- IfnumIndices
is not positive.
-
getInvShape
Computes the shape of the 'inverse' tensor given the original shape and the number of indices.- Parameters:
originalShape
- Shape of the original tensor.numIndices
- Number of indices that are involved in the inverse sum.- Returns:
- The shape of the 'inverse' tensor.
-
getProduct
private static int getProduct(int[] dims, int numIndices) Computes the total number of entries in the lastnumIndices
dimensions of a tensor with dimensions specified bydims
.- Parameters:
dims
- Dimensions of the tensor.numIndices
- Number of last indices to compute product for.- Returns:
- The total number of entries in the last
numIndices
dimensions of a tensor with dimensions specified bydims
. That is, the product of the lastnumIndices
entries ofdims
.
-