Git Product home page Git Product logo

rcpparmadillo's Introduction

RcppArmadillo: R and Armadillo via Rcpp

CI License CRAN Debian package r-universe Dependencies Coverage Status Last Commit Downloads (monthly) Downloads (total) CRAN use CRAN indirect BioConductor use CSDA

Synopsis

RcppArmadillo provides an interface from R to and from Armadillo by utilising the Rcpp R/C++ interface library.

What is Armadillo?

Armadillo is a high-quality linear algebra library for the C++ language, aiming towards a good balance between speed and ease of use. It provides high-level syntax and functionality deliberately similar to Matlab (TM). See its website more information about Armadillo.

So give me an example!

Glad you asked. Here is a light-weight and fast implementation of linear regression:

#include <RcppArmadillo/Lighter>
// [[Rcpp::depends(RcppArmadillo)]]

// [[Rcpp::export]]
Rcpp::List fastLm(const arma::mat& X, const arma::colvec& y) {
    int n = X.n_rows, k = X.n_cols;

    arma::colvec coef = arma::solve(X, y);     // fit model y ~ X
    arma::colvec res  = y - X*coef;            // residuals
    double s2 = arma::dot(res, res) / (n - k); // std.errors of coefficients
    arma::colvec std_err = arma::sqrt(s2 * arma::diagvec(arma::pinv(arma::trans(X)*X)));

    return Rcpp::List::create(Rcpp::Named("coefficients") = coef,
                              Rcpp::Named("stderr")       = std_err,
                              Rcpp::Named("df.residual")  = n - k);
}

You can Rcpp::sourceCpp() the file above to compile the function. A version is also included in the package as the fastLm() function.

The RcppArmadillo/Lighter header includes Rcpp via its Rcpp/Lighter header which precludes some more compile-time heavy features such as 'Rcpp Modules' which we may not need. See the Rcpp docs more details about 'Light', 'Lighter' and 'Lightest'. In the example above, the switch saves about 15% of total compilation time.

Status

The package is mature yet under active development with releases to CRAN about once every other month, and widely-used by other CRAN packages as can be seen from the CRAN package page. As of April 2024, there are 1135 CRAN packages using RcppArmadillo.

Documentation

The package contains a pdf vignette which is a pre-print of the paper by Eddelbuettel and Sanderson in CSDA (2014), as well as an introductory vignette for the sparse matrix conversions.

Installation

RcppArmadillo is a CRAN package, and lives otherwise in its own habitat on GitHub within the RcppCore GitHub organization.

Run

install.packages("RcppArmadillo")

to install from your nearest CRAN mirror.

Authors

Dirk Eddelbuettel, Romain Francois, Doug Bates, Binxiang Ni, and Conrad Sanderson

License

GPL (>= 2)

rcpparmadillo's People

Contributors

berrij avatar binxiangni avatar coatless avatar conradsnicta avatar dmbates avatar eddelbuettel avatar gvegayon avatar helmingstay avatar jaganmn avatar kevinushey avatar kthohr avatar msk avatar nathan-russell avatar romainfrancois avatar sgsokol avatar solivella avatar t-kalinowski avatar thirdwing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rcpparmadillo's Issues

compile error Redhat 6.6 & R 3.1.2

I'm continually having issues trying to get this package installed. I was wondering if you've seen this issue or knew a fix. I've searched all over the web and have yet to come across the same issue.

Any help would be greatly appreciated!

R version: 3.1.2
Epel version: epel-release-6-8.noarch
Red Hat Enterprise Linux Server release 6.6 (Santiago)

  • installing source package ‘RcppArmadillo’ ...
    ** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
  • checking LAPACK_LIBS: divide-and-conquer complex SVD available via R-supplied LAPACK
    ** libs
    g++ -m64 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include" -I../inst/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c RcppArmadillo.cpp -o RcppArmadillo.o
    In file included from ../inst/include/armadillo:97,
    from ../inst/include/RcppArmadilloForward.h:46,
    from ../inst/include/RcppArmadillo.h:30,
    from RcppArmadillo.cpp:22:
    ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_type<std::__traitor<std::__is_integer, std::__is_floating >:: >::value’:
    ../inst/include/armadillo_bits/op_expmat_meat.hpp:51: instantiated from here
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_elem2’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_elem1’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_col’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_row’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_diagview’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_mtGlue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_mtOp’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_eGlue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_eOp’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Glue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Op’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Gen’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Mat’
    ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_typestd::__traitor<std::__is_integer<double, std::__is_floating >:: >::value’:
    ../inst/include/armadillo_bits/op_expmat_meat.hpp:51: instantiated from here
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_elem2’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_elem1’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_col’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview_row’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_subview’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_diagview’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_mtGlue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_mtOp’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_eGlue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_eOp’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Glue’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Op’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Gen’
    ../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:614: error: trying to instantiate ‘template struct arma::is_Mat’
    make: *** [RcppArmadillo.o] Error 1
    ERROR: compilation failed for package ‘RcppArmadillo’

zgesvx missing in Rlapack

This is used by Baptiste's cda package, and per email from KH leads to a regression test error on systems using Rlapack.

Armadillo 7.900.0 and C++11 transition

Opening an issue to tick off a few things we (hi, @coatless) could look into:

  • support C++11 and OpenMP in package build
    • easy for RcppArmadillo itself and essentially done
    • but less relevant as eg fastLm() does not "need" it)
  • adjust RcppArmadillo.package.skeleton() to set these two options as well
    • maybe with a fallback option?
  • maybe beef up configure to test compilers and simply fall back C++98 for g++ older than 4.9 ?

All this is predicated on Armadillo actually still falling back sanely to a non-C++11 world, and Conrad is increasingly unlikely to support this 'forever' (and has given ample warning)

That would mean more proactively setting some of the config variables. More work, but we would not exclude the poor souls

Failure to build on CentOS6 GCC 4.4.7

When compiled on a CentOS6 (GCC 4.4.7) platform, RcppArmadillo 0.6.700.3.0
has similar bug to one fixed in 0.4.550.2.0

I just came to install

RcppArmadillo 0.6.700.3.0

on a CentOS 6 system (GCC 4.4.7) and it failed to compile.

When I went looking for the error, I found this at stackoverflow from 2014

RcppArmadillo: failing to install on CentOS

in which Dirk said that a similar bug had been fixed, in 0.4.550.2.0,
available from this GitHub repo.

Sadly, and somewhat strangely, this GitHub repo doesn't have
any releases (perhaps because "releases" are moved across to
the CRAN ?) however, the version above was not seemingly
propagated over to the CRAN repos, so it was confusing for
a short while.

I did think to try 0.4.550.1.0 but I guess 0.4.550.2.0 was needed
because it fixed the bug in the 1-before-it (pun intended) becuase
that failed to compile as well.

I did manage to follow the other advice from the stackoverflow
question, which was to use 0.4.500.0, which is in the CRAN archive
for RcppArmadillo.

I attach the compilation errors from 0.6.700.3.0 in case they are of any use.
20160415-RcppArmadillo.txt

R 3.3.2 Ubuntu 16.04 install error: invalid cast from type ‘Rcpp::Vector<19>....

I'm trying to install RcppArmadillo on ubuntu 16.04, but am getting an error I can't seem to find mentioned anywhere.

My version of gcc / g++ is 4.8.5, but I tried with 5.4.0 with exactly the same result.

Installing package into ‘/home/gpistre/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/RcppArmadillo_0.7.700.0.0.tar.gz'

* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking whether we are using the GNU C++ compiler... (cached) yes
checking whether g++ accepts -g... (cached) yes
checking whether g++ version is sufficient... (4.9.3) yes
checking LAPACK_LIBS... system LAPACK found
configure: creating ./config.status
config.status: creating inst/include/RcppArmadilloLapack.h
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/home/gpistre/R/x86_64-pc-linux-gnu-library/3.3/Rcpp/include" -DARMA_64BIT_WORD -I../inst/include -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/RcppArmadillo.h:38:0,
                 from RcppArmadillo.cpp:22:
../inst/include/RcppArmadilloAs.h: In instantiation of ‘Rcpp::traits::Exporter<arma::Cube<eT> >::cube_t Rcpp::traits::Exporter<arma::Cube<eT> >::get() [with T = long long int; Rcpp::traits::Exporter<arma::Cube<eT> >::cube_t = arma::Cube<long long int>]’:
../inst/include/RcppArmadilloAs.h:174:48:   required from here
../inst/include/RcppArmadilloAs.h:139:49: error: invalid cast from type ‘Rcpp::Vector<19>::iterator {aka Rcpp::internal::Proxy_Iterator<Rcpp::internal::generic_proxy<19> >}’ to type ‘long long int*’
                 dims[0], dims[1], dims[2], false);
                                                 ^
/usr/lib/R/etc/Makeconf:141: recipe for target 'RcppArmadillo.o' failed
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/gpistre/R/x86_64-pc-linux-gnu-library/3.3/RcppArmadillo’
Warning in install.packages :
  installation of package ‘RcppArmadillo’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpCwdr9A/downloaded_packages’

