私はRcppを使い始めました。私は2つの数値ベクトルを取り、その和集合を計算し数値ベクトルを返す単純なプログラムを持っています。リスティングは(test.cpp
)の下に貼り付けられます。実装されていないタイプ 'builtin' in 'coerceToReal' [Rcpp]
#include <Rcpp.h>
#include <algorithm>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector test(NumericVector x, NumericVector y) {
int n = x.size() + y.size();
std::vector<int> v(n);
std::vector<int>::iterator it;
std::sort(x.begin(), x.end());
std::sort(y.begin(), y.end());
it=std::set_union(x.begin(), x.end(), y.begin(), y.end(), v.begin());
v.resize(it-v.begin());
return wrap(v);
}
/*** R
x <- c(5,10,15,20,25)
y <- c(50,40,30,20,10)
test(x, y)
*/
私は値
x <- sample(20000)
y <- sample(20000)
test(x, y)
機能が動作してプログラムを実行してみてください。しかし、とき、私は何が起こっているかの値
x <- sample(1000000)
y <- sample(1000000)
test(x, y)
出力
Error in .Primitive(".Call")(<pointer: 0x7f1819d8af20>, x, y) :
unimplemented type 'builtin' in 'coerceToReal'
とプログラムがクラッシュ任意のアイデアの数を増やしますか?ポインタや参照をありがとう。
それは私のためにうまくいく...あなたのシステム仕様は何ですか? –
@JosephWood Linuc Ubuntuボックス、16 GB RAM。 – Andrej