HI Dirk, hi Romain,
allright, this is now clear to me, if I want to reuse memory, the allocated
memory from R (so implicitly in C) must of course have the same type -
otherwise the memory has a different size.
On the other side I then assume, that the Rcpp:asclass M() function makes a
cast
Thank you Romain!
All clear now!
Best
Simon
On Jun 7, 2013, at 1:13 PM, Romain Francois rom...@r-enthusiasts.com wrote:
Le 07/06/13 13:09, Simon Zehnder a écrit :
HI Dirk, hi Romain,
allright, this is now clear to me, if I want to reuse memory, the allocated
memory from R (so
It would appear that my Rcpp book is now shipping from Springer, and should
within days from Amazon et al. See my blog
http://dirk.eddelbuettel.com/blog/2013/06/07#rcppbook_available
and the 'Rcpp book' page at our slowly-growing rcpp.org site
http://www.rcpp.org/book/
for more. I will
Hi Romain, hi Dirk,
sorry for posting here again, but I found something in some way connected to
this discussion - and pretty interesting concerning the Rcpp::as() function:
1. I create a class containing a list:
setClass(myclass, representation(par = list))
l - list(lambda = array(0, dim =
Le 07/06/13 15:14, Simon Zehnder a écrit :
Hi Romain, hi Dirk,
sorry for posting here again, but I found something in some way connected to this
discussion - and pretty interesting concerning the Rcpp::as() function:
1. I create a class containing a list:
setClass(myclass, representation(par
Hi Romain,
thanks for this precise answer. So the suggested methods below will work
without making a copy of the object. What is about the implicit call of
Rcpp::as() inside arma::mat()? It is a very convenient way to create an arma
object reusing memory and it seems to work just fine.
Dear Rcpp experts,
I would like to be able to store the R random seed from a Rcpp
function and then reset it. In other words I would like to replicate
the following code in Rcpp:
savedSeed - .Random.seed
x - Rfunction(parameters1);
.Random.seed - savedSeed
x1 - Rfunction(parameters2);
where
Hi Matteo,
I do not know what you really want to do, but if you want to replicate results,
you could do the following in Rcpp before running the RNG:
Rcpp::Environment baseEnv(package:base);
Rcpp::Function setSeed = baseEnv[set.seed];
setSeed(0);//any other number would do it here
Best
You can do something like this (i'm on my phone, so you might have to change
it):
Environment g = Environment::global_env() ;
Environment::Binding RandomSeed = g[.Random.seed] ;
You get the current value of the binding like this:
NumericVector someVariable = RandomSeed ;
And then when you
Thanks for you replies.
I need to seed the seed because I'm estimating the likelihood
function in an MCMC algorithm, and I need to use the same random numbers in
order
to get a good acceptance ratio. (I could also pass vectors of random
numbers around but
that's quite messy).
For some reason
This would be easier if base::set.seed() accepted a value of .Random.seed
instead of just a scalar integer or, new to R-3.0.0, NULL. If set.seed()
returned the
previous value of .Random.seed (NULL if there was no previous value) things
might be even easier. People should not have to know where
Matteo,
Maybe you may need to figure this out in plain C(++) code based on the
Writing R Extensions manual first. R makes an assumption about keeping the
RNGs in a good state, I am not entirely sure if you actually can do what you
want to do. Just because you can call an R function from Rcpp
On Jun 7, 2013 12:12 PM, Dirk Eddelbuettel e...@debian.org wrote:
Maybe what you want is more easily done with the RNGs from C++ (esp
C++11),
Boost, ... or something different from R. It may work, but we are
(currently) simply not set up for it.
If you go with something different from R,
Dirk,
you are right, intuitively I see that the way I'm doing things doesn't
seem very save. The motivation behind my experimentation is that
I'm trying to move things from R to C++ in order to avoid that segfault
problem that we observed a couple of weeks ago.
Probably I'm clinging a bit too
14 matches
Mail list logo