Skip to content

Commit

Permalink
bool operands
Browse files Browse the repository at this point in the history
  • Loading branch information
rhijmans committed Apr 5, 2022
1 parent ee27848 commit c80d45d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/clamp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Rcpp::NumericVector do_clamp(std::vector<double> d, std::vector<double> r, bool
}
} else {
for (size_t i=0; i<n; i++) {
if ( (d[i] < r[0]) | (d[i] > r[1])) {
if ( (d[i] < r[0]) || (d[i] > r[1])) {
val[i] = NAN;
} else {
val[i] = d[i];
Expand Down
10 changes: 5 additions & 5 deletions src/reclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, b
} else {
val[i] = d[i];
for (size_t j=0; j<a; j++) {
if ((d[i] >= rcl[j]) & (d[i] <= rcl[j+a])) {
if ((d[i] >= rcl[j]) && (d[i] <= rcl[j+a])) {
val[i] = rcl[j+b];
break;
}
Expand Down Expand Up @@ -83,7 +83,7 @@ Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, b
} else {
val[i] = d[i];
for (size_t j=0; j<a; j++) {
if ((d[i] > rcl[j]) & (d[i] <= rcl[j+a])) {
if ((d[i] > rcl[j]) && (d[i] <= rcl[j+a])) {
val[i] = rcl[j+b];
break;
}
Expand All @@ -99,7 +99,7 @@ Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, b
} else {
val[i] = d[i];
for (size_t j=0; j<a; j++) {
if ((d[i] > rcl[j]) & (d[i] <= rcl[j+a])) {
if ((d[i] > rcl[j]) && (d[i] <= rcl[j+a])) {
val[i] = rcl[j+b];
break;
}
Expand Down Expand Up @@ -129,7 +129,7 @@ Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, b
} else {
val[i] = d[i];
for (size_t j=0; j<a; j++) {
if ((d[i] >= rcl[j]) & (d[i] < rcl[j+a])) {
if ((d[i] >= rcl[j]) && (d[i] < rcl[j+a])) {
val[i] = rcl[j+b];
break;
}
Expand All @@ -145,7 +145,7 @@ Rcpp::NumericVector reclassify(Rcpp::NumericVector d, Rcpp::NumericMatrix rcl, b
} else {
val[i] = d[i];
for (size_t j=0; j<a; j++) {
if ((d[i] >= rcl[j]) & (d[i] < rcl[j+a])) {
if ((d[i] >= rcl[j]) && (d[i] < rcl[j+a])) {
val[i] = rcl[j+b];
break;
}
Expand Down

0 comments on commit c80d45d

Please sign in to comment.