[poincare/derivative] Derivate special numbers

Derivate the numbers Undefined, Unreal, Infinity symbolically :
  Undefined -> Undefined
  Unreal    -> Unreal
  Infinity  -> Undefined
This commit is contained in:
Gabriel Ozouf
2020-12-03 14:41:00 +01:00
committed by EmilieNumworks
parent 76eb155ed5
commit 7ae03975cc
5 changed files with 21 additions and 3 deletions

View File

@@ -37,6 +37,11 @@ public:
// Layout
Layout createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode = Preferences::PrintFloatMode::Decimal, int numberOfSignificantDigits = 0) const override;
/* Derivation
* Unlike Numbers that derivate to 0, Infinity derivates to Undefined. */
bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override;
private:
// Simplification
LayoutShape leftLayoutShape() const override { assert(!m_negative); return LayoutShape::MoreLetters; }
@@ -56,6 +61,7 @@ public:
static int NameSize() {
return 4;
}
bool derivate(ExpressionNode::ReductionContext reductionContext, Expression symbol, Expression symbolValue);
private:
InfinityNode * node() const { return static_cast<InfinityNode *>(Number::node()); }
};

View File

@@ -30,8 +30,8 @@ public:
}
/* Derivation
* Overrides NumberNode's derivate to revert to a non-derivable state */
bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override { return false; }
* Unlike Numbers that derivate to 0, Undefined derivates to Undefined. */
bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override { return true; }
// Layout
Layout createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;

View File

@@ -28,7 +28,7 @@ public:
}
/* Derivation
* Overrides NumberNode's derivate to revert to a non-derivable state */
* Unlike Numbers that derivate to 0, Unreal derivates to Unreal. */
bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override { return false; }
// Layout