小编cgm*_*mil的帖子

Rcpp精度问题

使用Rcpp考虑R中的以下C++函数:

cppFunction('long double statZn_cpp(NumericVector dat, double kn) {
  double n = dat.size();
  // Get total sum and sum of squares; this will be the "upper sum"
  // (i.e. the sum above k)
  long double s_upper, s_square_upper;
  // The "lower sums" (i.e. those below k)
  long double s_lower, s_square_lower;
  // Get lower sums
  // Go to kn - 1 to prevent double-counting in main
  // loop
  for (int i = 0; i < kn - 1; ++i) {
    s_lower += dat[i]; …
Run Code Online (Sandbox Code Playgroud)

c++ precision r rounding rcpp

0
推荐指数
1
解决办法
685
查看次数

标签 统计

c++ ×1

precision ×1

r ×1

rcpp ×1

rounding ×1