C++ - Avoid allocating memory with dqsample_int #105
Replies: 2 comments
-
|
Any reason why you want to do this? I would expect that return value optimization leads to one vector with 1000 elements being allocated per loop. In principle, R has a "copy on write" policy, that means one should not change an existing vector directly. I don't think this is relevant here, but I am hesitant to offer something like that in the public API. |
Beta Was this translation helpful? Give feedback.
-
|
Sorry for the (very late) reply. My original idea was to see if there was a way to avoid additional memory allocations by somehow modifying the elements of the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I am doing some Monte Carlo simulation—using
dqset_seedanddqsample_intin C++—and I was wondering is there a way to avoid allocating memory for each sample if I want to simply overwrite the contents of an existingRcpp::IntegerVector? Below is an example of how I currently have the code set up:I am still not that familiar with C++, so I apologize if there is an obvious solution.
Beta Was this translation helpful? Give feedback.
All reactions