mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-27 17:50:04 +01:00
39 lines
1002 B
C++
39 lines
1002 B
C++
#include <poincare/absolute_value.h>
|
|
#include <poincare/complex.h>
|
|
#include "layout/absolute_value_layout.h"
|
|
|
|
extern "C" {
|
|
#include <assert.h>
|
|
}
|
|
#include <cmath>
|
|
|
|
namespace Poincare {
|
|
|
|
Expression::Type AbsoluteValue::type() const {
|
|
return Type::AbsoluteValue;
|
|
}
|
|
|
|
Expression * AbsoluteValue::clone() const {
|
|
AbsoluteValue * a = new AbsoluteValue(m_operands, true);
|
|
return a;
|
|
}
|
|
|
|
void AbsoluteValue::immediateSimplify() {
|
|
if (operand(0)->sign() > 0) {
|
|
replaceWith(const_cast<Expression *>(operand(0)), true);
|
|
}
|
|
}
|
|
|
|
template<typename T>
|
|
Complex<T> AbsoluteValue::computeOnComplex(const Complex<T> c, AngleUnit angleUnit) {
|
|
return Complex<T>::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));
|
|
}
|
|
|
|
}
|