From aec46b608e6b7d67a4b96d52c58d2c3fce8486fb Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Thu, 24 Jun 2021 11:29:24 -0500 Subject: [PATCH] Add a method to Expr. (Split out from earlier "Eigen library integration" commit) --- src/expr.cpp | 5 +++++ src/expr.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/expr.cpp b/src/expr.cpp index 6030cb1..b612dd2 100644 --- a/src/expr.cpp +++ b/src/expr.cpp @@ -430,6 +430,11 @@ bool Expr::DependsOn(hParam p) const { bool Expr::Tol(double a, double b) { return fabs(a - b) < 0.001; } + +bool Expr::IsZeroConst() const { + return op == Op::CONSTANT && EXACT(v == 0.0); +} + Expr *Expr::FoldConstants() { Expr *n = AllocExpr(); *n = *this; diff --git a/src/expr.h b/src/expr.h index efd44a5..d59930b 100644 --- a/src/expr.h +++ b/src/expr.h @@ -73,6 +73,7 @@ public: void ParamsUsedList(List *list) const; bool DependsOn(hParam p) const; static bool Tol(double a, double b); + bool IsZeroConst() const; Expr *FoldConstants(); void Substitute(hParam oldh, hParam newh);