with indices (they are found only in scalar combinations) with some symbols*/
//scalar tensor <-> symbol
THashMap<Tensor, Tensor> tensorSubstitutions = new THashMap<>();
//all symbols will have names scalar1,scalar2, etc.
SymbolsGenerator generator = new SymbolsGenerator("scalar", ArraysUtils.addAll(samples, toInverse, equation));
//processing equations
int i;
for (i = 0; i < equations.length; ++i) {
Expression eq = equations[i];
//iterating over the whole equation
FromChildToParentIterator iterator = new FromChildToParentIterator(eq);
Tensor t;
while ((t = iterator.next()) != null) {
if (!(t instanceof Product) || t.getIndices().size() == 0)
continue;
//split tensor into symbolic and tensor (with nonzero length of indices) parts
Split split = Split.splitIndexless(t);
if (split.factor.getIndices().size() == 0)//there is no nonsymbolic part in tensor, e.g. t = a*b
continue;
//there is non symbolic part in current tensor, e.g. t = a*k_{i}*k^{i}, so
//split.summand = a, split.factor = k_{i}*k^{i}
if (!tensorSubstitutions.containsKey(split.factor)) {
//map does not contains rule for current scalar (e.g. k_{i}*k^{i})
Tensor s;
//adding new rule for the scalar, e.g. k_{i}*k^{i} = scalar2
tensorSubstitutions.put(split.factor, s = generator.take());
//replacing this scalar with symbol
iterator.set(Tensors.multiply(s, split.summand));
} else
//map is already contains rule for current scalar
//replacing this scalar with symbol from map