Rcpp11 on windows.

123 views
Skip to first unread message

Romain François

unread,
Apr 15, 2014, 6:58:02 AM4/15/14
to r-an...@googlegroups.com
Hello,

This is a message to let you know that as far as I’ve tested, the devel version of Rcpp11 works on windows (with the current version of Rtools).

The compiler that is shipped with the current Rtools is gcc 4.6.3 with partial support for C++11. This page details the subset of C++11 that is supported:
http://gcc.gnu.org/gcc-4.6/cxx0x_status.html

It is not ideal, as I had to compromise a few features I liked (delegated constructors and template aliases, i.e. the using keyword instead of typedef), but at least we have something we can use.
If there are windows users here, can you please test Rcpp11. Something like this should run the tests:

source_gist( "https://gist.github.com/romainfrancois/10721547" )

and end with something like:

Conversion from SEXP to C++ type with as<> : ....................................
data frame manipulation with Rcpp::DataFrame : ..............
environments : ..............................................................
functions : .........
Language : ..............
Pairlist : ....................
Formula : ......
Matrix : ............1........
Rcpp API : .........................................
NA : ..............
R math : ......................................................................................................
RObject : ........................................................................................
String : .........
sugar : ...............................................
sugar matrix : ...
sugar : ...........................
Vector : .......................................................
wrap : ................
External pointers : ..