Can't install on Centos

I may have missed something obvious but I am struggling getting this installed on CentOS. This is what I see when I install

trying URL 'http://mirror.mdx.ac.uk/R/src/contrib/RcppArmadillo_0.4.550.1.0.tar.gz'

Content type 'application/x-gzip' length 936961 bytes (915 Kb)
opened URL
==================================================
downloaded 915 Kb

* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
* checking LAPACK_LIBS: divide-and-conquer complex SVD available via R-supplied LAPACK
** libs
g++ -m64 -I/usr/include/R -DNDEBUG  -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include"  -I../inst/include -fpic  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic  -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/armadillo:97,
                 from ../inst/include/RcppArmadilloForward.h:46,
                 from ../inst/include/RcppArmadillo.h:30,
                 from RcppArmadillo.cpp:22:
../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_type<std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum> >::value’:
../inst/include/armadillo_bits/op_expmat_meat.hpp:51:   instantiated from here
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_elem2’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_elem1’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_col’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_row’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_diagview’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_mtGlue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_mtOp’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_eGlue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_eOp’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Glue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Op’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Gen’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<unsigned int>, std::__is_floating<unsigned int> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Mat’
../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_type<std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum> >::value’:
../inst/include/armadillo_bits/op_expmat_meat.hpp:51:   instantiated from here
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_elem2’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_elem1’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_col’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview_row’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_subview’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_diagview’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_mtGlue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_mtOp’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_eGlue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_eOp’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Glue’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Op’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Gen’
../inst/include/armadillo_bits/traits.hpp:614: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type
../inst/include/armadillo_bits/traits.hpp:614: error:   trying to instantiate ‘template<class T> struct arma::is_Mat’
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/usr/lib64/R/library/RcppArmadillo’

The downloaded source packages are in
    ‘/tmp/RtmpMKgQGd/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("RcppArmadillo") :
  installation of package ‘RcppArmadillo’ had non-zero exit status

Support for Rcpp::as< arma::Cube<T> >

I took a shot at implementing a means of converting Rcpp::Vectors to arma::Cubes, but wanted to get some feedback on my code before submitting a PR because I think there are some minor sticking points worth discussing. The full change is reflected in RcppArmadilloAs.h on my fork, in the form of

  1. a specialization of Rcpp::Exporter< arma::Cube<T> >; and
  2. 3 further Exporter specializations, one for each of arma::fcube, arma::ucube, and arma::cx_fcube

The first specialization works for fine for the Cube<double>, Cube<sword>, and Cube<cx_double>, but was choking on the remaining three typedefs. I could not come up with an elegant approach to encapsulate everything in one template, so I ended up with the additional three specializations that "piggy back" on their counterparts which do compile; e.g. to get an arma::Cube<float> / arma::fcube, a SEXP is first converted to an arma::cube using (1), and then converted to an arma::fcube using Armadillo's conv_to< >::from utility. Presumably this adds additional overhead which is not ideal, but as stated, I was unable to avoid this extra step. I am certainly open to any alternative suggestions however.

In my unit test file (using the C++ functions here), two of the tests involving arma::cx_fcubes use a modified tolerance value of 1.5e-7 when compared to base R's equivalent calculation. I suspect this has to do with a loss of precision in the conversion from double to float, but regardless I wanted to call attention to this.

Finally, my Exporter specialization is written such that an exception will be thrown if the input object to be converted does not have exactly three dimensions. Is this desirable?

Taking into account everything above, the corresponding Travis build was successful, but I certainly some discussion is in order.

Rcpp dependency

Could we keep RcppArmadillo's master branch dependent on the released Rcpp?

It has been beneficial in the past to be able to quickly release RcppArmadillo when Armadillo releases. But depending on an unreleased Rcpp version with an uncertain release date, we lose that ability which is a net loss.

Problem of assert when adding RcppArmadillo code.

I added some RcppArmadillo code to my package and it resulted in a warning during checking:

checking compiled code ... WARNING
File ‘bigstatsr/libs/bigstatsr.so’:
  Found ‘__assert_fail’, possibly from ‘assert’ (C)
    Object: ‘RcppExports.o’

You can see Travis-CI results there.

I am on CentOS 7 (Linux) with version 3.3.1 of R (Travis-CI tests oldrel, release and devel) and tried with both the latest and previous versions of RcppArmadillo (0.7.600.1.0 & 0.7.500.0.0).

I really don't know how to handle this error as I don't use any #include <assert.h> and, when checking, R uses the -DNDEBUG flag.
Any help would be really appreciated.

Intermitted seg fault returning arma::sp_mat to R

I've been regularly getting seg faults in code that returns a largeish sp_mat from C++ to R (as a sparse matrix). I can consistently reproduce it with the code, it happens about 75% of the time. But I haven't been able to isolate a minimally reproducible example.

Where it occurs, is when R calls a C++ function that calls a nested function that creates and returns an sp_mat that is then immediately returned to R. I've traced the segfault to the return line.

Calling t() twice works-around it.

If:

// [[Rcpp::export]]
arma::sp_mat referenceWij(const arma::ivec& i,
                                  const arma::ivec& j,
                                  arma::vec& d,
                                  Rcpp::Nullable<Rcpp::NumericVector> threads,
                                  double perplexity) {
#ifdef _OPENMP
    checkCRAN(threads);
#endif
  ReferenceEdges ref = ReferenceEdges(perplexity, i, j, d);
  ref.run();
  sp_mat wij = ref.getWIJ();
  return wij; // segfaults on this line ~ 75% of the time.
}

But:

// [[Rcpp::export]]
arma::sp_mat referenceWij(const arma::ivec& i,
                                  const arma::ivec& j,
                                  arma::vec& d,
                                  Rcpp::Nullable<Rcpp::NumericVector> threads,
                                  double perplexity) {
#ifdef _OPENMP
    checkCRAN(threads);
#endif
  ReferenceEdges ref = ReferenceEdges(perplexity, i, j, d);
  ref.run();
  sp_mat wij = ref.getWIJ();
  wij = wij.t(); 
  wij = wij.t();
  return wij;  // Does not seg fault ever
}

SUPERLU support

How would one go about enabling SUPERLU support with RcppArmadillo?

Specifically, I would like to be able to use spsolve with SUPERLU under the hood.

Should this amount to enabling ARMA_USE_SUPERLU in inst/include/armadillo_bits/config.hpp and installing package from source?

Or is this a deeper issue?

Thank you.

Requires g++ 4.6

The latest version requires g++ 4.6 in the configure script. I'm wondering if this is due to the use of some newer C++ features in the source, or if it doesn't really need 4.6.

We run R on an IBM Netezza PureData appliance box, which is a managed R environment. Hence, we don't have the ability to upgrade g++. RcppArmadillo is a dependency of an R package we use, but we're unable to install version 0.7.100.3.0 due to this requirement.

configure: WARNING: Only g++ version 4.6 or greater can be used with RcppArmadillo.
configure: error: Please use a different compiler.
ERROR: configuration failed for package RcppArmadillo

Consequently, we're explicitly installing the CRAN archive version 0.6.700.6.0, which achieves what we need.

If this is a real requirement, please just close this request, but if not we'd like to suggest lowering the g++ version requirement in the configuration to the previous version that was specified.

Presumably, IBM will update the NZR software in the appliance in future, but in the enterprise environment that typically takes considerable time.

Thanks!

zgges missing in Rlapack (Compiling error on Windows 7)

I've run into an issue when compiling a package on Windows 7 using RcppArmadillo version 0.5.299.0, but that compiles just fine on Mac (10.10.4) and Linux (Ubuntu 15.04).

Basically, my package needs the new qz() function that was just added to Armadillo, and this addition seems to have created an 'undefined reference' error for LAPACK's 'zgges', and a few others.

I've tried this on 2 different Windows 7 systems and I get the same error.

library(devtools)
dev_mode()
install_github("RcppCore/RcppArmadillo")
install_github("kthohr/BMR")

RcppArmadillo compiles just fine, but I get the following error when compiling my package:

Downloading github repo kthohr/BMR@master
Installing BMR
Skipping 1 packages ahead of CRAN: RcppArmadillo
"C:/R-32~1.1/bin/x64/R" --no-site-file --no-environ --no-save --no-restore CMD INSTALL  \
  "C:/Users/Keith/AppData/Local/Temp/RtmpqgKoti/devtoolsa9433925f91/kthohr-BMR-a083c4a"  \
  --library="C:/R-3.2.1/library" --install-tests 

* installing *source* package 'BMR' ...
** libs

