#include #include #include "layout/absolute_value_layout.h" extern "C" { #include } #include namespace Poincare { Expression::Type AbsoluteValue::type() const { return Type::AbsoluteValue; } Expression * AbsoluteValue::clone() const { AbsoluteValue * a = new AbsoluteValue(m_operands, true); return a; } Expression * AbsoluteValue::immediateSimplify() { if (operand(0)->sign() > 0) { return replaceWith(const_cast(operand(0)), true); } if (operand(0)->sign() < 0) { Expression * op = const_cast(operand(0)); Expression * newOp = op->turnIntoPositive(); return replaceWith(newOp, true); } return this; } template Complex AbsoluteValue::computeOnComplex(const Complex c, AngleUnit angleUnit) { return Complex::Float(c.r()); } ExpressionLayout * AbsoluteValue::privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const { assert(floatDisplayMode != FloatDisplayMode::Default); assert(complexFormat != ComplexFormat::Default); return new AbsoluteValueLayout(operand(0)->createLayout(floatDisplayMode, complexFormat)); } }