Skip to content

Commit

Permalink
Fix CRAN Solaris issue of pow overloading (#19)
Browse files Browse the repository at this point in the history
* 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...
  • Loading branch information
coatless committed Mar 24, 2020
1 parent e2dcc35 commit 651d621
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 30 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
12 changes: 11 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -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.
- Estimate Q matrices with varying _k_ values and compare.
4 changes: 4 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![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)
<!-- badges: end -->

Perform a Bayesian estimation of the Exploratory
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<!-- badges: end -->

Perform a Bayesian estimation of the Exploratory Deterministic Input,
Expand Down
22 changes: 4 additions & 18 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
34 changes: 24 additions & 10 deletions inst/include/edina_meat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(K - k) - 1.0);
}

return vv;
Expand All @@ -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<double>(K - k) - 1.0);
alpha(k) = (twopow <= CL);
CL = CL - twopow * alpha(k);
}
Expand Down Expand Up @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

arma::mat alpha_mat(nClass, K);

for(unsigned int cc = 0; cc < nClass; cc++){
Expand All @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

arma::mat ETA(J, nClass);

Expand All @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

unsigned int nqjs =
static_cast<unsigned int>(std::pow(2.0, static_cast<double>(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) {
Expand All @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

unsigned int nqjs =
static_cast<unsigned int>(std::pow(2.0, static_cast<double>(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) {
Expand Down Expand Up @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

arma::mat ETAbyQ(nClass, nClass - 1);
for (unsigned int cc = 0; cc < nClass; ++cc) {
arma::vec alpha_c = inv_bijectionvector(K, cc);
Expand Down Expand Up @@ -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<unsigned int>(std::pow(2.0, static_cast<double>(K)));

// Total Chain length with burn
// Prevents overflow
Expand Down

0 comments on commit 651d621

Please sign in to comment.