*** arch - i386
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c adfc.cpp -o adfc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c bvarmc.cpp -o bvarmc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c bvarsc.cpp -o bvarsc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c bvartvpc.cpp -o bvartvpc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c bvarwc.cpp -o bvarwc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c cvarc.cpp -o cvarc.o
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c dsgec.cpp -o dsgec.o
dsgec.cpp: In function 'SEXPREC* gensysCpp(SEXP, SEXP, SEXP, SEXP, SEXP)':
dsgec.cpp:482:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
g++ -m32 -I"C:/R-32~1.1/include" -DNDEBUG    -I"C:/R-3.2.1/library/Rcpp/include" -I"C:/R-3.2.1/library/RcppArmadillo/include" -I"d:/RCompile/r-compiling/local/local320/include"     -O2 -Wall  -mtune=core2 -c dsgevarc.cpp -o dsgevarc.o
g++ -m32 -shared -s -static-libgcc -o BMR.dll tmp.def adfc.o bvarmc.o bvarsc.o bvartvpc.o bvarwc.o cvarc.o dsgec.o dsgevarc.o -LC:/R-32~1.1/bin/i386 -lRlapack -LC:/R-32~1.1/bin/i386 -lRblas -lgfortran -Ld:/RCompile/r-compiling/local/local320/lib/i386 -Ld:/RCompile/r-compiling/local/local320/lib -LC:/R-32~1.1/bin/i386 -lR
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib2qzIdNS_3MatISt7complexIdEEES5_EEbRNS2_IS3_IT_EEES9_S9_S9_RKNS_4BaseIS7_T0_EERKNSA_IS7_T1_EEc[bool arma::auxlib::qz<double, arma::Mat<std::complex<double> >, arma::Mat<std::complex<double> > >(arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> >&, arma::Base<std::complex<double>, arma::Mat<std::complex<double> > > const&, arma::Base<std::complex<double>, arma::Mat<std::complex<double> > > const&, char)]+0x3de): undefined reference to `zgges_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib18inv_inplace_lapackISt7complexIdEEEbRNS_3MatIT_EE[bool arma::auxlib::inv_inplace_lapack<std::complex<double> >(arma::Mat<std::complex<double> >&)]+0x119): undefined reference to `zgetri_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib18inv_inplace_lapackISt7complexIdEEEbRNS_3MatIT_EE[bool arma::auxlib::inv_inplace_lapack<std::complex<double> >(arma::Mat<std::complex<double> >&)]+0x21d): undefined reference to `zgetri_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib3invISt7complexIdEEEbRNS_3MatIT_EERKS6_b[bool arma::auxlib::inv<std::complex<double> >(arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> > const&, bool)]+0x1ff): undefined reference to `zgetri_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib3invISt7complexIdEEEbRNS_3MatIT_EERKS6_b[bool arma::auxlib::inv<std::complex<double> >(arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> > const&, bool)]+0x2fb): undefined reference to `zgetri_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib8solve_odISt7complexIdENS_3MatIS3_EEEEbRNS4_IT_EES8_RKNS_4BaseIS6_T0_EE[bool arma::auxlib::solve_od<std::complex<double>, arma::Mat<std::complex<double> > >(arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> >&, arma::Base<std::complex<double>, arma::Mat<std::complex<double> > > const&)]+0x2ad): undefined reference to `zgels_'
dsgec.o:dsgec.cpp:(.text$_ZN4arma6auxlib8solve_udISt7complexIdENS_3MatIS3_EEEEbRNS4_IT_EES8_RKNS_4BaseIS6_T0_EE[bool arma::auxlib::solve_ud<std::complex<double>, arma::Mat<std::complex<double> > >(arma::Mat<std::complex<double> >&, arma::Mat<std::complex<double> >&, arma::Base<std::complex<double>, arma::Mat<std::complex<double> > > const&)]+0x36d): undefined reference to `zgels_'
collect2: ld returned 1 exit status
no DLL was created
ERROR: compilation failed for package 'BMR'
* removing 'C:/R-3.2.1/library/BMR'
Error: Command failed (1)

Any thoughts on why I'm getting this linking error to LAPACK would be great.

For reference, my Makevars.win file is

PKG_LIBS = $(shell $(R_HOME)/bin${R_ARCH_BIN}/Rscript.exe -e "Rcpp:::LdFlags()") $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

sort_index compatibility issue pre and post version 0.5

Hi,

I have two version of RcppArmadillo on two different servers: RcppArmadillo_0.5.200.1.0 and RcppArmadillo_0.4.650.1.1

When I run sort_index with RcppArmadillo_0.5.200.1.0, the output is returned as a column. Whereas, when I run sort_index with RcppArmadillo_0.4.650.1.1, the output is returned as a row.

sort_index with RcppArmadillo_0.5.200.1.0 also doesn't handle Inf whereas RcppArmadillo_0.4.650.1.1 treats Inf as largest possible value.

I believe this incompability was introduced in v0.5 when 'sort_index() and stable_sort_index() have been placed in the delayed operations framework for increased efficiency'

In case you want to test this out, I used the following code:

library('Rcpp')
library('inline')

rcpp_inc <- '
using namespace Rcpp;
'

src <- ' 
arma::mat m=Rcpp::as<arma::mat>(Mat);
arma::rowvec z=m.row(0);
arma::urowvec o=arma::sort_index(z, "ascend"); // ascending order
return wrap(o);
'

fn <- cxxfunction(signature(Mat="numeric"), src, plugin='RcppArmadillo', rcpp_inc)

set.seed(0)
mat <- matrix( c(rnorm(5*10,mean=0,sd=1), rnorm(5*10,mean=5,sd=1)), 10, 10)
mat[1,1] <- Inf

fn(mat)

With RcppArmadillo_0.4.650.1.1, the output is a row:

> fn(mat)
     [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
[1,]    3    2    1    4    8    7    5    6    9     0

With RcppArmadillo_0.5.200.1.0, if I don't uncomment mat[1,1] <- Inf, then I get the following error:
Error: sort_index(): detected non-finite values

If I remove the infinite, then I still have to make urowvec into uvec to avoid Error: Mat::init(): requested size is not compatible with row vector layout because the output is a column:

> fn(mat)
      [,1]
 [1,]    3
 [2,]    2
 [3,]    1
 [4,]    0
 [5,]    4
 [6,]    8
 [7,]    7
 [8,]    5
 [9,]    6
[10,]    9

Please fix this compatibility issue. I much prefer the old return style and ability to handle infinite values.

I have a package that depends on RcppArmadillo (https://github.com/hms-dbmi/scde), developed using RcppArmadillo_0.4.650.1.1. Would you recommend I update my code to conform to RcppArmadillo_0.5.200.1.0's return outputs or will you be updating RcppArmadillo_0.5.200.1.0 to be compatible with RcppArmadillo_0.4.650.1.1?

Thanks! Feel free to let me know if I could be of assistance with anything else.

Best,
Jean

Error installing RcppArmadillo

Hello,

I am new to R and I having some issues installing packages. I am trying to install RcppArmadillo and I am getting the next error:

install.packages("RcppArmadillo")

ld: warning: directory not found for option '-L/usr/local/lib/gcc/x86_64-apple-darwin13.0.0/4.8.2'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [RcppArmadillo.so] Error 1
ERROR: compilation failed for package 'RcppArmadillo'

  • removing '/Library/Frameworks/R.framework/Versions/3.2/Resources/library/RcppArmadillo'

Could you please help me?

Some info: I use OSX el Capitan 10.11.
R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Platform: x86_64-apple-darwin13.4.0 (64-bit)
R Studio Version 0.99.489

Thanks a lot,

Isabel

std::snprintf not found with GCC 4.8, 4.6

Hi,
For some reason, GCC 4.8 and 4.6 tell me that snprintf is not part of std. I tried virtually every -std options, and nothing works. However, replacing std::snprintf by just snprintf in arma_boost.hpp solved the problem as it falls back on snprintf from C99.

While I consider this to be a compiler bug, would it be possible to just change it in your code to use snprintf instead of std::snprintf ?

LAPACK Requirements

From an email I sent on Dec 10 with no apparent result.

Step One: Extracting Armadillo requirements

This extract double and complex valued functions from def_lapack.hpp in the Armadillo sources.

awk '/\#define/ { print $3} ' def_lapack.hpp  | tr A-Z a-z | \
    sort | uniq | grep "^[dz]" > /tmp/arma-lapack.txt

Step Two: Compare to R

Compare this to src/modules/lapack/README in the R sources.

for w in $(cat /tmp/arma-lapack.txt); do echo -n "$w: "; grep -c "$w.f" README ; done

Or more compactly focusing just on missing ones:

(for w in $(cat /tmp/arma-lapack.txt); \
     do echo -n "$w: "; grep -c "$w.f" README ; done) | grep 0

Step Three: Result

On both Dec 10 and today (Jan 2) after changes in R updating to LAPACK 3.6.0, the resulting set of missing (complex-valued) Armadillo functions is:

   zgees zgels zgesvx zgetri zgges zggev
   zheevd zpotri zsytrf zsytri ztrsyl ztrtri 

Trouble with installing under FreeBSD...

When I tried to install RcppArmadillo, I got the following error message:

* installing *source* package 'RcppArmadillo' ...
** package 'RcppArmadillo' successfully unpacked and MD5 sums checked
./configure: not found
ERROR: configuration failed for package 'RcppArmadillo'
* removing '/usr/local/lib/R/library/RcppArmadillo'

I don't know how to solve this problem.

Any help will be appreciated.

Single-row matrix passed on from R is "not compatible with requested type" arma::mat

This might be either bug or a feature, but RcppArmadillo seems to incorrectly handle single row matrix objects. Consider the following function:

arma::mat foo(const arma::mat& x) {
  return x;
}

pass single-row matrix through it:

foo(matrix(1:5, nrow = 1))
## Error in foo(matrix(mtcars[1, ], nrow = 1)) :
##  not compatible with requested type

Imagine some function that passes matrix to foo(), since this behavior, additional exception handling
is needed so that different functions are called for single-row matrix as input vs multi-row
matrix. On another hand, one should rather not expect of users to treat differently single-row vs multi-row matrices and matrix should be passed as matrix (especially a matrix that was explicitly passed as matrix, I'm not talking about converting vectors to matrices).

As far as I know Armadillo alone does not have any problems with handling single-row matrices.

Valgrind error inv_sympd

I am getting a valgrind error from inv_sympd. I made a minimalistic package which can be used to reproduce the error at least in my RHEL7 using R version 3.2.2 ,RcppArmadillo_0.6.400.2.2, Rcpp_0.12.2 and valgrind-3.10.0. Here is the R part:

library(debugpkg)
set.seed(123)
X <- crossprod(matrix(rnorm(25),5,5))

# this works fine
armainv(X)

# this works seeminly fine but valgrind gives an error
armainv_pd(X)

And C++ part:

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]

using namespace Rcpp;

// [[Rcpp::export]]
NumericMatrix inv(const arma::mat& X) {
  // this works fine
  arma::mat res = arma::inv(X);
  return wrap(res);
}


// [[Rcpp::export]]
NumericMatrix inv_sympd(const arma::mat& X) {
  // this gives errors in valgrind
  arma::mat res = arma::inv_sympd(X);
  return wrap(res);
}

Here is the (long) output from valgrind:

[jovetale@mad-325-04 debugpkg]$ R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" --vanilla < valg.R
==19555== Memcheck, a memory error detector
==19555== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==19555== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==19555== Command: /usr/lib64/R/bin/exec/R --vanilla
==19555== 

R version 3.2.2 (2015-08-14) -- "Fire Safety"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-redhat-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(debugpkg)
> set.seed(123)
> X <- crossprod(matrix(rnorm(25),5,5))
> 
> # this works fine
> armainv(X)
          [,1]       [,2]       [,3]       [,4]      [,5]
[1,] 166.59171  54.847240 -83.687938  69.901724 18.774028
[2,]  54.84724  19.031467 -28.314272  22.515022  5.733955
[3,] -83.68794 -28.314272  43.680000 -34.961842 -8.592805
[4,]  69.90172  22.515022 -34.961842  29.764602  8.004206
[5,]  18.77403   5.733955  -8.592805   8.004206  2.866702
> 
> # this works seeminly fine but valgrind gives an error
> armainv_pd(X)
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F34084: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13F3408A: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F3447A: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F14CDC: dpotf2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F344CB: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13F14CE2: dpotf2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F344CB: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F15022: dpotf2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F344CB: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13F14D8E: dpotf2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F344CB: dpotrf_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C930D0: potrf<double> (wrapper_lapack.hpp:353)
==19555==    by 0x14C930D0: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:426)
==19555==    by 0x14C930D0: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C930D0: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C930D0: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13FB1557: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13FB155A: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13FB1650: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F2F2EE: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13F2F313: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F2F6BA: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13EBE1C9: dtrti2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F2F733: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13EBE1F2: dtrti2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F2F733: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13EBE4FA: dtrti2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F2F733: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13EBE235: dtrti2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F2F733: dtrtri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB1609: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F3A924: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13F3A92A: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13F3ACFA: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13EA830F: dlauu2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F3AD4B: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13EA8315: dlauu2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F3AD4B: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x53EA46D: lsame_ (in /usr/lib64/R/lib/libRblas.so)
==19555==    by 0x13EA852E: dlauu2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F3AD4B: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x13EA836F: dlauu2_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13F3AD4B: dlauum_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x13FB162D: dpotri_ (in /usr/lib64/R/lib/libRlapack.so)
==19555==    by 0x14C93148: potri<double> (wrapper_lapack.hpp:388)
==19555==    by 0x14C93148: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:431)
==19555==    by 0x14C93148: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C93148: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C93148: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
==19555== Conditional jump or move depends on uninitialised value(s)
==19555==    at 0x14C9314C: inv_sympd<double, arma::Mat<double> > (auxlib_meat.hpp:433)
==19555==    by 0x14C9314C: apply<arma::Mat<double> > (op_inv_meat.hpp:146)
==19555==    by 0x14C9314C: Mat<arma::Mat<double>, arma::op_inv_sympd> (Mat_meat.hpp:4549)
==19555==    by 0x14C9314C: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:17)
==19555==    by 0x14C919EA: debugpkg_inv_sympd (RcppExports.cpp:27)
==19555==    by 0x4F0F6A7: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4F13A: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F5139F: ??? (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4EF42: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F50386: Rf_applyClosure (in /usr/lib64/R/lib/libR.so)
==19555==    by 0x4F4ED1E: Rf_eval (in /usr/lib64/R/lib/libR.so)
==19555==  Uninitialised value was created by a stack allocation
==19555==    at 0x14C92F85: inv_sympd(arma::Mat<double> const&) (arma_inv.cpp:15)
==19555== 
          [,1]       [,2]       [,3]       [,4]      [,5]
[1,] 166.59171  54.847240 -83.687938  69.901724 18.774028
[2,]  54.84724  19.031467 -28.314272  22.515022  5.733955
[3,] -83.68794 -28.314272  43.680000 -34.961842 -8.592805
[4,]  69.90172  22.515022 -34.961842  29.764602  8.004206
[5,]  18.77403   5.733955  -8.592805   8.004206  2.866702
> 
> # R -d "valgrind --tool=memcheck --leak-check=full --track-origins=yes" --vanilla < valg.R
> 
==19555== 
==19555== HEAP SUMMARY:
==19555==     in use at exit: 34,969,172 bytes in 17,153 blocks
==19555==   total heap usage: 33,759 allocs, 16,606 frees, 64,147,377 bytes allocated
==19555== 
==19555== LEAK SUMMARY:
==19555==    definitely lost: 0 bytes in 0 blocks
==19555==    indirectly lost: 0 bytes in 0 blocks
==19555==      possibly lost: 0 bytes in 0 blocks
==19555==    still reachable: 34,969,172 bytes in 17,153 blocks
==19555==         suppressed: 0 bytes in 0 blocks
==19555== Reachable blocks (those to which a pointer was found) are not shown.
==19555== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==19555== 
==19555== For counts of detected and suppressed errors, rerun with: -v
==19555== ERROR SUMMARY: 25 errors from 25 contexts (suppressed: 1 from 1)

RcppArmadillo sp_mat doesn't interpret Sparse Symmetric Matrix correctly

This code produces a sparse symmetric matrix, a special case when crossprod(x) is known to be symmetric.

require(Matrix)
x = rsparsematrix(10000, 50, .05)
x2 = crossprod(x)

Note that the nonzero values stored in x2 only reflect the upper triangle

x2@x #only upper triangle part!

When this is sent to RcppArmadillo as a sp_mat, only the upper triangle is sent, and it thinks that the lower triangle is all 0

#include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]

using namespace Rcpp;
using namespace arma;

// [[Rcpp::export]]
sp_mat foo(sp_mat X) {
  return X;
}
foo(crossprod(rsparsematrix(10000, 5, .01)))

randu and randn hang on 0.6.5

Hello and thank you for Rcpp and RcppArmadillo!

I am currently using Rcpp 0.11.6 on R 3.2 on Ubuntu 14.04, using packages installed from the CRAN ubuntu repo. I am currently using RcppArmadillo 0.4.400.0, because newer versions of RcppArmadillo fail the following test (in R) :

library(Rcpp)
library(RcppArmadillo)
library(inline)
testarmadillo <-cxxfunction(sig=c(n="integer"), 
                                            body='
     arma::mat f = arma::join_rows(arma::randu(Rcpp::as<int>(n)),  
                                   arma::randn(Rcpp::as<int>(n)));
     return wrap(f);',
                                            plugin="RcppArmadillo") # COMPILES NO ERRORS
testarmadillo(10)  # HANGS INFINITELY

Calling randu or randn causes the terminal to hang infinitely. I have to kill the terminal to stop the process. I have checked various RcppArmadillo versions (archived on CRAN), and it seems to occur on every version greater than 0.4.4 (such as 0.4.5, 0.5, etc....) as well as the latest version. It works on 0.4.4.000.0. There are no warnings when I compile RcppArmadillo.

RcppArmadillo.package.skeleton( "foobar" ) produces errors in checking

Running

library(RcppArmadillo)
RcppArmadillo.package.skeleton( "foobar" )

as instructed by ?RcppArmadillo.package.skeleton and then on the command line

R CMD build foobar
R CMD check foobar_1.0.tar.gz

exits with two errors:

* checking Rd contents ... OK
* checking for unstated dependencies in examples ... WARNING
Warning: parse error in file 'foobar-Ex.R':
20:11: unexpected symbol
19: 
20: ~~ simple examples
              ^
* checking line endings in C/C++/Fortran sources/headers ... OK
* checking line endings in Makefiles ... OK
* checking compilation flags in Makevars ... OK
* checking for GNU extensions in Makefiles ... OK
* checking for portable use of $(BLAS_LIBS) and $(LAPACK_LIBS) ... OK
* checking compiled code ... OK
* checking examples ... ERROR
Running examples in ‘foobar-Ex.R’ failed
The error most likely occurred in:

> ### Name: foobar-package
> ### Title: What the package does (short line)
> ### Aliases: foobar-package foobar
> ### Keywords: package
> 
> ### ** Examples
> 
> ~~ simple examples of the most important functions ~~
Error: unexpected symbol in "~~ simple examples"
Execution halted
* checking PDF version of manual ... WARNING
LaTeX errors when creating PDF version.
This typically indicates Rd problems.
LaTeX errors found:
! LaTeX Error: File `Rd.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

