Search in sources :

Example 6 with LimitException

use of org.matheclipse.core.eval.exception.LimitException in project symja_android_library by axkr.

the class FrobeniusSolve method evaluate.

/**
 * {@inheritDoc}
 */
@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    if (ast.arg1().isList() && ast.arg2().isInteger()) {
        IAST list = ast.getAST(1);
        try {
            int[] listInt = Validate.checkListOfInts(ast, list, true, false, engine);
            if (listInt != null) {
                for (int i = 0; i < listInt.length; i++) {
                    if (listInt[i] < 0 && ast.size() < 4) {
                    }
                }
                IInteger[] solution;
                IASTAppendable result = F.ListAlloc(8);
                FrobeniusSolver solver = getSolver(listInt, (IInteger) ast.arg2());
                // all solutions
                int numberOfSolutions = -1;
                if (ast.size() == 4) {
                    numberOfSolutions = ast.arg3().toIntDefault(-1);
                }
                while ((solution = solver.take()) != null) {
                    if (result.size() >= Config.MAX_AST_SIZE) {
                        throw new ASTElementLimitExceeded(result.size());
                    }
                    result.append(F.List(solution));
                }
                return result;
            }
        } catch (LimitException le) {
            throw le;
        } catch (RuntimeException rex) {
            LOGGER.debug("FrobeniusSolve.evaluate() failed", rex);
        }
    }
    return F.NIL;
}
Also used : IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) FrobeniusSolver(org.matheclipse.core.frobenius.FrobeniusSolver) IInteger(org.matheclipse.core.interfaces.IInteger) IAST(org.matheclipse.core.interfaces.IAST) LimitException(org.matheclipse.core.eval.exception.LimitException) ASTElementLimitExceeded(org.matheclipse.core.eval.exception.ASTElementLimitExceeded)

Example 7 with LimitException

use of org.matheclipse.core.eval.exception.LimitException in project symja_android_library by axkr.

the class NDSolve method evaluate.

@Override
public IExpr evaluate(final IAST ast, EvalEngine engine) {
    if (!ToggleFeature.DSOLVE) {
        return F.NIL;
    }
    if (ast.arg3().isList()) {
        final IAST tRangeList = (IAST) ast.arg3();
        if (!(tRangeList.isAST2() || tRangeList.isAST3())) {
            return F.NIL;
        }
        try {
            final IAST listOfVariables = Validate.checkIsVariableOrVariableList(ast, 2, ast.topHead(), engine);
            if (!listOfVariables.isPresent()) {
                return F.NIL;
            }
            final int numberOfVariables = listOfVariables.argSize();
            final ISymbol timeVar = (ISymbol) tRangeList.arg1();
            IExpr tMinExpr = F.C0;
            IExpr tMaxExpr = tRangeList.arg2();
            if (tRangeList.isAST3()) {
                tMinExpr = tRangeList.arg2();
                tMaxExpr = tRangeList.arg3();
            }
            final double tMin = tMinExpr.evalDouble();
            final double tMax = tMaxExpr.evalDouble();
            final double tStep = 0.1;
            IASTAppendable listOfEquations = Validate.checkEquations(ast, 1).copyAppendable();
            IExpr[][] boundaryCondition = new IExpr[2][numberOfVariables];
            int i = 1;
            while (i < listOfEquations.size()) {
                IExpr equation = listOfEquations.get(i);
                if (equation.isFree(timeVar)) {
                    if (determineSingleBoundary(equation, listOfVariables, timeVar, boundaryCondition, engine)) {
                        listOfEquations.remove(i);
                        continue;
                    }
                }
                i++;
            }
            IExpr[] dotEquations = new IExpr[numberOfVariables];
            i = 1;
            while (i < listOfEquations.size()) {
                IExpr equation = listOfEquations.get(i);
                if (!equation.isFree(timeVar)) {
                    if (determineSingleDotEquation(equation, listOfVariables, timeVar, dotEquations, engine)) {
                        listOfEquations.remove(i);
                        continue;
                    }
                }
                i++;
            }
            if (listOfVariables.isList()) {
                AbstractIntegrator abstractIntegrator = new DormandPrince853Integrator(1.0e-8, 100.0, 1.0e-10, 1.0e-10);
                // AbstractIntegrator abstractIntegrator = new ClassicalRungeKuttaIntegrator(1.0);
                double[] primaryState = new double[numberOfVariables];
                for (int j = 0; j < numberOfVariables; j++) {
                    primaryState[j] = ((INum) engine.evalN(boundaryCondition[1][j])).doubleValue();
                }
                OrdinaryDifferentialEquation ode = new FirstODE(engine, dotEquations, listOfVariables, timeVar);
                if (listOfVariables.size() > 1) {
                    IASTAppendable[] resultLists = new IASTAppendable[numberOfVariables];
                    for (int j = 0; j < primaryState.length; j++) {
                        resultLists[j] = F.ListAlloc();
                    }
                    for (double time = tMin; time < tMax; time += tStep) {
                        final ODEStateAndDerivative finalstate = abstractIntegrator.integrate(ode, new ODEState(time, primaryState), time + tStep);
                        primaryState = finalstate.getPrimaryState();
                        for (int j = 0; j < primaryState.length; j++) {
                            resultLists[j].append(F.list(F.num(time), F.num(primaryState[j])));
                        }
                    }
                    IASTAppendable primaryList = F.ListAlloc();
                    IASTAppendable secondaryList = F.ListAlloc();
                    for (int j = 1; j < listOfVariables.size(); j++) {
                        secondaryList.append(F.Rule(listOfVariables.get(j), engine.evaluate(F.Interpolation(resultLists[j - 1]))));
                    }
                    primaryList.append(secondaryList);
                    return primaryList;
                }
            }
        } catch (LimitException le) {
            throw le;
        } catch (RuntimeException rex) {
            LOGGER.log(engine.getLogLevel(), ast.topHead(), rex);
        }
    }
    return F.NIL;
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) ODEState(org.hipparchus.ode.ODEState) IASTAppendable(org.matheclipse.core.interfaces.IASTAppendable) AbstractIntegrator(org.hipparchus.ode.AbstractIntegrator) OrdinaryDifferentialEquation(org.hipparchus.ode.OrdinaryDifferentialEquation) IAST(org.matheclipse.core.interfaces.IAST) IExpr(org.matheclipse.core.interfaces.IExpr) LimitException(org.matheclipse.core.eval.exception.LimitException) DormandPrince853Integrator(org.hipparchus.ode.nonstiff.DormandPrince853Integrator) ODEStateAndDerivative(org.hipparchus.ode.ODEStateAndDerivative)

