From c463727a51d0df34db0c670d3b170195bb3d4eba Mon Sep 17 00:00:00 2001 From: Zachary Kurtz Date: Wed, 20 Oct 2021 11:35:08 -0400 Subject: [PATCH] Patch a few source code bugs (#188) * explicitly cast sparse matrix * fix travis badge * bump patch version --- DESCRIPTION | 2 +- README.Rmd | 2 +- README.md | 3 +-- src/ADMM.cpp | 8 ++++---- src/RcppExports.cpp | 5 +++++ src/svthresh.cpp | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3fbed5e..5d6c4da 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: SpiecEasi Title: Sparse Inverse Covariance for Ecological Statistical Inference -Version: 1.1.1 +Version: 1.1.2 Authors@R: c( person("Zachary", "Kurtz", role = c("aut", "cre"), email="zdkurtz@gmail.com"), person("Christian", "Mueller", role = "aut"), diff --git a/README.Rmd b/README.Rmd index 3c5bc60..fbc1909 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,7 +15,7 @@ if (!runchunks) load('.README.RData') ``` SpiecEasi ========= -[![Build Status](https://travis-ci.org/zdk123/SpiecEasi.svg?branch=pulsar)](https://travis-ci.org/zdk123/SpiecEasi) +[![Build Status](https://app.travis-ci.com/zdk123/SpiecEasi.svg?branch=master)](https://app.travis-ci.com/zdk123/SpiecEasi) Sparse InversE Covariance estimation for Ecological Association and Statistical Inference diff --git a/README.md b/README.md index 4d9e0a2..ed717f1 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ SpiecEasi ========= -[![Build -Status](https://travis-ci.org/zdk123/SpiecEasi.svg?branch=pulsar)](https://travis-ci.org/zdk123/SpiecEasi) +[![Build Status](https://app.travis-ci.com/zdk123/SpiecEasi.svg?branch=master)](https://app.travis-ci.com/zdk123/SpiecEasi) Sparse InversE Covariance estimation for Ecological Association and Statistical Inference diff --git a/src/ADMM.cpp b/src/ADMM.cpp index ea2f57d..faaf253 100644 --- a/src/ADMM.cpp +++ b/src/ADMM.cpp @@ -22,7 +22,7 @@ arma::mat sqrtmNewt2(arma::mat& C, arma::mat& sqrt0, const double& errTol) { arma::sp_mat SOFTTHRESH2(arma::mat& Sig, const float& lambda, const bool& shrinkDiag = true) { arma::mat A = symmatu(Sig); - int n = A.n_cols; +// int n = A.n_cols; arma::sp_mat S(sign(A)); arma::mat M(abs(A)-lambda); M.elem(find(M < 0)).zeros(); @@ -33,9 +33,9 @@ arma::sp_mat SOFTTHRESH2(arma::mat& Sig, const float& lambda, const bool& shrink void svdPowSym(arma::mat& U, arma::vec& d, arma::mat& V, arma::mat& A, int k, int q) { - int l = k; +// int l = k; int m = A.n_rows; - int n = A.n_cols; +// int n = A.n_cols; arma::mat P = randu(m,k-1); arma::mat Q, R; qr(Q, R, (P.t()*A).t()); @@ -190,7 +190,7 @@ List ADMM(const arma::mat& SigmaO, const double& lambda, arma::mat& I, } X.cols(0 , n-1 ) = R; - X.cols(n , n*2-1) = S; + X.cols(n , n*2-1) = arma::mat(S); X.cols(n*2, n*3-1) = L; RO = over_relax_par*R + (1-over_relax_par)*RY; diff --git a/src/RcppExports.cpp b/src/RcppExports.cpp index c214a8f..8887b30 100644 --- a/src/RcppExports.cpp +++ b/src/RcppExports.cpp @@ -6,6 +6,11 @@ using namespace Rcpp; +#ifdef RCPP_USE_GLOBAL_ROSTREAM +Rcpp::Rostream& Rcpp::Rcout = Rcpp::Rcpp_cout_get(); +Rcpp::Rostream& Rcpp::Rcerr = Rcpp::Rcpp_cerr_get(); +#endif + // ADMM List ADMM(const arma::mat& SigmaO, const double& lambda, arma::mat& I, arma::mat& Lambda, arma::mat& Y, double beta, int r, double mu, const double& eta, const double& muf, const int& maxiter, const double& newtol, const double& tol, const double& over_relax_par, bool shrinkDiag); RcppExport SEXP _SpiecEasi_ADMM(SEXP SigmaOSEXP, SEXP lambdaSEXP, SEXP ISEXP, SEXP LambdaSEXP, SEXP YSEXP, SEXP betaSEXP, SEXP rSEXP, SEXP muSEXP, SEXP etaSEXP, SEXP mufSEXP, SEXP maxiterSEXP, SEXP newtolSEXP, SEXP tolSEXP, SEXP over_relax_parSEXP, SEXP shrinkDiagSEXP) { diff --git a/src/svthresh.cpp b/src/svthresh.cpp index 0d57d17..47d01c5 100644 --- a/src/svthresh.cpp +++ b/src/svthresh.cpp @@ -8,7 +8,7 @@ using namespace arma; //soft thresholding operator of symmetric matrix arma::sp_mat SOFTTHRESH(arma::mat Sig, float lambda, bool shrinkDiag = true) { arma::mat A = symmatu(Sig); - int n = A.n_cols; +// int n = A.n_cols; arma::sp_mat S(sign(A)); arma::mat M(abs(A)-lambda); M.elem(find(M < 0)).zeros();