RfastOfficial / Rfast

A collection of Rfast functions for data analysis. Note 1: The vast majority of the functions accept matrices only, not data.frames. Note 2: Do not have matrices or vectors with have missing data (i.e NAs). We do no check about them and C++ internally transforms them into zeros (0), so you may get wrong results. Note 3: In general, make sure you give the correct input, in order to get the correct output. We do no checks and this is one of the many reasons we are fast.
144 stars 19 forks source link

Unable to install #86

Closed cdeverau closed 11 months ago

cdeverau commented 11 months ago

Describe the bug rvmf.cpp fails to compile consistently when attempting to install Rfast via CRAN or locally (as suggested in #85).

To Reproduce Copy-pasted from execution of packages.install("Rfast"):

g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I'/usr/local/lib/R/site-library/Rcpp/include' -I'/usr/local/lib/R/site-library/RcppArmadillo/include' -I'/usr/local/lib/R/site-library/RcppParallel/include' -fopenmp -fpic -g -O2 -fdebug-prefix-map=/build/r-base-8OPFog/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -c rvmf.cpp -o rvmf.o

Error: rvmf.cpp: In function ‘void rvmf(unsigned int, arma::colvec, double, arma::mat&)’: rvmf.cpp:87:56: error: no matching function for call to ‘randn(unsigned int&, const uword&, arma::distr_param)’ mat x1 = randn(n, mu.n_elem, distr_param(0, 1)); ^ In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:451:0, from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48, from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29, from rvmf.cpp:4: /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:38:1: note: candidate: template typename arma::arma_real_or_cx_only::result arma::randn() randn() ^~~~~ /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:38:1: note: template argument deduction/substitution failed: /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp: In substitution of ‘template typename arma::arma_real_or_cx_only::result arma::randn() [with eT = arma::Mat]’: rvmf.cpp:87:56: required from here /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:38:1: error: no type named ‘result’ in ‘struct arma::arma_real_or_cx_only<arma::Mat >’ /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:62:1: note: candidate: template const arma::Gen<T1, arma::gen_randn> arma::randn(arma::uword, arma::arma_empty_class, const typename arma::arma_Mat_Col_Row_only::result) randn(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only::result junk2 = nullptr) ^~~~~ /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:62:1: note: template argument deduction/substitution failed: rvmf.cpp:87:31: note: cannot convert ‘mu.arma::Col::.arma::Mat::n_elem’ (type ‘const uword {aka const unsigned int}’) to type ‘arma::arma_empty_class’ mat x1 = randn(n, mu.n_elem, distr_param(0, 1));


In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:451:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:105:1: note: candidate: template<class obj_type> const arma::Gen<T1, arma::gen_randn> arma::randn(arma::uword, arma::uword, const typename arma::arma_Mat_Col_Row_only<obj_type>::result*)
 randn(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:105:1: note:   template argument deduction/substitution failed:
rvmf.cpp:87:39: note:   cannot convert ‘arma::distr_param(0, 1)’ (type ‘arma::distr_param’) to type ‘const result* {aka const arma::Mat<double>*}’
     mat x1 = randn<mat>(n, mu.n_elem, distr_param(0, 1));
                                       ^~~~~~~~~~~~~~~~~
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:451:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:129:1: note: candidate: template<class obj_type> const arma::Gen<T1, arma::gen_randn> arma::randn(const arma::SizeMat&, const typename arma::arma_Mat_Col_Row_only<obj_type>::result*)
 randn(const SizeMat& s, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:129:1: note:   template argument deduction/substitution failed:
rvmf.cpp:87:56: note:   candidate expects 2 arguments, 3 provided
     mat x1 = randn<mat>(n, mu.n_elem, distr_param(0, 1));
                                                        ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:451:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:167:1: note: candidate: template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randn> arma::randn(arma::uword, arma::uword, arma::uword, const typename arma::arma_Cube_only<cube_type>::result*)
 randn(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:167:1: note:   template argument deduction/substitution failed:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp: In substitution of ‘template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randn> arma::randn(arma::uword, arma::uword, arma::uword, const typename arma::arma_Cube_only<cube_type>::result*) [with cube_type = arma::Mat<double>]’:
rvmf.cpp:87:56:   required from here
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:167:1: error: no type named ‘result’ in ‘struct arma::arma_Cube_only<arma::Mat<double> >’
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:181:1: note: candidate: template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randn> arma::randn(const arma::SizeCube&, const typename arma::arma_Cube_only<cube_type>::result*)
 randn(const SizeCube& s, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:181:1: note:   template argument deduction/substitution failed:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp: In substitution of ‘template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randn> arma::randn(const arma::SizeCube&, const typename arma::arma_Cube_only<cube_type>::result*) [with cube_type = arma::Mat<double>]’:
rvmf.cpp:87:56:   required from here
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randn.hpp:181:1: error: no type named ‘result’ in ‘struct arma::arma_Cube_only<arma::Mat<double> >’
rvmf.cpp: In function ‘T rvonmises(unsigned int, double, double, bool)’:
rvmf.cpp:136:48: error: no matching function for call to ‘randu<arma::colvec>(unsigned int&, arma::distr_param)’
     u = randu<colvec>(n, distr_param(0.0, pi_2));
                                                ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:450:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:38:1: note: candidate: template<class eT> typename arma::arma_real_or_cx_only<T>::result arma::randu()
 randu()
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:38:1: note:   template argument deduction/substitution failed:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp: In substitution of ‘template<class eT> typename arma::arma_real_or_cx_only<T>::result arma::randu() [with eT = arma::Col<double>]’:
rvmf.cpp:136:48:   required from here
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:38:1: error: no type named ‘result’ in ‘struct arma::arma_real_or_cx_only<arma::Col<double> >’
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:62:1: note: candidate: template<class obj_type> const arma::Gen<T1, arma::gen_randu> arma::randu(arma::uword, arma::arma_empty_class, const typename arma::arma_Mat_Col_Row_only<obj_type>::result*)
 randu(const uword n_elem, const arma_empty_class junk1 = arma_empty_class(), const typename arma_Mat_Col_Row_only<obj_type>::result* junk2 = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:62:1: note:   template argument deduction/substitution failed:
rvmf.cpp:136:48: note:   cannot convert ‘arma::distr_param(0.0, pi_2)’ (type ‘arma::distr_param’) to type ‘arma::arma_empty_class’
     u = randu<colvec>(n, distr_param(0.0, pi_2));
                                                ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:450:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:105:1: note: candidate: template<class obj_type> const arma::Gen<T1, arma::gen_randu> arma::randu(arma::uword, arma::uword, const typename arma::arma_Mat_Col_Row_only<obj_type>::result*)
 randu(const uword n_rows, const uword n_cols, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:105:1: note:   template argument deduction/substitution failed:
rvmf.cpp:136:48: note:   cannot convert ‘arma::distr_param(0.0, pi_2)’ (type ‘arma::distr_param’) to type ‘arma::uword {aka unsigned int}’
     u = randu<colvec>(n, distr_param(0.0, pi_2));
                                                ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:450:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:129:1: note: candidate: template<class obj_type> const arma::Gen<T1, arma::gen_randu> arma::randu(const arma::SizeMat&, const typename arma::arma_Mat_Col_Row_only<obj_type>::result*)
 randu(const SizeMat& s, const typename arma_Mat_Col_Row_only<obj_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:129:1: note:   template argument deduction/substitution failed:
rvmf.cpp:136:48: note:   cannot convert ‘n’ (type ‘unsigned int’) to type ‘const arma::SizeMat&’
     u = randu<colvec>(n, distr_param(0.0, pi_2));
                                                ^
In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:450:0,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:48,
                 from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:29,
                 from rvmf.cpp:4:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:167:1: note: candidate: template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randu> arma::randu(arma::uword, arma::uword, arma::uword, const typename arma::arma_Cube_only<cube_type>::result*)
 randu(const uword n_rows, const uword n_cols, const uword n_slices, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:167:1: note:   template argument deduction/substitution failed:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp: In substitution of ‘template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randu> arma::randu(arma::uword, arma::uword, arma::uword, const typename arma::arma_Cube_only<cube_type>::result*) [with cube_type = arma::Col<double>]’:
rvmf.cpp:136:48:   required from here
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:167:1: error: no type named ‘result’ in ‘struct arma::arma_Cube_only<arma::Col<double> >’
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:181:1: note: candidate: template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randu> arma::randu(const arma::SizeCube&, const typename arma::arma_Cube_only<cube_type>::result*)
 randu(const SizeCube& s, const typename arma_Cube_only<cube_type>::result* junk = nullptr)
 ^~~~~
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:181:1: note:   template argument deduction/substitution failed:
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp: In substitution of ‘template<class cube_type> const arma::GenCube<typename cube_type::elem_type, arma::gen_randu> arma::randu(const arma::SizeCube&, const typename arma::arma_Cube_only<cube_type>::result*) [with cube_type = arma::Col<double>]’:
rvmf.cpp:136:48:   required from here
/usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/fn_randu.hpp:181:1: error: no type named ‘result’ in ‘struct arma::arma_Cube_only<arma::Col<double> >’
/usr/lib/R/etc/Makeconf:177: recipe for target 'rvmf.o' failed
make: *** [rvmf.o] Error 1
ERROR: compilation failed for package ‘Rfast’

**Expected behavior**
Installation of the package.

**Desktop (please complete the following information):**
 - OS: Ubuntu 18.04
 - R-Version 4.2.1
 - Rfast-Version current, fresh install

Any help is appreciated, thank you!
ManosPapadakis95 commented 11 months ago

First of all upgrade R to the latest version. Also upgrade RcppArmadillo which seems to be the problem. Issue #85 has nothing to do.

cdeverau commented 11 months ago

I was also having the issue described in #85, which is why I mentioned it. Upgrading RcppArmadillo worked, thanks!