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
_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
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:/
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 :-)
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
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
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
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
/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
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)
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
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
; 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
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
>> 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
> 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
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
> 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
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?
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
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)
__
> 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
> 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
> * 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%
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
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
> 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
__
>
> 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
> 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
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.
> [ 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
> 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
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
> 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
__
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
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
> 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.
> 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
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
> 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
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.
> 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
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
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
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)
_
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
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
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
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
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
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
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
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
___
, 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
> 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
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
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
> 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
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
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
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
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/
>> | 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:
> 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
> 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
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
> 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
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)
___
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
(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)
__
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
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
=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
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
>> 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
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(
> 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!
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 :
>
>
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)
___
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
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
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
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
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
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
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/
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
/
> | "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
> 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()
> 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
90 matches
Mail list logo