Re: [Rcpp-devel] float for BigMatrix

2015-06-02 Thread Yue Li
Thanks a lot Scott! That works! > On Jun 2, 2015, at 12:39 AM, Scott Ritchie wrote: > > Oh nice catch! It’s not in the latest version on CRAN, but if you install the > development version from github > (devtools::install_github("kaneplusplus/bigmemory")) you will be able to > create a big ma

Re: [Rcpp-devel] float for BigMatrix

2015-06-01 Thread Scott Ritchie
Oh nice catch! It’s not in the latest version on CRAN, but if you install the development version from github ( devtools::install_github("kaneplusplus/bigmemory")) you will be able to create a big matrix with a type float. You will just need to explicitly tell R to store the data as a float, i.e. a

Re: [Rcpp-devel] float for BigMatrix

2015-06-01 Thread Yue Li
I see. Thanks for the explanation Scott. Wish the bigmatrix will get native float type. I found a related post here: https://github.com/kaneplusplus/bigmemory/issues/4 Yue > On Jun 2, 2015, at 12:27 AM, Scott Ritchie wrote: > > Hi Yue, >

Re: [Rcpp-devel] float for BigMatrix

2015-06-01 Thread Scott Ritchie
Hi Yue, The call (float *)xpMat->matrix() is simply telling C++ to interpret the stored memory as a float, so it’s simply breaking up the stored binary data into float-sized chunks instead of double-sized chunks, so you get nonsense numbers. To store as a float, you would have to cast double_bigma

[Rcpp-devel] float for BigMatrix

2015-06-01 Thread Yue Li
Dear List, I wonder if there is a way to convert a big matrix to ‘float’ instead of ‘double’ within a Rcpp program. The reason for using float is mainly for performance improvement. For instance, I have a simple function named ‘print_bigmat’ as shown below. As shown in the output, ‘double_bigm