1. Failure(@test-Matrix.R#62): Matrix columns work -----------------------------
runit_NumericMatrix_cumsum(x) not equal to t(apply(x, 1, cumsum))
Mean relative difference: 9.083672e+222


(the failure is something we can reproduce everywhere, we’ll fix this shortly).

I will do some more testing and then negotiate if I can release again so that windows users get a Rcpp11 that works.

Romain

Chris Wray

unread,
Apr 15, 2014, 8:38:24 AM4/15/14
to Romain François, r-an...@googlegroups.com
Hi I am running  R (current official release) on a Win x64 machine. 

I turned R on, and simply did: source_gist( "https://gist.github.com/romainfrancois/10721547" ) [with no other set-up or tweaks], and I got the output below:

Conversion from SEXP to C++ type with as<> : ....................................
data frame manipulation with Rcpp::DataFrame : ..........1.2.
environments : ...............................................................
functions : .........
Language : ..............
Pairlist : ....................
Formula : ......
Matrix : .....................
Rcpp API : ........................................
NA : ..............
R math : ......................................................................................................
RObject : ........................................................................................
String : .........
sugar : ...............................................
sugar matrix : ...
sugar : ...........................
Vector : .......................................................
wrap : ................
External pointers : ..


1. Failure(@test-DataFrame.R#37): DataFrame can be created from proxies ----------------------------------------------------------------------------------
SlotProxy(tr1, "y") code did not generate an error

2. Failure(@test-DataFrame.R#41): DataFrame can be created from proxies ----------------------------------------------------------------------------------
AttributeProxy(tr1, "y") code did not generate an error

Error: Test failures
In addition: Warning messages:
1: In getPackageName(where) :
  Created a package name, ‘2014-04-15 13:25:52’, when none found
2: In getPackageName(where) :
  Created a package name, ‘2014-04-15 13:25:52’, when none found
3: In getPackageName(where) :
  Created a package name, ‘2014-04-15 13:25:52’, when none found

My session info is:
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppTest_3.1.0.0.999 testthat_0.8.1       devtools_1.5         ggplot2_0.9.3.1     

loaded via a namespace (and not attached):
 [1] codetools_0.2-8    colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4       evaluate_0.5.3     grid_3.1.0         gtable_0.1.2      
 [8] httr_0.3           inline_0.3.13      labeling_0.2       MASS_7.3-31        memoise_0.1        munsell_0.4.2      parallel_3.1.0    
[15] plyr_1.8.1         proto_0.3-10       RColorBrewer_1.0-5 Rcpp_0.11.1        RCurl_1.95-4.1     reshape2_1.2.2     scales_0.2.3      
[22] stringr_0.6.2      tools_3.1.0        whisker_0.3-2  


In addition to the 2 errors above, I initially got the matrix error you described in your post, whilst using Rtools ver 3.1.0.1939. 
But this matrix error went away using Rtools ver 3.1.0.1942 (the current version).



Romain

--
You received this message because you are subscribed to the Google Groups "R and C++" group.
To unsubscribe from this group and stop receiving emails from it, send an email to r-and-cpp+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Romain François

unread,
Apr 15, 2014, 9:04:38 AM4/15/14
to Chris Wray, r-an...@googlegroups.com
Thanks, 

Can you let me know what this gives you:
 
    setClass("track", representation(x="data.frame", y = "function"), where = environment())
    df <- data.frame( x = 1:10, y = 1:10 )
    tr1 <- new( "track", x = df, y = rnorm )
    RcppTest:::SlotProxy(tr1, "y")

Romain

Chris Wray

unread,
Apr 15, 2014, 9:09:12 AM4/15/14
to Romain François, r-an...@googlegroups.com
Sure

> setClass("track", representation(x="data.frame", y = "function"), where = environment())
> df <- data.frame( x = 1:10, y = 1:10 )
> tr1 <- new( "track", x = df, y = rnorm )
> RcppTest:::SlotProxy(tr1, "y")
$...


[[2]]
data.frame(value = x(...))


No errors, warnings or messages. 
thanks

Romain François

unread,
Apr 15, 2014, 1:53:09 PM4/15/14
to Chris Wray, r-an...@googlegroups.com
That’s a mystery why you don’t get these errors. I’ve just double checked on my windows vm with updated everything. The only thing I can think of is perhaps a nasty interaction with Rcpp. Could you try again without all these packages loaded. I only have these loaded after the call to source_gist. 

> sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252 LC_NUMERIC=C                   LC_TIME=French_France.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RcppTest_3.1.0.0.999 testthat_0.8.1.0.99  devtools_1.5        

loaded via a namespace (and not attached):
 [1] codetools_0.2-8 digest_0.6.4    evaluate_0.5.3  httr_0.3        memoise_0.1     parallel_3.1.0  RCurl_1.95-4.1  stringr_0.6.2   tools_3.1.0     whisker_0.3-2 


BTW, The matrix error is taken care of. It was just a test bug. initializing a vector with a size no longer initializes values to 0, as in Rcpp, so with the code: 

// [[Rcpp::export]]
NumericMatrix runit_NumericMatrix_cumsum( NumericMatrix input ){
    int nr = input.nrow(), nc = input.ncol() ;
    NumericMatrix output(nr, nc) ;
    NumericVector tmp( nr);
    for( int i=0; i<nc; i++){
        tmp = tmp + input.column(i) ;
        NumericMatrix::Column target( output, i ) ;
        std::copy( tmp.begin(), tmp.end(), target.begin() ) ;
    }
    return output ;
}

we were getting garbage in tmp. I’ve updated the test code to: NumericVector tmp( nr, 0); which does initialize to 0. 

Romain

8pawe...@gmail.com

unread,
May 2, 2014, 5:17:48 PM5/2/14
to r-an...@googlegroups.com, rom...@r-enthusiasts.com
It appears to compile on my win7 32/64 bit R.

I'm having a hard time getting your `test` function (posted on SO, demonstrating `Array` with `Numeric3D`) to compile, though. (Thanks for your pointer to install `attributes`.)

    > sourceCpp('../src/foo.cpp')
    In file included from c:/R/R-3.1.0/library/Rcpp11/include/Rcpp.h:198:0,
                     from file4b103ace6f02.cpp:1:
    c:/R/R-3.1.0/library/Rcpp11/include/Rcpp/Index.h: In constructor 'Rcpp::Index<N>::Index(Args ...) [with Args = {long long unsigned int, long long unsigned int, long long unsigned int}, <template-parameter-2-2> = void, int N = 3]':
    c:/R/R-3.1.0/library/Rcpp11/include/Rcpp/Array.h:26:30:   instantiated from 'Rcpp::Array<N, RTYPE, StoragePolicy>::Array(Args ...) [with Args = {int, int, int}, <template-parameter-2-2> = void, int N = 3, int RTYPE = 14, StoragePolicy = Rcpp::PreserveStorage]'
    file4b103ace6f02.cpp:9:22:   instantiated from here
    c:/R/R-3.1.0/library/Rcpp11/include/Rcpp/Index.h:21:76: error: could not convert '{args#0, args#1, args#2}' from '<brace-enclosed initializer list>' to 'std::array<long long unsigned int, 3ull>'
    make: *** [file4b103ace6f02.o] Error 1
    Warning message:
    running command 'make -f "c:/R/R-31~1.0/etc/x64/Makeconf" -f "c:/R/R-31~1.0/share/make/winshlib.mk" CXX='$(CXX1X) $(CXX1XSTD)' CXXFLAGS='$(CXX1XFLAGS)' CXXPICFLAGS='$(CXX1XPICFLAGS)' SHLIB_LDFLAGS='$(SHLIB_CXX1XLDFLAGS)' SHLIB_LD='$(SHLIB_CXX1XLD)' SHLIB="file4b103ace6f02.dll" WIN=64 TCLBIN=64 OBJECTS="file4b103ace6f02.o"' had status 2 


BTW, your R code for Chris Wray fails for me:

    > setClass("track", representation(x="data.frame", y = "function"), where = environment())
    > df <- data.frame( x = 1:10, y = 1:10 )
    > tr1 <- new( "track", x = df, y = rnorm )
    > RcppTest:::SlotProxy(tr1, "y")
    Error: could not convert using R function : as.data.frame



My `sessionInfo()`:

    > sessionInfo()
    R version 3.1.0 (2014-04-10)
    Platform: x86_64-w64-mingw32/x64 (64-bit)
    
    locale:
    [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252 LC_NUMERIC=C                           LC_TIME=English_United States.1252    
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods   base     
    
    other attached packages:
    [1] Rcpp11_3.1.0.1.99 attributes_0.0    r2utils_0.1      
    
    loaded via a namespace (and not attached):
    [1] compiler_3.1.0 tools_3.1.0   


Can you offer any guidance? Thank you.

-bill


Reply all
Reply to author
Forward
0 new messages