Re: [Rcpp-devel] DataFrame::create() in endless loop

2012-02-28 Thread Darren Cook
s back to your C++ code at a later stage, isn't it? I.e. not a solution if you wanted to manipulate the data in R. (I'm asking here in case I've misunderstood the scope of its purpose.) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my

[Rcpp-devel] Internals: how does DataFrame get initialized?

2012-02-28 Thread Darren Cook
_8h_source.html [3]: http://dirk.eddelbuettel.com/code/rcpp/html/DataFrame_8h_source.html -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel m

Re: [Rcpp-devel] Internals: how does DataFrame get initialized?

2012-02-28 Thread Darren Cook
gt; TIA, >> >> Darren >> >> >> [1]: Extracted from: >> >> http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-January/003345.html >> >> >> [2]: >> http://dirk.eddelbuettel.com/code/rcpp/html/Named_8h_source.html >> http:/

Re: [Rcpp-devel] Internals: how does DataFrame get initialized?

2012-02-29 Thread Darren Cook
Rcpp/DottedPair.h?view=markup&root=rcpp [3]: Another way of saying that is that it seems I could move all DottedPair's functions into Robject, then write: class DottedPair: public Robject {} and everything should still compile and work. (Or I've misunderstood something :-)

Re: [Rcpp-devel] Problem with RInside "hello world" example

2012-05-22 Thread Darren Cook
think default locations for all R packages), but it gives you an idea of what you're missing. Darren P.S. In that same directory I've also a rather long Makefile that describes itself as a "simple Makefile". It doesn't look like I wrote it; I guess it is from the RIn

Re: [Rcpp-devel] multidimensional arrays

2012-06-15 Thread Darren Cook
u are an R expert, write the R version first. Don't assume C++ will be quicker. Inexpertly written C++ can be slower than the same code in interpreted languages. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.or

Re: [Rcpp-devel] Rcpp and inline, compiler configuration errors, windows 7

2012-07-03 Thread Darren Cook
ing. Consult the user's > guide for more details about POSIX paths: > http://cygwin.com/cygwin-ug-net/using.html#using-pathnames g++: not > found -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs

Re: [Rcpp-devel] link issue when Rcpp package is installed in a path with space

2012-07-17 Thread Darren Cook
I spend a lot of time with web-facing code, these space problems on Windows R mean something isn't being quoted properly, and that implies a potential security exploit. (Thankfully I've not needed R on Windows, yet, touch wood...) Darren -- Darren Cook, Software Researcher/Developer htt

Re: [Rcpp-devel] Rcpp:wrap - any limitations for vector s ize?

2012-08-09 Thread Darren Cook
/stat.ethz.ch/R-manual/R-devel/doc/html/NEWS.html and scroll down to the LONG VECTORS section. Also see: http://developer.r-project.org/216update.txt Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blo

Re: [Rcpp-devel] How to manage testing code for Rcpp based project?

2012-08-21 Thread Darren Cook
han phpUnit, JUnit, etc. (If you want to discuss how I think RUnit could be improved, private email please.) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles)

Re: [Rcpp-devel] How to manage testing code for Rcpp based project?

2012-08-21 Thread Darren Cook
xperience the software industry has with the xUnit approach.) Darren [1]: http://www.johnmyleswhite.com/notebook/2010/08/17/unit-testing-in-r-the-bare-minimum/ -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/bl

Re: [Rcpp-devel] RInside destructor not working properly?

2012-08-27 Thread Darren Cook
a "nothing we can do about" reason why RInside works the way it does. So I wonder if you can create a global RInside instance using a global test environment call? http://code.google.com/p/googletest/wiki/AdvancedGuide#Global_Set-Up_and_Tear-Down Darren -- Darren Cook, Software Researc

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

