[Rcpp-devel] multidimensional arrays
mailinglist.honeypot at gmail.com
Fri Jun 15 15:46:37 CEST 2012
Just a quick note: don't forget to punch "reply all" when replying to
emails from the list so that more people can help you and that the
list can be used as a resource for others.
On Fri, Jun 15, 2012 at 9:34 AM, Frederico Mestre
<mestre.frederico at gmail.com> wrote:
> I'm sorry if I wasn't clear enough. I´m really used to work in R but I'm
> getting really confused with C++. I know that my questions were a little
> vague. I was thinking about using Rcpp and inline in order to be, as much as
> possible, working in R, were I'm comfortable.
> As an input to my function I would have the mean area of habitat patch, its
> standard deviation (in order to have patches of several sizes), the mean
> distance between patches and its standard deviation. Also, the dispersal
> ability of my species.
> Then the simulated landscape would be allowed to change (increase or
> decrease each of the parameters). Which would represent the evolution
> through time.
> The output I intend is to be able to evaluate how the mean extinction
> probability and colonization probability changes with these changing
> Another output is the average speed of progression of a species throughout
> the simulations. This would allow me to say, given some parameters of the
> landscape, at what average speed would the species spread in the landscape
> (p. ex. in km/year).
> Then all this would have to be repeated x times using some sort of loop. I
> don't need to retain the "landscapes" only the mean values of each of the
What you are proposing to do sounds perfectly reasonable and doable --
I strongly suspect all of it doesn't have to be done in C++, though.
If you have all of this already whipped up in R, there are ways to
find the "pain points" and just convert those small portions to C(++)
-- I suspect you probably already know where these problems are.
Still, the point I was trying to make in my follow up emails is that
there isn't much anybody can do here to help you -- no one will
provide the code to do exactly what you want.
Most of us will have no idea of the details of the simulation you are
trying to run, etc. You know what I mean? It's not clear what you are
expecting from the people on this list.
As you are converting some of your code from R to C(++) and you are
finding difficulty with some Rcpp specific issue that is still foggy
after reading the "Writing extensions in R" document (this is from
"base" R) as well as relevant Rcpp docs (and its article in JSS), then
please come back and ask a more specific question that involves a more
specific problem description and the code that you're trying (both the
R and C++) ... preferably pointing to the specific line(s) that are
giving you trouble.
*Then* we can help ...
> -----Mensagem original-----
> De: Steve Lianoglou [mailto:mailinglist.honeypot at gmail.com]
> Enviada em: sexta-feira, 15 de Junho de 2012 14:29
> Para: Frederico Mestre
> Assunto: Re: [Rcpp-devel] multidimensional arrays
> Hi Frederico,
> But where was the question itself then?
> I might be missing something, but your question practically amounted to an
> announcement saying that you want to use C++ ... and that's it
> On Fri, Jun 15, 2012 at 7:57 AM, Frederico Mestre
> <mestre.frederico at gmail.com> wrote:
>> Yes, you're probably right, my question is more related with the C++
>> itself and maybe this is not the place to put it.
>> -----Mensagem original-----
>> De: Steve Lianoglou [mailto:mailinglist.honeypot at gmail.com]
>> Enviada em: sexta-feira, 15 de Junho de 2012 11:34
>> Para: Frederico Mestre
>> Cc: rcpp-devel at lists.r-forge.r-project.org
>> Assunto: Re: [Rcpp-devel] multidimensional arrays
>> Hi Frederico,
>> On Fri, Jun 15, 2012 at 5:27 AM, Frederico Mestre
>> <mestre.frederico at gmail.com> wrote:
>>> Hello all:
>>> I’m a regular user of R, but my knowledge of C++ is limited.
>>> I need to create functions to generate random landscapes (with two
>>> classes) based on area and distance amongst patches. This would take
>>> quite a long time in R so I thought it would be better to use Rcpp
>>> (which seems a simpler way to integrate R and C++). I need to
>>> generate these landscapes for the current time and their evolution in
>>> the future (about 1000 to each of these time steps).
>>> I thought it would be better to generate these “landscapes” as
>>> multidimensional arrays but I’m finding it hard to work with C++.
>>> Would it be adequate to use this functions:
>>> rdlandscape <- cxxfunction(signature(x = "numeric"), body = "C++
>>> I don’t need to retain these objects after the run just calculate
>>> several parameters (as extinction probability) of a species that
>>> would be present in these landscapes.
>>> Any ideas?
>> It's hard to provide any ideas -- you're giving us very little to work
>> We're not sure (at least I'm not) what exactly you're trying to do, so
>> I'll take it as truth that generating these in R will result in
>> prohibitively long running time, in this case looking to Rcpp is a
>> great idea -- yes, it makes integrating C++ w/ R much easier.
>> But what type of ideas are you looking to get here -- assuming you
>> substitute the correct C++ code in your `body="C++ code", then you'll
>> be a happy camper ... the trick is getting the right code in there.
>> Also, once you do get the right code, you probably want to turn this
>> stuff into a package so you don't have to inline/compile it every time
>> you start a new R session.
>> People can provide more help when you start implementing these thing
>> and run into a particular wall with Rcpp itself. At that point, please
>> provide a better description of what you're trying to do, what you've
>> actually tried, and where the exact problem is. Until then, there
>> isn't much else we can do for you now.
>> Steve Lianoglou
>> Graduate Student: Computational Systems Biology
>> | Memorial Sloan-Kettering Cancer Center
>> | Weill Medical College of Cornell University Contact Info:
> Steve Lianoglou
> Graduate Student: Computational Systems Biology
> | Memorial Sloan-Kettering Cancer Center
> | Weill Medical College of Cornell University Contact Info:
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
More information about the Rcpp-devel