mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/constant] Constants differentiate to 0
This commit is contained in:
committed by
LeaNumworks
parent
a178c88e54
commit
764d14fed1
@@ -50,6 +50,9 @@ public:
|
||||
Expression shallowReduce(ReductionContext reductionContext) override;
|
||||
LayoutShape leftLayoutShape() const override { return LayoutShape::OneLetter; };
|
||||
|
||||
/* Derivation */
|
||||
bool derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) override;
|
||||
|
||||
private:
|
||||
char m_name[0]; // MUST be the last member variable
|
||||
|
||||
@@ -70,6 +73,7 @@ public:
|
||||
|
||||
// Simplification
|
||||
Expression shallowReduce(ExpressionNode::ReductionContext reductionContext);
|
||||
bool derivate(ExpressionNode::ReductionContext reductionContext, Expression symbol, Expression symbolValue);
|
||||
|
||||
private:
|
||||
ConstantNode * node() const { return static_cast<ConstantNode *>(Expression::node()); }
|
||||
|
||||
@@ -78,6 +78,10 @@ Expression ConstantNode::shallowReduce(ReductionContext reductionContext) {
|
||||
return Constant(this).shallowReduce(reductionContext);
|
||||
}
|
||||
|
||||
bool ConstantNode::derivate(ReductionContext reductionContext, Expression symbol, Expression symbolValue) {
|
||||
return Constant(this).derivate(reductionContext, symbol, symbolValue);
|
||||
}
|
||||
|
||||
bool ConstantNode::isConstantCodePoint(CodePoint c) const {
|
||||
UTF8Decoder decoder(m_name);
|
||||
bool result = (decoder.nextCodePoint() == c);
|
||||
@@ -106,4 +110,9 @@ Expression Constant::shallowReduce(ExpressionNode::ReductionContext reductionCon
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Constant::derivate(ExpressionNode::ReductionContext reductionContext, Expression symbol, Expression symbolValue) {
|
||||
replaceWithInPlace(Rational::Builder(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user