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

2011-09-22 Thread Darren Cook
In another thread Noah wrote "I wasn't asking a C++ question...I thought there might have been a problem with Rcpp". No intention to pick on Noah here, but I thought it was a good chance to suggest a simple troubleshooting technique. The technique is simple, but not so simple that it cannot have i

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

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

2011-09-22 Thread Noah Silverman
I wasn't asking a C++ question. Due to a type at 2am, (My fault), I thought there might have been a problem with Rcpp. If you notice, I sent a redaction almost immediately after, asking everyone to ignore my previous e-mail. -- Noah Silverman UCLA Department of Statistics 8117 Math Sciences B

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

2011-09-22 Thread Tama Ma
Maybe I can give a slightly more elegant solution from Boost... (fingers crossed...) In this manner, the ugly for-loop is removed... For the toy-example, I would suggest the following: std::vector data; data.reserve(20); // extreamly important (maximize cache effect) std::copy(boost::countin

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

2011-09-22 Thread Noah Silverman
Xian, Your comment is ridiculous. You know nothing about my application, size or data, or other transformation on the data. I can assure you that using Rcpp speeds up my process by a factor of at least 100. I don't know how you measure things, but in my world, that is a VERY appropriate

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

2011-09-22 Thread Darren Cook
> I think this is the current prize-winner of inappropriate use of Rcpp... > How about using R to sort your vector?! There is also the fact that the array is being created ready-sorted :-). I assumed this was an artificially simplified example from real code. Or a learning toy. > This isn't reall

[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] 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 http://dcook

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

2011-09-22 Thread Jonas Rauch
Hi, I don't have access to a computer with R atm so I can't try. But the includes="#include , #include , #include . #include " looks fishy to me. First of all, note the dot before the last "include" instead of a comma. Secondly: wouldn't you need something like the below? includes=c("#include ","#i

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

2011-09-22 Thread Noah Silverman
Hi, I have a vector of doubles that I want to sort. Using Rcpp and inline. When attempting to create the function, I receive an error. Does anybody have any suggestions? === Test <- cxxfunction( signature(), plugin="Rcpp", includes="#include , #include , #incl