@Test public void test1() { GeneralIndicesInsertion gii = new GeneralIndicesInsertion(); gii.addInsertionRule(parseSimple("A^a'_b'"), Matrix1); gii.addInsertionRule(parseSimple("B^a'_b'"), Matrix1); gii.addInsertionRule(parseSimple("C^a'_b'"), Matrix1); gii.addInsertionRule(parseSimple("cv_b'"), Matrix1); gii.addInsertionRule(parseSimple("v^b'"), Matrix1); CC.current().getParseManager().defaultParserPreprocessors.add(gii); Tensor t, exp; t = parse("A*B*C"); exp = parse("C*B*A"); TAssert.assertEquals(inverseOrderOfMatrices(t, Matrix1), exp); t = parse("cv*A*B*C"); exp = parse("cv*C*B*A"); TAssert.assertEquals(inverseOrderOfMatrices(t, Matrix1), exp); t = parse("A*B*C*v"); exp = parse("C*B*A*v"); TAssert.assertEquals(inverseOrderOfMatrices(t, Matrix1), exp); t = parse("cv*A*B*C*v"); exp = parse("cv*C*B*A*v"); TAssert.assertEquals(inverseOrderOfMatrices(t, Matrix1), exp); }
public static Tensor parse(String tensor, String upper, String lower, String... indicator) { Indicator indicator1 = indicator.length == 0 ? Indicator.TRUE_INDICATOR : new NamesIndicator(indicator); return CC.current() .getParseManager() .parse( tensor, new IndicesInsertion( ParserIndices.parseSimple(upper), ParserIndices.parseSimple(lower), indicator1)); }