Example 8 with LimitException

use of org.matheclipse.core.eval.exception.LimitException in project symja_android_library by axkr.

the class AbstractMatrix1Expr method numericEval.

@Override
public IExpr numericEval(final IAST ast, final EvalEngine engine) {
    RealMatrix matrix;
    IExpr arg1 = ast.arg1();
    int[] dim = checkMatrixDimensions(arg1);
    if (dim != null) {
        try {
            if (engine.isArbitraryMode()) {
                FieldMatrix<IExpr> fieldMatrix = Convert.list2Matrix(arg1);
                if (fieldMatrix != null) {
                    Predicate<IExpr> zeroChecker = optionZeroTest(ast, 2, engine);
                    return matrixEval(fieldMatrix, zeroChecker);
                }
                return F.NIL;
            }
            matrix = arg1.toRealMatrix();
            if (matrix != null) {
                return realMatrixEval(matrix);
            } else {
                FieldMatrix<IExpr> fieldMatrix = Convert.list2Matrix(arg1);
                if (fieldMatrix != null) {
                    Predicate<IExpr> zeroChecker = optionZeroTest(ast, 2, engine);
                    return matrixEval(fieldMatrix, zeroChecker);
                }
            }
        } catch (LimitException le) {
            throw le;
        } catch (final MathRuntimeException mre) {
            // org.hipparchus.exception.MathIllegalArgumentException: inconsistent dimensions: 0 != 3
            LOGGER.log(engine.getLogLevel(), ast.topHead(), mre);
        } catch (final RuntimeException e) {
            LOGGER.debug("AbstractMatrix1Expr.numericEval() failed", e);
        }
    }
    return F.NIL;
}
Also used : MathRuntimeException(org.hipparchus.exception.MathRuntimeException) MathRuntimeException(org.hipparchus.exception.MathRuntimeException) RealMatrix(org.hipparchus.linear.RealMatrix) IExpr(org.matheclipse.core.interfaces.IExpr) LimitException(org.matheclipse.core.eval.exception.LimitException)