2012-09-12 Thread Darren Cook
; pre-processor macro and C++ template code (AKA magic pixie dust) in > PREFIX/lib64/R/library/Rcpp/include/Rcpp/stats/dpq/dpq.h If this was StackOverflow, that would definitely get my upvote. The Rcpp sugar code is jolly hard to work through. Darren -- Darren Cook, Software Researcher/Deve

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

2012-09-13 Thread Darren Cook
post, I blogged my answer: http://darrendev.blogspot.jp/2012/09/vs-in-r.html Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcp

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

2012-09-25 Thread Darren Cook
>> benchmark(fun1(), fun2(), fun3(), fun4(), order = "relative", > replications = 1e5L) > test replications elapsed relative user.self sys.self user.child > sys.child > 4 fun4() 106.161.000 6.060 NA > NA > 3 fun3() 106.191.005 5.91

Re: [Rcpp-devel] Fwd: Stack Overflow Question

2012-10-10 Thread Darren Cook
> Garret said that its too "localized", in his post of SO, what he means > with this? It can be a problem of my code or it has to be a problem with the > system I'm > running the program? It could be your system, or it could be a bug in your code that only affects your system. It could be the Rcp

Re: [Rcpp-devel] R/Rcpp/RcppEigen Optimization WAS: NumericVector Double mismatch when indexing an array

2012-10-23 Thread Darren Cook
amdfam100.5 > RcppEigen-O2 -march=amdfam100.013 Wow, those are huge differences. Am I misreading, or does that say RcppEigen runs *seven* times quicker with the -march=amdfam10 option? Can that be explained? (e.g. does the AMDFAM10 processor have some feature that speeds it up 7

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

2012-11-04 Thread Darren Cook
> 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 something bey

Re: [Rcpp-devel] [ANN] RInside 0.2.9

2012-11-06 Thread Darren Cook
you have code that can throw you cannot use the no-throw variant > as you would end up with undefined behaviour. Hello Dirk, Where would you choose to use parseEvalQNT() instead of parseEvalQ()? (I.e. even if you were 100% sure your code would never throw, does parseEvalQ() have a downside?

Re: [Rcpp-devel] [ANN] Rcpp 0.10.0

2012-11-14 Thread Darren Cook
Hello Dirk, Romain, JJ, Very interesting-looking new release. Thank-you for all your efforts! > Rcpp attributes derive their syntax from C++11 style attributes ... Does this depend on g++ and/or c+11 support? Or do you the do the parsing yourself? Darren -- Darren Cook, Software Researc

Re: [Rcpp-devel] Rcpp 0.10.0

2012-11-14 Thread Darren Cook
gt; > It is worth making a few tests with some dummy classes that prints on > copy constructor to see how many times it is used, etc ... -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) __

Re: [Rcpp-devel] Rcpp "version" of R's match function

2012-11-16 Thread Darren Cook
> I agree that we might want to have these things in a package say RcppBase. > Then Rcpp can remain the R to cpp layer. And anybody who want to implement > an R base function in cpp, can contribute it to RcppBase. Sounds like a good idea, except for the naming (which makes it sound like the Rcpp b

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-19 Thread Darren Cook
> The example is not particularly well chosen, but I think the problem > of vectorisation is a real one. To vectorise code in R you need to > have a big R vocabulary; to vectorise code in Rcpp, you need to be > able to write a loop. So even if it's a not a completely fair > comparison to R, it's

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-19 Thread Darren Cook
> * vacc3: vectorised with loop in C++ I shaved a bit off this with a simple micro-optimization. In vacc3a replace: p = std::max(p, 0.0); p = std::min(p, 1.0); with: if(p<0.0)p=0.0;else if(p>1.0)p=1.0; //Clip I called it vacc6, and a couple of runs are shown below. It is worth about 4-5%

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
t; I'm thinking of naming it pminmax. Any better idea ? I'd expect a function called minmax() to return two values, the min and max function. The "p" prefix is too subtle for me :-) How about clip(): p = clip(p, 0.0, 1.0); This is such a common operation that I'm su

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
ons relative to the number of memory-accessing operations. Your mapply(...,FUNCTOR) version, on the other hand, should be able to be as quick as vacc3(), shouldn't it? Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blog

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
> I believe that such a function is normally called "clamp". I'd not heard that before; is that the mathematical word for it? (clip is terminology from graphics programming, where a clipping rectangle is another word for a window or viewport) Darren __

Re: [Rcpp-devel] R vectorisation vs. C++ vectorisation

2012-11-21 Thread Darren Cook
> > http://en.wikipedia.org/wiki/Clamping_(graphics) Thanks Dirk. Compare with http://en.wikipedia.org/wiki/Clipping_%28computer_graphics%29 and it seems my use of the word clip was a bit sloppy. So, yes, clamp() does seem like the more suitable name. Darren -- Darren Cook, Software Rese

Re: [Rcpp-devel] A beginners guide to Rcpp

2012-11-29 Thread Darren Cook
> Rcpp is a worthwhile effort and your work is admirable, but > it is not perfect. ... (if you care about that, of course). I think Dirk's point was that this is an interesting topic, but this list is the wrong place for discussing it. (Dirk, I couldn't track down the r-devel discussion you ment

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

2012-12-05 Thread Darren Cook
how many learnings you get from the process) :-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.

