@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); }
@Test public void test8() { for (int i = 0; i < 100; ++i) { CC.resetTensorNames(); Tensor t = parse("L*L*(L-1)*A*B", "^ijpq", "_pqrs", "A", "B"); Indices indices = ParserIndices.parseSimple("^ijpq_pqrs"); assertIndicesParity(t.getIndices().getFree(), indices.getFree()); } }
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)); }