mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] Decimal: templatize Decimal constructor on float/double
This commit is contained in:
@@ -47,14 +47,14 @@ Expression * CubicModel::simplifiedExpression(double * modelCoefficients, Poinca
|
||||
new Decimal(a),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(3),
|
||||
new Decimal(3.0),
|
||||
false),
|
||||
false);
|
||||
Expression * bx2Expression = new Multiplication(
|
||||
new Decimal(b),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(2),
|
||||
new Decimal(2.0),
|
||||
false),
|
||||
false);
|
||||
Expression * cxExpression = new Multiplication(
|
||||
|
||||
@@ -38,7 +38,7 @@ Expression * QuadraticModel::simplifiedExpression(double * modelCoefficients, Po
|
||||
new Decimal(a),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(2),
|
||||
new Decimal(2.0),
|
||||
false),
|
||||
false);
|
||||
Expression * bxExpression = new Multiplication(
|
||||
|
||||
@@ -56,21 +56,21 @@ Expression * QuarticModel::simplifiedExpression(double * modelCoefficients, Poin
|
||||
new Decimal(a),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(4),
|
||||
new Decimal(4.0),
|
||||
false),
|
||||
false);
|
||||
Expression * bx3Expression = new Multiplication(
|
||||
new Decimal(b),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(3),
|
||||
new Decimal(3.0),
|
||||
false),
|
||||
false);
|
||||
Expression * cx2Expression = new Multiplication(
|
||||
new Decimal(c),
|
||||
new Power(
|
||||
new Symbol('x'),
|
||||
new Decimal(2),
|
||||
new Decimal(2.0),
|
||||
false),
|
||||
false);
|
||||
Expression * dxExpression = new Multiplication(
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
static int exponent(const char * integralPart, int integralPartLength, const char * fractionalPart, int fractionalPartLength, const char * exponent, int exponentLength, bool exponentNegative);
|
||||
static Integer mantissa(const char * integralPart, int integralPartLength, const char * fractionalPart, int fractionalPartLength, bool negative);
|
||||
Decimal(Integer mantissa, int exponent);
|
||||
Decimal(double f);
|
||||
template <typename T> Decimal(T f);
|
||||
int exponent() const { return m_exponent; }
|
||||
Integer mantissa() const { return m_mantissa; }
|
||||
// Expression subclassing
|
||||
|
||||
@@ -75,9 +75,10 @@ Decimal::Decimal(Integer mantissa, int exponent) :
|
||||
{
|
||||
}
|
||||
|
||||
Decimal::Decimal(double f) {
|
||||
m_exponent = IEEE754<double>::exponentBase10(f);
|
||||
int64_t mantissaf = std::round(f * std::pow(10.0, -m_exponent+PrintFloat::k_numberOfStoredSignificantDigits+1));
|
||||
template <typename T>
|
||||
Decimal::Decimal(T f) {
|
||||
m_exponent = IEEE754<T>::exponentBase10(f);
|
||||
int64_t mantissaf = std::round((double)f * std::pow((double)10.0, (double)(-m_exponent+PrintFloat::k_numberOfStoredSignificantDigits+1)));
|
||||
m_mantissa = Integer(mantissaf);
|
||||
}
|
||||
|
||||
@@ -275,4 +276,7 @@ int Decimal::simplificationOrderSameType(const Expression * e, bool canBeInterru
|
||||
return ((int)sign())*unsignedComparison;
|
||||
}
|
||||
|
||||
template Decimal::Decimal(double);
|
||||
template Decimal::Decimal(float);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user