IndicesInsertion insertion = new IndicesInsertion(IndicesFactory.createSimple(null, upper),
IndicesFactory.createSimple(null, lower),
indicator);
StringBuilder sb;
Tensor temp;
String covariantIndicesString;
Transformation n2 = new SqrSubs(Tensors.parseSimple("n_l")), n2Transformer = new Transformer(TraverseState.Leaving, new Transformation[]{n2});
Transformation[] transformations = ArraysUtils.addAll(new Transformation[]{EliminateMetricsTransformation.ELIMINATE_METRICS, n2Transformer}, riemannBackground);
for (i = 0; i < actualHatQuantities; ++i) {
hatQuantities[i] = new Expression[operatorOrder + 1 - i];
covariantIndicesString = IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, 0, covariantIndices.length - i), OutputFormat.Redberry);
for (j = 0; j < operatorOrder + 1 - i; ++j) {
sb = new StringBuilder();
sb.append(getStringHatQuantitieName(i)).
append(IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, j, covariantIndices.length - i), OutputFormat.Redberry)).
append("=iK*").
append(getStringInputName(1 + i)).
append(covariantIndicesString);
for (k = 0; k < j; ++k)
sb.append("*n").append(IndicesUtils.toString(IndicesUtils.inverseIndexState(covariantIndices[k]), OutputFormat.Redberry));
temp = Tensors.parse(sb.toString(), insertion);
temp = inputValues[0].transform(temp);
temp = inputValues[i + 1].transform(temp);
temp = ExpandTransformation.expand(temp, transformations);
for (Transformation t : transformations)
temp = t.transform(temp);
hatQuantities[i][j] = (Expression) temp;
}
}
for (; i < HAT_QUANTITIES_GENERAL_COUNT; ++i) {
hatQuantities[i] = new Expression[1];
sb = new StringBuilder();
sb.append(getStringHatQuantitieName(i)).append("=0");
hatQuantities[i][0] = (Expression) Tensors.parse(sb.toString(), insertion);
}
kn = new Expression[operatorOrder + 1];
covariantIndicesString = IndicesUtils.toString(covariantIndices, OutputFormat.Redberry);
String matricIndices = IndicesUtils.toString(ArraysUtils.addAll(upper, lower), OutputFormat.Redberry);
for (i = 0; i < operatorOrder + 1; ++i) {
sb = new StringBuilder();
sb.append("Kn").append(IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, i, covariantIndices.length), OutputFormat.Redberry)).
append(matricIndices).
append("=K").
append(covariantIndicesString).
append(matricIndices);
for (k = 0; k < i; ++k)
sb.append("*n").append(IndicesUtils.toString(IndicesUtils.inverseIndexState(covariantIndices[k]), OutputFormat.Redberry));
temp = Tensors.parse(sb.toString());
temp = inputValues[0].transform(temp);
temp = inputValues[1].transform(temp);
temp = ExpandTransformation.expand(temp, transformations);
for (Transformation t : transformations)
temp = t.transform(temp);
kn[i] = (Expression) temp;
}
final int[] symmetry = new int[F.get(0).getIndices().size()];
symmetry[0] = 1;
symmetry[1] = 0;
for (i = 2; i < symmetry.length; ++i)
symmetry[i] = i;
Tensors.addSymmetry((SimpleTensor) F.get(0), IndexType.LatinLower, true, symmetry);
this.F = F;
covariantIndicesString = IndicesUtils.toString(Arrays.copyOfRange(covariantIndices, 0, 2), OutputFormat.Redberry);
sb = new StringBuilder();
sb.append("HATF").
append(covariantIndicesString).
append("=iK*F").
append(covariantIndicesString);
Tensor HATF = (Expression) Tensors.parse(sb.toString(), insertion);
HATF = F.transform(HATF);
HATF = inputValues[0].transform(HATF);
this.HATF = (Expression) HATF;
}