gpt4 book ai didi

c++ - 将 double * 转换为 std::vector 给我错误

转载 作者:行者123 更新时间:2023-11-28 01:21:20 26 4
gpt4 key购买 nike

<分区>

我看过其他关于这个问题的帖子。我跟着他们。

我用来将 double 组转换为 double vector 的代码是-

cppFunction("


std::vector<double> ArrayToVector(double *arr){

std::vector<double> vec(arr, arr+ sizeof(arr)/sizeof(arr[0]));

return vec;
}



")

但是我得到了这个错误:

file52e20f14d34.cpp:28:52: error: cannot initialize a variable of type 'Rcpp::traits::input_parameter<double>::type *' (aka 'InputParameter<double> *') with an lvalue of type 'SEXP' (aka 'SEXPREC *')
Rcpp::traits::input_parameter< double >::type *arr(*arrSEXP);
^ ~~~~~~~~
1 error generated.
make: *** [file52e20f14d34.o] Error 1
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/3.5/Resources/library/Rcpp/include" -I"/private/var/folders/4w/v4pl36r9475cb2fkspc3qxkm0000gp/T/RtmpSXqByM/sourceCpp-x86_64-apple-darwin15.6.0-1.0.1" -I/usr/local/include -fPIC -Wall -g -O2 -c file52e20f14d34.cpp -o file52e20f14d34.o
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.

谁能解释一下为什么会这样?任何帮助将不胜感激。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com