Re: [Rcpp-devel] Error when trying to your piSugar example

2013-01-12 Thread Darren Cook
> [ Little rant: I find it fexing how the R-on-Windows FAQ said for years "do > not install in a path with spaces"... > We tried to tackly this issue once by making the path quote-safe but > failed. Hello Dirk, Do you remember why it failed? It does look as simple as putting double quotes around e

Re: [Rcpp-devel] Matkov chain simulation with Rcpp

2013-02-03 Thread Darren Cook
> The main problem for me is the "sample" function of R, which I could not > implement in Rcpp. A "sample" function was discussed here recently, e.g. http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-December/005025.html (But it has a dependency on RcppArmadillo, which might be undesi

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-11 Thread Darren Cook
s header-only, and the boost license was designed to be liberal. So embedding just the parts of Boost.Random that you need in Armadillo is a possibility. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html

Re: [Rcpp-devel] Mersenne Twister in RcppArmadillo?

2013-02-14 Thread Darren Cook
> It runs in parallel does not mean it works correctly. BTW, the O'Reilly Parallel R book mentions random number generation in quite a few places. Reading it, you really feel nostalgic for the simple life of good 'ole single-threaded random number generators :-) Darren __

[Rcpp-devel] Admin: add reply-to headers?

2013-03-30 Thread Darren Cook
copy and paste. I.e. I have to jump through one more loop to reply off-list. -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list

Re: [Rcpp-devel] Consuming power of R outines through C++

2013-06-17 Thread Darren Cook
C++, that Rcpp will be more to your taste. It is real C++, and real R... the downside being you get the learning curve of both ;-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blog

Re: [Rcpp-devel] macros RCPP_FUNCTION_...,

2013-06-18 Thread Darren Cook
> This is an opportunity for a quick diet. Just before the summer. Looking good in a bikini is always important. :-) That no-one uses it in any CRAN package is also compelling. (I just searched on StackOverflow and no mention there either.) Dirk wrote: >> APIs are contracts we have with users.

Re: [Rcpp-devel] simple Rcpp function produces: "AddressSanitizer: attempting free on address which was not malloc"

2013-07-08 Thread Darren Cook
> The C++ function, though, is quite simple -- I wonder if anyone might be > able to spot easily what is going on? > ... > double Cnm; > Cnm = nChoosek(*n, *m); > ... > int* combmat; > combmat = new int[(int)Cnm**(m+0)]; I'm not sure if this is the cause of the complaint, but i

[Rcpp-devel] OT: Boost NT