! Emergency stop.
<read *> 

l.4 \usepackage
               {makeidx}^^M
!  ==> Fatal error occurred, no output PDF file produced!
* checking PDF version of manual without hyperrefs or index ... ERROR
* DONE

This might be related to this to a similar problem.

Add g++ version to SystemRequirements field in DESCRIPTION

Related to #97 , adding information about the required g++ version in the DESCRIPTION would make selecting an appropriate release easier. I realize that the SystemRequirements field doesn't really enforce anything, but the user information would nonetheless be helpful.

installation issue

Having troubles installing the library, could you please help?:

> library(devtools)
> install_github('RcppCore/RcppArmadillo')
Downloading GitHub repo RcppCore/RcppArmadillo@master
Installing RcppArmadillo
'/usr/lib/R/bin/R' --no-site-file --no-environ --no-save --no-restore CMD  \
  INSTALL  \
  '/tmp/RtmpAKuXjx/devtools655039c1e2f9/RcppCore-RcppArmadillo-2f9f114'  \
  --library='/home/psenin/R/x86_64-pc-linux-gnu-library/3.2' --install-tests 
* installing *source* package ‘RcppArmadillo’ ...
* checking LAPACK_LIBS: divide-and-conquer complex SVD available via system LAPACK
** libs
ccache clang++ -Qunused-arguments -I/usr/share/R/include -DNDEBUG   -I"/home/psenin/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"  -I../inst/include -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from RcppArmadillo.cpp:22:
In file included from ../inst/include/RcppArmadillo.h:30:
In file included from ../inst/include/RcppArmadilloForward.h:46:
In file included from ../inst/include/armadillo:50:
../inst/include/armadillo_bits/compiler_setup.hpp:273:7: error: builtin feature check macro requires a parenthesized identifier
  #if __has_attribute(__const__)
      ^
