Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cpp/java benchmark program: wrong output due to logic error #595

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/bench/cpp/deriv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ static const Expr* mul( const Expr* x, const Expr* y ) {
return new ValExpr(((ValExpr*)x)->value * ((ValExpr*)y)->value);
}
else if (x->kind==Val && ((ValExpr*)x)->value==0) {
return x;
return new ValExpr(0);
}
else if (y->kind==Val && ((ValExpr*)y)->value==0) {
return y;
return new ValExpr(0);
}
else if (x->kind==Val && ((ValExpr*)x)->value==1) {
return y;
Expand Down
6 changes: 3 additions & 3 deletions test/bench/java/deriv.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ static Expr mul( Expr x, Expr y ) {
return new ValExpr( a.value * b.value );
}
else if (x instanceof ValExpr a && a.value == 0) {
return x;
return new ValExpr(0);
}
else if (y instanceof ValExpr b && b.value == 0) {
return y;
return new ValExpr(0);
}
else if (x instanceof ValExpr a && a.value == 1) {
return y;
Expand All @@ -110,7 +110,7 @@ else if (y instanceof ValExpr b) {
else if (x instanceof ValExpr a && y instanceof MulExpr b && b.left instanceof ValExpr bl) {
return mul(new ValExpr(a.value * bl.value), b.right);
}
else if (y instanceof MulExpr b && b.left instanceof MulExpr) {
else if (y instanceof MulExpr b && b.left instanceof ValExpr) {
return mul(b.left, mul(x,b.right));
}
else if (x instanceof MulExpr a) {
Expand Down