2013-10-14 Thread Darren Cook
operations that are automatically parallelized. I'd be interested to hear from the experts here if it is something that could usefully be made to work with Rcpp, or if it is perfect subset of what can already be done with Rcpp and R. Darren -- Darren Cook, Software Researcher/Developer

Re: [Rcpp-devel] Rcpp Makevars COPYING policy?

2013-10-15 Thread Darren Cook
> Intellectual property rights confuse the heck out of me so I wanted to ask > explicitly before stepping on any toes. Rcpp is GPL-2. However, the > Makevars in the ./src/ directory don't necessarily carry the same license > header as your Cpp source. What are your intentions for derivative use of

Re: [Rcpp-devel] xts inputs and outputs for Rcpp translation

2014-02-06 Thread Darren Cook
ith a few attributes attached. (Or a NumericVector if it is a single-column xts object.) If you've never poked around in xts internals this is probably going to be a bit painful ;-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.

Re: [Rcpp-devel] Mailing list scope (was: Distribution of Rcpp codebase)

2014-04-08 Thread Darren Cook
> I though this mailing list was about discussing R and C++, but > apparently I was wrong. Fair enough if this is just Rcpp related. > Perhaps I’ll leave the mailing list as I’m not that interested in > Rcpp anymore. If you start a new mailing list, whether specifically for Rcpp11, or on the gener

Re: [Rcpp-devel] g++ flags

2014-04-30 Thread Darren Cook
are still available. Darren -- Darren Cook, Software Researcher/Developer My new book: Data Push Apps with HTML5 SSE Published by O'Reilly: (ask me for a discount code!) http://shop.oreilly.com/product/0636920030928.do Also on Amazon and at all go

[Rcpp-devel] Bug report: need to wrap return of sugar functions

2011-08-14 Thread Darren Cook
lt;14, true, Rcpp::Vector<14>, true, Rcpp::Vector<14> >, true, Rcpp::Vector<14> >’ to non-scalar type ‘Rcpp::NumericMatrix’ requested -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs an

Re: [Rcpp-devel] Bug report: need to wrap return of sugar functions

2011-08-15 Thread Darren Cook
e situations. Thanks for the reply. In that case I'm reporting a bug in the documentation :-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) _

[Rcpp-devel] Using C++0x in g++ changes ifelse behaviour

2011-08-15 Thread Darren Cook
7; Traceback: 1: .Primitive(".Call")(, x_) 2: fun(x) 3: print(fun(x)) 4: eval.with.vis(expr, envir, enclos) 5: eval.with.vis(ei, envir) 6: source("test4.R") -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my

Re: [Rcpp-devel] Bug report: need to wrap return of sugar functions

2011-08-15 Thread Darren Cook
w(),x.ncol()); > return y; > ' > fun=cxxfunction(signature(x_ ="integer"),src2,plugin="Rcpp") > print(fun(x)) > > === > does this do it for you Hello Christopher, Thanks for the suggestion. It works perfectly (I suspect some template magic could m

[Rcpp-devel] Code Refactor Proposal: exception specifiers

2011-08-15 Thread Darren Cook
ut not available until g++ 4.6) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://l

Re: [Rcpp-devel] Using C++0x in g++ changes ifelse behaviour

2011-08-15 Thread Darren Cook
gcc/Optimize-Options.html -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lis

Re: [Rcpp-devel] Code Refactor Proposal: exception specifiers

2011-08-15 Thread Darren Cook
pect them to be a compile-time check, that has no effect on run-time (*), but in reality they are the opposite: they are not used at compile-time, but are used at run-time.) Darren *: Which I think is how they work in Java? (My java is getting rather rusty.) -- Darren Cook, Software Rese

[Rcpp-devel] Parameter Naming (was: Speed gain assistance)

2011-08-18 Thread Darren Cook
in this. E.g. see "Rename Method" in Martin Fowler's Refactoring; "It's All Writing" in The Pragmatic Programmer (ch.8); etc. [2]: I realize many R functions are direct translations of mathematical functions, so calling a parameter "p" is not as meaningless as