../inst/include/armadillo_bits/compiler_setup.hpp:273:32: error: expected end of line in preprocessor expression
  #if __has_attribute(__const__)
                           ^
2 errors generated.
make: *** [RcppArmadillo.o] Erreur 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/psenin/R/x86_64-pc-linux-gnu-library/3.2/RcppArmadillo’
Erreur : Command failed (1)

My R version:

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu precise (12.04.5 LTS)
locale:
 [1] LC_CTYPE=fr_FR.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=fr_FR.UTF-8        LC_COLLATE=fr_FR.UTF-8    
 [5] LC_MONETARY=fr_FR.UTF-8    LC_MESSAGES=fr_FR.UTF-8   
 [7] LC_PAPER=fr_FR.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C       
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     
other attached packages:
[1] devtools_1.9.1       BiocInstaller_1.20.1
loaded via a namespace (and not attached):
[1] httr_1.0.0    R6_2.1.1      magrittr_1.5  tools_3.2.2   curl_0.9.4   
[6] memoise_0.2.1 stringi_1.0-1 stringr_1.0.0 digest_0.6.8 

Compilation failure when installed via Bioconductor in R v3.2.5

Not sure this is the right place to submit an issue related to RcppArmadillo and Bioconductor, please remove if it's not appropriate.

I first tried to install my stable R v3.2.2 toolchain on a new CentOS v6.7 machine and the latest DESeq2 package (or one of its dependencies) required RcppArmadillo which failed to compile.

I didn't see this a month or two ago when I last did a rollout, so I thought maybe some dependencies are now only supported in R v3.2.5 (latest) so I did a fresh install of R v3.2.5 and the first package I tried to install was "RcppArmadillo" on its own from Bioconductor; it failed also.

Error and steps to replicate below:

$ sudo /opt/R-3.2.5/bin/R --no-save

> source('/tmp/biocLite.R') Bioconductor version 3.2 (BiocInstaller 1.20.1), ?biocLite for help

> biocLite(c('RcppArmadillo')) BioC_mirror: http://bioconductor.org Using Bioconductor 3.2 (BiocInstaller 1.20.1), R 3.2.5 (2016-04-14).

... ommitting output of successful compile and install of "Rcpp" and other auto dependencies

Installing package(s) ‘RcppArmadillo’ trying URL 'http://cran.rstudio.com/src/contrib/RcppArmadillo_0.6.700.3.0.tar.gz' Content type 'application/x-gzip' length 1002967 bytes (979 KB) downloaded 979 KB

* installing source package ‘RcppArmadillo’ ...
package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked checking LAPACK_LIBS: R-supplied partial LAPACK found some operations may not be available

g++ -I/opt/R-3.2.5/lib64/R/include -DNDEBUG -I/usr/local/include -I"/opt/R-3.2.5/lib64/R/library/Rcpp/include" -I../inst/include -fpic -g -O2 -c R cppArmadillo.cpp -o RcppArmadillo.o In file included from ../inst/include/armadillo:107, from ../inst/include/RcppArmadilloForward.h:46, from ../inst/include/RcppArmadillo.h:31, from RcppArmadillo.cpp:22: ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_type<std::__traitor<std::__is_integer<int>, std::__is_floatin g<int> >::<anonymous enum> >::value’: ../inst/include/armadillo_bits/op_logmat_meat.hpp:289: instantiated from here ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_elem2’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_elem1’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_col’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_row’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_diagview’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_mtGlue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_mtOp’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_eGlue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_eOp’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Glue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Op’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Gen’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<int>, std::__is_floating<int> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Mat’ ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_type<std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum> >::value’: ../inst/include/armadillo_bits/op_logmat_meat.hpp:289: instantiated from here ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_elem2’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_elem1’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_col’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview_row’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_subview’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_diagview’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_mtGlue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_mtOp’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_eGlue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_eOp’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Glue’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Op’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Gen’ ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitor<std::__is_integer<double>, std::__is_floating<double> >::<anonymous enum>’ is/uses anonymous type ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template<class T> struct arma::is_Mat’
make: [RcppArmadillo.o] Error 1 ERROR: compilation failed for package ‘RcppArmadillo’ removing ‘/opt/R-3.2.5/lib64/R/library/RcppArmadillo’

The downloaded source packages are in ‘/tmp/RtmphzwtY3/downloaded_packages’ Updating HTML index of packages in '.Library' Making 'packages.html' ... done Warning message: In install.packages(pkgs = doing, lib = lib, ...) : installation of package ‘RcppArmadillo’ had non-zero exit status

> sessionInfo() R version 3.2.5 (2016-04-14) Platform: x86_64-pc-linux-gnu (64-bit) Running under: CentOS release 6.7 (Final)

locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 [7] LC_PAPER=en_US.UTF-8 LC_NAME=C [9] LC_ADDRESS=C LC_TELEPHONE=C [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] BiocInstaller_1.20.1

loaded via a namespace (and not attached): [1] tools_3.2.5
> q()

$ g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) Copyright (C) 2010 Free Software Foundation, Inc.

It's been a while since I've touched C++, I can't tell whether it's a C++ version incompatibility, or compiler directive issue or something else entirely - hoping you might know what it could be, cheers.

Setting random seed

I could not find any way to set the random seed for functions that use armadillo's RNG from R. Would it be possible to add one? I have tried the following code, and it seems to work, but of course I am not familiar with RcppArmadillo's internals, so it might not be enough.


