CacheContainer cacheContainer = new CacheContainer(sunName, fName, dName, N);
Expression[] expressions = cachedSubstitutions.get(cacheContainer);
if (expressions != null)
return expressions;
List<Expression> expressionsList = new ArrayList<>();
IndexGenerator generator = new IndexGenerator();
//creating T_a*T_b = 1/2N g_ab + I/2*f_abc*T^c + 1/2*d_abc*T^c
int upper, lower, contracted, firstMetric, secondMetric, thirdMetric;
SimpleIndices indicesOfA = IndicesFactory.createSimple(null,
firstMetric = generator.generate(metricType),
upper = (0x80000000 | generator.generate(matrixType)),
contracted = generator.generate(matrixType));
SimpleIndices indicesOfB = IndicesFactory.createSimple(null,
secondMetric = generator.generate(metricType),
(0x80000000 | contracted),
lower = generator.generate(matrixType));
SimpleIndices indicesOfC = IndicesFactory.createSimple(null,
(0x80000000 | (thirdMetric = generator.generate(metricType))),
upper, lower);
Tensor lhs = multiply(simpleTensor(sunName, indicesOfA),
simpleTensor(sunName, indicesOfB));
//(1/(2*N))*g_ab
Tensor gTerm = multiply(Complex.ONE_HALF, reciprocal(N),
createMetric(firstMetric, secondMetric), createKronecker(upper, lower));
SimpleIndices fIndices = IndicesFactory.createSimple(null, firstMetric, secondMetric, thirdMetric);
Tensor C = simpleTensor(sunName, indicesOfC);
//(I/2)*f_abc*T^c
Tensor fTerm = multiply(Complex.ONE_HALF, Complex.IMAGE_ONE,
simpleTensor(fName, fIndices), C);
//(1/2)*d_abc*T^c
Tensor dTerm = multiply(Complex.ONE_HALF,
simpleTensor(dName, fIndices), C);
expressionsList.add(expression(lhs, sum(gTerm, fTerm, dTerm)));
//creating Tr[T] = 0
indicesOfA = IndicesFactory.createSimple(null, firstMetric, (0x80000000 | contracted), contracted);
expressionsList.add(expression(simpleTensor(sunName, indicesOfA), Complex.ZERO));
//creating d_apq*d_b^pq = (N**2 - 4)/N * g_ab
indicesOfA = IndicesFactory.createSimple(null,
upper = generator.generate(metricType),
firstMetric = generator.generate(metricType),
secondMetric = generator.generate(metricType));
indicesOfB = IndicesFactory.createSimple(null,
lower = generator.generate(metricType),
(0x80000000 | firstMetric),
(0x80000000 | secondMetric));
lhs = multiply(simpleTensor(dName, indicesOfA), simpleTensor(dName, indicesOfB));
Tensor rhs = multiply(reciprocal(N), subtract(pow(N, 2), Complex.FOUR), createMetric(upper, lower));