Skip to content

Commit

Permalink
Fixing CRAN warning by changing C++ code to use fabs insteat of abs
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinErickson committed Feb 11, 2024
1 parent a1c8ad3 commit 45caef2
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions NEWS.md
@@ -1,5 +1,6 @@
# GauPro 0.2.11.9000

Fixed CRAN warning.

# GauPro 0.2.11

Expand Down
7 changes: 1 addition & 6 deletions cran-comments.md
@@ -1,9 +1,4 @@
I received an email from Brian
Ripley on 3/29/23 telling me to correct the error on
https://cran.r-project.org/web/checks/check_results_GauPro.html.

The error on that page was from a unreliable test. I have improved the test to
make it reliable.
I fixed the warning on CRAN.

## Test environments
* local Windows 11 install, R 4.2.3
Expand Down
2 changes: 0 additions & 2 deletions scratch/ToDo.md
Expand Up @@ -47,5 +47,3 @@ diff(range(Z))^2. Or else give message to normalize.
* Fix GHA/Linux bug with cubic

* increasing nugget to get invertibility, only print last

* badger badges
10 changes: 5 additions & 5 deletions src/corr_cubic_matrix.cpp
Expand Up @@ -25,7 +25,7 @@ NumericMatrix corr_cubic_matrixC(NumericMatrix x, NumericMatrix y, NumericVector
double total = 1;
for(int k = 0; k < nsum; ++k) {
// total += theta[k] * pow((x(i,k) - y(j,k)), 2.0);
double d = abs(x(i,k) - y(j,k)) / theta[k];
double d = fabs(x(i,k) - y(j,k)) / theta[k];
double r = 0;
if (d <= .5) {
r = 1-6*pow(d, 2.0)+6*pow(d, 3.0);
Expand Down Expand Up @@ -61,7 +61,7 @@ NumericMatrix corr_cubic_matrix_symC(NumericMatrix x, NumericVector theta) {
double total = 1;
for(int k = 0; k < nsum; ++k) {
// total += theta[k] * pow((x(i,k) - x(j,k)), 2.0);
double d = abs(x(i,k) - x(j,k)) / theta[k];
double d = fabs(x(i,k) - x(j,k)) / theta[k];
double r = 0;
if (d <= .5) {
r = 1-6*pow(d, 2.0) + 6*pow(d, 3.0);
Expand Down Expand Up @@ -96,7 +96,7 @@ NumericVector corr_cubic_matrixvecC(NumericMatrix x, NumericVector y,
double total = 1;
for(int k = 0; k < nsum; ++k) {
// total += theta[k] * pow((x(i,k) - y(k)), 2.0);
double d = abs(x(i,k) - y(k)) / theta[k];
double d = fabs(x(i,k) - y(k)) / theta[k];
double r = 0;
if (d <= .5) {
r = 1-6*pow(d, 2.0)+6*pow(d, 3.0);
Expand Down Expand Up @@ -153,7 +153,7 @@ arma::cube kernel_cubic_dC(arma::mat x, arma::vec theta, arma::mat C_nonug,
NumericVector dvec(nsum), rvec(nsum);
for(int k = 0; k < nsum; ++k) {
// total += theta[k] * pow((x(i,k) - x(j,k)), 2.0);
double d = abs(x(i,k) - x(j,k)) / theta[k];
double d = fabs(x(i,k) - x(j,k)) / theta[k];
dvec[k] = d;
double r = 0;
if (d <= .5) {
Expand All @@ -174,7 +174,7 @@ arma::cube kernel_cubic_dC(arma::mat x, arma::vec theta, arma::mat C_nonug,
} else {
grad = -1;
}
double d = abs(x(i,k) - x(j,k)) / theta[k];
double d = fabs(x(i,k) - x(j,k)) / theta[k];
double dr = 0;
if (d <= .5) {
// tmp2 = 1-6*pow(d, 2)+6*pow(d,3);
Expand Down

0 comments on commit 45caef2

Please sign in to comment.