Skip to content
Prev 6044 / 10988 Next

[Rcpp-devel] Delayed usage of auxiliary memory in RcppArmadillo

Hi Romain,

thanks for refreshing my C++ basics

As I am regrettably not privileged to spare the amount of time on C++
skill improvement I would like to, but have the assignment to
construct stochastic models and implement them, I focus here on a
solution and maybe someone can help me, with his experience in C++
(at this point I'd like to apologize for maybe confusing list members 
with my wrong statements below).

Back to the origin of my problem I intend to solve:

I have a variable STOREPOST, that indicates, if additional
information should be stored during the processing of my algorithm. In
the case
STOREPOST is not true I would like to avoid the construction of an
arma::mat object and in the case that STOREPOST is true an arma::mat
object should be constructed with auxiliary memory from R.

 From your corrections below I understand, that the way I showed is
not appropriate to solve my problem, as the temporary object in the
if-clause is not known anymore to the compiler
from the line on I close the bracket ('}') of the if-condition. I
also assume, that using a pointer '*arma::mat maybeM' does not change
this,
as the object inside the if-clause is still a temporary rvalue
(please correct me here if I am wrong).

I would like to ask, if a list member has maybe an advice for me? Should 
I construct two
different algorithms (that would be a very easy solution - maybe not
the
way a C++ programmer would use). Or would you construct a base class
and one that inherits from the base class containing additional
members? I think there are a lot
of pitfalls I do not see yet.


Best

Simon
On 06/11/2013 12:02 AM, romain at r-enthusiasts.com wrote: