Le 07/06/13 16:07, Simon Zehnder a écrit :
Hi Romain,
thanks for this precise answer. So the suggested methods below will work
without making a copy of the object.
yes
What is about the implicit call of Rcpp::as<>() inside arma::mat()? It is a
very convenient way to create an arma object 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 muc
On Jun 7, 2013 12:12 PM, "Dirk Eddelbuettel" 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, I've had good
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 doe
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 .
Sorry, what I want to do is to call an R function from Rcpp:
cppFunction('
List myFun(int n, Function foo)
{
RNGScope scope;
Environment g = Environment::global_env();
Environment::Binding RandomSeed = g[".Random.seed"];
IntegerVector someVariable = RandomSeed;
NumericVector
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 what
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 yo
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
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);
wher
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.
Be
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(
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, d
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 u
Thank you Romain!
All clear now!
Best
Simon
On Jun 7, 2013, at 1:13 PM, Romain Francois 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 implicitly in C) must o
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 implicitly in C) must of course have the same type -
otherwise the memory has a different size.
so far, this is obvious.
On the other
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:as() function makes a
cast and there
17 matches
Mail list logo