Re: [Rcpp-devel] Parameter Naming

2011-08-23 Thread Darren Cook
th, or even for a one-off data import, I end up still maintaining 3 or 4 years later; I sometimes wonder if my clients are deliberately lying to me about their intentions ;-) -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and ar

Re: [Rcpp-devel] Parameter Naming

2011-08-23 Thread Darren Cook
P.S. I think it was obvious from the context that this version contained a typo but, just in case anyone was confused, it should've looked like: nearlyAsGoodDemo <- cxxfunction(signature(x_="integer"), plugin='Rcpp', body=' Rcpp::IntegerVector x(x_); return 2*x; ') Darren ___

[Rcpp-devel] Where is compileCode() ?

2011-08-23 Thread Darren Cook
, I just downloaded the R source code, and it is not in there either?! Darren [1]: libLFile <- compileCode(f, code, language = language, verbose = verbose) -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs

Re: [Rcpp-devel] Using C++0x in g++ changes ifelse behaviour

2011-08-23 Thread Darren Cook
> How to set g++ compiler flags using Rcpp and inline? > http://stackoverflow.com/q/7063265/841830 I've worked out, and added an answer to the above. In a nutshell, set settings$env$PKG_CXXFLAGS, where settings is the return of getPlugin("Rcpp"). (I set the answer as "community wiki", so othe

Re: [Rcpp-devel] RInside: compiling examples (ubuntu)

2011-08-25 Thread Darren Cook
lib64/R/" it still complains. I need to remove the trailing slash to appease it. -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel ma

Re: [Rcpp-devel] shallow/deep copy

2011-08-30 Thread Darren Cook
it is good, but I personally do it that way, without regret. -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-deve

Re: [Rcpp-devel] shallow/deep copy

2011-08-31 Thread Darren Cook
> Can I ask for specific reasons why people prefer explicit? Any potential > danger for not being explicit? Hello Zhongyi, It is hard to show in a toy example; in fact "using namespace" is best for code examples where you want to get an idea across and not cloud it with too much other code. But

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

2011-09-01 Thread Darren Cook
st of the effort. (Just seen Dirk's reply; I think what may be going on is that cache.ref(i) may get optimized to end up as a single pointer dereference, but the function call to offset() is too complex, so it ends up not even getting inlined.) Darren -- Darren Cook, Software Researcher/Develo

[Rcpp-devel] Best way to return raw array

2011-09-01 Thread Darren Cook
lts. E.g. mysample_cpp(10) [1] 1.0e+01 1.0e+01 1.0e+01 1.0e+01 1.0e+01 1.0e+01 6.74011e+199 1.0e+01 1.0e+01 1.0e+01 So, Q1: Was there no memory leak? I.e. R has taken control of my memory block and will delete it for me? Q2: Is this the best way to do it

Re: [Rcpp-devel] Best way to return raw array

2011-09-01 Thread Darren Cook
oing the above two while bypassing the ugly verbose code of the usual way to write R extensions. Or, in a sound bite: "Rcpp is not just for C++ newbies" ;-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Darren Cook
been allocated with a 'malloc', and > so you should release it with a 'free'? Good point :-) The legacy code API will tell me how it should be deleted. (With some APIs it will be a special function.) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/

Re: [Rcpp-devel] Best way to return raw array

2011-09-02 Thread Darren Cook
>> | double *p=third_party_function(nn); >> | NumericVector ret(p,p+nn); >> | delete p; >> | return ret; > What puzzles me is why Darren's original version doesn't work. Due to an embarrassing bug in my test code: delete should be delete[]. So, I think we can say these two idioms are equivalent:

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

