Search in sources :

Example 6 with Options

use of org.matheclipse.core.eval.util.Options in project symja_android_library by axkr.

the class NFourierTransform method evaluate.

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    Validate.checkRange(ast, 4, 5);
    IExpr expr = ast.arg1();
    ISymbol t = Validate.checkSymbolType(ast, 2);
    // IExpr omega = ast.arg3();
    if (ast.size() > 4) {
        final Options options = new Options(ast.topHead(), ast, 4, engine);
        IExpr optionFourierParameters = options.getOption("FourierParameters");
        if (optionFourierParameters.isList()) {
        // analyze the parameters, if they are correct
        }
    }
    UnivariateFunction f = new UnaryNumerical(expr, t, engine);
    FastFourierTransformer fft = new FastFourierTransformer(DftNormalization.STANDARD);
    org.hipparchus.complex.Complex[] result = fft.transform(f, -1.0, 1.0, 8, TransformType.FORWARD);
    return Object2Expr.convertComplex(result);
}
Also used : Options(org.matheclipse.core.eval.util.Options) UnaryNumerical(org.matheclipse.core.generic.UnaryNumerical) ISymbol(org.matheclipse.core.interfaces.ISymbol) UnivariateFunction(org.hipparchus.analysis.UnivariateFunction) IExpr(org.matheclipse.core.interfaces.IExpr) FastFourierTransformer(org.hipparchus.transform.FastFourierTransformer)

Example 7 with Options

use of org.matheclipse.core.eval.util.Options in project symja_android_library by axkr.

the class MonomialList method evaluate.

@Override
public IExpr evaluate(final IAST ast, final EvalEngine engine) {
    Validate.checkRange(ast, 2, 5);
    IExpr expr = F.evalExpandAll(ast.arg1());
    VariablesSet eVar;
    IAST symbolList = F.List();
    List<IExpr> varList;
    if (ast.isAST1()) {
        // extract all variables from the polynomial expression
        eVar = new VariablesSet(ast.arg1());
        eVar.appendToList(symbolList.args());
        varList = eVar.getArrayList();
    } else {
        symbolList = Validate.checkSymbolOrSymbolList(ast, 2);
        varList = new ArrayList<IExpr>(symbolList.size() - 1);
        for (int i = 1; i < symbolList.size(); i++) {
            varList.add(symbolList.get(i));
        }
    }
    TermOrder termOrder = TermOrderByName.Lexicographic;
    try {
        if (ast.size() > 3) {
            if (ast.arg3() instanceof IStringX) {
                // NegativeLexicographic
                String orderStr = ast.arg3().toString();
                termOrder = Options.getMonomialOrder(orderStr, termOrder);
            }
            final Options options = new Options(ast.topHead(), ast, 2, engine);
            IExpr option = options.getOption("Modulus");
            if (option.isSignedNumber()) {
                return monomialListModulus(expr, varList, termOrder, option);
            }
        }
        if (USE_JAS_POLYNOMIAL) {
            return monomialList(expr, varList, termOrder);
        } else {
            ExprPolynomialRing ring = new ExprPolynomialRing(symbolList, new ExprTermOrder(termOrder.getEvord()));
            ExprPolynomial poly = ring.create(expr);
            return poly.monomialList();
        }
    } catch (JASConversionException jce) {
        // toInt() conversion failed
        if (Config.DEBUG) {
            jce.printStackTrace();
        }
    }
    return F.NIL;
}
Also used : Options(org.matheclipse.core.eval.util.Options) TermOrder(edu.jas.poly.TermOrder) ExprTermOrder(org.matheclipse.core.polynomials.ExprTermOrder) VariablesSet(org.matheclipse.core.convert.VariablesSet) JASConversionException(org.matheclipse.core.eval.exception.JASConversionException) ExprPolynomialRing(org.matheclipse.core.polynomials.ExprPolynomialRing) ExprTermOrder(org.matheclipse.core.polynomials.ExprTermOrder) JASIExpr(org.matheclipse.core.convert.JASIExpr) IExpr(org.matheclipse.core.interfaces.IExpr) IAST(org.matheclipse.core.interfaces.IAST) IStringX(org.matheclipse.core.interfaces.IStringX) ExprPolynomial(org.matheclipse.core.polynomials.ExprPolynomial)

Example 8 with Options

use of org.matheclipse.core.eval.util.Options in project symja_android_library by axkr.

the class CoefficientRules method evaluate.

