Re: [Rcpp-devel] new to R, so don't understand Rcpp limits

2017-08-04 Thread Christian Gunning
> | Hi, > | I need to share some data between my Python code and my c++ code, C++ > does > | not really have a lot of nice ideas like DataFrames. But if you save a > | dataframe from Python into csv, you can readily read it using R. Csv is > not > | the best way to go, but it is a simple case. > >

[Rcpp-devel] R.e. element wise multiplication of a subcube and a row of a matrix

2017-01-09 Thread Christian Gunning
> I am posting again a question about the subject cited. I tried to search > this problem but did not find. My question is why we cannot multiply > element wise a subcube and a row of a matrix. > > Any help would be appriciated. The following is sample code which is giving > erros about the operand

Re: [Rcpp-devel] Timings for a program

2017-01-06 Thread Christian Gunning
Why is there a dot in ".*"? Are you perhaps thinking of Matlab? On Fri, Jan 6, 2017 at 8:53 PM, Shaami wrote: > I have deleted two for loops from my code and trying to use vectors in place > of them. For reference, there's very little benefit to removing loops in a compiled language. What Marty

Re: [Rcpp-devel] Timings for a program

2017-01-05 Thread Christian Gunning
> I am new to Rcpp. I have converted my R program into an Rcpp program. > I want to ask a general question. Using Rcpp, my code is taking about 3 > minutes to produce output for 100 observations. But it is taking about 2.45 > hours to produce output for 1000 observations. Any suggestions or technic

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-14 Thread Christian Gunning
On Wed, Dec 14, 2016 at 12:23 PM, Johannes Kruisselbrink wrote: > > Good point. Actually, I didn't even realize there were so many is-nan > functions to choose from. But indeed, we used the R-core ISNAN function on > doubles accessed via Rcpp. Me either :) Of course, the above isn't particular to

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-14 Thread Christian Gunning
> so skipping the entire object is not really an option. Understood - just wanted to highlight the existence of Rcpp::is_nan / Rcpp::any in case they were broadly relevant. > Nevertheless, the question still remains why the rcpp isNaN call is so > much slower. Take care to distinguish the R-core

Re: [Rcpp-devel] Rcpp ISNAN slower than C ISNAN?