2011-09-02 Thread Darren Cook
> There is a noNA() wrapper for Rcpp sugar to push performance -- NA checking > is implemented on access 'because that is how R does' (and our first task to > reproduce numbers you'd get at the R prompt) but if you know what you are > doing and are aware of possible pitfalls you can skip this. See

Re: [Rcpp-devel] Data Persistence when using inline

2011-09-07 Thread Darren Cook
> If the code was in pure C++, it would be trivial to have an object > and then just pass a pointer to that object. I can't figure out how > to do the same thing with R+Rcpp+inline. I asked myself a similar question a few weeks back (actually it came from one of the questions at the end of the go

Re: [Rcpp-devel] External pointer to an instance of a C++ class

2011-09-14 Thread Darren Cook
leting an instance of BigStrongMan with a Man* pointer. (It is fine to do this, just make sure the destructors are virtual, so that BigStrongMan's destructor can be called.) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.or

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

2011-09-22 Thread Darren Cook
> std::sort(data.front(), data.back()); front() and back() return references to the first and last items. I.e. they return doubles, not iterators. I think what you wanted was: std::sort(data.begin(),data.end()); Darren -- Darren Cook, Software Researcher/Developer h

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

2011-09-22 Thread Darren Cook
t;} >>std::sort(data.front(), data.back()); >>return Rcpp::wrap(data); -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___

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

2011-09-22 Thread Darren Cook
otes of additional information :-) Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-proje

Re: [Rcpp-devel] Creating a std::vector of objects with const members

2011-10-06 Thread Darren Cook
(Or better is vector of smart pointers, so you don't have to worry about memory management.) Or, define a copy constructor. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) __

Re: [Rcpp-devel] Question regarding integrating preexisting C++ code via Rcpp

2011-10-11 Thread Darren Cook
allest Possible Example would be very interesting to the Rcpp developers, I'm sure. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-de

Re: [Rcpp-devel] Question regarding integrating preexisting C++ code via Rcpp

2011-10-12 Thread Darren Cook
ee #include statements inside your function body? The cxxfunction has an includes parameter where you should put them. I think of "includes" as meaning "global stuff". So you could put your "using std::vector" line in there too (that is just a style difference, though). Also

Re: [Rcpp-devel] multiple function when using Inline

2011-10-20 Thread Darren Cook
=cxxfunction(signature(),src,plugin="Rcpp",includes=header) print(fun()) If you don't see what is happening, add verbose=TRUE to the cxxfunction call, and take a look at the source code that has been constructed. Darren -- Darren Cook, Software Researcher/Devel

Re: [Rcpp-devel] Picking off a matrix-valued list element inside a class constructor?

2011-10-23 Thread Darren Cook
omeone else knows the magic syntax? (For reference these were what I tried: m =Rcpp::IntegerMatrix(l["m"]); m =(Rcpp::IntegerMatrix)l["m"]; m.operator=(l["m"]); ) > [...] > private: > Rcpp::IntegerMatrix m; > } <-- NEED SEMI-COLON

Re: [Rcpp-devel] Picking off a matrix-valued list element inside a class constructor?

2011-10-24 Thread Darren Cook
>> i would advise using this as the ctor of CCC : >> >> CCC(Rcpp::List l) : m( l["m"] ) {} > > Thanks, Romain. Pardon my ignorance, but did you mean that I should use that > declaration literally, or was it merely intended to suggest the approach? This is the preferred way in C++ to initializ

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

2011-11-03 Thread Darren Cook
n r_m; >> ' >> >> require(inline) >> require(RcppArmadillo) >> myfun = cxxfunction(signature(mem='numeric'), src, plugin='Rcpp') >> >> ll <<- mm <<- matrix((1:10)/10, nrow=2) >> llint <<- mmint <<- matrix(

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

2011-11-04 Thread Darren Cook
> I.e. the point of his code was to show that a matrix of doubles gets > modified, a matrix of ints does not. Or change the first line from NumericMatrix to: Rcpp::IntegerMatrix r_m(mem); Then the behaviour is reversed. The matrix of doubles does not get modified, but the matrix of ints does!

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

