/** * Allows to parse expressions with repeated indices of the same variance (like T_aa or T_a*T^a which results in T^a_a * and T^a*T_a respactively) * * @param b allow or not to parse repeated indices with same variance */ public void setParserAllowsSameVariance(boolean b) { parseManager.getParser().setAllowSameVariance(b); }
/** * @param expression string expression * @return tensor */ public Tensor parse(String expression) { return parse(expression, defaultTensorPreprocessors, defaultParserPreprocessors); }
/** * Resets all definitions. */ public synchronized void reset() { resetTensorNames(); parseManager.reset(); }
/** * Creates context from the settings * * @param contextSettings settings * @see ContextSettings */ public Context(ContextSettings contextSettings) { this.parseManager = new ParseManager(contextSettings.getParser()); this.converterManager = contextSettings.getConverterManager(); this.nameManager = new NameManager(contextSettings.getNameManagerSeed(), contextSettings.getKronecker(), contextSettings.getMetricName()); this.defaultOutputFormat = contextSettings.getDefaultOutputFormat(); EnumSet<IndexType> metricTypes = EnumSet.noneOf(IndexType.class); EnumSet<IndexType> matrixTypes = EnumSet.allOf(IndexType.class); for (IndexType type : contextSettings.getMetricTypes()) { matrixTypes.remove(type); metricTypes.add(type); this.metricTypesBits.set(type.getType()); } this.metricTypes = Collections.unmodifiableSet(metricTypes); this.matrixTypes = Collections.unmodifiableSet(matrixTypes); }
/** * Returns whether repeated indices of the same variance are allowed to be parsed * * @return whether repeated indices of the same variance are allowed to be parsed */ public boolean getParserAllowsSameVariance() { return parseManager.getParser().isAllowSameVariance(); }
/** * @param expression string expression * @param nodesPreprocessors AST transformers * @return tensor */ public Tensor parse(String expression, ParseTokenTransformer... nodesPreprocessors) { return parse(expression, new Transformation[0], nodesPreprocessors); }
public SchoutenIdentities4(SimpleTensor leviCivita) { this.leviCivita = leviCivita; ChangeIndicesTypesAndTensorNames tokenTransformer = new ChangeIndicesTypesAndTensorNames(TypesAndNamesTransformer.Utils.and( TypesAndNamesTransformer.Utils.changeName(new String[]{"e"}, new String[]{leviCivita.getStringName()}), TypesAndNamesTransformer.Utils.changeType(IndexType.LatinLower, IndicesUtils.getTypeEnum(leviCivita.getIndices().get(0))))); this.schouten1 = new Tensor[schoutenCombinations1.length]; for (int i = 0; i < schouten1.length; i++) schouten1[i] = tokenTransformer.transform(CC.current().getParseManager().getParser().parse(schoutenCombinations1[i])).toTensor(); this.schouten2 = new Tensor[schoutenCombinations2.length]; for (int i = 0; i < schouten2.length; i++) schouten2[i] = tokenTransformer.transform(CC.current().getParseManager().getParser().parse(schoutenCombinations2[i])).toTensor(); this.schouten3 = new Tensor[schoutenCombinations3.length]; for (int i = 0; i < schouten3.length; i++) schouten3[i] = tokenTransformer.transform(CC.current().getParseManager().getParser().parse(schoutenCombinations3[i])).toTensor(); allSchouten = new Tensor[][]{schouten1, schouten2, schouten3}; }
/** * Converts string expression into tensor. * * @param expression string to be parsed * @return result of parsing * @throws cc.redberry.core.parser.ParserException if expression does not satisfy correct Redberry * input notation for tensors */ public static Tensor parse(String expression) { return CC.current().getParseManager().parse(expression); }
protected AbstractTransformationWithGammas(DiracOptions options) { checkNotation(options.gammaMatrix, options.gamma5, options.leviCivita); if (!options.created) options.triggerCreate(); this.gammaName = options.gammaMatrix.getName(); this.gamma5Name = options.gamma5 == null ? Integer.MIN_VALUE : options.gamma5.getName(); final IndexType[] types = TraceUtils.extractTypesFromMatrix(options.gammaMatrix); this.metricType = types[0]; this.matrixType = types[1]; this.tokenTransformer = createTokenTransformer(metricType, matrixType, options.gammaMatrix, options.gamma5, options.leviCivita); this.expandAndEliminate = options.expandAndEliminate; this.traceOfOne = (Expression) tokenTransformer.transform(CC.current().getParseManager().getParser().parse("d^a'_a'=" + options.traceOfOne)).toTensor(); this.deltaTrace = (Expression) tokenTransformer.transform(CC.current().getParseManager().getParser().parse("d^a_a=" + options.dimension)).toTensor(); }
/** * Converts string expression into tensor, additionally transforming AST according to specified * AST transformers. * * @param expression string to be parsed * @param preprocessors AST transformers * @return result of parsing * @throws cc.redberry.core.parser.ParserException if expression does not satisfy correct Redberry * input notation for tensors */ public static Tensor parse(String expression, ParseTokenTransformer... preprocessors) { return CC.current().getParseManager().parse(expression, preprocessors); }