From 45caef27eeb13ecd7a764ebe767c831e25500429 Mon Sep 17 00:00:00 2001 From: Collin Erickson Date: Sat, 10 Feb 2024 23:32:44 -0500 Subject: [PATCH] Fixing CRAN warning by changing C++ code to use fabs insteat of abs --- NEWS.md | 1 + cran-comments.md | 7 +------ scratch/ToDo.md | 2 -- src/corr_cubic_matrix.cpp | 10 +++++----- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index 218ecd1..aa921bf 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,6 @@ # GauPro 0.2.11.9000 +Fixed CRAN warning. # GauPro 0.2.11 diff --git a/cran-comments.md b/cran-comments.md index 3f0cf51..57485aa 100644 --- a/cran-comments.md +++ b/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 diff --git a/scratch/ToDo.md b/scratch/ToDo.md index 09a0cb4..77c69fa 100644 --- a/scratch/ToDo.md +++ b/scratch/ToDo.md @@ -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 diff --git a/src/corr_cubic_matrix.cpp b/src/corr_cubic_matrix.cpp index 6a5a17f..c5fa423 100644 --- a/src/corr_cubic_matrix.cpp +++ b/src/corr_cubic_matrix.cpp @@ -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); @@ -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); @@ -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); @@ -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) { @@ -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);