[Rcpp-devel] Fwd: Re: Filling a big.matrix in Rcpp

Aileen Lin aileenshanhong.lin at gmail.com
Fri Mar 15 01:12:02 CET 2013


Aileen Lin

View my profile: au.linkedin.com/in/aileen2
---------- Forwarded message ----------
From: "Aileen Lin" <aileenshanhong.lin at gmail.com>
Date: 15 Mar 2013 10:44
Subject: Re: [Rcpp-devel] Filling a big.matrix in Rcpp
To: "Dirk Eddelbuettel" <edd at debian.org>
Cc:

I tried your source code and had two warning messages:

g++  -I"C:/R/R-215~1.2/include" -DNDEBUG
-I"C:/R/R-2.15.2/library/Rcpp/include"
-I"H:/R/win-library/2.15/bigmemory/include"      -O2 -Wall  -mtune=core2 -c
rcpp_bm_test.cpp -o rcpp_bm_test.o
In file included from
H:/R/win-library/2.15/bigmemory/include/boost/smart_ptr/detail/spinlock_sync.hpp:18:0,
                 from
H:/R/win-library/2.15/bigmemory/include/boost/smart_ptr/detail/spinlock.hpp:38,
                 from
H:/R/win-library/2.15/bigmemory/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from
H:/R/win-library/2.15/bigmemory/include/boost/smart_ptr/shared_ptr.hpp:37,
                 from
H:/R/win-library/2.15/bigmemory/include/boost/shared_ptr.hpp:17,
                 from
H:/R/win-library/2.15/bigmemory/include/bigmemory/BigMatrix.h:6,
                 from
H:/R/win-library/2.15/bigmemory/include/bigmemory/MatrixAccessor.hpp:4,
                 from rcpp_bm_test.cpp:7:
H:/R/win-library/2.15/bigmemory/include/boost/smart_ptr/detail/yield_k.hpp:58:48:
warning: declaration of 'void boost::detail::Sleep(unsigned int)' with C
language linkage [enabled by default]
H:/R/win-library/2.15/bigmemory/include/boost/interprocess/detail/win32_api.hpp:382:49:
warning: conflicts with previous declaration 'void
boost::interprocess::winapi::Sleep(long unsigned int)' [enabled by default]
g++ -shared -s -static-libgcc -o sourceCpp_24751.dll tmp.def rcpp_bm_test.o
C:/R/R-2.15.2/library/Rcpp/lib/i386/libRcpp.a -LC:/R/R-215~1.2/bin/i386 -lR

Do you have the same warning messages? Do you know how to get rid of it?
Thank you.



On 15 March 2013 05:33, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 14 March 2013 at 12:24, Smith, Dale wrote:
> | Write it up for Rcpp Gallery.
>
> Yup. Our thoughts too.  Here is a slightly modified version which works as
> a
> single cpp file thanks to the wonders of sourceCpp() --- bigmemory headers
> are found automagically, and the example is executed too.
>
> Dirk
>
>
>
> // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode:
> nil; -*-
>
> #include <Rcpp.h>
>
> // The next line is all it takes to find the bigmemory
> // headers -- thanks to the magic of Rcpp attributes
>
> // [[Rcpp::depends(bigmemory)]]
> #include <bigmemory/MatrixAccessor.hpp>
>
>
> // We define a simple function, and pass the incoming XPtr as a SEXP;
> // we could also pass a templated XPtr. Function returns only a bool.
>
> // [[Rcpp::export]]
> bool fun(SEXP A) {
>     Rcpp::XPtr<BigMatrix> bigMat(A);
>     MatrixAccessor<int> Am(*bigMat);
>
>     int nrows = bigMat->nrow();
>     int ncolumns = bigMat->ncol();
>     for (int j = 0; j < ncolumns; j++){
>         for (int i = 1; i < nrows; i++){
>             Am[j][i] = Am[j][i] + Am[j][i-1];
>         }
>     }
>     return Rcpp::wrap(true);
> }
>
> // R code for testing below
>
> /*** R
> require(bigmemory)
>
> # set up big.matrix
> nrows <- 10000
> bkFile <- "bigmat.bk"
> descFile <- "bigmatk.desc"
> bigmat <- filebacked.big.matrix(nrow=nrows, ncol=3,type="integer", init=1,
>                                 backingfile=bkFile,
> backingpath=".",descriptorfile=descFile,
>                                 dimnames=c(NULL,NULL))
> matDesc <- bigmemory::describe(bigmat)
>
> fun(bigmat at address)
>
> cat("Done\n")
> */
>
>
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>



-- 
Aileen L.

View my Linkedin profile: http://au.linkedin.com/in/aileen2

 Being happy doesn't mean you're perfect. It just means you've decided to
look beyond the imperfections- K.B Indiana (age
14)<http://www.boardofwisdom.com/default.asp?topic=1010&search=K%2EB+Indiana+%28age+14%29>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130315/1f44068a/attachment.html>


More information about the Rcpp-devel mailing list