SEXP R_igraph_srand(SEXP pseed) {
  unsigned seed=INTEGER(AS_INTEGER(pseed))[0];
  srand(seed);
  return R_NilValue;
}
srand <- function(seed) {
  seed <- as.numeric(seed)
  if (length(seed) != 1) { stop("Length of `seed' must be 1") }
  res <- .Call("R_igraph_srand", seed, PACKAGE="igraph")
  invisible(res)
}

This is using the igraph package, because I needed this in a project that uses igraph, but obviously it would use RcppArmadillo....

If you think this makes sense and my solution is good enough, I can submit a complete pull request as well, with docs and testing.

If there is already a way to set the seed, I just overlooked, then sorry for the noise.

implement for as<arma::sp_mat> for Matrix classes other than dgCMatrix

It would nice if RcppArmadillo knew how to deal with all Matrix-objects inheriting from CsparseMatrix (i.e. all Matrix classes in sorted compressed column-oriented form), not just dgCMatrix. The ngCMatrix-class doesn't have an x-slot, for example, because the entries are all TRUE/FALSE, so the current implementation of as<arma::sp_mat> fails.
Of course it's usually possible to do a conversion to dgCMatrix on the R-side, but that's messy -- right now, in R you have to do something like

as(as(X, "CsparseMatrix"), "dMatrix")

to every Matrix-object you're handing over to RcppArmadillo to be sort-of-safe that it ends up having the correct class -- but the above will still fail to create a dgC-matrix if X inherits from symmetricMatrix, for example. You have to do the conversion in this roundabout way because, as Martin Maechler explicitly writes in the Matrix docs, as(X, <MatrixClass>) should only be used to convert X to "virtual Matrix super classes" like CsparseMatrix and not actual classes like dgCMatrix, and there aren't any direct as-methods to make a dgCMatrix from, say, an ngTMatrix or a ddiMatrix.

These conversions in R can be costly as the matrix gets copied around, it would be more efficient to create the sp_mat directly. If that is too difficult, the RcppArmadillo-converter could at least check the class of its input to give more informative/correct error messages.

Thanks for all your great work on these packages!

cube sum edge cases

Hello,

I think I have found a bug on the cube code that appears with specific dimensions.
I have created a small test case here: https://gist.github.com/rvalieris/24ad10caac132757ff31

The problem is on cube_sum1, depending on the dimensions of the cube(slices=1 seems to be the rule) different things happen, examples:

40x16x1: no errors, wrong result
80x16x1: error: addition: can't interpret cube with dimensions 1x1072642625x1 as a matrix with dimensions 16x1
90x21x1: valgrind errors, crash
99x21x1: valgrind errors, no crash, wrong result
99x21x2: no errors, right result

I'm comparing the results with cube_sum2 which is what I intended cube_sum1 to do.
This was tested on RcppArmadillo_0.6.400.2.2

At this point I am not sure what the source of the problem is.., is this my misuse of tube(), bug on Rcpparmadillo, armadilo itself or something else ?

Possible error in fastLm documentation

Hi,

The documentation for the RcppArmadillo fastLm states :

Value

fastLmPure returns a list with three components:

coefficients

a vector of coefficients

stderr

a vector of the (estimated) standard errors of the coefficient estimates

df.residual

a scalar denoting the degrees of freedom in the model

While fastLmPure actually returns coefficients and stderr in one-column matrix objects:

flm <- fastLmPure( cbind(1, log(trees$Girth)), log(trees$Volume) )
print(flm)
$coefficients
          [,1]
[1,] -2.353325
[2,]  2.199970

$stderr
           [,1]
[1,] 0.23066284
[2,] 0.08983455

$df.residual
[1] 29

OpenMP Support for Standalone Scripts in 7.900.0

Add $(SHLIB_OPENMP_CFLAGS) to inlineCxxPlugin <- Rcpp:::Rcpp.plugin.maker in inline.R to support OpenMP support added in Armadillo 7.900.0

inlineCxxPlugin <- Rcpp:::Rcpp.plugin.maker(
	include.before = "#include <RcppArmadillo.h>", 
	libs           = "$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CFLAGS)", 
	package        = "RcppArmadillo"
)

Per comment, I don't think $(SHLIB_OPENMP_CXXFLAGS) is applicable for Rcpp.plugin.maker as it doesn't have a slot for them.

index_sort gives us the wrong results

Hi, I used the index_sort in RcppArmadillo and found it seems return a wrong result.

Here is some simple codes for illustration.

In cpp file,

// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export()]]
Rcpp::List cRank(arma::mat T0s,int i) {
    arma::vec T0stmp = T0s.col(i);
    int tmp3 = 0;
    arma::uvec rankarma  = arma::stable_sort_index(T0stmp);
    return Rcpp::List::create(Rcpp::Named("minp0") = rankarma);
}

In R codes:

tmp = rnorm(10)
tmp
cRank(as.matrix(tmp),0)$minp0
rank(tmp)

The results are quite different.

It would be great if anyone can tell me what's wrong with my codes or this function (index_sort).

Thanks.

Memory allocation when creating an arma::cube from an existing pointer

This has come up on stackoverflow.

Creating an arma::cube object from the pointer to an existing NumericVector shouldn't result in much if any increased use of RAM. However, if the number of slices is large, there is a big spike of memory usage. This seems to relate to code in create_mat within "Cube_meat.hpp" which allocates RAM for matrix pointers for a cube object, but I can't work out why it should require so much RAM. With the example below on my machine (which has 12 GB of RAM), the memory never becomes an issue. However, ramping up the array size further can quickly lead to me running out of RAM altogether.

I'm using R 3.2.1 and RcppArmadillo 0.5.200.1.0 running under 64 bit Windows 8.1. I've also tested R 3.2.1 on Scientific Linux 6 (based on RHEL 6) and can demonstrate the same behaviour.

Reproducible example:

library("RcppArmadillo")
library("inline")
code <- "
Rcpp::NumericVector input_(input);
IntegerVector dim = input_.attr(\"dim\");
arma::cube disturb(input_.begin(), dim[0], dim[1], dim[2], false);
disturb[0, 0, 0] = 45;
return wrap(2);
"
Test <- cxxfunction(signature(input = "numeric"), plugin = "RcppArmadillo", body = code)
input <- array(1e7, 2, 2)
Test(input)
# no change in memory usage

dim(input) <- c(2, 1e7, 2)
gc()
Test(input)
# no change in memory usage

dim(input) <- c(2, 2, 1e7)
gc()
Test(input)
# spike in memory usage

dim(input) <- c(20, 2, 1e6)
gc()
Test(input)
# no change in memory usage
library("RcppArmadillo")
library("inline")
code <- "
Rcpp::NumericVector input_(input);
IntegerVector dim = input_.attr(\"dim\");
arma::cube disturb(input_.begin(), dim[0], dim[1], dim[2], false);
disturb[0, 0, 0] = 45;
return wrap(2);
"
Test <- cxxfunction(signature(input = "numeric"), plugin = "RcppArmadillo", body = code)
input <- array(0, c(1e7, 2, 2))
Test(input)
# no change in memory usage

dim(input) <- c(2, 1e7, 2)
gc()
Test(input)
# no change in memory usage

dim(input) <- c(2, 2, 1e7)
gc()
Test(input)
# spike in memory usage

dim(input) <- c(20, 2, 1e6)
gc()
Test(input)
# no change in memory usage

Revert DESCRIPTION change on Depends

Imports of Rcpp was a good idea -- but the unit tests need Rcpp as well. That could be handled by Suggests: (as we long did with RUnit) -- but that runs into

* checking DESCRIPTION meta-information ... NOTE
Package listed in more than one of Depends, Imports, Suggests, Enhances:
  ‘Rcpp’
A package should be listed in only one of these fields.

So I see no choice but to revert to Depends.

RcppArmadillo in conflict with a pre-installed Armadillo package on macOS 10.12

The issue is that Armadillo by default enables ARMA_USE_WRAPPER option in its build configurations. Once Armadillo is installed, any R project depending on RcppArmadillo, once built, will report an error like:

dlopen(/Library/Frameworks/R.framework/Versions/3.3/Resources/library/[LIBRARAY_NAME]/libs/fastplm.so, 6): Symbol not found: _wrapper_ddot_
  Referenced from: /Library/Frameworks/R.framework/Versions/3.3/Resources/library/[LIBRARAY_NAME]/libs/fastplm.so
  Expected in: flat namespace

Disable this option, however, will lead to any program depending on the native Armadillo library fail to link.

I suspect that in the configuration of RcppAramdillo. the system header path comes before the library-provided path, though I am not an expert on header resolution issue.

To reproduce this, one can download the source code for Armadillo, just: cd , cmake ., make, make install. The platform I am using is macOS 10.12 Sierra.

Problem when I use the RcppArmadillo with the C++11

When I use the RcppArmadillo I must add the "Sys.setenv("PKG_CXXFLAGS"="-std=c++11")" in the .cpp script before I compiled, and I could not just add the " // [[Rcpp::plugins(cpp11)]]" in the script to enable C++11. Here is the sessionInfo

sessionInfo()
R version 3.1.1 (2014-07-10)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets compiler methods
[8] base

other attached packages:
[1] dplyr_0.2 reshape2_1.4 Rcpp_0.11.3 plyr_1.8.1 pipeR_0.3-1

loaded via a namespace (and not attached):
[1] assertthat_0.1 parallel_3.1.1 stringr_0.6.2 tools_3.1.1

I wonder how could I just add the "// [[Rcpp::plugins(cpp11)]]" in the script or when I using the inline package?

Version numbering

The scheme we used for years to a) always prepend a zero to the upstream number and b) add an additonal sub-version to not clash with what could be a new version by Conrad.

