Rでdlibの行列を使用してcppプログラムを実行しようとしています。何時間もコードを実行しようとしていましたが、手伝って頂けますか?'SEXP'からRcppのlong intへの無効な変換
私のコードの断片ではあります:
#include <Rcpp.h>
#include <cmath>
#include <vector>
// [[Rcpp::depends(RcppEigen)]]
#include <RcppEigen.h>
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::depends(dlib)]]
#include <dlib/optimization/optimization.h>
using namespace Eigen;
using namespace std;
using namespace dlib;
typedef matrix<double,0,1> column_vector;
残念ながら、私はので、ソースのCPPエラーのコードをコンパイルすることはできません:コンソールから
~/R/win-library/3.4/Rcpp/include/Rcpp/internal/Exporter.h
Line 31 invalid conversion from 'SEXP' to long int [-fpermissive]
とログを:
C:/RBuildTools/3.4/mingw_64/bin/g++ -std=gnu++11 -I"C:/PROGRA~1/R/R-34~1.1/include" -DNDEBUG -I"C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include" -I"C:/Users/user_name/Documents/R/win-library/3.4/RcppEigen/include" -I"C:/Users/user_name/Documents/R/win-library/3.4/dlib/include" -I"C:/Users/user_name/Documents/project_name/cpp_to_R" -I"d:/Compiler/gcc-4.9.3/local330/include" -std=c++0x -O2 -Wall -mtune=core2 -c project_name.cpp -o project_name.o
In file included from C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/as.h:25:0,
from C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/RcppCommon.h:160,
from C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp.h:27,
from project_name.cpp:1:
C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/internal/Exporter.h: In instantiation of 'Rcpp::traits::Exporter<T>::Exporter(SEXP) [with T = dlib::matrix<double, 0l, 1l>; SEXP = SEXPREC*]':
C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/as.h:87:51: required from 'T Rcpp::internal::as(SEXP, Rcpp::traits::r_type_generic_tag) [with T = dlib::matrix<double, 0l, 1l>; SEXP = SEXPREC*]'
C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/as.h:152:82: required from 'T Rcpp::as(SEXP) [with T = dlib::matrix<double, 0l, 1l>; SEXP = SEXPREC*]'
C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/InputParameter.h:72:62: required from 'Rcpp::ConstReferenceInputParameter<T>::ConstReferenceInputParameter(SEXP) [with T = dlib::matrix<double, 0l, 1l>; SEXP = SEXPREC*]'
project_name.cpp:279:80: required from here
C:/Users/user_name/Documents/R/win-library/3.4/Rcpp/include/Rcpp/internal/Exporter.h:31:31: error: invalid conversion from 'SEXP' to 'long int' [-fpermissive]
Exporter(SEXP x) : t(x){}
^
In file included from C:/Users/user_name/Documents/R/win-library/3.4/dlib/include/dlib/optimization/../matrix.h:6:0,
from C:/Users/user_name/Documents/R/win-library/3.4/dlib/include/dlib/optimization/optimization_search_strategies.h:8,
from C:/Users/user_name/Documents/R/win-library/3.4/dlib/include/dlib/optimization/optimization.h:9,
from project_name.cpp:8:
C:/Users/user_name/Documents/R/win-library/3.4/dlib/include/dlib/optimization/../matrix/matrix.h:1019:18: note: initializing argument 1 of 'dlib::matrix<T, num_rows, num_cols, mem_manager, layout>::matrix(long int) [with T = double; long int num_rows = 0l; long int num_cols = 1l; mem_manager = dlib::memory_manager_stateless_kernel_1<char>; layout = dlib::row_major_layout]'
explicit matrix (
^
make: *** [project_name.o] Error 1
Warning message:
running command 'make -f "C:/PROGRA~1/R/R-34~1.1/etc/x64/Makeconf" -f "C:/PROGRA~1/R/R-34~1.1/share/make/winshlib.mk" CXX='$(CXX11) $(CXX11STD)' CXXFLAGS='$(CXX11FLAGS)' CXXPICFLAGS='$(CXX11PICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX11LDFLAGS)' SHLIB_LD='$(SHLIB_CXX11LD)' SHLIB="sourceCpp_78.dll" WIN=64 TCLBIN=64 OBJECTS="project_name.o"' had status 2
Error in Rcpp::sourceCpp("cpp_to_R/project_name.cpp") :
Error 1 occurred building shared library.
ここで何が間違っていますか?私はそれを得ることはありません:(
編集:。。
このエラーは、私は私のcolumn_vector
Rには 'long int'がありませんので、これを変換することはできません。 'double'か普通のサイズ' int'を選びます。 –
私はすでにintに変更しようとしていました。それは動作しません( "31行目は 'SEXP'からint [-fpermissive]への無効な変換です)。 – Poia
'long int'!=' int' –