Search in sources :

Example 1 with AbstractVisitor

use of org.matheclipse.core.visit.AbstractVisitor in project symja_android_library by axkr.

the class SerializableTest method testIntegrateDefinition.

public void testIntegrateDefinition() {
    RulesData rulesData = F.Integrate.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsStringCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 2 with AbstractVisitor

use of org.matheclipse.core.visit.AbstractVisitor in project symja_android_library by axkr.

the class SerializableTest method testSinDefinition.

public void testSinDefinition() {
    // try to share common sub-IASTs first:
    RulesData rulesData = F.Sin.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 3 with AbstractVisitor

use of org.matheclipse.core.visit.AbstractVisitor in project symja_android_library by axkr.

the class KryoUtil method main.

public static void main(String[] args) throws Exception {
    // List<Class<?>> asList = Arrays.asList(B3.class.getDeclaredClasses());
    // for (int i = 0; i < asList.size(); i++) {
    // System.out.println(
    // "kryo.register(B3." + asList.get(i).getSimpleName() + ".class);");
    // }
    // List<Class<?>> asList = Arrays.asList(UtilityFunctionCtors.class.getDeclaredClasses());
    // for (int i = 0; i < asList.size(); i++) {
    // System.out.println("kryo.register(Class.forName(\"" + asList.get(i).toString().substring(6)
    // + "\"), new IASTSerializer());");
    // }
    F.initSymbols();
    Kryo kryo = initKryo();
    // IBuiltInSymbol object = S.Im;
    // IAST object = F.Sin(F.x);
    // IAST object =F.ternaryAST3(F.f, F.x, F.Dummy("$dummy"), F.stringx("string"));
    Integrate.CONST.await();
    Context rubiContext = Context.RUBI;
    Output rubiOutput = new Output(new FileOutputStream("rubi_context.bin"));
    kryo.writeClassAndObject(rubiOutput, rubiContext);
    rubiOutput.close();
    Input rubInput = new Input(new FileInputStream("rubi_context.bin"));
    rubiContext = (Context) kryo.readClassAndObject(rubInput);
    System.out.println(rubiContext.toString());
    rubInput.close();
    IBuiltInSymbol symbol = S.Integrate;
    RulesData rulesData = symbol.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    Output output = new Output(new FileOutputStream("integrate.bin"));
    kryo.writeClassAndObject(output, rulesData);
    output.close();
    Input input = new Input(new FileInputStream("integrate.bin"));
    RulesData object2 = (RulesData) kryo.readClassAndObject(input);
    System.out.println(object2.definition());
    input.close();
}
Also used : IBuiltInSymbol(org.matheclipse.core.interfaces.IBuiltInSymbol) AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) Input(com.esotericsoftware.kryo.io.Input) RulesData(org.matheclipse.core.patternmatching.RulesData) Output(com.esotericsoftware.kryo.io.Output) FileOutputStream(java.io.FileOutputStream) Kryo(com.esotericsoftware.kryo.Kryo) FileInputStream(java.io.FileInputStream)

Example 4 with AbstractVisitor

use of org.matheclipse.core.visit.AbstractVisitor in project symja_android_library by axkr.

the class SerializableTest method testSinDefinition.

public void testSinDefinition() {
    // try to share common sub-IASTs first:
    RulesData rulesData = F.Sin.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Example 5 with AbstractVisitor

use of org.matheclipse.core.visit.AbstractVisitor in project symja_android_library by axkr.

the class SerializableTest method testIntegrateDefinition.

public void testIntegrateDefinition() {
    // do a dummy evaluation to load integration rules
    F.Integrate.of(F.x, F.x);
    RulesData rulesData = F.Integrate.getRulesData();
    AbstractVisitor visitor = Share.createVisitor();
    rulesData.accept(visitor);
    equalsStringCopy(rulesData);
}
Also used : AbstractVisitor(org.matheclipse.core.visit.AbstractVisitor) RulesData(org.matheclipse.core.patternmatching.RulesData)

Aggregations

RulesData (org.matheclipse.core.patternmatching.RulesData)5 AbstractVisitor (org.matheclipse.core.visit.AbstractVisitor)5 Kryo (com.esotericsoftware.kryo.Kryo)1 Input (com.esotericsoftware.kryo.io.Input)1 Output (com.esotericsoftware.kryo.io.Output)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 IBuiltInSymbol (org.matheclipse.core.interfaces.IBuiltInSymbol)1