mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[solver] Fix Equation with new Poincare APi
This commit is contained in:
@@ -6,7 +6,7 @@ namespace Solver {
|
||||
|
||||
Equation::Equation() :
|
||||
Shared::ExpressionModel(),
|
||||
m_standardForm(nullptr)
|
||||
m_standardForm()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -27,33 +27,28 @@ void Equation::setContent(const char * c) {
|
||||
|
||||
void Equation::tidy() {
|
||||
ExpressionModel::tidy();
|
||||
if (m_standardForm) {
|
||||
delete m_standardForm;
|
||||
m_standardForm = nullptr;
|
||||
}
|
||||
tidyStandardForm();
|
||||
}
|
||||
|
||||
Expression * Equation::standardForm(Context * context) const {
|
||||
if (m_standardForm == nullptr) {
|
||||
Expression * e = expression(context);
|
||||
if (e->type() == ExpressionNode::Type::Equal) {
|
||||
m_standardForm = static_cast<const Equal *>(e)->standardEquation(*context, Preferences::sharedPreferences()->angleUnit());
|
||||
} else if (e->type() == ExpressionNode::Type::Rational && static_cast<Rational *>(e)->isOne()) {
|
||||
Expression Equation::standardForm(Context * context) const {
|
||||
if (m_standardForm.isUninitialized()) {
|
||||
const Expression e = expression(context);
|
||||
if (e.type() == ExpressionNode::Type::Equal) {
|
||||
m_standardForm = static_cast<const Equal&>(e).standardEquation(*context, Preferences::sharedPreferences()->angleUnit());
|
||||
} else if (e.type() == ExpressionNode::Type::Rational && static_cast<const Rational&>(e).isOne()) {
|
||||
// The equality was reduced which means the equality was always true.
|
||||
m_standardForm = RationalReference(0);
|
||||
m_standardForm = Rational(0);
|
||||
} else {
|
||||
// The equality has an undefined operand
|
||||
assert(e->type() == ExpressionNode::Type::Undefined);
|
||||
assert(e.type() == ExpressionNode::Type::Undefined);
|
||||
}
|
||||
}
|
||||
return m_standardForm;
|
||||
}
|
||||
|
||||
void Equation::tidyStandardForm() {
|
||||
if (m_standardForm) {
|
||||
delete m_standardForm;
|
||||
m_standardForm = nullptr;
|
||||
}
|
||||
// Free the pool of the m_standardForm
|
||||
m_standardForm = Expression();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user