@Override public Expression build() { return new Expression(indices, left, right); }
@Override public Tensor transform(Tensor tensor) { if (factorScalars) { Expression[] replacementsOfScalars = TensorUtils.generateReplacementsOfScalars(tensor, new LocalSymbolsProvider(tensor, "sclr")); for (Expression e : replacementsOfScalars) tensor = e.transform(tensor); tensor = factorSymbolicTerms(tensor); for (Expression e : replacementsOfScalars) tensor = e.transpose().transform(tensor); return tensor; } else return factorSymbolicTerms(tensor); }
boolean symmetricForm, Transformation[] transformations) { if (!(equation.get(0) instanceof Product)) throw new IllegalArgumentException("Equation l.h.s. is not a product of tensors."); Product leftEq = (Product) equation.get(0); if (!IndexMappings.mappingExists(t, toInverse.get(0))) { inverseLhs = (SimpleTensor) t; break; temp = toInverse.transform(temp); temp = generalInverse.transform(temp); if (equation.get(1) instanceof Sum) for (Tensor summand : equation.get(1)) rightSplit.add(Split.splitScalars(summand)); else rightSplit.add(Split.splitScalars(equation.get(1))); for (Tensor summand : equation.get(0)) { Split current = Split.splitScalars(summand); boolean one = false;
if (coef.isIdentity() && !keepFreeParameters)//if current coefficient is free parameter zeroSubs.add(Tensors.expression(coef.get(0), Complex.ZERO)); } else { for (int si = solution.length - 1; si >= 0; --si) solution[si] = (Expression) coef.transform(solution[si]); solution[si] = (Expression) sub.transpose().transform(solution[si]); solutions.add(solution); coefficientsResults = new Expression[reducedSystem.unknownCoefficients.length];
int i; for (i = 0; ; i++) { file.append(equations[i].toString(OutputFormat.WolframMathematica).replace("=", "==")); if (i == equations.length - 1) break;
file.println("eq[" + (i + 1) + "]:=" + equations[i].toString(OutputFormat.Maple) + ":");
private Tensor traceOfProduct(Tensor tensor) { Tensor oldTensor = tensor, newTensor; while (true) { newTensor = oldTensor; newTensor = simplifications.transform(newTensor); newTensor = singleTrace.transform(newTensor); newTensor = pairProduct.transform(newTensor); newTensor = ExpandAndEliminateTransformation.expandAndEliminate(newTensor); if (newTensor == oldTensor) break; oldTensor = newTensor; } return newTensor; }
this.matrixIndicesCount = inputValues[1].get(0).getIndices().size() - operatorOrder; temp = inputValues[0].transform(temp); temp = inputValues[i + 1].transform(temp); temp = ExpandTransformation.expand(temp, transformations); for (Transformation t : transformations) 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) 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; if (((SimpleTensor) F.get(0)).getIndices().getSymmetries().availableForModification()) //<= this is ok. Tensors.addSymmetry((SimpleTensor) F.get(0), IndexType.LatinLower, true, symmetry); this.F = F; HATF = F.transform(HATF); HATF = inputValues[0].transform(HATF); this.HATF = (Expression) HATF;
/** * Swaps l.h.s. and r.h.s. of expression. * * @return swapped expression */ public Expression transpose() { return new Expression(indices, right, left); } }
/** * This method calculates one-loop counterterms of the vector field in the * non-minimal gauge. */ public static void testVectorField() { Expression iK = Tensors.parseExpression("iK_a^b=d_a^b+c*n_a*n^b"); Expression K = Tensors.parseExpression("K^{lm}_a^{b}=g^{lm}*d_{a}^{b}-k/2*(g^{lb}*d_a^m+g^{mb}*d_a^l)"); Expression S = Tensors.parseExpression("S^p^l_m=0"); Expression W = Tensors.parseExpression("W^{a}_{b}=P^{a}_{b}+(k/2)*R^a_b"); Expression F = Tensors.parseExpression("F_lmab=R_lmab"); Expression lambda = Tensors.parseExpression("k=gamma/(1+gamma)"); Expression gamma = Tensors.parseExpression("c=gamma"); iK = (Expression) gamma.transform(lambda.transform(iK)); K = (Expression) gamma.transform(lambda.transform(K)); S = (Expression) gamma.transform(lambda.transform(S)); W = (Expression) gamma.transform(lambda.transform(W)); OneLoopInput input = new OneLoopInput(2, iK, K, S, W, null, null, F); OneLoopCounterterms action = OneLoopCounterterms.calculateOneLoopCounterterms(input); }
temp = input.getL().transform(temp); temp = hatK.transform(temp); temp = ExpandTransformation.expand(temp, common); for (Transformation tr : common) temp = hatK.transform(temp); temp = input.getL().transform(temp); for (Expression t : calculatedCombinations) temp = new NaiveSubstitution(t.get(0), t.get(1)).transform(temp);//t.transform(temp); temp = hatK.transform(temp); temp = input.getL().transform(temp); for (Expression t : calculatedCombinations) temp = new NaiveSubstitution(t.get(0), t.get(1)).transform(temp);//t.transform(temp); temp = input.getL().transform(temp); temp = input.getF().transform(temp); temp = input.getHatF().transform(temp); for (Transformation riemannBackround : input.getRiemannBackground()) temp = riemannBackround.transform(temp); temp = nabla.transform(temp); temp = input.getF().transform(temp); temp = input.getHatF().transform(temp);
/** * Creates a set of substitutions. * * @param expressions an array of the expressions * @param applyIfModified if false, then if some substitution was * applied to some tensor in tree, then others * will be skipped in current subtree. */ public SubstitutionTransformation(Expression[] expressions, boolean applyIfModified) { this.applyIfModified = applyIfModified; primitiveSubstitutions = new PrimitiveSubstitution[expressions.length]; for (int i = expressions.length - 1; i >= 0; --i) primitiveSubstitutions[i] = createPrimitiveSubstitution(expressions[i].get(0), expressions[i].get(1)); }
@Override public Expression create(Tensor... tensors) { if (tensors.length != 2) throw new IllegalArgumentException("Wrong number of arguments."); if (tensors[0] == null || tensors[1] == null) throw new NullPointerException(); if (!TensorUtils.isZero(tensors[1]) && !TensorUtils.isIndeterminate(tensors[1]) && !tensors[0].getIndices().getFree().equalsRegardlessOrder(tensors[1].getIndices().getFree())) throw new TensorException(String.format("Inconsistent indices in expression: %s != %s", tensors[0].getIndices().getFree(), tensors[1].getIndices().getFree())); return new Expression(IndicesFactory.create(tensors[0].getIndices().getFree()), tensors[0], tensors[1]); } }
DiracSimplify1(DiracOptions options) { super(options, IDENTITY); ParseToken[] ss = {s1, s2, s3, s4}; this.subs = new Expression[ss.length]; for (int i = 0; i < ss.length; ++i) subs[i] = (Expression) deltaTrace.transform(tokenTransformer.transform(ss[i]).toTensor()); }
public Expression[] getNablaS() { if (operatorOrder < 1) return new Expression[0]; Expression[] nablaS = new Expression[getHatQuantities(1).length]; StringBuilder sb; for (int i = 0; i < nablaS.length; ++i) { sb = new StringBuilder().append("NABLAS_{l_{9}}").append(getHatQuantities(1)[i].get(0).getIndices().toString(OutputFormat.Redberry)).append("=0"); nablaS[i] = (Expression) Tensors.parse(sb.toString()); } return nablaS; }
return t; return t instanceof Sum ? new Sum(newData, t.getIndices()) : new Expression(t.getIndices(), newData[0], newData[1]);