本文介绍了向 Rcpp 中的 DatetimeVector 添加新组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有人能帮助我将新组件推回 DatetimeVector,我将不胜感激.DatetimeVector 只有 begin、end、getDatetimes 和 size 方法.

I would appreciate if someone could help me in push_back a new component into DatetimeVector. A DatetimeVector only has begin, end, getDatetimes and size methods.

推荐答案

我会说不要.出于多种原因:

I'd say don't. For multiple reasons:

  1. 所有 Rcpp 类型使用需要连续内存的底层 SEXP.因此,添加单个元素总是需要复制所有元素——代价高昂.
  2. DatetimeVector 类非常糟糕.多年前我写它是为了将数据传递给 QuantLib.
  3. 现在,我们可以通过简单的 NumericVector 类到 POSIXct 来做得更好——参见 Rblpapi
  1. All Rcpp types uses an underlying SEXP which requires contiguous memory. So adding a single element always requires copying all--expensive.
  2. The DatetimeVector class is pretty bad. I wrote it many years ago to pass data to QuantLib.
  3. These days we can do better via simple NumericVector classes to POSIXct -- see eg here in Rblpapi

这篇关于向 Rcpp 中的 DatetimeVector 添加新组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:27