#include #include #include extern "C" { #include } #include namespace Poincare { ConfidenceInterval::ConfidenceInterval() : Function("confidence", 2) { } Expression::Type ConfidenceInterval::type() const { return Type::ConfidenceInterval; } Expression * ConfidenceInterval::cloneWithDifferentOperands(Expression** newOperands, int numberOfOperands, bool cloneOperands) const { assert(newOperands != nullptr); ConfidenceInterval * ci = new ConfidenceInterval(); ci->setArgument(newOperands, numberOfOperands, cloneOperands); return ci; } template Evaluation * ConfidenceInterval::templatedEvaluate(Context& context, AngleUnit angleUnit) const { Evaluation * fInput = m_args[0]->evaluate(context, angleUnit); Evaluation * nInput = m_args[1]->evaluate(context, angleUnit); T f = fInput->toScalar(); T n = nInput->toScalar(); delete fInput; delete nInput; if (std::isnan(f) || std::isnan(n) || n != (int)n || n < 0 || f < 0 || f > 1) { return new Complex(Complex::Float(NAN)); } Complex operands[2]; operands[0] = Complex::Float(f - 1/std::sqrt(n)); operands[1] = Complex::Float(f + 1/std::sqrt(n)); return new ComplexMatrix(operands, 1, 2); } }