So 0.3.920.3.1 is preferable over 0.3.920.4 which Conrad might use.

header only and dependency

It would be nice if RcppArmadillo was header only and did not depend on Rcpp. The dependency can be resolved in client packages, e.g. a package can choose to use the Rcpp implementation in Rcpp11 plus armadillo from RcppArmadillo.

The alternative is for me to fork RcppArmadillo.

pass arma::cube object as function argument gives error

I don not think this is a bug but if you pass and arma::mat object or arma::field as an argument to a function instead, the code runs smoothly. Therefore it seems that the package does not implement the same functionality for arma::cube.

Possible memory leak with arma::sp_mat within Rcpp::List

Hi, I don't know if this behavior is expected (I don't think so), but whenever I try to pass dgCMatrix objects within lists to RcppArmadillo via arma::sp_mat valgrind catches a memory leak. Here is a minimal example in which I create a list with dense matrices arma::mat and sparse matrices arma::sp_mat

The code for arma::sp_mat:

library(Matrix)
library(Rcpp)

code <-
'// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
using namespace Rcpp;

// [[Rcpp::export]]
List passMats(List l) {
  arma::sp_mat m1 = as< arma::sp_mat >(l[0]);
  arma::sp_mat m2 = as< arma::sp_mat >(l[1]);

  return List::create(
    _["mat1"] = m1,
    _["mat2"] = m2
  );
}'

sourceCpp(code=code)

x <- matrix(0,4,4)
x <- methods::as(x, "dgCMatrix")
passMats(list(x,x))

devtools::session_info()

And this is the output that I get from running R -d valgrind --vanilla

==3233== Memcheck, a memory error detector
==3233== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3233== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==3233== Command: /usr/lib/R/bin/exec/R --vanilla
==3233== 

R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Matrix)
> library(Rcpp)
> 
> code <-
+ '// [[Rcpp::depends(RcppArmadillo)]]
+ #include <RcppArmadillo.h>
+ using namespace Rcpp;
+ 
+ // [[Rcpp::export]]
+ List passMats(List l) {
+   arma::sp_mat m1 = as< arma::sp_mat >(l[0]);
+   arma::sp_mat m2 = as< arma::sp_mat >(l[1]);
+ 
+   return List::create(
+     _["mat1"] = m1,
+     _["mat2"] = m2
+   );
+ }'
> 
> sourceCpp(code=code)
> 
> x <- matrix(0,4,4)
> x <- methods::as(x, "dgCMatrix")
> passMats(list(x,x))
$mat1
4 x 4 sparse Matrix of class "dgCMatrix"

[1,] . . . .
[2,] . . . .
[3,] . . . .
[4,] . . . .

$mat2
4 x 4 sparse Matrix of class "dgCMatrix"

[1,] . . . .
[2,] . . . .
[3,] . . . .
[4,] . . . .

> 
> devtools::session_info()
Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.5 (2016-04-14)
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_US                       
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-05-03                  

Packages -----------------------------------------------------------------------
 package       * version     date       source        
 devtools        1.11.1      2016-04-21 CRAN (R 3.2.5)
 digest          0.6.9       2016-01-08 CRAN (R 3.2.3)
 lattice         0.20-33     2015-07-14 CRAN (R 3.2.1)
 Matrix        * 1.2-5       2016-04-17 CRAN (R 3.2.5)
 memoise         1.0.0       2016-01-29 CRAN (R 3.2.3)
 Rcpp          * 0.12.4      2016-03-26 CRAN (R 3.2.4)
 RcppArmadillo   0.6.700.3.0 2016-04-06 CRAN (R 3.2.5)
 withr           1.0.1       2016-02-04 CRAN (R 3.2.3)