Example 9 with LimitException

use of org.matheclipse.core.eval.exception.LimitException in project symja_android_library by axkr.

the class Iterator method create.

/**
 * Iterator specification for functions like <code>Table()</code> or <code>Sum()</code> or <code>
 * Product()</code>
 *
 * @param list a list representing an iterator specification
 * @param symbol the variable symbol
 * @param engine the evaluation engine
 * @return the iterator
 */
public static IIterator<IExpr> create(final IAST list, final ISymbol symbol, final EvalEngine engine) {
    EvalEngine evalEngine = engine;
    IExpr lowerLimit;
    IExpr upperLimit;
    IExpr step;
    ISymbol variable;
    boolean fNumericMode;
    if (symbol != null && (!symbol.isVariable() || symbol.isProtected())) {
        // Cannot assign to raw object `1`.
        throw new ArgumentTypeException(IOFunctions.getMessage("setraw", F.list(symbol), EvalEngine.get()));
    }
    boolean localNumericMode = evalEngine.isNumericMode();
    try {
        if (list.hasNumericArgument()) {
            evalEngine.setNumericMode(true);
        }
        fNumericMode = evalEngine.isNumericMode();
        switch(list.size()) {
            case 2:
                lowerLimit = F.C1;
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg1());
                step = F.C1;
                variable = symbol;
                if (upperLimit instanceof Num) {
                    return new DoubleIterator(variable, 1.0, ((INum) upperLimit).doubleValue(), 1.0);
                }
                if (upperLimit.isInteger()) {
                    try {
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        return new IntIterator(symbol, 1, iUpperLimit, 1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isRational()) {
                    try {
                        return new RationalIterator(symbol, F.C1, (IRational) upperLimit, F.C1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isQuantity()) {
                    return new QuantityIterator(symbol, (IQuantity) upperLimit);
                } else if (upperLimit.isReal()) {
                    return new ISignedNumberIterator(variable, F.C1, (ISignedNumber) upperLimit, F.C1);
                }
                break;
            case 3:
                lowerLimit = evalEngine.evalWithoutNumericReset(list.arg1());
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg2());
                step = F.C1;
                variable = symbol;
                if (upperLimit.isList()) {
                    if (variable != null) {
                        if (!variable.isVariable() || variable.isProtected()) {
                            // Cannot assign to raw object `1`.
                            throw new ArgumentTypeException(IOFunctions.getMessage("setraw", F.list(variable), EvalEngine.get()));
                        }
                    } else {
                        // Raw object `1` cannot be used as an iterator.
                        throw new ArgumentTypeException(IOFunctions.getMessage("itraw", F.list(list.arg1()), EvalEngine.get()));
                    }
                    return new ExprListIterator(variable, (IAST) upperLimit, evalEngine);
                }
                if (lowerLimit instanceof Num && upperLimit instanceof Num) {
                    return new DoubleIterator(variable, ((INum) lowerLimit).doubleValue(), ((INum) upperLimit).doubleValue(), 1.0);
                }
                if (lowerLimit.isInteger() && upperLimit.isInteger()) {
                    try {
                        int iLowerLimit = ((IInteger) lowerLimit).toInt();
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        return new IntIterator(symbol, iLowerLimit, iUpperLimit, 1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isRational() && upperLimit.isRational()) {
                    try {
                        return new RationalIterator(symbol, (IRational) lowerLimit, (IRational) upperLimit, F.C1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isQuantity() && upperLimit.isQuantity()) {
                    return new QuantityIterator(symbol, (IQuantity) lowerLimit, (IQuantity) upperLimit);
                } else if (lowerLimit.isReal() && upperLimit.isReal()) {
                    return new ISignedNumberIterator(variable, (ISignedNumber) lowerLimit, (ISignedNumber) upperLimit, F.C1);
                }
                break;
            case 4:
                lowerLimit = evalEngine.evalWithoutNumericReset(list.arg1());
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg2());
                step = evalEngine.evalWithoutNumericReset(list.arg3());
                variable = symbol;
                if (lowerLimit instanceof Num && upperLimit instanceof Num && step instanceof Num) {
                    return new DoubleIterator(variable, ((INum) lowerLimit).doubleValue(), ((INum) upperLimit).doubleValue(), ((INum) step).doubleValue());
                }
                if (lowerLimit.isInteger() && upperLimit.isInteger() && step.isInteger()) {
                    try {
                        int iLowerLimit = ((IInteger) lowerLimit).toInt();
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        int iStep = ((IInteger) step).toInt();
                        return new IntIterator(symbol, iLowerLimit, iUpperLimit, iStep);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isRational() && upperLimit.isRational() && step.isRational()) {
                    try {
                        return new RationalIterator(symbol, (IRational) lowerLimit, (IRational) upperLimit, (IRational) step);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isQuantity() && upperLimit.isQuantity() && step.isQuantity()) {
                    return new QuantityIterator(symbol, (IQuantity) lowerLimit, (IQuantity) upperLimit, (IQuantity) step);
                } else if (lowerLimit.isReal() && upperLimit.isReal() && step.isReal()) {
                    return new ISignedNumberIterator(variable, (ISignedNumber) lowerLimit, (ISignedNumber) upperLimit, (ISignedNumber) step);
                }
                break;
            default:
                lowerLimit = null;
                upperLimit = null;
                step = null;
                variable = null;
        }
        return new ExprIterator(variable, lowerLimit, upperLimit, step, fNumericMode, evalEngine);
    } catch (LimitException le) {
        throw le;
    } catch (ArgumentTypeException atex) {
        throw atex;
    } catch (RuntimeException rex) {
        throw new ClassCastException();
    } finally {
        evalEngine.setNumericMode(localNumericMode);
    }
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) Num(org.matheclipse.core.expression.Num) INum(org.matheclipse.core.interfaces.INum) ISignedNumber(org.matheclipse.core.interfaces.ISignedNumber) IInteger(org.matheclipse.core.interfaces.IInteger) EvalEngine(org.matheclipse.core.eval.EvalEngine) IRational(org.matheclipse.core.interfaces.IRational) IExpr(org.matheclipse.core.interfaces.IExpr) LimitException(org.matheclipse.core.eval.exception.LimitException) ArgumentTypeException(org.matheclipse.core.eval.exception.ArgumentTypeException)

Example 10 with LimitException

use of org.matheclipse.core.eval.exception.LimitException in project symja_android_library by axkr.

the class Iterator method create.

/**
 * Iterator specification for functions like <code>Table()</code> or <code>Sum()</code> or <code>
 * Product()</code>
 *
 * @param list a list representing an iterator specification
 * @param position the position of the list in the argument sequence, for printing an error if
 *        list cannot be converted into an iterator form
 * @param engine the evaluation engine
 * @return the iterator
 */
public static IIterator<IExpr> create(final IAST list, int position, final EvalEngine engine) {
    EvalEngine evalEngine = engine;
    IExpr lowerLimit;
    IExpr upperLimit;
    IExpr step;
    ISymbol variable;
    boolean fNumericMode;
    // fNumericMode = evalEngine.isNumericMode() ||
    // list.isMember(Predicates.isNumeric(), false);
    boolean localNumericMode = evalEngine.isNumericMode();
    try {
        if (list.hasNumericArgument()) {
            evalEngine.setNumericMode(true);
        }
        fNumericMode = evalEngine.isNumericMode();
        int iterationLimit = evalEngine.getIterationLimit();
        switch(list.size()) {
            case 2:
                lowerLimit = F.C1;
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg1());
                step = F.C1;
                variable = null;
                if (upperLimit instanceof Num) {
                    return new DoubleIterator(variable, 1.0, ((INum) upperLimit).doubleValue(), 1.0);
                }
                if (upperLimit.isInteger()) {
                    try {
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        if (iUpperLimit > iterationLimit && iterationLimit > 0) {
                            IterationLimitExceeded.throwIt(iUpperLimit, upperLimit);
                        }
                        return new IntIterator(variable, 1, iUpperLimit, 1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isRational()) {
                    try {
                        int iUpperLimit = ((IRational) upperLimit).floor().toInt();
                        if (iUpperLimit > iterationLimit && iterationLimit > 0) {
                            IterationLimitExceeded.throwIt(iUpperLimit, upperLimit);
                        }
                        return new RationalIterator(variable, F.C1, (IRational) upperLimit, F.C1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isQuantity()) {
                    return new QuantityIterator(variable, (IQuantity) upperLimit);
                } else if (upperLimit.isReal()) {
                    return new ISignedNumberIterator(variable, F.C1, (ISignedNumber) upperLimit, F.C1);
                }
                if (!list.arg1().isVariable()) {
                    throw new ArgumentTypeException(IOFunctions.getMessage("vloc", F.list(list.arg1()), EvalEngine.get()));
                }
                break;
            case 3:
                lowerLimit = F.C1;
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg2());
                step = F.C1;
                if (list.arg1() instanceof ISymbol) {
                    ISymbol sym = (ISymbol) list.arg1();
                    if (!sym.isVariable() || sym.isProtected()) {
                        // Cannot assign to raw object `1`.
                        throw new ArgumentTypeException(IOFunctions.getMessage("setraw", F.list(sym), EvalEngine.get()));
                    }
                    variable = sym;
                } else {
                    // Raw object `1` cannot be used as an iterator.
                    throw new ArgumentTypeException(IOFunctions.getMessage("itraw", F.list(list.arg1()), EvalEngine.get()));
                }
                if (upperLimit.isList()) {
                    return new ExprListIterator(variable, (IAST) upperLimit, evalEngine);
                }
                if (upperLimit instanceof Num) {
                    return new DoubleIterator(variable, 1.0, ((INum) upperLimit).doubleValue(), 1.0);
                }
                if (upperLimit.isInteger()) {
                    try {
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        return new IntIterator(variable, 1, iUpperLimit, 1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isRational()) {
                    try {
                        return new RationalIterator(variable, F.C1, (IRational) upperLimit, F.C1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (upperLimit.isQuantity()) {
                    return new QuantityIterator(variable, (IQuantity) upperLimit);
                } else if (upperLimit.isReal()) {
                    return new ISignedNumberIterator(variable, F.C1, (ISignedNumber) upperLimit, F.C1);
                }
                break;
            case 4:
                lowerLimit = evalEngine.evalWithoutNumericReset(list.arg2());
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg3());
                step = F.C1;
                if (list.arg1().isSymbol()) {
                    ISymbol sym = (ISymbol) list.arg1();
                    if (!sym.isVariable() || sym.isProtected()) {
                        // Cannot assign to raw object `1`.
                        throw new ArgumentTypeException(IOFunctions.getMessage("setraw", F.list(sym), EvalEngine.get()));
                    }
                    variable = sym;
                } else {
                    // Raw object `1` cannot be used as an iterator.
                    throw new ArgumentTypeException(IOFunctions.getMessage("itraw", F.list(list.arg1()), EvalEngine.get()));
                }
                if (lowerLimit instanceof Num && upperLimit instanceof Num) {
                    return new DoubleIterator(variable, ((INum) lowerLimit).doubleValue(), ((INum) upperLimit).doubleValue(), 1.0);
                }
                if (lowerLimit.isInteger() && upperLimit.isInteger()) {
                    try {
                        int iLowerLimit = ((IInteger) lowerLimit).toInt();
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        return new IntIterator(variable, iLowerLimit, iUpperLimit, 1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isRational() && upperLimit.isRational()) {
                    try {
                        return new RationalIterator(variable, (IRational) lowerLimit, (IRational) upperLimit, F.C1);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isQuantity() && upperLimit.isQuantity()) {
                    return new QuantityIterator(variable, (IQuantity) lowerLimit, (IQuantity) upperLimit);
                } else if (lowerLimit.isReal() && upperLimit.isReal()) {
                    ISignedNumber iLowerLimit = (ISignedNumber) lowerLimit;
                    ISignedNumber iUpperLimit = (ISignedNumber) upperLimit;
                    return new ISignedNumberIterator(variable, iLowerLimit, iUpperLimit, F.C1);
                }
                break;
            case 5:
                lowerLimit = evalEngine.evalWithoutNumericReset(list.arg2());
                upperLimit = evalEngine.evalWithoutNumericReset(list.arg3());
                step = evalEngine.evalWithoutNumericReset(list.arg4());
                if (list.arg1() instanceof ISymbol) {
                    ISymbol sym = (ISymbol) list.arg1();
                    if (!sym.isVariable() || sym.isProtected()) {
                        // Cannot assign to raw object `1`.
                        throw new ArgumentTypeException(IOFunctions.getMessage("setraw", F.list(sym), EvalEngine.get()));
                    }
                    variable = sym;
                } else {
                    // Raw object `1` cannot be used as an iterator.
                    throw new ArgumentTypeException(IOFunctions.getMessage("itraw", F.list(list.arg1()), EvalEngine.get()));
                }
                if (lowerLimit instanceof Num && upperLimit instanceof Num && step instanceof Num) {
                    return new DoubleIterator(variable, ((INum) lowerLimit).doubleValue(), ((INum) upperLimit).doubleValue(), ((INum) step).doubleValue());
                }
                if (lowerLimit.isInteger() && upperLimit.isInteger() && step.isInteger()) {
                    try {
                        int iLowerLimit = ((IInteger) lowerLimit).toInt();
                        int iUpperLimit = ((IInteger) upperLimit).toInt();
                        int iStep = ((IInteger) step).toInt();
                        return new IntIterator(variable, iLowerLimit, iUpperLimit, iStep);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isRational() && upperLimit.isRational() && step.isRational()) {
                    try {
                        return new RationalIterator(variable, (IRational) lowerLimit, (IRational) upperLimit, (IRational) step);
                    } catch (ArithmeticException ae) {
                    // 
                    }
                } else if (lowerLimit.isQuantity() && upperLimit.isQuantity() && step.isQuantity()) {
                    return new QuantityIterator(variable, (IQuantity) lowerLimit, (IQuantity) upperLimit, (IQuantity) step);
                } else if (lowerLimit.isReal() && upperLimit.isReal() && step.isReal()) {
                    return new ISignedNumberIterator(variable, (ISignedNumber) lowerLimit, (ISignedNumber) upperLimit, (ISignedNumber) step);
                }
                break;
            default:
                // Argument `1` at position `2` does not have the correct form for an iterator.
                String str = IOFunctions.getMessage("itform", F.list(list, F.ZZ(position)), EvalEngine.get());
                throw new ArgumentTypeException(str);
        }
        return new ExprIterator(variable, lowerLimit, upperLimit, step, fNumericMode, evalEngine);
    } catch (LimitException le) {
        throw le;
    } catch (ArgumentTypeException atex) {
        throw atex;
    } catch (RuntimeException rex) {
        // Argument `1` at position `2` does not have the correct form for an iterator.
        String str = IOFunctions.getMessage("itform", F.list(list, F.ZZ(position)), EvalEngine.get());
        throw new ArgumentTypeException(str);
    } finally {
        evalEngine.setNumericMode(localNumericMode);
    }
}
Also used : ISymbol(org.matheclipse.core.interfaces.ISymbol) Num(org.matheclipse.core.expression.Num) INum(org.matheclipse.core.interfaces.INum) ISignedNumber(org.matheclipse.core.interfaces.ISignedNumber) IInteger(org.matheclipse.core.interfaces.IInteger) EvalEngine(org.matheclipse.core.eval.EvalEngine) IRational(org.matheclipse.core.interfaces.IRational) IExpr(org.matheclipse.core.interfaces.IExpr) LimitException(org.matheclipse.core.eval.exception.LimitException) ArgumentTypeException(org.matheclipse.core.eval.exception.ArgumentTypeException)

Aggregations

LimitException (org.matheclipse.core.eval.exception.LimitException)13 IExpr (org.matheclipse.core.interfaces.IExpr)10 IAST (org.matheclipse.core.interfaces.IAST)7 ISymbol (org.matheclipse.core.interfaces.ISymbol)5 IInteger (org.matheclipse.core.interfaces.IInteger)4 EvalEngine (org.matheclipse.core.eval.EvalEngine)3 Num (org.matheclipse.core.expression.Num)3 INum (org.matheclipse.core.interfaces.INum)3 ISignedNumber (org.matheclipse.core.interfaces.ISignedNumber)3 MathRuntimeException (org.hipparchus.exception.MathRuntimeException)2 RealMatrix (org.hipparchus.linear.RealMatrix)2 ArgumentTypeException (org.matheclipse.core.eval.exception.ArgumentTypeException)2 ValidateException (org.matheclipse.core.eval.exception.ValidateException)2 ApcomplexNum (org.matheclipse.core.expression.ApcomplexNum)2 ApfloatNum (org.matheclipse.core.expression.ApfloatNum)2 IASTAppendable (org.matheclipse.core.interfaces.IASTAppendable)2 IASTMutable (org.matheclipse.core.interfaces.IASTMutable)2 IRational (org.matheclipse.core.interfaces.IRational)2 Entry (java.util.Map.Entry)1 TreeSet (java.util.TreeSet)1