2016-12-13 Thread Christian Gunning
> |for (i = 0; i < numObjects; i++) { > | for (j = 0; j < numCodes; j++) { > |dist = 0; > |for (k = 0; k < numVars; k++) { > | if (!ISNAN(data[i * numVars + k])) { > |tmp = data[i * numVars + k] - codes[j * numVars + k]; > > Why not drop data and codes

Re: [Rcpp-devel] RFC: Rcpp modules vs. RefClass

2016-12-05 Thread Christian Gunning
On Wed, Nov 30, 2016 at 8:23 AM, Whit Armstrong wrote: > My point regarding the clang parser is that one really shouldn't have to > write any R or Rcpp wrappers at all. > I realize this is a bit academic, but I suppose my position reduces to "RefClass + Rcpp = no wrappers at all". For many (mos

Re: [Rcpp-devel] RFC: Rcpp modules vs. RefClass

2016-11-30 Thread Christian Gunning
On Mon, Nov 28, 2016 at 9:40 PM, Christian Gunning wrote: > > B) Are there any *gotchas* with using Rcpp "modify-in-place" functions > inside RefClass methods? > After some reading, I'm going to answer my own question and point to one possible *gotcha* that wasn'

Re: [Rcpp-devel] RFC: Rcpp modules vs. RefClass

2016-11-30 Thread Christian Gunning
e the RefClass holds state, and the Rcpp functions operate on the state using by-reference semantics. -Christian On Tue, Nov 29, 2016 at 5:33 AM, Whit Armstrong wrote: > Have a look at this project: > https://github.com/richfitz/RcppR6 > > > On Mon, Nov 28, 2016 at 11:40 PM, Chri

Re: [Rcpp-devel] RFC: Rcpp modules vs. RefClass

2016-11-29 Thread Christian Gunning
All, Thanks for the comments, much appreciated. To summarize what I'm hearing: A) No major problems with the described approach B) Not much evidence for previous use of this approach On Tue, Nov 29, 2016 at 12:02 PM, Kevin Ushey wrote: > To be brief -- Rcpp modules are effectively in maintenanc

[Rcpp-devel] RFC: Rcpp modules vs. RefClass

2016-11-28 Thread Christian Gunning
ny suggested improvements on the above? Thanks much, Christian Gunning -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal – Panama! ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] Rcpp-devel Digest, Vol 85, Issue 8

2016-11-23 Thread Christian Gunning
On Wed, Nov 23, 2016 at 4:00 AM, rcpp-devel-requ...@lists.r-forge.r-project.org < rcpp-devel-requ...@lists.r-forge.r-project.org> wrote: > > Using the amazingly useful > > http://gallery.rcpp.org/articles/using-the-Rcpp-based- > sample-implementation/ > > I get a bunch of compiler warnings (copied

Re: [Rcpp-devel] Integrating C-library libmseed to R

2016-07-13 Thread Christian Gunning
On 12 July 2016 at 19:33, Leo Leo wrote: > | Dear Rcpp_devel enthusiats, > | > | May I ask you for exploiting your potential? I am working on a package to > | handle seismic data (https://github.com/coLeo Leo < > behelfsadre...@googlemail.com> > Cffeemuggler

Re: [Rcpp-devel] rpois returns double?

2015-04-25 Thread Christian Gunning
message: > In rpois(10, 2^31) : NAs produced > > storage.mode(.Last.value) > [1] "integer" > > > > Bill Dunlap > TIBCO Software > wdunlap tibco.com > > On Sat, Apr 25, 2015 at 9:33 AM, Michael Weylandt < > michael.weyla...@gmail.com> wrote:

[Rcpp-devel] rpois returns double?

2015-04-24 Thread Christian Gunning
Quick question, mainly out of curiousity. I get that Rcpp uses the R api on the backend, and in the R api, R::rpois returns a double (and Rcpp::rpois returns NumericVector). The R C code doesn't offer much in the way of explanation of why double is returned, but always returns a floor() ( https://

Re: [Rcpp-devel] Accessing list of list members to permute them

2015-03-30 Thread Christian Gunning
On Mon, Mar 30, 2015 at 6:00 AM, rcpp-devel-requ...@lists.r-forge.r-project.org < rcpp-devel-requ...@lists.r-forge.r-project.org> wrote: > > > // [[Rcpp::export]] > > List rearrangelist(List x){ > int ni=15; > int nj=4; > int nk=999; > List output; > > for (int i= 0 ; i

[Rcpp-devel] R.e. Using Rcpp and MATLAB MAT-File API to Read MAT Files

2015-03-25 Thread Christian Gunning
Can you provide a link to the mat.h file referenced in the source (which I assume is the same as the API mentioned below)? Also, see Dirk's comments about compilers here: http://stackoverflow.com/questions/10723165/using-visual-c-with-r and here: dirk.eddelbuettel.com/code/rcpp/Rcpp-FAQ.pdf Best,

Re: [Rcpp-devel] R.e. A RcppArmadillo based program cannot compile under Windows and RStudio

2015-03-11 Thread Christian Gunning
g/extralibs64/local/lib -LC:/R-31~1.3/bin/i386 -lR > Error in inDL(x, as.logical(local), as.logical(now), ...) : > unable to load shared object > 'C:/Users/lxh/AppData/Local/Temp/RtmporLzPl/sourcecpp_19a8798d5d84/sourceCpp_59453.dll': > LoadLibrary failure: The specified module

[Rcpp-devel] ??lxh???

2015-03-10 Thread Christian Gunning
lxh, A quick word r.e. list etiquette -- you can help others process your request by including in your email a short & informative title, and a one or two sentence description of what you're trying to accomplish. I'm not on windows, so all I can say is that it works for me. Have you verified that

Re: [Rcpp-devel] Rcpp-devel Digest, Vol 64, Issue 16

2015-02-26 Thread Christian Gunning
I thought I'd step in and grab this one :) "In general, it's certainly a reasonable point that there is a trade-off to be made -- user-friendliness against the potential extra copies (not sure whether this has ever been measured -- as in counting the cases of `clone`-less existing code-bases where

Re: [Rcpp-devel] Using an Rcpp module package in an R Reference Class

2014-10-14 Thread Christian Gunning
On Tue, Oct 14, 2014 at 9:19 AM, Dr Gregory Jefferis wrote: > >> * Rcpp: RCPP_EXPOSED_CLASS_NODECL(RaggedArray) >> * Rcpp: setRcppClass("RaggedArray") >> * roxygen2/NAMESPACE: @exportClass RaggedArray > > I'm not sure if the exact issue here, but you could look at this package > that I wrote: > >

[Rcpp-devel] Using an Rcpp module package in an R Reference Class

2014-10-14 Thread Christian Gunning
Dear all, I have a working package that uses the Rcpp module mechanism (my RaggedArray project, as per previous discussion), and a working pure-R reference class (RefClass) that does computation on a list-based ragged array. I'm unsure on how to integrate the RaggedArray module into the RefClass.

Re: [Rcpp-devel] Trouble with package unit test and sourceCpp()

2014-09-27 Thread Christian Gunning
Thanks. I ended up using RcppParallel as my guide and finally got everything working. On Fri, Sep 26, 2014 at 5:27 AM, Dirk Eddelbuettel wrote: > > Christian, > > On 26 September 2014 at 03:51, Christian Gunning wrote: > | This is a bit of a late response - I finally got bac

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2014-09-26 Thread Christian Gunning
throw a range_error in probs don't sum to ~1. Pull request is here: https://github.com/RcppCore/RcppArmadillo/pull/22 Best, Christian On Thu, Mar 28, 2013 at 11:18 PM, Christian Gunning wrote: > Dirk, > > See attached for minor edits related to Walker Alias method. Based on &g

Re: [Rcpp-devel] Trouble with package unit test and sourceCpp()

2014-09-26 Thread Christian Gunning
; eval -> eval -> sourceCpp WARNING: The tools required to build C++ code for R were not found. Please install GNU development tools including a C++ compiler. Execution halted Any thoughts? -Christian On Wed, Sep 3, 2014 at 4:23 AM, Dirk Eddelbuettel wrote: > > On 2 September

Re: [Rcpp-devel] Pass an Rcpp module object to a method belonging to another module from R?

2014-09-09 Thread Christian Gunning
> Below is a simplified example, with question marks where I'm not sure what > to do. I've tried accepting a pointer to A, playing with using XPtrs, and a > bunch of things which made far less sense, but so far no luck. As an addendum to others' comments... I've been working on a kinda-sorta simi

[Rcpp-devel] Trouble with package unit test and sourceCpp()

2014-09-02 Thread Christian Gunning
Dear all, I'm working on a package that includes a unit test that calls sourceCpp() to test a particular use-case. As in [1], test(".") works swimmingly, but check() and vanilla "R CMD check" fail with the ominous error "cannot open file 'startup.Rs': No such file or directory". If I understand

[Rcpp-devel] Rcpp::ListOf.size() returns signed int?

2014-09-01 Thread Christian Gunning
Minor implementation question - As a learning exercise, I'm working through g++ warnings. After reading SO posts r.e. int vs size_t, I've set all variables that hold or compare object size information to type std::size_t. This fixes compiler warnings for Vector.size(), which doxygen shows have re

Re: [Rcpp-devel] How to detach a package completely

2014-08-30 Thread Christian Gunning
Have you tried Hadley's devtools package? It probably has the best tools for auto-reloading packages. On occasion it will jam on me and I have to restart R, but most times load_all("Hello", recompile=T) should do what you want. ---Christian Quote: Dear everybody I apologize whether this question

Re: [Rcpp-devel] Blog post - optimizing ragged arrays in R and Rcpp

2014-07-06 Thread Christian Gunning
gt; Hi, > > On 3 July 2014 at 21:27, Christian Gunning wrote: > | I just posted a short article on ragged arrays in R and Rcpp (it will > | also be auto-posted to R-bloggers). I've tried to be as comprehensive > | as possible in discussing the problem background, as well as pr

[Rcpp-devel] Blog post - optimizing ragged arrays in R and Rcpp

2014-07-03 Thread Christian Gunning
faced this problem, and if there are prior solutions that I've overlooked. http://helmingstay.blogspot.com/2014/07/computational-speed-is-common-complaint.html Best, Christian Gunning University of New Mexico -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a

Re: [Rcpp-devel] Speed up of the data.frame creation in DataFrame.h

2014-06-08 Thread Christian Gunning
> Subject: Re: [Rcpp-devel] Speed up of the data.frame creation in > DataFrame.h > Message-ID: <757ef798-6bc6-4150-93cd-b5f23d901...@gmail.com> > Content-Type: text/plain; charset=windows-1252 > > The fix I was proposing actually has implications much deeper than I thought. > I would need

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2013-04-12 Thread Christian Gunning
Johnathan, Thanks for formatting this, it looks great. I've added the case of without replacement, and a brief discussion of Walker's alias (that depends on the SVN version of RcppArmadillo, r4296), confirmed that it works with a local install of jekyll, and pushed it back to your github repo. Ca

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2013-03-28 Thread Christian Gunning
Dirk, See attached for minor edits related to Walker Alias method. Based on the timing tests from the gallery draft and discussion with Johnathan, we decided it was a bad idea to include code that deviates from R's behavior, and is slower than R to boot. Thus, the C++ sample now throws an inform

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2013-03-11 Thread Christian Gunning
Dirk (and list for reference), On Sun, Mar 10, 2013 at 6:16 PM, Dirk Eddelbuettel wrote: > > Christian, Jonathan, > > On 8 March 2013 at 20:42, Christian Gunning wrote: > | With some helpful prodding from Jonathan, I sat down with the sample > | code today. I moved sample.h

Re: [Rcpp-devel] S3 methods with cppFunction/sourceCpp

2012-12-27 Thread Christian Gunning
be to pass env > = NULL to cppFunction which will result in the function being returned > rather than added to the calling environment. You could then wrap the > returned function in an appropriately named S3 function. Cool, that makes sense. Thanks for the quick reply! -Christian > J.J.

[Rcpp-devel] S3 methods with cppFunction/sourceCpp

2012-12-27 Thread Christian Gunning
I just realized that cppFunction can't natively build S3 functions, since fun.class isn't valid C++ function name. I'm wondering if adding and S3class argument (default value = FALSE, otherwise class name as character) to cppFunction makes sense -- all that's needed is appending the class name

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-12-25 Thread Christian Gunning
35 AM, Dirk Eddelbuettel wrote: > > On 15 November 2012 at 04:00, Christian Gunning wrote: > | | Also, you may need to add RNGScope() if you use R's RNG. > | | > | | > | | > | | Yes, I should have mentioned that in my post. Calling RNGScope() is &

Re: [Rcpp-devel] Rcpp internal benchmark tool

2012-12-09 Thread Christian Gunning
> | I haven't seen any discussion on this in a while. Is this something > | that warrants discussion, or something to keep in mind for later? > | I'd prefer such a package to depend on RcppArmadillo so that my > | implementation of sample() can be easily included. Are there > | downsides to this?

Re: [Rcpp-devel] Rcpp internal benchmark tool

2012-12-08 Thread Christian Gunning
> On 8 December 2012 at 15:44, Romain Francois wrote: > | I've been using the microbenchmark package extensively and took > | inspiration from it to implement a Timer class in Rcpp to measure > | performance at a lower level. Very exciting. > > That's probably quite useful. I had an older/simpler

[Rcpp-devel] R.e. "No matching function for call to as(double&)" error at compile time

2012-12-06 Thread Christian Gunning
> /* up to the above line, everything compiles. > Now I want to get a double out from first element of test.*/ > > double test0 = Rcpp::as(test[0]); Does this work? double test0 = test[0]; In general, including a self-contained minimal example helps. sourceRcpp() makes this trivial. -Christian -

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-05 Thread Christian Gunning
Can you post a minimal full example? -Christian On Tue, Dec 4, 2012 at 8:39 PM, Honglang Wang wrote: > Yes, the main issue for my coding is the allocation of memory. And I have > fixed one of the biggest memory allocation issue: 4000 by 4000 diagonal > matrix. And since I am not familiar with Rc

Re: [Rcpp-devel] How to increase the coding efficiency

2012-12-04 Thread Christian Gunning
What exactly do these timings show? A single call you your function? How many calls? Building on Romain's point: -- a portion of your function's runtime is in memory allocation (and you have a lot of allocations here). If you're calling your function thousands or millions of times, then it might

Re: [Rcpp-devel] Rcpp advocacy question -- build environment

2012-11-28 Thread Christian Gunning
Thanks all for the helpful comments. Personally I've found the uniformity provided by Rstudio a great aid in teaching environments. I've struggled with introducing Rcpp to folks, and I agree these developments are very exciting. > And I say all that with the affection I personally have for Emacs

Re: [Rcpp-devel] Rcpp advocacy question -- build environment

2012-11-27 Thread Christian Gunning
On Tue, Nov 27, 2012 at 3:29 AM, JJ Allaire wrote: > > RStudio has been adding support for sourceCpp recently (preview version > here: http://www.rstudio.com/ide/download/preview). One feature particularly > helpful for students new to C++ is that for failed compilations the GCC > error log is par

[Rcpp-devel] Rcpp advocacy question -- build environment

2012-11-26 Thread Christian Gunning
Advice for introducing students to Rcpp: I'm TAing for a statistical programming class next semester, and I'm talking to the instructor about including Rcpp examples -- sourceCpp() makes this very easy to sell! The question is build environment for folks with windows machines. Personally, I think

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-11-15 Thread Christian Gunning
> > | Also, you may need to add RNGScope() if you use R's RNG. > | > | > | > | Yes, I should have mentioned that in my post. Calling RNGScope() is > left to > | the user, since multiple calls to sample() can conceivably happen inside > a > | single RNGScope(). > > With that, maybe best to be i

Re: [Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-11-14 Thread Christian Gunning
On Wed, Nov 14, 2012 at 6:14 AM, Dirk Eddelbuettel wrote: > > Thank you, got both emails! Will take a closer look -- we were busy with > releasing Rcpp 0.10.0 which will rock :) > Sorry, I posted to list from wrong address; 0.10.0 looks great. I found the copious informational links at the bot

[Rcpp-devel] Sample function(s) for inclusion in RcppArmadillo

2012-11-14 Thread Christian Gunning
Rcpp/Armadillo equivalent to R's sample(). // This is to be used in C++ functions, and should *not* be called from R. // It should yield identical results to R in most cases // (note that Walker's alias method is not implemented). // // Copyright (C) 2012 Christian Gunning // // This file

Re: [Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-11-04 Thread Christian Gunning
> > Update -- I've implemented all of R's sample (with identical results) > > except for the walker alias method. I used Armadillo for > ProbSampleReplace > > and ProbSampleNoReplace, since there's no good STL replacement for R's > > revsort. > > Out of curiosity, what does revsort do? It must be

Re: [Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-11-03 Thread Christian Gunning
get a chance. If anyone wants this in the meantime, I can email the source as a package that contains some example glue and unit tests. best, Christian On Sat, Nov 3, 2012 at 4:52 AM, Christian Gunning wrote: > Dear all, > > Code for uniform sampling is below, following the prototype

[Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-11-03 Thread Christian Gunning
Dear all, Code for uniform sampling is below, following the prototype from earlier post. Results/unit-tests (not included) are identical to R-core sample(). -Christian template T sample(const T &x, const unsigned int size, const bool replace ) { int ii, jj; int nOrig = x.size(); T

Re: [Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-11-02 Thread Christian Gunning
On Sun, Oct 28, 2012 at 2:28 AM, Christian Gunning wrote: > > I spent some time looking at this today. Guidance/advice on the best > approach here? Should I take that as a no? -Christian -- A man, a plan, a cat, a ham, a yak, a yam, a hat, a canal

Re: [Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-10-28 Thread Christian Gunning
On Sat, Oct 27, 2012 at 7:50 AM, Dirk Eddelbuettel wrote: > > > We make them look like STL containers by giving them begin(), > end(), ... member functions but they are still R objects ("SEXP") underneath. > > That means in particular that the carefully crafted STL algos with their > performance g

[Rcpp-devel] problem with sample() implemented in Rcpp/RcppArmadillo

2012-10-27 Thread Christian Gunning
> I am very new to c++ so I apologize in advance if this is a stupid question: I ran into this myself when I started using Rcpp -- it's a good question. The R API is extensive, but it's vanilla C and doesn't handle vectors (and you already know how to sample() a scalar, right?). > For a larger

[Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-20 Thread Christian Gunning
> What I would really do here is to create a simple struct or rather class that > upon initialization creates the workspace and holds it. > > Doesn't fit as easily in the inline paradigm though. Can one place object definitions in includes and then use them in the body? I'm rusty on inline -- I r

[Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Christian Gunning
> Giovanni, > > Anything you pass from R into your C++ routine should be considered > read-only. It's typically a bad idea to do in-place updates of the R > object you passed in as an argument. Really? I was under the impression that the ability of in-place modification was a conscious design dec

[Rcpp-devel] How to modifying the elements of a list in the global environment?

2012-10-19 Thread Christian Gunning
>> ### For the Rcpp part, set aside working space in the global environment >> workspace <- lapply(1:K, function(k) matrix(0.0, N, M)) > > Then I try to access the matrices in the 'workspace' list and modify them, > but so far I have had no success. The first attemp, bolow, does not compile... > >

[Rcpp-devel] Correlation in ArmadilloRcpp with missing values (nan)

2012-10-10 Thread Christian Gunning
> Maybe I am not good in coding, but even though I managed to make uvec with > ones and zeros, I cannot use it to select rows in given column, compiler > complains > error: no matching function for call to > ?arma::Mat::submat(arma::uvec&, int&)? Take a second look at the docs. From http://arma.

Re: [Rcpp-devel] NA value for dates

2012-10-06 Thread Christian Gunning
+1 > I would LOVE to offer assistance, but I don't think I can do much - my C/C++ > knowledge is fairly limited. Seems to me like you're doing pretty well so far! As often as not, identifying the *location* of the problem is the hardest part. > I checked out Rcpp's src/Date.cpp . It seems all t

[Rcpp-devel] Three-dimensional vectors example

2012-09-25 Thread Christian Gunning
On Tue, Sep 25, 2012 at 3:00 AM, wrote: > > Someone just asked on StackOverflow about creating 3d arrays: > http://stackoverflow.com/questions/12569992/constructing-3d-array-in-rcpp > > The best I could come up with is below. Did I miss something better? > > Full disclosure: The last I needed this

Re: [Rcpp-devel] NumericVector Double mismatch when indexing an array

2012-09-25 Thread Christian Gunning
> Indeed, changing the sample size from 5 to 500 results in; For completeness, I've included an iterator example, tested over a range of sample sizes, and plotted the results with the code below. From where I sit, it looks like the relative timings flatten out (more or less) at 1e4. I'm not sure

[Rcpp-devel] Runtime debugging tips for package/module?

2012-09-14 Thread Christian Gunning
I've successfully compiled/installed a package built with Rcpp.package.skeleton(module=T). The C++ codebase is larger and more complex than I'm used, and I'm now in the testing/runtime-debugging phase. I'm wondering what "standard" runtime debugging tools are available for errors that don't cause s

Re: [Rcpp-devel] Unit Test Question Was: pnorm/qnorm?

2012-09-13 Thread Christian Gunning
On Thu, Sep 13, 2012 at 9:20 AM, Dirk Eddelbuettel wrote: > > I am firmly in the 'Don't do '=' for assignment, ever' camp. > > | Is there any real downside to this habit? It came up at the BioC > | conference developer day this year and was more or less immediately > | dismissed. > > Just say no.

Re: [Rcpp-devel] Unit Test Question Was: pnorm/qnorm?

2012-09-13 Thread Christian Gunning
On Wed, Sep 12, 2012 at 7:59 AM, wrote: > > The "pixie dust" referred to your assertions that we "used some secret tools" > or "were hiding something". > > Neither one is true. It's all there. It's just damn hard to read. But it's > not hidden... I'm officially of the opinion the template code

Re: [Rcpp-devel] Exposing R through C++

2012-09-12 Thread Christian Gunning
>I understand that I cannot use Visual Studio compiler to build code written in >C++ that uses Rcpp header files. Assuming this is the >case, what are the >other options that I have to be able to code in C++ which either internally >uses Rcpp sugar for R functionality or >implements its own meth

Re: [Rcpp-devel] Trouble passing arguments to R functions that have been passed in (maybe)

2012-09-11 Thread Christian Gunning
On Tue, Sep 11, 2012 at 3:00 AM, wrote: > > It seems to be the casethat when the memory issue occurs, garbage > collection has just been called by R, at least according to gcinfo.In > particular, it is called when bar is called and cleans up the arguments > that bar is about to use, thus causing a

Re: [Rcpp-devel] Filling a list with iterator, or setting names from CharacterVector/SEXP?

2012-09-07 Thread Christian Gunning
> | Can I use as() and then iterate over the CharacterVector? > > Sure, works via Rcpp::as< std::vector< std::string> >(foo) Perfect, thanks. Revised example included below for reference. > I am not sure what it is that you want but if you look e.g. at RcppExamples > and its examples related t

Re: [Rcpp-devel] Filling a list with iterator, or setting names from CharacterVector/SEXP?

2012-08-31 Thread Christian Gunning
On Fri, Aug 31, 2012 at 5:50 AM, Dirk Eddelbuettel wrote: > > Yes -- I needed this the other day to return what I got in C++ as a > std::vector vecstr. I used something like > > Rcpp::CharacterVector charvec( vecstr.begin(), vecstr.end() ) Ok, I was wondering about std::vector. But how

Re: [Rcpp-devel] Filling a list with iterator, or setting names from CharacterVector/SEXP?

2012-08-30 Thread Christian Gunning
2012 at 9:52 PM, Christian Gunning wrote: > > > using namespace Rcpp ; > class World { > public: > World(SEXP my_) : my(my_) { > mynames = my.attr("dimnames"); > CharacterVector rownames = mynames[0]; > nrows =

[Rcpp-devel] Filling a list with iterator, or setting names from CharacterVector/SEXP?

2012-08-30 Thread Christian Gunning
I'm trying to implement a class lets me access elements by name in the actual C++ code. I'm handing in a matrix from R, and using the colnames and rownames of the matrix to generate a named list containing the relevant indices. My main interest here is legible code -- I'm trying to set up user-modi

Re: [Rcpp-devel] Very Large Matrices in RcppArmillao

2012-07-17 Thread Christian Gunning
On Tue, Jul 17, 2012 at 12:50 AM, Christian Gunning wrote: > On Mon, Jul 16, 2012 at 10:30 PM, > wrote: >> 2. I have found in the past that some of the speeds gains from >> RcppArmadillo in comparison to pure R are lost when passing large matrices >> as argument

Re: [Rcpp-devel] Rcpp-devel Digest, Vol 33, Issue 8

2012-07-08 Thread Christian Gunning
> On 7 July 2012 at 17:05, Joshua Wiley wrote: > | Thank you so much! That worked and helped me understand why it was > | happening :) The idea of pointers is new to me so I think I need to > | spend more time learning about that. There's a nice cheatsheet here that points out some gotchas and n

Re: [Rcpp-devel] can one modify array in R memory from C++ without copying it?

2011-11-02 Thread Christian Gunning
On Wed, Nov 2, 2011 at 4:00 AM, wrote: > > > 1. in my previous post  i used exactly that same constructor you are > talking about as you can see from the code i posted Sorry about that, completely missed it... Using what's below, this should work fine. > 3. i am not 100% sure but this toy test t

Re: [Rcpp-devel] can one modify array in R memory from C++ without copying it?

2011-11-01 Thread Christian Gunning
On Tue, Nov 1, 2011 at 9:11 PM, wrote: > >> .Call("modify", m) >> m >     [,1] [,2] [,3] [,4] [,5] > [1,]    1    3    5    7    9 > [2,]    2    4    6    8   10 > > > It didn't segfault, but the memory in R process didn't change as you see, > although the matrix in armadillo code doubled. Which

Re: [Rcpp-devel] One main needs to call a few other functions

2011-10-21 Thread Christian Gunning
On Thu, Oct 20, 2011 at 7:58 PM, wrote: > to me the concern exists whether the other > function is in a package or not, how would a call be made to an outside > compiled object code from within Rcpp. This is a pretty confusing sentence(s). Clearer questions tend to elicit clearer answers :) > M

Re: [Rcpp-devel] C++ code for ordinary differential equations

2011-10-05 Thread Christian Gunning
> Tst tst tst: You're loosing your Debian/Ubuntu instincts: > > edd@max:~$ wajig search sundials > libsundials-cvode1 - ordinary differentialequation solver (SUNDIALS library) ... > edd@max:~$ > > Bingo, another Rcpp project in the making :) Now wait just a sec -- with the powers of apt-cache sear

[Rcpp-devel] R.e. Is it C++ or Rcpp problem?

2011-09-23 Thread Christian Gunning
On Fri, Sep 23, 2011 at 3:00 AM, wrote: > > You don't need a makefile for the kind of minimal example you'll post to > a mailing list, so: >  1. Slap your code in a file called tmp.cpp. >    (Don't forget header includes.) > >  2. Whiz to a shell, in that directory. > >  3. Dramatically type: >  

Re: [Rcpp-devel] R.e. is std::sort function broken??

2011-09-22 Thread Christian Gunning
> You know nothing about my application, size or data, or other transformation > on the data. Well, that's because you didn't tell me (us) anything about any of the above. I was simply commenting on the code that you posted, which was all that I could see, not being a mind-reader myself. > To ma

[Rcpp-devel] R.e. is std::sort function broken??

2011-09-22 Thread Christian Gunning
I think this is the current prize-winner of inappropriate use of Rcpp... How about using R to sort your vector?! This isn't really an Rcpp question, but since you asked, .push_back() is a great way to slow yourself down. hth :) -xian On Thu, Sep 22, 2011 at 3:00 AM, wrote: > >        body=" >  

Re: [Rcpp-devel] arma::mat and Rcpp::NumericMatrix

2011-09-16 Thread Christian Gunning
Jeff, A few random comments in addition to Dirk's sound advice: 1. I recommend using bigger matrices for testing just to get a feel. For testing loop speed, you want the proportion of loop time to be *very high* compared to the R interpreter overhead, resolution of your timer, etc. Here, the e

Re: [Rcpp-devel] Data Persistence with Rcpp

2011-09-08 Thread Christian Gunning
On Wed, Sep 7, 2011 at 3:13 PM, wrote: >  The question absolutely pertains to using the inline functionality. I think this is a reasonable R/C++ question -- i.e. Rcpp. inline is more or less orthogonal to Rcpp. inline is a great Rcpp jump-starter. > As each new data arrives, I want to pass it

Re: [Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

2011-09-01 Thread Christian Gunning
On Thu, Sep 1, 2011 at 5:13 PM, Dirk Eddelbuettel wrote: > Uh-oh. Factor 10. Wow. Yeah, huh? To be fair, this example is ultra-contrived. The *only* thing that happened was indexing. Is it possible that compiler magic (ala loop unrolling that isn't done for () ) accounts for any of the speedup?

Re: [Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

2011-09-01 Thread Christian Gunning
On Thu, Sep 1, 2011 at 9:19 AM, Dirk Eddelbuettel wrote: > > > I think (but feel to free me wrong by looking at headers and code :-) that > operator() and operator[] do the same thing. I see a huge difference in this set of examples ( which are painfully repetitive on many levels) that are identi

[Rcpp-devel] R.e. First foray into Rcpp and comparison of speed with R

2011-09-01 Thread Christian Gunning
> In R I was able to > vectorize all within line computations, but in C++ I have to use explicit > looping, right? At a glance, I don't see any glaring speed-related flaws. Honestly, I'm curious to see what the R version of the Compute looks like. Others might advise on the use of iterators... >

Re: [Rcpp-devel] shallow/deep copy

2011-08-31 Thread Christian Gunning
On Wed, Aug 31, 2011 at 3:00 AM, wrote: > > Rcpp::NumericVector x = as(x_); > std::vector x = as< std::vector >(x_); Nice clarification of what's going on under the hood, Darren. For the first case, the above is synonymous with: Rcpp::NumericVector x(x_); If you want a deep copy, you can use:

Re: [Rcpp-devel] Pointer troubles

2011-08-18 Thread Christian Gunning
> Comment: A concise example that uses an XPtr in a C++ function is > still lacking. Sorry I missed Manuel's example when I last posted. I guess I was thinking something like below, which is a direct analog of apply. This concisely mirrors the semantics in RcppDE (interchangable work function for

Re: [Rcpp-devel] R.e. Speed gain assistance (Wray, Christopher)

2011-08-18 Thread Christian Gunning
On Thu, Aug 18, 2011 at 7:57 AM, Hadley Wickham wrote: >> Take a look at this (unweighted) sample() function.  It's giving R a >> run for it's money, and is pretty fast even for very large n, and it >> looks statistically correct (not sure if I'm glossing over ugly, >> machine-specific details of

Re: [Rcpp-devel] R.e. Speed gain assistance (Wray, Christopher)

2011-08-18 Thread Christian Gunning
> No probs - and sorry for the unclear post! Thanks No worries. There are some important points here, some that have been raised repeatedly. On Thu, Aug 18, 2011 at 7:57 AM, wrote: > > R> (1:50)[runif(10,0,20)] > > And I was wondering if I had missed some sugar-type of construct that would > al

[Rcpp-devel] R.e. Speed gain assistance (Wray, Christopher)

2011-08-18 Thread Christian Gunning
There's a number of things going on in your example. Are you sure that sample() is the bottleneck? You might want to try breaking this into smaller pieces and benchmarking each with rbenchmark. On Wed, Aug 17, 2011 at 3:00 AM, wrote: > > I have thought (but not tried) importing R's sample funct

Re: [Rcpp-devel] Overloaded constructors?

2011-08-11 Thread Christian Gunning
> class A { > public: > A(int argument) {} > A(std::string name) {} > }; > > Now, given such a class - is there a way to distinguish the two constructors? > The way I understand the code in the Rcpp module is to allow for different > constructors with different numbers of arguments, but overloade

Re: [Rcpp-devel] Pointer troubles

2011-08-04 Thread Christian Gunning
Q: In latex code after quote, I've highlighted the new/free/finalizer issue (adapted from Romain). Alternately, this code (again, Romain's) highlights passing an SEXP to XPtr<...>. It seems that one or the other should be primary. SEXP doubleIntPointer(SEXP test){ XPtr test2(test) ; retu

Re: [Rcpp-devel] Pointer troubles

2011-08-03 Thread Christian Gunning
On Wed, Aug 3, 2011 at 10:22 AM, wrote: > Simple examples are in a demo file in the > package, see demo(CompiledBenchmark) -- or more importantly, see its source > and the RcppDE source. I'm now cobbling together a small XPtr section in Rcpp-quickref based on these 2 related threads, which have b

Re: [Rcpp-devel] Short blog post on loop speed in R

2011-06-23 Thread Christian Gunning
On Sun, Jun 19, 2011 at 11:20 AM, Douglas Bates wrote: > > > As for the use of Rcpp, the STL containers and algorithms can be > exploited to an even greater extent.  If you are willing to jump > through the hoops of defining a struct that inherits from > std::binary_function then you can shorten t

[Rcpp-devel] Short blog post on loop speed in R

2011-06-18 Thread Christian Gunning
Dear all, I haven't been able to keep up with the list this month (I'm looking forward to catching up on the Module developments), but I just posted this, which might be of interest to some. http://helmingstay.blogspot.com/2011/06/efficient-loops-in-r-complexity-versus.html If anyone has a few s

Re: [Rcpp-devel] redimension help

2011-06-08 Thread Christian Gunning
> I have developed a function that builds a series of vectors and a matrix > of undetermined size. ?Rather than attempt dynamic objects (which I > wouldn't know how to do anyway) I have been able to initialize with row > dimensions that cannot be exceeded on these objects. If this is your goal, I

Re: [Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?

2011-06-06 Thread Christian Gunning
> At the moment the only way i see is to make an R call to "new" and construct > the object this way... >> Many of the methods for this class return other members of this class. >> Can I create a new instance of the reference class in R from within >> the module? I'm sure it is possible, I'm jus

Re: [Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?

2011-06-03 Thread Christian Gunning
> At the moment the only way i see is to make an R call to "new" and construct > the object this way... >> Many of the methods for this class return other members of this class. >> Can I create a new instance of the reference class in R from within >> the module?  I'm sure it is possible, I'm jus

[Rcpp-devel] R.e. Fwd: problem with rmultinom function

2011-05-31 Thread Christian Gunning
On Tue, May 31, 2011 at 10:55 AM, wrote: > Hi, > I sent this message a couple of days ago, but I haven't heard anything yet. > I think you didnt receive it, that's why I send it again. I didn't see anything. If you're not subscribed to the list, submissions silently fail. Plus, you must send fr

  1   2   >