2011-11-04 Thread Darren Cook
which means new > data, hence the original data does not get modified. > > If you pass a matrix of double, no copy is required, therefore Rcpp > operates directly on the data. > > Those are features. > > > > Le 4 nov. 2011 à 08:01, Darren Cook a écrit : > >

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

2011-11-06 Thread Darren Cook
ential for error. Real programmers on the other hand are human, make mistakes, and have deadlines. -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___

Re: [Rcpp-devel] Using lbfgsb with a Rcpp::List.

2011-11-20 Thread Darren Cook
on might also work and be more readable: Rcpp::List &TheList=*(static_cast(ex)); double blah = Rcpp::as(TheList["numbers"]); Both of them untested. As Dirk is saying, using void* is C-style code. C++ style would use templates and functors to be both safer and slightly q

Re: [Rcpp-devel] c++ class as argument in rcpp function (using modules)

2011-12-21 Thread Darren Cook
World*)w2)->msg; } Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://list

Re: [Rcpp-devel] Segfaults

2012-01-04 Thread Darren Cook
Steve Lianoglou wrote: > When I use inline for anything semi-permanent (the last step before > turning it into a package, let's say), I typically have a thin R > wrapper function that calls down to my inline function and I never > call the inline function directly anywhere else. The job of the thin

Re: [Rcpp-devel] Segfaults

2012-01-05 Thread Darren Cook
ou can deliberately skip over it when you know your parameters are valid (e.g. because the parent function has already checked them). A common technique for optimization. Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.h

Re: [Rcpp-devel] rcpp as a compiler to create stand-alone applications

2012-02-06 Thread Darren Cook
buntu.com/community/FolderEncryption -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org http

Re: [Rcpp-devel] rcpp as a compiler to create stand-alone applications

2012-02-06 Thread Darren Cook
l of a project proposal that has a dependency on other software: * System administrator has to do something; * Security issues: 1000s of files to monitor, not just one; * Versioning issues makes it more fragile. You can form a good counter-argument for each point. The problem is that you *ha

Re: [Rcpp-devel] how to get rid of the warning message: no graphics system to unregister

2012-02-11 Thread Darren Cook
in main() and then pass it around by reference? Or are you create RInside instances inside other functions, or inside loop bodies? If the latter, can you refactor to do the former so you only have one instance? HTH, Darren -- Darren Cook, Software Researcher/Developer http://dcook.org/work/

[Rcpp-devel] RInside and multi-threading

2012-02-11 Thread Darren Cook
e the same connection unless they guarantee that no eval calls are run in parallel." -- Darren Cook, Software Researcher/Developer http://dcook.org/work/ (About me and my work) http://dcook.org/blogs.html (My blogs and articles) ___ Rcpp-devel mailing

Re: [Rcpp-devel] RInside and multi-threading

2012-02-12 Thread Darren Cook
/ > | "Rserve is thread safe across connections, but eval methods are not > | thread safe within one connection. This means that multiple threads > | should not use the same connection unless they guarantee that no eval > | calls are run in parallel." -- Darren Cook, Software Rese

Re: [Rcpp-devel] RInside and multi-threading

2012-02-12 Thread Darren Cook
> I took it to mean it forks per connection. The quote below is talking > about threads in a client application sharing a connection to an Rserve > server. Assuming I didn't misunderstood that much, it implies R can > handle non-eval commands in parallel, ... Ah, I see my misunderstanding: eval()

Re: [Rcpp-devel] how to get rid of the warning message: no graphics system to unregister

2012-02-13 Thread Darren Cook
> Here is the test code I first used to call the R function from C++ > program. At the end, the warning message came out. > > double two_sample_logrank(RInside R, double* t, int* d, > int sample_size){ ... I think you've worked this out, but I thought this line should have been: double tw