Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
Højsgaard |Cc: rcpp-devel@lists.r-forge.r-project.org |Subject: Re: [Rcpp-devel] sugar: x+y and y+x gives different results when |there are NA's in y | |You get UB if the first is bigger than the second. | |Envoyé de mon iPhone | |> Le 22 nov. 2014 à 14:30, Søren Højsgaard a écrit : |> |&

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
omain Francois [mailto:rom...@r-enthusiasts.com] > |Sent: 22. november 2014 13:25 > |To: Søren Højsgaard > |Cc: rcpp-devel@lists.r-forge.r-project.org > |Subject: Re: [Rcpp-devel] sugar: x+y and y+x gives different results when > |there are NA's in y > | > |This has nothing to do with N

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
OK; thanks! Shall I read this such as "the behaviour is undefined"? Søren |-Original Message- |From: Romain Francois [mailto:rom...@r-enthusiasts.com] |Sent: 22. november 2014 13:25 |To: Søren Højsgaard |Cc: rcpp-devel@lists.r-forge.r-project.org |Subject: Re: [Rcpp-devel] suga

Re: [Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Romain Francois
This has nothing to do with NA. It's just about the size difference. sugar does not make attempt at recycling. Your responsibility. Romain > Le 22 nov. 2014 à 11:48, Søren Højsgaard a écrit : > > Dear all, > Came across this: > > #include > using namespace Rcpp; > > //[[Rcpp::export]] > Li

[Rcpp-devel] sugar: x+y and y+x gives different results when there are NA's in y

2014-11-22 Thread Søren Højsgaard
Dear all, Came across this: #include using namespace Rcpp; //[[Rcpp::export]] List sumxy(NumericVector x, NumericVector y){ NumericVector xy = x+y; NumericVector yx = y+x; return List::create(xy, yx); } /*** R x <- c(1,3,5,7) y <- c(NA,2,4,6,8) x+y y+x sumxy(x, y) */ > x <- c(1,3,5,7)

Re: [Rcpp-devel] Sugar: This is not just a windows issue (partial fix): was sugar under Windows/g++ (MinGW) odd behavior.

2011-01-27 Thread Dominick Samperi
On Tue, Jan 25, 2011 at 3:23 AM, Romain Francois wrote: > I'll have a look at this when I get a chance. Obviously my proposed "partial fix" is really not satisfactory because it would involve a lot of vector copying, defeating the purpose of expression templates. The real issue is that the way R

Re: [Rcpp-devel] Sugar: This is not just a windows issue (partial fix): was sugar under Windows/g++ (MinGW) odd behavior.

2011-01-25 Thread Romain Francois
I'll have a look at this when I get a chance. Romain Le 25/01/11 02:58, Dominick Samperi a écrit : I reported a problem in another thread that I thought only surfaced under Windows, but I was wrong (see Subject line). The problem also appears under GCC 4.5+, and it appears that somebody already

[Rcpp-devel] Sugar: This is not just a windows issue (partial fix): was sugar under Windows/g++ (MinGW) odd behavior.

2011-01-24 Thread Dominick Samperi
I reported a problem in another thread that I thought only surfaced under Windows, but I was wrong (see Subject line). The problem also appears under GCC 4.5+, and it appears that somebody already noticed problems with this version of GCC and introduced the compiler define IS_GCC_450_OR_LATER to na

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-18 Thread Dominick Samperi
This link explains very clearly why VC++ creates a temporary to initialize the local reference, complete with a decision graph, and it seems that the Rcpp expression template code should lead to the "create temporary" branch: http://msdn.microsoft.com/en-us/library/szywdw8k.aspx These comments com

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-18 Thread Dominick Samperi
Opps, I was too quick to declare victory here. That warning about temporary reference initialization is not innocuous: crashes still occur under VC++ (even with the updated RcppCommon.h) but it is difficult to predict when they will occur. The Extractor.h work-around fixes the problem for now. The

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-18 Thread Dominick Samperi
To finish up this thread, it turns out that the VC++ problems did help to reveal an architecture-dependent behavior of Rprintf (under GCC) that developers probably should be aware of, and it also points to a potential problem with the way temporary references are initialized in the expression templ

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-16 Thread Dominick Samperi
It appears that this is a matter of compiler interpretation of the C++ standards, and it is not easy to see which compiler is correct (g++ or VC++). When I disable the VC++ work-around I get the following warning from this compiler about the Plus_Vector_Vector constructor: c:\w\dev\stats\rbuild\R

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-15 Thread Dominick Samperi
Romain, I found a work-around for the VC++ problem. All I have to do is make sure the code that is currently ifdef-ed in Extractor.h is NOT enabled under VC++ (when _MSC_VER is defined). Currently this code is conditionally compiled with #ifndef IF_GCC_450_OR_LATER, so the additional condition tha

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-15 Thread Dominick Samperi
So that there is no confusion, I should add that the problems that I report here do not occur under Linux/g++ or under MinGW/g++ (the supported environments), where Rcpp/sugar seems to work fine. On Sat, Jan 15, 2011 at 1:23 PM, Dominick Samperi wrote: > > > On Sat, Jan 15, 2011 at 4:15 AM, Romai

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-15 Thread Dominick Samperi
On Sat, Jan 15, 2011 at 4:15 AM, Romain Francois wrote: > Le 13/01/11 16:29, Dominick Samperi a écrit : > > The template expression code is very interesting, but it >> does not work as expected under >> Windows/g++/MinGW/32bit/Rterm.exe. The problem >> does not appear when I use Rgui.exe, or if I

Re: [Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-15 Thread Romain Francois
Le 13/01/11 16:29, Dominick Samperi a écrit : The template expression code is very interesting, but it does not work as expected under Windows/g++/MinGW/32bit/Rterm.exe. The problem does not appear when I use Rgui.exe, or if I use 64bit Windows! Consider the following C++ code called using .Call

[Rcpp-devel] sugar under Wingows/g++ (MinGW) odd behavior.

2011-01-13 Thread Dominick Samperi
The template expression code is very interesting, but it does not work as expected under Windows/g++/MinGW/32bit/Rterm.exe. The problem does not appear when I use Rgui.exe, or if I use 64bit Windows! Consider the following C++ code called using .Call('testsugar',1:5,1:5): RcppExport SEXP testsuga

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-07 Thread Dirk Eddelbuettel
On 7 January 2011 at 12:54, Romain Francois wrote: | Le 05/01/11 14:01, Dirk Eddelbuettel a écrit : | > | > On 5 January 2011 at 10:55, Cedric Ginestet wrote: | > | Dear All, | > | | > | Here are some simulations that I have run this morning. Romain's suggestion to | > | compute xV.size() before

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-07 Thread Romain Francois
Le 05/01/11 14:01, Dirk Eddelbuettel a écrit : On 5 January 2011 at 10:55, Cedric Ginestet wrote: | Dear All, | | Here are some simulations that I have run this morning. Romain's suggestion to | compute xV.size() before the loop and Douglas' idea of using accumulate appear | to work best. Howeve

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-05 Thread Dirk Eddelbuettel
On 5 January 2011 at 10:55, Cedric Ginestet wrote: | Dear All, | | Here are some simulations that I have run this morning. Romain's suggestion to | compute xV.size() before the loop and Douglas' idea of using accumulate appear | to work best. However, both are substantially slower than the r-base

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-05 Thread Cedric Ginestet
Dear All, Here are some simulations that I have run this morning. Romain's suggestion to compute xV.size() before the loop and Douglas' idea of using accumulate appear to work best. However, both are substantially slower than the r-base function. I have also included two more versions: (i) o

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Romain Francois
Le 04/01/11 19:09, Douglas Bates a écrit : On Tue, Jan 4, 2011 at 12:04 PM, Douglas Bates wrote: On Tue, Jan 4, 2011 at 11:13 AM, Romain Francois wrote: Le 04/01/11 17:42, Romain Francois a écrit : Le 04/01/11 16:35, Andrew Redd a écrit : Cedric, This was addressed about 2 weeks ago on t

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Douglas Bates
On Tue, Jan 4, 2011 at 12:04 PM, Douglas Bates wrote: > On Tue, Jan 4, 2011 at 11:13 AM, Romain Francois > wrote: >> Le 04/01/11 17:42, Romain Francois a écrit : >>> >>> Le 04/01/11 16:35, Andrew Redd a écrit : Cedric, This was addressed about 2 weeks ago on the list, please read t

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Douglas Bates
On Tue, Jan 4, 2011 at 11:13 AM, Romain Francois wrote: > Le 04/01/11 17:42, Romain Francois a écrit : >> >> Le 04/01/11 16:35, Andrew Redd a écrit : >>> >>> Cedric, >>> This was addressed about 2 weeks ago on the list, please read the >>> archives. Basic point, Rcpp/sugar will not be faster than

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Romain Francois
Le 04/01/11 17:42, Romain Francois a écrit : Le 04/01/11 16:35, Andrew Redd a écrit : Cedric, This was addressed about 2 weeks ago on the list, please read the archives. Basic point, Rcpp/sugar will not be faster than basic functions in R. Do something more complicated to see improvements. I wou

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Romain Francois
Le 04/01/11 16:35, Andrew Redd a écrit : Cedric, This was addressed about 2 weeks ago on the list, please read the archives. Basic point, Rcpp/sugar will not be faster than basic functions in R. Do something more complicated to see improvements. I would suggest something that involves lots of

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Dirk Eddelbuettel
On 4 January 2011 at 15:14, Cedric Ginestet wrote: | Happy new year to everyone, | | I have made a very straightforward comparison of the performance of standard R, | Rcpp function and sugar, and found that the latter produces the poorest | performance. Let me know what you think and how I could

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Andrew Redd
Cedric, This was addressed about 2 weeks ago on the list, please read the archives. Basic point, Rcpp/sugar will not be faster than basic functions in R. Do something more complicated to see improvements. I would suggest something that involves lots of copies and edits, that will mess with R's m

[Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Cedric Ginestet
Happy new year to everyone, I have made a very straightforward comparison of the performance of standard R, Rcpp function and sugar, and found that the latter produces the poorest performance. Let me know what you think and how I could improve such performance assessment. ###

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread Douglas Bates
On Wed, Dec 22, 2010 at 5:33 AM, wrote: >  Hello, > > Following Gabor's thread yesterday, I looked into R source code and figure > that we don't need to test for NA when using numeric vector. See this: > > require(inline) > require(Rcpp) > > pl <- cxxfunction( , ' >    return List::create( >    

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread romain
Le mer 22/12/10 13:02, "Gabor Grothendieck" ggrothendi...@gmail.com a écrit: > On Wed, Dec 22, 2010 at 6:33 AM, i...@r-enthusiasts.com> wrote: > Also, I'm trying to write the looping internally in > order to get a better comparison. With the attached file, I > get: > The attachment does not see

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread Gabor Grothendieck
On Wed, Dec 22, 2010 at 6:33 AM, wrote: > Also, I'm trying to write the looping internally in order to get a better > comparison. With the attached file, I get: The attachment does not seem to have made it through. -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-

[Rcpp-devel] sugar performance

2010-12-22 Thread romain
Hello, Following Gabor's thread yesterday, I looked into R source code and figure that we don't need to test for NA when using numeric vector. See this: require(inline) require(Rcpp) pl <- cxxfunction( , ' return List::create( NA_REAL + NA_REAL, NA_REAL + 1.0, 1

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread Cedric Ginestet
Perfect. You were correct. It was just to do with my compiler. It worked. For future reference, my compiler's version is: gcc 4.4.3 Cheers, Cedric On 22/12/10 10:49, rom...@r-enthusiasts.com wrote: Hmm. It works for me : romain@ /tmp $ Rscript scalar.R Le chargement a nécessité le package : Rc

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread romain
Hmm. It works for me : romain@ /tmp $ Rscript scalar.R Le chargement a nécessité le package : Rcpp Le chargement a nécessité le package : methods Le chargement a nécessité le package : inline [1] 0.118499288 -1.817607621 -0.222048483 -1.237370127 -0.311005542 [6] -1.171129611 -1.762177277

Re: [Rcpp-devel] SUGAR: Vector-Scalar operations

2010-12-22 Thread Cedric Ginestet
Dear Rcpp experts, I've got another problem related to Rcpp Sugar. Basically, I would like to have the same functionality that you get from R's vectors, where binary operations with scalars are automatically interpreted as elementwise operations. See the following code and error message: ###

Re: [Rcpp-devel] Sugar/inline and RTools

2010-12-13 Thread Romain Francois
el-boun...@lists.r-forge.r-project.org] on behalf of Romain Francois [rom...@r-enthusiasts.com] Sent: 13 December 2010 10:07 To: rcpp-devel@lists.r-forge.r-project.org Subject: Re: [Rcpp-devel] Sugar/inline and RTools Hello, Le 12/12/10 16:28, Dirk Eddelbuettel a écrit : Hi Chris, On 12 December 20

Re: [Rcpp-devel] Sugar/inline and RTools

2010-12-13 Thread Wray, Christopher
I could get around openmp support lacking in rtools, I guess there will always be the potential to come across other similar issues..given the "min" distribution. Thanks for all suggestions/comments. chris. From: rcpp-devel-boun...@lists.r-forge.r-project.org [rcpp-devel-boun...@lists.r-f

Re: [Rcpp-devel] Sugar/inline and RTools

2010-12-13 Thread Romain Francois
Hello, Le 12/12/10 16:28, Dirk Eddelbuettel a écrit : Hi Chris, On 12 December 2010 at 15:03, Wray, Christopher wrote: | Hi, | Im using windows7, R2.12, Rtools2.12 and all the latest packages of inline, | rcpp, etc. Over the last few weeks I have managed to get loads of the | examples working,

Re: [Rcpp-devel] Sugar/inline and RTools

2010-12-12 Thread Dirk Eddelbuettel
Hi Chris, On 12 December 2010 at 15:03, Wray, Christopher wrote: | Hi, | Im using windows7, R2.12, Rtools2.12 and all the latest packages of inline, | rcpp, etc. Over the last few weeks I have managed to get loads of the | examples working, and all makes sense and is pretty clear. I had a couple

[Rcpp-devel] Sugar/inline and RTools

2010-12-12 Thread Wray, Christopher
Hi, Im using windows7, R2.12, Rtools2.12 and all the latest packages of inline, rcpp, etc. Over the last few weeks I have managed to get loads of the examples working, and all makes sense and is pretty clear. I had a couple of questions/comments: 1. RTools: On windows, I understand that Rcpp an

Re: [Rcpp-devel] Sugar

2010-11-01 Thread Romain Francois
Le 01/11/10 16:00, Andrew Redd a écrit : Doesn't sugar require Rcpp vectors, which encapsulate R SEXP vectors? If that is the case you really cannot separate them at all since there is a direct dependency on R. -Andrew It is more like both Rcpp vectors and sugar functions both depend on the

Re: [Rcpp-devel] Sugar

2010-11-01 Thread Romain Francois
Le 01/11/10 15:57, Shane Conway a écrit : My two cents: That seems sensible; an alternative view would be to say that sugar is in the same vein as the rest of Rcpp, might regularly be used in the same code, and the goal should be to keep everything as simple as possible (i.e. one library). I, f

Re: [Rcpp-devel] Sugar

2010-11-01 Thread Andrew Redd
Doesn't sugar require Rcpp vectors, which encapsulate R SEXP vectors? If that is the case you really cannot separate them at all since there is a direct dependency on R. -Andrew On Mon, Nov 1, 2010 at 7:57 AM, Shane Conway wrote: > My two cents: > > That seems sensible; an alternative view wou

Re: [Rcpp-devel] Sugar

2010-11-01 Thread Romain Francois
Le 01/11/10 06:13, Dominick Samperi a écrit : Comments on Sugar... Rcpp sugar seems to be an enhancement for C++ more than an interface function, so wouldn't it make sense to maintain it as a separate C++ class library? not to me. sugar brings (parts of the) R syntax at the C++ level, it seem

Re: [Rcpp-devel] Sugar

2010-11-01 Thread Shane Conway
My two cents: That seems sensible; an alternative view would be to say that sugar is in the same vein as the rest of Rcpp, might regularly be used in the same code, and the goal should be to keep everything as simple as possible (i.e. one library). I, for one, don't see the need to separate them.

[Rcpp-devel] Sugar

2010-10-31 Thread Dominick Samperi
Comments on Sugar... Rcpp sugar seems to be an enhancement for C++ more than an interface function, so wouldn't it make sense to maintain it as a separate C++ class library? More generally, it would be useful to know what portions of Rcpp can function without the R engine running. This can be dete

Re: [Rcpp-devel] sugar version of apply

2010-07-08 Thread Dirk Eddelbuettel
On 8 July 2010 at 14:06, Romain Francois wrote: | Hello, | | Now that we have extended sugar so that it can deal with matrices, e.g : | | signature( x = "numeric", y = "numeric" ), | ' | NumericVector xx(x) ; |

[Rcpp-devel] sugar version of apply

2010-07-08 Thread Romain Francois
Hello, Now that we have extended sugar so that it can deal with matrices, e.g : signature( x = "numeric", y = "numeric" ), ' NumericVector xx(x) ; NumericVector yy(y);

[Rcpp-devel] sugar: ifelse, pmin, pmax, lapply

2010-06-19 Thread Romain Francois
Hi, I've implemented lazy versions of them in Rcpp::sugar. Here are some examples: fx <- cxxfunction( signature( x = "integer" ), ' IntegerVector xx(x) ; List res = lapply( xx, seq_len ); return res ; ', plugin = "Rcpp" ) checkEquals( fx( 1:10 ), lapply( 1:10, seq_le