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
2b7bbdb0
"plugins/vscode:/vscode.git/clone" did not exist on "6cc49dbe48ced91d1389346146c4aa5965d88604"
Commit
2b7bbdb0
authored
May 06, 2015
by
peastman
Browse files
Implemented select() in custom expressions
parent
73be43c5
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
tests/TestParser.cpp
tests/TestParser.cpp
+5
-0
No files found.
tests/TestParser.cpp
View file @
2b7bbdb0
...
...
@@ -178,6 +178,8 @@ void verifyDerivative(const string& expression, const string& expectedDeriv) {
verifySameValue
(
computed
,
expected
,
2.0
,
3.0
);
verifySameValue
(
computed
,
expected
,
-
2.0
,
3.0
);
verifySameValue
(
computed
,
expected
,
2.0
,
-
3.0
);
verifySameValue
(
computed
,
expected
,
0.0
,
-
3.0
);
verifySameValue
(
computed
,
expected
,
2.0
,
0.0
);
}
/**
...
...
@@ -249,6 +251,8 @@ int main() {
verifyEvaluation
(
"step(x-3)+y*step(x)"
,
2.0
,
3.0
,
3.0
);
verifyEvaluation
(
"floor(x)"
,
-
2.1
,
3.0
,
-
3.0
);
verifyEvaluation
(
"ceil(x)"
,
-
2.1
,
3.0
,
-
2.0
);
verifyEvaluation
(
"select(x, 1.0, y)"
,
0.3
,
2.0
,
1.0
);
verifyEvaluation
(
"select(x, 1.0, y)"
,
0.0
,
2.0
,
2.0
);
verifyInvalidExpression
(
"1..2"
);
verifyInvalidExpression
(
"1*(2+3"
);
verifyInvalidExpression
(
"5++4"
);
...
...
@@ -282,6 +286,7 @@ int main() {
verifyDerivative
(
"max(5, x^2)"
,
"(1-step(5-x^2))*2*x"
);
verifyDerivative
(
"abs(3*x)"
,
"step(3*x)*3+(1-step(3*x))*-3"
);
verifyDerivative
(
"floor(x)+0.5*x*ceil(x)"
,
"0.5*ceil(x)"
);
verifyDerivative
(
"select(x, x^2, 3*x)"
,
"select(x, 2*x, 3)"
);
testCustomFunction
(
"custom(x, y)/2"
,
"x*y"
);
testCustomFunction
(
"custom(x^2, 1)+custom(2, y-1)"
,
"2*x^2+4*(y-1)"
);
cout
<<
Parser
::
parse
(
"x*x"
).
optimize
()
<<
endl
;
...
...
Prev
1
2
Next
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