@Override
public IExpr evaluate(final IAST ast, final EvalEngine engine) {
    Validate.checkRange(ast, 2, 5);
    IExpr expr = F.evalExpandAll(ast.arg1());
    VariablesSet eVar;
    IAST symbolList = F.List();
    List<IExpr> varList;
    if (ast.isAST1()) {
        // extract all variables from the polynomial expression
        eVar = new VariablesSet(ast.arg1());
        eVar.appendToList(symbolList.args());
        varList = eVar.getArrayList();
    } else {
        symbolList = Validate.checkSymbolOrSymbolList(ast, 2);
        varList = new ArrayList<IExpr>(symbolList.size() - 1);
        for (int i = 1; i < symbolList.size(); i++) {
            varList.add((ISymbol) symbolList.get(i));
        }
    }
    TermOrder termOrder = TermOrderByName.Lexicographic;
    try {
        if (ast.size() > 3) {
            if (ast.arg3() instanceof IStringX) {
                String orderStr = ast.arg3().toString();
                termOrder = Options.getMonomialOrder(orderStr, termOrder);
            }
            final Options options = new Options(ast.topHead(), ast, 2, engine);
            IExpr option = options.getOption("Modulus");
            if (option.isSignedNumber()) {
                return coefficientRulesModulus(expr, varList, termOrder, option);
            }
        }
        if (MonomialList.USE_JAS_POLYNOMIAL) {
            return coefficientRules(expr, varList, termOrder);
        } else {
            ExprPolynomialRing ring = new ExprPolynomialRing(symbolList, new ExprTermOrder(termOrder.getEvord()));
            ExprPolynomial poly = ring.create(expr);
            return poly.coefficientRules();
        }
    } catch (JASConversionException jce) {
        // toInt() conversion failed
        if (Config.DEBUG) {
            jce.printStackTrace();
        }
    }
    return F.NIL;
}
Also used : Options(org.matheclipse.core.eval.util.Options) TermOrder(edu.jas.poly.TermOrder) ExprTermOrder(org.matheclipse.core.polynomials.ExprTermOrder) VariablesSet(org.matheclipse.core.convert.VariablesSet) JASConversionException(org.matheclipse.core.eval.exception.JASConversionException) ExprPolynomialRing(org.matheclipse.core.polynomials.ExprPolynomialRing) ExprTermOrder(org.matheclipse.core.polynomials.ExprTermOrder) JASIExpr(org.matheclipse.core.convert.JASIExpr) IExpr(org.matheclipse.core.interfaces.IExpr) IAST(org.matheclipse.core.interfaces.IAST) IStringX(org.matheclipse.core.interfaces.IStringX) ExprPolynomial(org.matheclipse.core.polynomials.ExprPolynomial)

Example 9 with Options

use of org.matheclipse.core.eval.util.Options in project symja_android_library by axkr.

the class GroebnerBasis method evaluate.

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    if (ast.size() >= 3) {
        if (ast.arg1().isVector() < 0 || ast.arg2().isVector() < 0) {
            return F.NIL;
        }
        TermOrder termOrder = TermOrderByName.Lexicographic;
        if (ast.size() > 3) {
            final Options options = new Options(ast.topHead(), ast, ast.size() - 1, engine);
            termOrder = options.getMonomialOrder(ast, termOrder);
        }
        IAST polys = (IAST) ast.arg1();
        IAST vars = (IAST) ast.arg2();
        if (vars.size() <= 1) {
            return F.NIL;
        }
        return computeGroebnerBasis(polys, vars, termOrder);
    }
    return F.NIL;
}
Also used : Options(org.matheclipse.core.eval.util.Options) TermOrder(edu.jas.poly.TermOrder) IAST(org.matheclipse.core.interfaces.IAST)

Aggregations

Options (org.matheclipse.core.eval.util.Options)9 IExpr (org.matheclipse.core.interfaces.IExpr)8 IAST (org.matheclipse.core.interfaces.IAST)6 ISymbol (org.matheclipse.core.interfaces.ISymbol)4 TermOrder (edu.jas.poly.TermOrder)3 JASIExpr (org.matheclipse.core.convert.JASIExpr)2 VariablesSet (org.matheclipse.core.convert.VariablesSet)2 JASConversionException (org.matheclipse.core.eval.exception.JASConversionException)2 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)2 IStringX (org.matheclipse.core.interfaces.IStringX)2 ExprPolynomial (org.matheclipse.core.polynomials.ExprPolynomial)2 ExprPolynomialRing (org.matheclipse.core.polynomials.ExprPolynomialRing)2 ExprTermOrder (org.matheclipse.core.polynomials.ExprTermOrder)2 UnivariateFunction (org.hipparchus.analysis.UnivariateFunction)1 MathIllegalStateException (org.hipparchus.exception.MathIllegalStateException)1 FastFourierTransformer (org.hipparchus.transform.FastFourierTransformer)1 WrappedException (org.matheclipse.core.eval.exception.WrappedException)1 WrongArgumentType (org.matheclipse.core.eval.exception.WrongArgumentType)1 UnaryNumerical (org.matheclipse.core.generic.UnaryNumerical)1