From 651d621f2b31b9ebf4717927fc149b4d479717fa Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Tue, 24 Mar 2020 09:57:22 -0500 Subject: [PATCH] Fix CRAN Solaris issue of pow overloading (#19) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix overload error in pow given by: error: call of overloaded ‘pow(int, unsigned int&)’ is ambiguous By switching over to static_cast's to double. * Add CRAN badges now that it is listed on CRAN. * Bump package version and update submission remarks... --- DESCRIPTION | 2 +- NEWS.md | 12 +++++++++++- README.Rmd | 4 ++++ README.md | 8 ++++++++ cran-comments.md | 22 ++++------------------ inst/include/edina_meat.h | 34 ++++++++++++++++++++++++---------- 6 files changed, 52 insertions(+), 30 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index d0fe0cd..7881da3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: edina Title: Bayesian Estimation of an Exploratory Deterministic Input, Noisy and Gate Model -Version: 0.1.0 +Version: 0.1.1 Authors@R: c( person("James Joseph", "Balamuta", email = "balamut2@illinois.edu", diff --git a/NEWS.md b/NEWS.md index dc6d56b..ea60138 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,17 @@ +# edina 0.1.1 + +## Bug Fix + +- Fix ambiguous overloaded of `pow` on Solaris. + +## Documentation + +- Added CRAN badges to README. + # edina 0.1.0 ## Features - Provides a high-performing modeling routine for the Exploratory Deterministic Input, Noisy "And" Gate model. -- Estimate Q matrices with varying _k_ values and compare. \ No newline at end of file +- Estimate Q matrices with varying _k_ values and compare. diff --git a/README.Rmd b/README.Rmd index 94a7d28..c90b9d6 100644 --- a/README.Rmd +++ b/README.Rmd @@ -17,6 +17,10 @@ knitr::opts_chunk$set( [![R build status](https://github.com/tmsalab/edina/workflows/R-CMD-check/badge.svg)](https://github.com/tmsalab/edina/actions) [![Package-License](http://img.shields.io/badge/license-GPL%20(%3E=2)-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) +[![CRAN Version Badge](http://www.r-pkg.org/badges/version/edina)](https://cran.r-project.org/package=edina) +[![CRAN Status](https://cranchecks.info/badges/worst/edina)](https://cran.r-project.org/web/checks/check_results_edina.html) +[![RStudio CRAN Mirror's Monthly Downloads](http://cranlogs.r-pkg.org/badges/edina?color=brightgreen)](http://www.r-pkg.org/pkg/edina) +[![RStudio CRAN Mirror's Total Downloads](http://cranlogs.r-pkg.org/badges/grand-total/edina?color=brightgreen)](http://www.r-pkg.org/pkg/edina) Perform a Bayesian estimation of the Exploratory diff --git a/README.md b/README.md index 09619e0..3683213 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,14 @@ [![R build status](https://github.com/tmsalab/edina/workflows/R-CMD-check/badge.svg)](https://github.com/tmsalab/edina/actions) [![Package-License](http://img.shields.io/badge/license-GPL%20\(%3E=2\)-brightgreen.svg?style=flat)](http://www.gnu.org/licenses/gpl-2.0.html) +[![CRAN Version +Badge](http://www.r-pkg.org/badges/version/edina)](https://cran.r-project.org/package=edina) +[![CRAN +Status](https://cranchecks.info/badges/worst/edina)](https://cran.r-project.org/web/checks/check_results_edina.html) +[![RStudio CRAN Mirror’s Monthly +Downloads](http://cranlogs.r-pkg.org/badges/edina?color=brightgreen)](http://www.r-pkg.org/pkg/edina) +[![RStudio CRAN Mirror’s Total +Downloads](http://cranlogs.r-pkg.org/badges/grand-total/edina?color=brightgreen)](http://www.r-pkg.org/pkg/edina) Perform a Bayesian estimation of the Exploratory Deterministic Input, diff --git a/cran-comments.md b/cran-comments.md index 4b6a491..8204fd6 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -8,22 +8,8 @@ 0 errors | 0 warnings | 1 note -- This is a new release and a resubmit to address CRAN remarks. - -**Remarks** - -- The following misspelled words are due to the shortening of the list of authors - to "et al." and the method acronym. - -> Possibly mis-spelled words in DESCRIPTION: -> EDINA (20:42) -> al (21:53) -> et (21:50) - -- From the last submission: - -- We've removed the `donttest` portion for `edina()` by dropping the number of - observations calculated to 1. We cannot remove the donttest option for - `auto_edina()` as it requires at least 10 seconds with 2 different matrices - being estimated. +> Days since last update: 0 +- This release addresses an issue uncovered with `pow()` on Solaris causing + the package to fail to build. + https://www.r-project.org/nosvn/R.check/r-patched-solaris-x86/edina-00install.html diff --git a/inst/include/edina_meat.h b/inst/include/edina_meat.h index d8f1419..2170359 100644 --- a/inst/include/edina_meat.h +++ b/inst/include/edina_meat.h @@ -24,7 +24,7 @@ inline arma::vec bijectionvector(unsigned int K) arma::vec vv(K); for (unsigned int k = 0; k < K; ++k) { - vv(k) = pow(2, K - k - 1); + vv(k) = std::pow(2.0, static_cast(K - k) - 1.0); } return vv; @@ -35,7 +35,7 @@ inline arma::vec inv_bijectionvector(unsigned int K, double CL) arma::vec alpha(K); for (unsigned int k = 0; k < K; ++k) { - double twopow = pow(2, K - k - 1); + double twopow = std::pow(2.0, static_cast(K - k) - 1.0); alpha(k) = (twopow <= CL); CL = CL - twopow * alpha(k); } @@ -138,7 +138,9 @@ inline arma::mat alpha_matrix(const arma::mat& Q) { int K = Q.n_cols; - double nClass = pow(2, K); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); + arma::mat alpha_mat(nClass, K); for(unsigned int cc = 0; cc < nClass; cc++){ @@ -151,7 +153,8 @@ inline arma::mat alpha_matrix(const arma::mat& Q) { inline arma::mat ETAmat(unsigned int K, unsigned int J, const arma::mat &Q) { - double nClass = pow(2, K); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); arma::mat ETA(J, nClass); @@ -171,8 +174,12 @@ inline arma::mat ETAmat(unsigned int K, unsigned int J, const arma::mat &Q) inline arma::cube ETAmat_nok(unsigned int K) { - unsigned int nClass = pow(2, K); - unsigned int nqjs = pow(2, K - 1); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); + + unsigned int nqjs = + static_cast(std::pow(2.0, static_cast(K) - 1.0)); + arma::vec zero_to_Km1 = arma::linspace(0, K - 1, K); arma::cube ETA_nok(K, nqjs, nClass); for (unsigned int k = 0; k < K; ++k) { @@ -194,8 +201,12 @@ inline arma::cube ETAmat_nok(unsigned int K) inline arma::cube ETAmat_nok_one_m_ac(unsigned int K) { - unsigned int nClass = pow(2, K); - unsigned int nqjs = pow(2, K - 1); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); + + unsigned int nqjs = + static_cast(std::pow(2.0, static_cast(K) - 1.0)); + arma::vec zero_to_Km1 = arma::linspace(0, K - 1, K); arma::cube ETA_nok(K, nqjs, nClass); for (unsigned int k = 0; k < K; ++k) { @@ -255,7 +266,9 @@ inline arma::vec abcounts(unsigned int N, const arma::vec &Yj, const arma::vec & inline arma::mat ClassbyQmat(unsigned int K) { - double nClass = pow(2, K); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); + arma::mat ETAbyQ(nClass, nClass - 1); for (unsigned int cc = 0; cc < nClass; ++cc) { arma::vec alpha_c = inv_bijectionvector(K, cc); @@ -617,7 +630,8 @@ inline Rcpp::List edina_Gibbs_Q(const arma::mat &Y, unsigned int K, // unsigned int K = Q.n_cols; // Number of Classes - unsigned int nClass = pow(2, K); + unsigned int nClass = + static_cast(std::pow(2.0, static_cast(K))); // Total Chain length with burn // Prevents overflow