> 
==3233== 
==3233== HEAP SUMMARY:
==3233==     in use at exit: 102,296,799 bytes in 54,646 blocks
==3233==   total heap usage: 108,090 allocs, 53,444 frees, 207,673,479 bytes allocated
==3233== 
==3233== 1,024 bytes in 1 blocks are definitely lost in loss record 171 of 2,960
==3233==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x12A32D8D: acquire<unsigned int> (memory.hpp:75)
==3233==    by 0x12A32D8D: acquire_chunked<unsigned int> (memory.hpp:112)
==3233==    by 0x12A32D8D: init (SpMat_meat.hpp:3964)
==3233==    by 0x12A32D8D: SpMat (SpMat_meat.hpp:76)
==3233==    by 0x12A32D8D: Rcpp::traits::Exporter<arma::SpMat<double> >::get() (RcppArmadilloAs.h:94)
==3233==    by 0x12A305B7: arma::SpMat<double> Rcpp::internal::as<arma::SpMat<double> >(SEXPREC*, Rcpp::traits::r_type_generic_tag) [clone .isra.63] (as.h:81)
==3233==    by 0x12A306D8: as<arma::SpMat<double> > (as.h:144)
==3233==    by 0x12A306D8: passMats(Rcpp::Vector<19, Rcpp::PreserveStorage>) (fileca12b327c2b.cpp:7)
==3233==    by 0x12A30CF5: sourceCpp_0_passMats (fileca12b327c2b.cpp:25)
==3233==    by 0x4F0BA37: ??? (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4ACCA: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4BE56: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4A8AE: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F71D61: Rf_ReplIteration (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F720B0: ??? (in /usr/lib/R/lib/libR.so)
==3233== 
==3233== 1,024 bytes in 1 blocks are definitely lost in loss record 172 of 2,960
==3233==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x12A32D8D: acquire<unsigned int> (memory.hpp:75)
==3233==    by 0x12A32D8D: acquire_chunked<unsigned int> (memory.hpp:112)
==3233==    by 0x12A32D8D: init (SpMat_meat.hpp:3964)
==3233==    by 0x12A32D8D: SpMat (SpMat_meat.hpp:76)
==3233==    by 0x12A32D8D: Rcpp::traits::Exporter<arma::SpMat<double> >::get() (RcppArmadilloAs.h:94)
==3233==    by 0x12A305B7: arma::SpMat<double> Rcpp::internal::as<arma::SpMat<double> >(SEXPREC*, Rcpp::traits::r_type_generic_tag) [clone .isra.63] (as.h:81)
==3233==    by 0x12A306FC: as<arma::SpMat<double> > (as.h:144)
==3233==    by 0x12A306FC: passMats(Rcpp::Vector<19, Rcpp::PreserveStorage>) (fileca12b327c2b.cpp:8)
==3233==    by 0x12A30CF5: sourceCpp_0_passMats (fileca12b327c2b.cpp:25)
==3233==    by 0x4F0BA37: ??? (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4ACCA: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4BE56: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4A8AE: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F71D61: Rf_ReplIteration (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F720B0: ??? (in /usr/lib/R/lib/libR.so)
==3233== 
==3233== 2,048 bytes in 1 blocks are definitely lost in loss record 1,212 of 2,960
==3233==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x12A32D61: acquire<double> (memory.hpp:75)
==3233==    by 0x12A32D61: acquire_chunked<double> (memory.hpp:112)
==3233==    by 0x12A32D61: init (SpMat_meat.hpp:3963)
==3233==    by 0x12A32D61: SpMat (SpMat_meat.hpp:76)
==3233==    by 0x12A32D61: Rcpp::traits::Exporter<arma::SpMat<double> >::get() (RcppArmadilloAs.h:94)
==3233==    by 0x12A305B7: arma::SpMat<double> Rcpp::internal::as<arma::SpMat<double> >(SEXPREC*, Rcpp::traits::r_type_generic_tag) [clone .isra.63] (as.h:81)
==3233==    by 0x12A306D8: as<arma::SpMat<double> > (as.h:144)
==3233==    by 0x12A306D8: passMats(Rcpp::Vector<19, Rcpp::PreserveStorage>) (fileca12b327c2b.cpp:7)
==3233==    by 0x12A30CF5: sourceCpp_0_passMats (fileca12b327c2b.cpp:25)
==3233==    by 0x4F0BA37: ??? (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4ACCA: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4BE56: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4A8AE: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F71D61: Rf_ReplIteration (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F720B0: ??? (in /usr/lib/R/lib/libR.so)
==3233== 
==3233== 2,048 bytes in 1 blocks are definitely lost in loss record 1,213 of 2,960
==3233==    at 0x4C2D110: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x4C2D227: posix_memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3233==    by 0x12A32D61: acquire<double> (memory.hpp:75)
==3233==    by 0x12A32D61: acquire_chunked<double> (memory.hpp:112)
==3233==    by 0x12A32D61: init (SpMat_meat.hpp:3963)
==3233==    by 0x12A32D61: SpMat (SpMat_meat.hpp:76)
==3233==    by 0x12A32D61: Rcpp::traits::Exporter<arma::SpMat<double> >::get() (RcppArmadilloAs.h:94)
==3233==    by 0x12A305B7: arma::SpMat<double> Rcpp::internal::as<arma::SpMat<double> >(SEXPREC*, Rcpp::traits::r_type_generic_tag) [clone .isra.63] (as.h:81)
==3233==    by 0x12A306FC: as<arma::SpMat<double> > (as.h:144)
==3233==    by 0x12A306FC: passMats(Rcpp::Vector<19, Rcpp::PreserveStorage>) (fileca12b327c2b.cpp:8)
==3233==    by 0x12A30CF5: sourceCpp_0_passMats (fileca12b327c2b.cpp:25)
==3233==    by 0x4F0BA37: ??? (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4ACCA: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4BE56: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F4A8AE: Rf_eval (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F71D61: Rf_ReplIteration (in /usr/lib/R/lib/libR.so)
==3233==    by 0x4F720B0: ??? (in /usr/lib/R/lib/libR.so)
==3233== 
==3233== LEAK SUMMARY:
==3233==    definitely lost: 6,144 bytes in 4 blocks
==3233==    indirectly lost: 0 bytes in 0 blocks
==3233==      possibly lost: 0 bytes in 0 blocks
==3233==    still reachable: 102,290,655 bytes in 54,642 blocks
==3233==         suppressed: 0 bytes in 0 blocks
==3233== Reachable blocks (those to which a pointer was found) are not shown.
==3233== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3233== 
==3233== For counts of detected and suppressed errors, rerun with: -v
==3233== ERROR SUMMARY: 4 errors from 4 contexts (suppressed: 0 from 0)

Using "regular" arma::mat

library(Matrix)
library(Rcpp)

code <-
'// [[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
using namespace Rcpp;

// [[Rcpp::export]]
List passMats(List l) {
  arma::mat m1 = as< arma::mat >(l[0]);  
  arma::mat m2 = as< arma::mat >(l[1]);

  return List::create(
    _["mat1"] = m1,
    _["mat2"] = m2
  );
}'

sourceCpp(code=code)

x <- matrix(0,4,4)
passMats(list(x,x))

devtools::session_info()

I get

==3317== Memcheck, a memory error detector
==3317== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==3317== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==3317== Command: /usr/lib/R/bin/exec/R --vanilla
==3317== 

R version 3.2.5 (2016-04-14) -- "Very, Very Secure Dishes"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(Matrix)
> library(Rcpp)
> 
> code <-
+ '// [[Rcpp::depends(RcppArmadillo)]]
+ #include <RcppArmadillo.h>
+ using namespace Rcpp;
+ 
+ // [[Rcpp::export]]
+ List passMats(List l) {
+   arma::mat m1 = as< arma::mat >(l[0]);
+   arma::mat m2 = as< arma::mat >(l[1]);
+ 
+   return List::create(
+     _["mat1"] = m1,
+     _["mat2"] = m2
+   );
+ }'
> 
> sourceCpp(code=code)
> 
> x <- matrix(0,4,4)
> passMats(list(x,x))
$mat1
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

$mat2
     [,1] [,2] [,3] [,4]
[1,]    0    0    0    0
[2,]    0    0    0    0
[3,]    0    0    0    0
[4,]    0    0    0    0

> 
> devtools::session_info()
Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.5 (2016-04-14)
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_US                       
 collate  en_US.UTF-8                 
 tz       <NA>                        
 date     2016-05-03                  

Packages -----------------------------------------------------------------------
 package       * version     date       source        
 devtools        1.11.1      2016-04-21 CRAN (R 3.2.5)
 digest          0.6.9       2016-01-08 CRAN (R 3.2.3)
 lattice         0.20-33     2015-07-14 CRAN (R 3.2.1)
 Matrix        * 1.2-5       2016-04-17 CRAN (R 3.2.5)
 memoise         1.0.0       2016-01-29 CRAN (R 3.2.3)
 Rcpp          * 0.12.4      2016-03-26 CRAN (R 3.2.4)
 RcppArmadillo   0.6.700.3.0 2016-04-06 CRAN (R 3.2.5)
 withr           1.0.1       2016-02-04 CRAN (R 3.2.3)
> 
==3317== 
==3317== HEAP SUMMARY:
==3317==     in use at exit: 102,127,759 bytes in 54,510 blocks
==3317==   total heap usage: 107,562 allocs, 53,052 frees, 207,005,727 bytes allocated
==3317== 
==3317== LEAK SUMMARY:
==3317==    definitely lost: 0 bytes in 0 blocks
==3317==    indirectly lost: 0 bytes in 0 blocks
==3317==      possibly lost: 0 bytes in 0 blocks
==3317==    still reachable: 102,127,759 bytes in 54,510 blocks
==3317==         suppressed: 0 bytes in 0 blocks
==3317== Reachable blocks (those to which a pointer was found) are not shown.
==3317== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==3317== 
==3317== For counts of detected and suppressed errors, rerun with: -v
==3317== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

For valgrind I'm using the following options:

--tool=memcheck
--memcheck:leak-check=full
--track-origins=yes
--error-limit=no

Am I doing/gettin something wrong here?

Thanks

Does not compile on RHEL 6.5.7

Downloaded from cran.r-project.org, I'm running on RHEL 6.5.7. I have the following gcc RPM packages installed:

compat-gcc-34-c++-3.4.6-19.el6.x86_64 compat-gcc-34-3.4.6-19.el6.x86_64 gcc-gfortran-4.4.7-4.el6.x86_64 libgcc-4.4.7-4.el6.x86_64 gcc-c++-4.4.7-4.el6.x86_64 libgcc-4.4.7-4.el6.i686 gcc-4.4.7-4.el6.x86_64

When I attempt to install it I get the following output.

sudo R CMD INSTALL RcppArmadillo_0.6.700.6.0.tar.gz

  • installing to library ‘/usr/lib64/R/library’
  • installing source package ‘RcppArmadillo’ ...
    ** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
  • checking LAPACK_LIBS: R-supplied partial LAPACK found
  • some operations may not be available
    ** libs
    g++ -m64 -I/usr/include/R -DNDEBUG -I/usr/local/include -I"/usr/lib64/R/library/Rcpp/include" -I../inst/include -fpic -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -c RcppArmadillo.cpp -o RcppArmadillo.o
    In file included from ../inst/include/armadillo:107,
    from ../inst/include/RcppArmadilloForward.h:46,
    from ../inst/include/RcppArmadillo.h:31,
    from RcppArmadillo.cpp:22:
    ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_typestd::__traitor<std::__is_integer<int, std::__is_floating >:: >::value’:
    ../inst/include/armadillo_bits/op_logmat_meat.hpp:289: instantiated from here
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_elem2’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_elem1’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_col’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_row’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_diagview’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_mtGlue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_mtOp’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_eGlue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_eOp’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Glue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Op’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Gen’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<int, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Mat’
    ../inst/include/armadillo_bits/traits.hpp: In instantiation of ‘const bool arma::is_arma_typestd::__traitor<std::__is_integer<double, std::__is_floating >:: >::value’:
    ../inst/include/armadillo_bits/op_logmat_meat.hpp:289: instantiated from here
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_elem2’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_elem1’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_col’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview_row’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_subview’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_diagview’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_mtGlue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_mtOp’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_eGlue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_eOp’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Glue’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Op’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Gen’
    ../inst/include/armadillo_bits/traits.hpp:642: error: ‘std::__traitorstd::__is_integer<double, std::__is_floating >::’ is/uses anonymous type
    ../inst/include/armadillo_bits/traits.hpp:642: error: trying to instantiate ‘template struct arma::is_Mat’
    make: *** [RcppArmadillo.o] Error 1
    ERROR: compilation failed for package ‘RcppArmadillo’
  • removing ‘/usr/lib64/R/library/RcppArmadillo’

The skeleton package should use Rcpp attributes too

We should use Rcpp attributes in the skeleton package, perhaps showing passing down references of arma::mat.

At the moment the skeleton shows an old school function using SEXP as a return type:

SEXP rcpparma_hello_world(){

    arma::mat m1 = arma::eye<arma::mat>( 3, 3 ) ;
    arma::mat m2 = arma::eye<arma::mat>( 3, 3 ) ;

    List res ;                                  
    res["mat+mat"] = m1 + 3 * ( m1 + m2 );
    return res ;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.