mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare] In Multiplication::shallowBeautify, when extracting the unit,
reduce without changing the unit in order to extract the right unit. This fixes the following bug: simplify "πππ23*_cK"
This commit is contained in:
committed by
LeaNumworks
parent
50bc31fcfa
commit
d789e8da97
@@ -191,6 +191,17 @@ public:
|
||||
m_symbolicComputation(symbolicComputation),
|
||||
m_unitConversion(unitConversion)
|
||||
{}
|
||||
static ReductionContext NonInvasiveReductionContext(ReductionContext reductionContext) {
|
||||
return ReductionContext(
|
||||
reductionContext.context(),
|
||||
reductionContext.complexFormat(),
|
||||
reductionContext.angleUnit(),
|
||||
reductionContext.unitFormat(),
|
||||
reductionContext.target(),
|
||||
SymbolicComputation::DoNotReplaceAnySymbol,
|
||||
UnitConversion::None
|
||||
);
|
||||
}
|
||||
Preferences::UnitFormat unitFormat() const { return m_unitFormat; }
|
||||
ReductionTarget target() const { return m_target; }
|
||||
SymbolicComputation symbolicComputation() const { return m_symbolicComputation; }
|
||||
|
||||
@@ -423,7 +423,9 @@ Expression Multiplication::shallowBeautify(ExpressionNode::ReductionContext redu
|
||||
// Step 2: Handle the units
|
||||
if (hasUnit()) {
|
||||
Expression units;
|
||||
self = deepReduce(reductionContext); // removeUnit has to be called on reduced expression
|
||||
/* removeUnit has to be called on reduced expression but we want to modify
|
||||
* the least the expression so we use the uninvasive reduction context. */
|
||||
self = deepReduce(ExpressionNode::ReductionContext::NonInvasiveReductionContext(reductionContext));
|
||||
self = removeUnit(&units);
|
||||
|
||||
if (self.isUndefined() || units.isUninitialized()) {
|
||||
|
||||
Reference in New Issue
Block a user