<div dir="ltr"><div><div>I apologize if my emails were badly phrased, or disrespectful. No intention of saying anything was broken, suspicious or wrong.</div></div><div><br></div><div>I second Gabor. His described use case matches mine. The outer loop is an optimization routine coming from other libraries. Rcpp is used to speed up the objective, gradient and hessian computations and hence the data is constantly passed along to all of these functions. Another use case to consider is recursion with data passed along. A toy example is gib(0) = values(0); gib(1) = values(1); gib(x) = gib(x-1) + gib(x-2) + values(x). Values = vector of non negative integers. A naive implementation with aux memory allocation may cause the number of copies in memory to grow with exponential order in x.<br>
</div><div><br></div><div><br></div><div><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

> In case ii) I'd try to use a different design and make it more like i): You<br>
> generally do not want to call down from R to object code a bazillion times as<br>
> there is always some overhead, and multiplying even something rather<br>
> efficient by a veryBigNumber can make small times large in the aggregate.<br>
<br>
Sure and sugar, rcpparmadillo and other facilities do make it easier to move<br>
more functionality into C++; nevertheless, it can be the case that a relatively<br>
small amount of R code repeatedly<br>
invoked is responsible for the performance hit in a program and from<br>
the viewpoint<br>
of reducing complexity and increasing maintainability it can be<br>
desirable to just<br>
move that minimum portion to the C++ side minimizing the dual language aspect<br>
of the code.  By making call overhead as fast<br>
as one can while retaining any automatic Rcpp features then this<br>
is facilitated.  If its not possible in general then if it were just possible<br>
for Armadillo objects and selected other situations then this would<br>
still be nice.<br>
<br>
><br>
> Dirk<br>
></blockquote></div></div></div></div>