cc.redberry.core.utils
Class TensorUtils
- java.lang.Object
-
- cc.redberry.core.utils.TensorUtils
-
public class TensorUtils extends java.lang.ObjectThis class contains various useful methods related with tensors.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidappendAllIndicesNamesIncludingScalarFunctionsT(Tensor tensor, TIntHashSet set)static voidappendAllIndicesNamesT(Tensor tensor, TIntHashSet set)static voidassertIndicesConsistency(Tensor t)static java.lang.Booleancompare1(Tensor u, Tensor v)Returnstrueif tensor u mathematically (not programming) equals to tensor v,falseif they they differ only in the sign andnullotherwise.static booleancontainsFractions(Tensor tensor)static booleancontainsSimpleTensors(Tensor tensor, TIntSet setOfNames)Returns whether specified tensor contains at least one of the simple tensors from the set.static Tensordet(Tensor[][] matrix)Gives a determinant of matrix.static booleanequals(Tensor u, Tensor v)Returnstrueif tensor u mathematically (not programming) equals to tensor v.static booleanequalsExactly(Tensor[] u, Tensor[] v)static booleanequalsExactly(Tensor u, java.lang.String v)static booleanequalsExactly(Tensor u, Tensor v)static java.util.List<Permutation>findIndicesSymmetries(int[] indices, Tensor tensor)static java.util.List<Permutation>findIndicesSymmetries(SimpleIndices indices, Tensor tensor)static Expression[]generateReplacementsOfScalars(Tensor tensor)Generates a set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor.static Expression[]generateReplacementsOfScalars(Tensor tensor, OutputPort<SimpleTensor> generatedCoefficients)Generates a set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor.static java.util.Collection<SimpleTensor>getAllDiffSimpleTensors(Tensor... tensors)static TIntHashSetgetAllDummyIndicesIncludingScalarFunctionsT(Tensor tensor)static TIntHashSetgetAllDummyIndicesT(Tensor tensor)static TIntHashSetgetAllIndicesNamesT(java.util.Collection<? extends Tensor> tensors)static TIntHashSetgetAllIndicesNamesT(Tensor... tensors)static TIntHashSetgetAllNamesOfSymbols(Tensor... tensors)static java.util.Set<SimpleTensor>getAllSymbols(Tensor... tensors)static java.util.Set<SimpleTensor>getAllSymbolsAndSymbolicFields(Tensor... tensors)static java.util.List<Permutation>getIndicesSymmetriesForIndicesWithSameStates(int[] indices, Tensor tensor)static TIntHashSetgetSimpleTensorsNames(Tensor t)static java.util.List<Permutation>getSymmetriesFromMappings(int[] indices, MappingsPort mappingsPort)static PermutationgetSymmetryFromMapping(int[] indices, Mapping mapping)static booleanhaveIndicesIntersections(Tensor u, Tensor v)Returns true if at least one free index ofuis contracted with some free index ofv.static booleanisImageOne(Tensor tensor)static booleanisIndeterminate(Tensor tensor)static booleanisIndexless(Tensor... tensors)static booleanisInteger(Tensor tensor)static booleanisIntegerEven(Tensor tensor)static booleanisIntegerOdd(Tensor tensor)static booleanisMinusOne(Tensor tensor)static booleanisNaturalNumber(Tensor tensor)static booleanisNegativeIntegerPower(Tensor t)Returns true, if specified tensor is a^(-N), where N - a natural numberstatic booleanisNegativeNaturalNumber(Tensor tensor)static booleanisNumeric(Tensor tensor)static booleanisOne(Tensor tensor)static booleanisPositiveIntegerPower(Tensor t)Returns true, if specified tensor is a^(N), where N - a natural numberstatic booleanisPositiveIntegerPowerOfProduct(Tensor t)Returns true, if specified tensor isa^(N), whereN- a natural number anda- is a product of tensorsstatic booleanisPositiveIntegerPowerOfSimpleTensor(Tensor t)Returns true, if specified tensor isa^(N), whereN- a natural number anda- is a simple tensorstatic booleanisPositiveNaturalNumber(Tensor tensor)static booleanisRealNegativeNumber(Tensor tensor)static booleanisRealPositiveNumber(Tensor tensor)static booleanisScalar(Tensor... tensors)static booleanisSymbol(Tensor t)static booleanisSymbolic(Tensor... tensors)static booleanisSymbolic(Tensor t)static booleanisSymbolOrNumber(Tensor t)static booleanisZero(Tensor tensor)static booleanisZeroDueToSymmetry(Tensor t)Returnstrueif specified tensor is zero in consequence of its symmetries: is both symmetric and asymmetric with respect to some permutation at the same time.static booleanisZeroOrIndeterminate(Tensor tensor)static booleanpassOutDummies(Tensor tensor)Returnstrueif tensor contains dummy indices.static booleanshareSimpleTensors(Tensor a, Tensor b)static inttreeDepth(Tensor tensor)
-
-
-
Method Detail
-
haveIndicesIntersections
public static boolean haveIndicesIntersections(Tensor u, Tensor v)
Returns true if at least one free index ofuis contracted with some free index ofv.- Parameters:
u- tensorv- tensor- Returns:
- true if at least one free index of
uis contracted with some free index ofv
-
isZeroOrIndeterminate
public static boolean isZeroOrIndeterminate(Tensor tensor)
-
isIndeterminate
public static boolean isIndeterminate(Tensor tensor)
-
isInteger
public static boolean isInteger(Tensor tensor)
-
isNaturalNumber
public static boolean isNaturalNumber(Tensor tensor)
-
isNumeric
public static boolean isNumeric(Tensor tensor)
-
isNegativeNaturalNumber
public static boolean isNegativeNaturalNumber(Tensor tensor)
-
isPositiveNaturalNumber
public static boolean isPositiveNaturalNumber(Tensor tensor)
-
isRealPositiveNumber
public static boolean isRealPositiveNumber(Tensor tensor)
-
isRealNegativeNumber
public static boolean isRealNegativeNumber(Tensor tensor)
-
isIndexless
public static boolean isIndexless(Tensor... tensors)
-
isScalar
public static boolean isScalar(Tensor... tensors)
-
isSymbol
public static boolean isSymbol(Tensor t)
-
isSymbolOrNumber
public static boolean isSymbolOrNumber(Tensor t)
-
isSymbolic
public static boolean isSymbolic(Tensor t)
-
isSymbolic
public static boolean isSymbolic(Tensor... tensors)
-
isOne
public static boolean isOne(Tensor tensor)
-
isZero
public static boolean isZero(Tensor tensor)
-
isImageOne
public static boolean isImageOne(Tensor tensor)
-
isMinusOne
public static boolean isMinusOne(Tensor tensor)
-
isIntegerOdd
public static boolean isIntegerOdd(Tensor tensor)
-
isIntegerEven
public static boolean isIntegerEven(Tensor tensor)
-
isPositiveIntegerPower
public static boolean isPositiveIntegerPower(Tensor t)
Returns true, if specified tensor is a^(N), where N - a natural number- Parameters:
t- tensor- Returns:
- true, if specified tensor is a^(N), where N - a natural number
-
isPositiveIntegerPowerOfSimpleTensor
public static boolean isPositiveIntegerPowerOfSimpleTensor(Tensor t)
Returns true, if specified tensor isa^(N), whereN- a natural number anda- is a simple tensor- Parameters:
t- tensor- Returns:
- true, if specified tensor is
a^(N), whereN- a natural number anda- is a simple tensor
-
isPositiveIntegerPowerOfProduct
public static boolean isPositiveIntegerPowerOfProduct(Tensor t)
Returns true, if specified tensor isa^(N), whereN- a natural number anda- is a product of tensors- Parameters:
t- tensor- Returns:
- true, if specified tensor is
a^(N), whereN- a natural number anda- is a product of tensors
-
isNegativeIntegerPower
public static boolean isNegativeIntegerPower(Tensor t)
Returns true, if specified tensor is a^(-N), where N - a natural number- Parameters:
t- tensor- Returns:
- true, if specified tensor is a^(-N), where N - a natural number
-
passOutDummies
public static boolean passOutDummies(Tensor tensor)
Returnstrueif tensor contains dummy indices.- Parameters:
tensor- tensor- Returns:
trueif tensor contains dummy indices
-
containsSimpleTensors
public static boolean containsSimpleTensors(Tensor tensor, TIntSet setOfNames)
Returns whether specified tensor contains at least one of the simple tensors from the set. The set represents a unique names of simple tensors.- Parameters:
tensor- tensorssetOfNames- int set of simple tensors names- Returns:
- true if tensor contains at least one of simple tensor with name that contains in the set
-
equalsExactly
public static boolean equalsExactly(Tensor u, java.lang.String v)
-
getAllDummyIndicesT
public static TIntHashSet getAllDummyIndicesT(Tensor tensor)
-
getAllDummyIndicesIncludingScalarFunctionsT
public static TIntHashSet getAllDummyIndicesIncludingScalarFunctionsT(Tensor tensor)
-
getAllIndicesNamesT
public static TIntHashSet getAllIndicesNamesT(java.util.Collection<? extends Tensor> tensors)
-
getAllIndicesNamesT
public static TIntHashSet getAllIndicesNamesT(Tensor... tensors)
-
appendAllIndicesNamesT
public static void appendAllIndicesNamesT(Tensor tensor, TIntHashSet set)
-
appendAllIndicesNamesIncludingScalarFunctionsT
public static void appendAllIndicesNamesIncludingScalarFunctionsT(Tensor tensor, TIntHashSet set)
-
equals
public static boolean equals(Tensor u, Tensor v)
Returnstrueif tensor u mathematically (not programming) equals to tensor v.- Parameters:
u- tensorv- tensor- Returns:
trueif specified tensors are mathematically (not programming) equal
-
compare1
public static java.lang.Boolean compare1(Tensor u, Tensor v)
Returnstrueif tensor u mathematically (not programming) equals to tensor v,falseif they they differ only in the sign andnullotherwise.- Parameters:
u- tensorv- tensor- Returns:
truetrueif tensor u mathematically (not programming) equals to tensor v,falseif they they differ only in the sign andnullotherwise
-
assertIndicesConsistency
public static void assertIndicesConsistency(Tensor t)
-
isZeroDueToSymmetry
public static boolean isZeroDueToSymmetry(Tensor t)
Returnstrueif specified tensor is zero in consequence of its symmetries: is both symmetric and asymmetric with respect to some permutation at the same time.- Parameters:
t- tensor- Returns:
trueif specified tensor is zero in consequence of its symmetries
-
getSymmetryFromMapping
public static Permutation getSymmetryFromMapping(int[] indices, Mapping mapping)
-
getSymmetriesFromMappings
public static java.util.List<Permutation> getSymmetriesFromMappings(int[] indices, MappingsPort mappingsPort)
-
findIndicesSymmetries
public static java.util.List<Permutation> findIndicesSymmetries(int[] indices, Tensor tensor)
-
findIndicesSymmetries
public static java.util.List<Permutation> findIndicesSymmetries(SimpleIndices indices, Tensor tensor)
-
getIndicesSymmetriesForIndicesWithSameStates
public static java.util.List<Permutation> getIndicesSymmetriesForIndicesWithSameStates(int[] indices, Tensor tensor)
-
getAllSymbols
public static java.util.Set<SimpleTensor> getAllSymbols(Tensor... tensors)
-
getAllSymbolsAndSymbolicFields
public static java.util.Set<SimpleTensor> getAllSymbolsAndSymbolicFields(Tensor... tensors)
-
getAllDiffSimpleTensors
public static java.util.Collection<SimpleTensor> getAllDiffSimpleTensors(Tensor... tensors)
-
getAllNamesOfSymbols
public static TIntHashSet getAllNamesOfSymbols(Tensor... tensors)
-
treeDepth
public static int treeDepth(Tensor tensor)
-
det
public static Tensor det(Tensor[][] matrix)
Gives a determinant of matrix.- Parameters:
matrix- matrix- Returns:
- determinant
-
containsFractions
public static boolean containsFractions(Tensor tensor)
-
getSimpleTensorsNames
public static TIntHashSet getSimpleTensorsNames(Tensor t)
-
generateReplacementsOfScalars
public static Expression[] generateReplacementsOfScalars(Tensor tensor)
Generates a set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor.- Parameters:
tensor- tensor- Returns:
- set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor
-
generateReplacementsOfScalars
public static Expression[] generateReplacementsOfScalars(Tensor tensor, OutputPort<SimpleTensor> generatedCoefficients)
Generates a set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor.- Parameters:
tensor- tensorgeneratedCoefficients- allows to control how coefficients are generated- Returns:
- set of replacement rules for all scalar (but not symbolic) sub-tensors appearing in the specified tensor
- See Also:
LocalSymbolsProvider
-
-
DataMelt 3.0 © DataMelt by jWork.ORG