Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
2d8e6684
"platforms/vscode:/vscode.git/clone" did not exist on "f4339363dcc4c904b2baae05949dedc0676b3f50"
Commit
2d8e6684
authored
Aug 06, 2009
by
Peter Eastman
Browse files
Added one optimization, plus fixed a bug.
parent
3bcccc3d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
libraries/lepton/src/ParsedExpression.cpp
libraries/lepton/src/ParsedExpression.cpp
+3
-1
No files found.
libraries/lepton/src/ParsedExpression.cpp
View file @
2d8e6684
...
...
@@ -162,7 +162,7 @@ ExpressionTreeNode ParsedExpression::substituteSimplerExpression(const Expressio
case
Operation
::
DIVIDE
:
{
double
numerator
=
getConstantValue
(
children
[
0
]);
if
(
numerator
=
0.0
)
// 0 divided by something
if
(
numerator
=
=
0.0
)
// 0 divided by something
return
ExpressionTreeNode
(
new
Operation
::
Constant
(
0.0
));
if
(
numerator
==
1.0
)
// 1 divided by something
return
ExpressionTreeNode
(
new
Operation
::
Reciprocal
(),
children
[
1
]);
...
...
@@ -188,6 +188,8 @@ ExpressionTreeNode ParsedExpression::substituteSimplerExpression(const Expressio
if
(
base
==
1.0
)
// 1 to any power is 1
return
ExpressionTreeNode
(
new
Operation
::
Constant
(
1.0
));
double
exponent
=
getConstantValue
(
children
[
1
]);
if
(
exponent
==
0.0
)
// x^0 = 1
return
ExpressionTreeNode
(
new
Operation
::
Constant
(
1.0
));
if
(
exponent
==
1.0
)
// x^1 = x
return
children
[
0
];
if
(
exponent
==
-
1.0
)
// x^-1 = recip(x)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment