use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class SerializableTest method testASTRealMatrix.
public void testASTRealMatrix() {
equalsCopy(new ASTRealMatrix(new double[][] { { 1.0, 2.0, 3.0 }, { 3.3, 4.4, 5.5 } }, false));
// PseudoInverse({{1,2,3},{3,4,5}})
EvalEngine engine = EvalEngine.get();
IExpr result = engine.evaluate(F.PseudoInverse(F.List(F.List(F.C1, F.C2, F.C3), F.List(F.C4, F.C5, F.C6))));
equalsCopy(result);
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class MMAFormTestCase method testWLForm004.
public void testWLForm004() {
EvalEngine engine = new EvalEngine("", 256, 256, System.out, System.err, true);
ExprParser parser = new ExprParser(engine, true);
IExpr expr = parser.parse("{f'(x), f''(x), f'''(x)} // Together");
assertEquals(expr.toMMA(), "Together[{f'[x],f''[x],Derivative[3][f][x]}]");
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class F method symjify.
/**
* Parses a Java string to a Symja expression. May throw a SyntaxError exception, if the string
* couldn't be parsed.
*
* @param str the expression which should be parsed
* @param evaluate if <code>true</code> evaluate the parsed string
* @return
* @throws SyntaxError
*/
public static IExpr symjify(final String str, boolean evaluate) {
EvalEngine engine = EvalEngine.get();
ExprParser parser = new ExprParser(engine);
IExpr temp = parser.parse(str);
return evaluate ? engine.evaluate(temp) : temp;
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class F method complexNum.
public static IComplexNum complexNum(final IComplex value) {
final IRational realFraction = value.getRealPart();
final IRational imagFraction = value.getImaginaryPart();
final EvalEngine engine = EvalEngine.get();
if (engine.isArbitraryMode()) {
return ApcomplexNum.valueOf(realFraction.toBigNumerator(), realFraction.toBigDenominator(), imagFraction.toBigNumerator(), imagFraction.toBigDenominator());
}
// double precision complex number
double nr = realFraction.numerator().doubleValue();
double dr = realFraction.denominator().doubleValue();
double ni = imagFraction.numerator().doubleValue();
double di = imagFraction.denominator().doubleValue();
return complexNum(nr / dr, ni / di);
}
use of org.matheclipse.core.eval.EvalEngine in project symja_android_library by axkr.
the class F method expandAll.
/**
* Apply <code>ExpandAll()</code> to the given expression if it's an <code>IAST</code>. If
* expanding wasn't possible this method returns the given argument.
*
* @param a the expression which should be evaluated
* @param expandNegativePowers
* @param distributePlus
* @return the evaluated expression
* @see EvalEngine#evaluate(IExpr)
*/
public static IExpr expandAll(IExpr a, boolean expandNegativePowers, boolean distributePlus) {
if (a.isAST()) {
EvalEngine engine = EvalEngine.get();
IAST ast = engine.evalFlatOrderlessAttributesRecursive((IAST) a).orElse((IAST) a);
return Algebra.expandAll(ast, null, expandNegativePowers, distributePlus, false, engine).orElse(ast);
}
return a;
}
Aggregations