#include #include #include #include #include extern "C" { #include #include } #include namespace Poincare { ExpressionLayout * Sequence::createLayout(PrintFloat::Mode floatDisplayMode, int numberOfSignificantDigits) const { return createSequenceLayoutWithArgumentLayouts(operand(0)->createLayout(floatDisplayMode, numberOfSignificantDigits), operand(1)->createLayout(floatDisplayMode, numberOfSignificantDigits), operand(2)->createLayout(floatDisplayMode, numberOfSignificantDigits)); } template Evaluation * Sequence::templatedApproximate(Context& context, AngleUnit angleUnit) const { Evaluation * aInput = operand(1)->privateApproximate(T(), context, angleUnit); Evaluation * bInput = operand(2)->privateApproximate(T(), context, angleUnit); T start = aInput->toScalar(); T end = bInput->toScalar(); delete aInput; delete bInput; if (std::isnan(start) || std::isnan(end) || start != (int)start || end != (int)end || end - start > k_maxNumberOfSteps) { return new Complex(Complex::Undefined()); } VariableContext nContext = VariableContext('n', &context); Evaluation * result = new Complex(emptySequenceValue()); for (int i = (int)start; i <= (int)end; i++) { if (shouldStopProcessing()) { delete result; return new Complex(Complex::Undefined()); } nContext.setApproximationForVariable((T)i); Evaluation * expression = operand(0)->privateApproximate(T(), nContext, angleUnit); Evaluation * newResult = evaluateWithNextTerm(T(), result, expression); delete result; delete expression; result = newResult; if (result == nullptr) { return new Complex(Complex::Undefined()); } } return result; } }