Я пытаюсь установить пакет mypackage5
с помощью RcppEigen.package.skeleton()
, но что-то не так с LogicalVector&
in Rcpp::List getPIcvalue
и RcppExport SEXP mypackage5_getPIcvalue
. Вот функция C++ с bool varIn[]
,
#include <RcppEigen.h>
#include <Rcpp.h>
using namespace Eigen;
using namespace Rcpp;
using std::string;
// getPIcvalue
Rcpp::List getPIcvalue(int p, bool nest, string criteria, bool varIn[], bool findIn, int n,const MatrixXd& Y,const MatrixXd& Xf,const MatrixXd& X0,double sigma);
RcppExport SEXP mypackage5_getPIcvalue(SEXP pSEXP,SEXP nestSEXP,SEXP criSEXP,SEXP varInSEXP,SEXP findInSEXP,SEXP nSEXP,SEXP YSEXP,SEXP XfSEXP,SEXP X0SEXP,SEXP sigmaSEXP) {
BEGIN_RCPP
SEXP __sexp_result;
{
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< int >::type p(pSEXP );
Rcpp::traits::input_parameter< bool >::type nest(nestSEXP );
Rcpp::traits::input_parameter< string >::type criteria(criSEXP );
Rcpp::traits::input_parameter< bool >::type varIn[](varInSEXP );
Rcpp::traits::input_parameter< bool >::type findIn(findInSEXP );
Rcpp::traits::input_parameter< int >::type n(nSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Y(YSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Xf(XfSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type X0(X0SEXP );
Rcpp::traits::input_parameter< double >::type sigma(sigmaSEXP );
Rcpp::List __result = getPIcvalue(p, nest, criteria, varIn[], findIn, n, Y, Xf, X0, sigma);
PROTECT(__sexp_result = Rcpp::wrap(__result));
}
UNPROTECT(1);
return __sexp_result;
END_RCPP
}
когда я запускаю Rcmd INSTALL --build mypackage5
, ошибка:
* installing *source* package 'mypackage5' ...
** libs
*** arch - i386
cygwin warning:
MS-DOS style path detected: C:/R/R-31~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-31~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -m32 -I"C:/R/R-31~1.1/include" -DNDEBUG -I"C:/Users/LJH/Documents/R/win-library/3.1/Rcpp/include" -I"C:/Users/LJH/Documents/R/win-library/3.1/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp: In function 'SEXPREC* mypackage5_getPIcvalue(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)':
RcppExports.cpp:27:68: error: expected primary-expression before ']' token
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-31~1.1/etc/i386/Makeconf" -f "C:/R/R-31~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="mypackage5.dll" OBJECTS="RcppExports.o rcppeigen_hello_world.o"' had status 2
cygwin warning:
MS-DOS style path detected: C:/R/R-31~1.1/etc/i386/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/R/R-31~1.1/etc/i386/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
g++ -m32 -I"C:/R/R-31~1.1/include" -DNDEBUG -I"C:/Users/LJH/Documents/R/win-library/3.1/Rcpp/include" -I"C:/Users/LJH/Documents/R/win-library/3.1/RcppEigen/include" -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
RcppExports.cpp: In function 'SEXPREC* mypackage5_getPIcvalue(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)':
RcppExports.cpp:27:68: error: expected primary-expression before ']' token
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-31~1.1/etc/i386/Makeconf" -f "C:/R/R-31~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="mypackage5.dll" OBJECTS="RcppExports.o rcppeigen_hello_world.o" symbols.rds' had status 2
ERROR: compilation failed for package 'mypackage5'
* removing 'C:/Users/LJH/Documents/mypackage5.Rcheck/mypackage5'
1-й, я пытаюсь изменить bool varIn[]
на bool *varIn
,
// getPIcvalue
Rcpp::List getPIcvalue(int p, bool nest, string criteria, bool *varIn, bool findIn, int n,const MatrixXd& Y,const MatrixXd& Xf,const MatrixXd& X0,double sigma);
RcppExport SEXP mypackage5_getPIcvalue(SEXP pSEXP,SEXP nestSEXP,SEXP criSEXP,SEXP varInSEXP,SEXP findInSEXP,SEXP nSEXP,SEXP YSEXP,SEXP XfSEXP,SEXP X0SEXP,SEXP sigmaSEXP) {
BEGIN_RCPP
SEXP __sexp_result;
{
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< int >::type p(pSEXP );
Rcpp::traits::input_parameter< bool >::type nest(nestSEXP );
Rcpp::traits::input_parameter< string >::type criteria(criSEXP );
Rcpp::traits::input_parameter< bool >::type varIn(varInSEXP );
Rcpp::traits::input_parameter< bool >::type findIn(findInSEXP );
Rcpp::traits::input_parameter< int >::type n(nSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Y(YSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Xf(XfSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type X0(X0SEXP );
Rcpp::traits::input_parameter< double >::type sigma(sigmaSEXP );
Rcpp::List __result = getPIcvalue(p, nest, criteria, varIn, findIn, n, Y, Xf, X0, sigma);
PROTECT(__sexp_result = Rcpp::wrap(__result));
}
UNPROTECT(1);
return __sexp_result;
END_RCPP
}
Я получил эту ошибку:
RcppExports.cpp: In function 'SEXPREC* mypackage5_getPIcvalue(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)':
RcppExports.cpp:27:96: error: cannot convert 'Rcpp::traits::input_parameter<bool>::type {aka Rcpp::InputParameter<bool>}' to 'bool*' for argument '4' to 'Rcpp::List getPIcvalue(int, bool, std::string, bool*, bool, int, const MatrixXd&, const MatrixXd&, const MatrixXd&, double)'
bool varIn[]
, я пытаюсь изменить bool varIn[]
на LogicalVector& varIn
,
// getPIcvalue
Rcpp::List getPIcvalue(int p, bool nest, string criteria, LogicalVector& varIn, bool findIn, int n,const MatrixXd& Y,const MatrixXd& Xf,const MatrixXd& X0,double sigma);
RcppExport SEXP mypackage5_getPIcvalue(SEXP pSEXP,SEXP nestSEXP,SEXP criSEXP,SEXP varInSEXP,SEXP findInSEXP,SEXP nSEXP,SEXP YSEXP,SEXP XfSEXP,SEXP X0SEXP,SEXP sigmaSEXP) {
BEGIN_RCPP
SEXP __sexp_result;
{
Rcpp::RNGScope __rngScope;
Rcpp::traits::input_parameter< int >::type p(pSEXP );
Rcpp::traits::input_parameter< bool >::type nest(nestSEXP );
Rcpp::traits::input_parameter< string >::type criteria(criSEXP );
Rcpp::traits::input_parameter< const LogicalVector& >::type varIn(varInSEXP );
Rcpp::traits::input_parameter< bool >::type findIn(findInSEXP );
Rcpp::traits::input_parameter< int >::type n(nSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Y(YSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type Xf(XfSEXP );
Rcpp::traits::input_parameter< const MatrixXd& >::type X0(X0SEXP );
Rcpp::traits::input_parameter< double >::type sigma(sigmaSEXP );
Rcpp::List __result = getPIcvalue(p, nest, criteria, varIn, findIn, n, Y, Xf, X0, sigma);
PROTECT(__sexp_result = Rcpp::wrap(__result));
}
UNPROTECT(1);
return __sexp_result;
END_RCPP
}
ошибка:
RcppExports.cpp: In function 'SEXPREC* mypackage5_getPIcvalue(SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP, SEXP)':
RcppExports.cpp:27:96: error: invalid initialization of reference of type 'Rcpp::LogicalVector& {aka Rcpp::Vector<10, Rcpp::PreserveStorage>&}' from expression of type 'Rcpp::traits::input_parameter<Rcpp::Vector<10, Rcpp::PreserveStorage> >::type {aka Rcpp::InputParameter<Rcpp::Vector<10, Rcpp::PreserveStorage> >}'
RcppExports.cpp:11:12: error: in passing argument 4 of 'Rcpp::List getPIcvalue(int, bool, std::string, Rcpp::LogicalVector&, bool, int, Eigen::MatrixXd&, Eigen::MatrixXd&, Eigen::MatrixXd&, double)'
make: *** [RcppExports.o] Error 1
Warning: running command 'make -f "Makevars.win" -f "C:/R/R-31~1.1/etc/i386/Makeconf" -f "C:/R/R-31~1.1/share/make/winshlib.mk" SHLIB_LDFLAGS='$(SHLIB_CXXLDFLAGS)' SHLIB_LD='$(SHLIB_CXXLD)' SHLIB="mypackage5.dll" OBJECTS="RcppExports.o rcppeigen_hello_world.o"' had status 2
Может кто-нибудь мне помочь? Заранее благодарю.
Атрибуты Rcpp не могут обрабатывать аргументы массива, такие как bool varIn[]
, или указатели, такие как bool *varIn
.
О вашей попытке 2, у вас есть некоторые const
Несс несоответствия между getPIcvalue
, который принимает LogicalVector&
и mypackage5_getPIcvalue
, которые по каким - то причинам использует Rcpp::traits::input_parameter< const LogicalVector& >::type
.
Вы сгенерировали mypackage5_getPIcvalue
вручную? Если да, то почему? Если нет, то есть ошибка в атрибутах Rcpp.
mypackage5_getPIcvalue
не было сгенерировано. Иногда, когда я запускаю Rcmd INSTALL --build mypackage5
, MatrixXd&
имеет ту же ошибку, что и LogicalVector&
.
Rcpp::traits::input_parameter< bool >::type varIn[](varInSEXP );
даже если бы bool[]
был поддержан, вам бы понадобился Rcpp::traits::input_parameter< bool[] >::type varIn(varInSEXP );
но, как я сказал выше, это не так.