<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Trying a plain text version. Apologies for the previous. <br>
</p>
<p>Dear Rcpp-devel,</p>
<p>Apologies in advance for the laborious problem statement. I hope
your experienced eyes will see a trivial mistake obscured to my
nascent ones.<br>
<br>
We have a C++ core library providing an API that is wrapped in R
(Rcpp) and Python (pybind11).<br>
<br>
A new feature implements the addition of a boolean vector
(validLib) as an API argument.<br>
<br>
When adding this to one of the API functions (Simplex), there is
no issue. Note that Simplex returns a DataFrame class object.<br>
<br>
When adding the same code to the API function SMap, which returns
a list, there seems to be a compiler error regarding the argument
as not allowed. (Error Log below).<br>
<br>
sessionInfo is also listed below.<br>
<br>
The same error (template argument deduction/substitution failed)
is found if I replace std::vector< bool > with
Rcpp::LogicalVector.<br>
<br>
The code layout:<br>
<br>
R API is accessed by R package user, function SMap() in R code
interface EDM.R.<br>
<br>
SMap (R) calls the Rcpp wrapped function RtoCpp_SMap(), returning
a list of R data.frames.<br>
<br>
RtoCpp_SMap() is mapped to SMap_rcpp() (cpp code in SMap.cpp) in
RcppEDMCommon.cpp.<br>
<br>
The function SMap_rcpp() calls the C++ API function SMap(). Note,
function (SMap) is overloaded.<br>
<br>
In RcppEDMCommon.h a prototype is defined. In RcppEDMCommon.cpp an
argument list is defined: Protoype in RcppEDMCommon.h<br>
<br>
namespace r = Rcpp;<br>
<br>
r::List SMap_rcpp( std::string pathIn,<br>
std::string dataFile,<br>
r::DataFrame dataList,<br>
std::string pathOut,<br>
std::string predictFile,<br>
std::string lib,<br>
std::string pred,<br>
int E,<br>
int Tp,<br>
int knn,<br>
int tau,<br>
double theta,<br>
int exclusionRadius,<br>
std::string columns,<br>
std::string target,<br>
std::string smapFile,<br>
std::string jacobians,<br>
bool embedded,<br>
bool const_predict,<br>
bool verbose,<br>
std::vector<bool> validLib );<br>
<br>
Argument list in RcppEDMCommon.cpp:<br>
<br>
auto SMapArgs = r::List::create(<br>
r::_["pathIn"] = std::string("./"),<br>
r::_["dataFile"] = std::string("./"),<br>
r::_["dataFrame"] = r::DataFrame(),<br>
r::_["pathOut"] = std::string("./"),<br>
r::_["predictFile"] = std::string(""),<br>
r::_["lib"] = std::string(""),<br>
r::_["pred"] = std::string(""),<br>
r::_["E"] = 0,<br>
r::_["Tp"] = 1,<br>
r::_["knn"] = 0,<br>
r::_["tau"] = -1,<br>
r::_["theta"] = 0,<br>
r::_["exclusionRadius"] = 0,<br>
r::_["columns"] = std::string(""),<br>
r::_["target"] = std::string(""),<br>
r::_["smapFile"] = std::string(""),<br>
r::_["jacobians"] = std::string(""),<br>
r::_["embedded"] = false,<br>
r::_["const_predict"] = false,<br>
r::_["verbose"] = false,<br>
r::_["validLib"] = std::vector<bool>() ); //
<== This is reported as the error<br>
<br>
Mapping in RcppEDMCommon.cpp:<br>
<br>
//-------------------------------------------------------------------------<br>
// Export / map the functions<br>
// First argument: R function name, see ../R/EDM.R<br>
// Second argument: pointer to Rcpp interface function<br>
// Third argument: arguments of the R function that
encapsulates the<br>
// C++ function in a Rcpp::List<br>
//-------------------------------------------------------------------------<br>
RCPP_MODULE(EDMInternal) {<br>
r::function( "RtoCpp_Simplex", &Simplex_rcpp,
SimplexArgs );<br>
r::function( "RtoCpp_SMap", &SMap_rcpp,
SMapArgs );<br>
}<br>
<br>
C++ API function call (overloaded) to core library from function
SMap_rcpp() in SMap.cc (C++ API prototype listed below):<br>
<br>
//----------------------------------------------------------<br>
//<br>
//----------------------------------------------------------<br>
r::List SMap_rcpp( std::string pathIn,<br>
std::string dataFile,<br>
r::DataFrame dataFrame,<br>
std::string pathOut,<br>
std::string predictFile,<br>
std::string lib,<br>
std::string pred,<br>
int E,<br>
int Tp,<br>
int knn,<br>
int tau,<br>
double theta,<br>
int exlusionRadius,<br>
std::string columns,<br>
std::string target,<br>
std::string smapFile,<br>
std::string jacobians,<br>
bool embedded,<br>
bool const_predict,<br>
bool verbose,<br>
std::vector<bool> validLib ) {<br>
<br>
SMapValues SM;<br>
<br>
if ( dataFile.size() ) {<br>
// dataFile specified, dispatch overloaded SMap, ignore
dataFrame<br>
<br>
SM = SMap( pathIn,<br>
dataFile,<br>
pathOut,<br>
predictFile,<br>
lib,<br>
pred,<br>
E,<br>
Tp,<br>
knn,<br>
tau,<br>
theta,<br>
exlusionRadius,<br>
columns,<br>
target,<br>
smapFile,<br>
jacobians,<br>
embedded,<br>
const_predict,<br>
verbose,<br>
validLib );<br>
}<br>
else if ( dataFrame.size() ) {<br>
DataFrame< double > dataFrame_ = DFToDataFrame(
dataFrame );<br>
<br>
SM = SMap( dataFrame_,<br>
pathOut,<br>
predictFile,<br>
lib,<br>
pred,<br>
E,<br>
Tp,<br>
knn,<br>
tau,<br>
theta,<br>
exlusionRadius,<br>
columns,<br>
target,<br>
smapFile,<br>
jacobians,<br>
embedded,<br>
const_predict,<br>
verbose,<br>
validLib );<br>
}<br>
else {<br>
Rcpp::warning( "SMap_rcpp(): Invalid input.\n" );<br>
}<br>
<br>
r::DataFrame df_pred = DataFrameToDF( SM.predictions );<br>
r::DataFrame df_coef = DataFrameToDF( SM.coefficients );<br>
r::List output = r::List::create( r::Named("predictions") =
df_pred,<br>
r::Named("coefficients") =
df_coef );<br>
<br>
return output;<br>
}<br>
<br>
As far as I can tell, the function arguments match the
definition. Again, this same code is implemented in another
function where there is no issue.<br>
<br>
An interesting feature of the error log is a "countdown" of
function arguments, variously providing notes, until the final
note and error exit:<br>
candidate expects 0 arguments, 21 provided<br>
candidate expects 1 argument, 21 provided<br>
...<br>
candidate expects 20 arguments, 21 provided<br>
<br>
<br>
-- Error Log --<br>
<br>
> R CMD build .<br>
* checking for file ‘./DESCRIPTION’ ... OK<br>
* preparing ‘rEDM’:<br>
* checking DESCRIPTION meta-information ... OK<br>
* cleaning src<br>
* installing the package to build vignettes<br>
-----------------------------------<br>
* installing *source* package ‘rEDM’ ...<br>
** using staged installation<br>
** libs<br>
...<br>
<br>
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG -I
./cppEDM/src/ -I'/usr/local/lib/R/site-library/Rcpp/include'
-I'/usr/local/lib/R/site-library/RcppThread/include' -fpic -g
-O2 -fdebug-prefix-map=/build/r-base-tbZjLv/r-base-4.1.0=.
-fstack-protector-strong -Wformat -Werror=format-security
-Wdate-time -D_FORTIFY_SOURCE=2 -g -c RcppEDMCommon.cpp -o
RcppEDMCommon.o<br>
RcppEDMCommon.cpp:60:51: error: no matching function for call to
‘Rcpp::Vector<19>::create(Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<Rcpp::DataFrame_Impl<Rcpp::PreserveStorage>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>, Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<int>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>,
Rcpp::traits::named_object<std::__cxx11::basic_string<char>
>, Rcpp::traits::named_object<bool>,
Rcpp::traits::named_object<bool>,
Rcpp::traits::named_object<bool>,
Rcpp::traits::named_object<std::vector<bool> >)’<br>
60 | r::_["validLib"] = std::vector<bool>() );<br>
| ^<br>
In file included from
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/Vector.h:52,<br>
from
/usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:40,<br>
from RcppEDMCommon.h:10,<br>
from RcppEDMCommon.cpp:14:<br>
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:1122:19:
note: candidate: ‘static Rcpp::Vector<RTYPE, StoragePolicy>
Rcpp::Vector<RTYPE, StoragePolicy>::create() [with int RTYPE
= 19; StoragePolicy = Rcpp::PreserveStorage]’<br>
1122 | static Vector create(){<br>
| ^~~~~~<br>
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:1122:19:
note: candidate expects 0 arguments, 21 provided<br>
...<br>
<br>
In file included from
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/vector/Vector.h:1126,<br>
from
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/Vector.h:52,<br>
from
/usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:40,<br>
from RcppEDMCommon.h:10,<br>
from RcppEDMCommon.cpp:14:<br>
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/generated/Vector__create.h:70:16:
note: candidate: ‘template<class T1> static
Rcpp::Vector<RTYPE, StoragePolicy> Rcpp::Vector<RTYPE,
StoragePolicy>::create(const T1&) [with T1 = T1; int RTYPE
= 19; StoragePolicy = Rcpp::PreserveStorage]’<br>
70 | static Vector create(const T1& t1){<br>
| ^~~~~~<br>
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/generated/Vector__create.h:70:16:
note: template argument deduction/substitution failed:<br>
RcppEDMCommon.cpp:60:51: note: candidate expects 1 argument, 21
provided<br>
...<br>
<br>
/usr/local/lib/R/site-library/Rcpp/include/Rcpp/generated/Vector__create.h:1159:16:
note: template argument deduction/substitution failed:<br>
RcppEDMCommon.cpp:60:51: note: candidate expects 20 arguments,
21 provided<br>
60 | r::_["validLib"] = std::vector<bool>() );<br>
| ^<br>
make: *** [/usr/lib/R/etc/Makeconf:177: RcppEDMCommon.o] Error 1<br>
ERROR: compilation failed for package ‘rEDM’<br>
* removing ‘/tmp/RtmpWluzdI/Rinst8d5e56742eb9/rEDM’<br>
-----------------------------------<br>
ERROR: package installation failed<br>
<br>
-- Version Info --<br>
<br>
> sessionInfo()<br>
R version 4.1.0 (2021-05-18)<br>
Platform: x86_64-pc-linux-gnu (64-bit)<br>
Running under: Ubuntu 20.04.1 LTS<br>
<br>
Matrix products: default<br>
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0<br>
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0<br>
<br>
locale:<br>
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C <br>
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 <br>
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 <br>
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C <br>
[9] LC_ADDRESS=C LC_TELEPHONE=C <br>
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C <br>
<br>
attached base packages:<br>
[1] stats graphics grDevices utils datasets methods
base <br>
<br>
other attached packages:<br>
[1] Rcpp_1.0.5<br>
<br>
loaded via a namespace (and not attached):<br>
[1] compiler_4.1.0<br>
<br>
-- C++ API prototype --<br>
<br>
// SMap is a special case since it can be called with a function
pointer<br>
// to the SVD solver. This is done so that interfaces such as
pybind11<br>
// can provide their own object for the solver.<br>
// 1) Data path/file with default SVD (LAPACK) assigned in Smap.cc
2)<br>
SMapValues SMap( std::string pathIn = "./data/",<br>
std::string dataFile = "",<br>
std::string pathOut = "./",<br>
std::string predictFile = "",<br>
std::string lib = "",<br>
std::string pred = "",<br>
int E = 0,<br>
int Tp = 1,<br>
int knn = 0,<br>
int tau = -1,<br>
double theta = 0,<br>
int exclusionRadius = 0,<br>
std::string columns = "",<br>
std::string target = "",<br>
std::string smapFile = "",<br>
std::string derivatives = "",<br>
bool embedded = false,<br>
bool const_predict = false,<br>
bool verbose = true,<br>
std::vector<bool> validLib =
std::vector<bool>() );<br>
<br>
// 2) DataFrame with default SVD (LAPACK) assigned in Smap.cc 2)<br>
SMapValues SMap( DataFrame< double > &dataFrameIn,<br>
std::string pathOut = "./",<br>
std::string predictFile = "",<br>
std::string lib = "",<br>
std::string pred = "",<br>
int E = 0,<br>
int Tp = 1,<br>
int knn = 0,<br>
int tau = -1,<br>
double theta = 0,<br>
int exclusionRadius = 0,<br>
std::string columns = "",<br>
std::string target = "",<br>
std::string smapFile = "",<br>
std::string derivatives = "",<br>
bool embedded = false,<br>
bool const_predict = false,<br>
bool verbose = true,<br>
std::vector<bool> validLib =
std::vector<bool>() );<br>
</p>
</body>
</html>