Re: [Rcpp-devel] lmBenchmark broken for RcppArmadillo?

2014-10-20 Thread Matt
I've confirmed that this works on R 3.1.1 under OS X, using RcppArmadillo
0.4.450.1.0:

*diff --git a/inst/examples/lmBenchmark.R b/inst/examples/lmBenchmark.R*

*index 9037107..dd49375 100644*

*--- a/inst/examples/lmBenchmark.R*

*+++ b/inst/examples/lmBenchmark.R*

@@ -37,7 +37,7 @@ exprs$QR <- expression(.Call("fastLm", mm, y, 1L,
PACKAGE="Rcp

 exprs$LLt <- expression(.Call("fastLm", mm, y, 3L, PACKAGE="RcppEigen"))



 if (suppressMessages(require("RcppArmadillo", character=TRUE,
quietly=TRUE))) {

-exprs$arma <- expression(.Call("fastLm", mm, y,
PACKAGE="RcppArmadillo"))

+exprs$arma <- expression(.Call("RcppArmadillo_fastLm", mm, y,
PACKAGE="Rcpp

 }



 if (suppressMessages(require("RcppGSL", character=TRUE, quietly=TRUE))) {
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] lmBenchmark broken for RcppArmadillo?

2014-10-20 Thread Dirk Eddelbuettel

On 20 October 2014 at 12:26, Matt wrote:
| I've confirmed that this works on R 3.1.1 under OS X, using RcppArmadillo 
| 0.4.450.1.0:

Thanks for testing / conforming, and of course for having alterted us in the
first place -- I am updating the example code.

Dirk
| 
| 
| diff --git a/inst/examples/lmBenchmark.R b/inst/examples/lmBenchmark.R
| 
| index 9037107..dd49375 100644
| 
| --- a/inst/examples/lmBenchmark.R
| 
| +++ b/inst/examples/lmBenchmark.R
| 
| @@ -37,7 +37,7 @@ exprs$QR <- expression(.Call("fastLm", mm, y, 1L, PACKAGE=
| "Rcp
| 
|  exprs$LLt <- expression(.Call("fastLm", mm, y, 3L, PACKAGE="RcppEigen"))
| 
|  
| 
|  if (suppressMessages(require("RcppArmadillo", character=TRUE, quietly=TRUE)))
| {
| 
| -    exprs$arma <- expression(.Call("fastLm", mm, y, PACKAGE="RcppArmadillo"))
| 
| +    exprs$arma <- expression(.Call("RcppArmadillo_fastLm", mm, y, PACKAGE=
| "Rcpp
| 
|  }
| 
|  
| 
|  if (suppressMessages(require("RcppGSL", character=TRUE, quietly=TRUE))) {
| 

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


[Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Gustaf Granath

Hi
Im trying to use some C++ functions in R. However, these functions are 
build around unsigned char* variables (1D array). I have for example a 
large matrix in R that represents black (e.g. 1-bit image, 0 and 1s). I 
cant find a solution to convert a character vector into unsigned char* 
within Rcpp. Im new to Rcpp and C++ so I might have missed something 
obvious here. Please direct me to resources on this topic (google did 
not help much).


A start:

SEXP test(SEXP cM){
  CharacterVector Vc(cM);
  int n = Vr.size();
  RawVector x(n); //is this the same as unsigned char* ?
//I tried to fill it with char*(Mr) but I 
didnt succeed

}

Thanks,

Gustaf

--
Gustaf Granath (PhD)
Post doc
McMaster University
School of Geography & Earth Sciences

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Dirk Eddelbuettel

Hi Gustaf,

On 20 October 2014 at 15:17, Gustaf Granath wrote:
| Im trying to use some C++ functions in R. However, these functions are 
| build around unsigned char* variables (1D array). I have for example a 
| large matrix in R that represents black (e.g. 1-bit image, 0 and 1s). I 
| cant find a solution to convert a character vector into unsigned char* 
| within Rcpp. Im new to Rcpp and C++ so I might have missed something 

Rcpp builds a bridge between R and C++, and supports (in C++) the types that
R supports.  Eg you won't find 'float' but only 'double' as that is what R
does. 

Here you will get character vectors easily. If they must be unsigned char,
you will probably have to cast them at the C++ level.

| obvious here. Please direct me to resources on this topic (google did 
| not help much).
| 
| A start:
| 
| SEXP test(SEXP cM){
|CharacterVector Vc(cM);
|int n = Vr.size();
|RawVector x(n); //is this the same as unsigned char* ?

No, RawVector is for R 'raw' types -- see help("raw") in R,

Dirk

|  //I tried to fill it with char*(Mr) but I 
| didnt succeed
| }
| 
| Thanks,
| 
| Gustaf
| 
| -- 
| Gustaf Granath (PhD)
| Post doc
| McMaster University
| School of Geography & Earth Sciences
| 
| ___
| Rcpp-devel mailing list
| Rcpp-devel@lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel


Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Romain Francois

> Le 20 oct. 2014 à 21:54, Dirk Eddelbuettel  a écrit :
> 
> 
> Hi Gustaf,
> 
> On 20 October 2014 at 15:17, Gustaf Granath wrote:
> | Im trying to use some C++ functions in R. However, these functions are 
> | build around unsigned char* variables (1D array). I have for example a 
> | large matrix in R that represents black (e.g. 1-bit image, 0 and 1s). I 
> | cant find a solution to convert a character vector into unsigned char* 
> | within Rcpp. Im new to Rcpp and C++ so I might have missed something 
> 
> Rcpp builds a bridge between R and C++, and supports (in C++) the types that
> R supports.  Eg you won't find 'float' but only 'double' as that is what R
> does. 
> 
> Here you will get character vectors easily. If they must be unsigned char,
> you will probably have to cast them at the C++ level.
> 
> | obvious here. Please direct me to resources on this topic (google did 
> | not help much).
> | 
> | A start:
> | 
> | SEXP test(SEXP cM){
> |CharacterVector Vc(cM);
> |int n = Vr.size();
> |RawVector x(n); //is this the same as unsigned char* ?
> 
> No, RawVector is for R 'raw' types -- see help("raw") in R,

Guess what raw is !!!

> demangle( "RawVector::stored_type" )
[1] "unsigned char"


> Dirk
> 
> |  //I tried to fill it with char*(Mr) but I 
> | didnt succeed
> | }
> | 
> | Thanks,
> | 
> | Gustaf
> | 
> | -- 
> | Gustaf Granath (PhD)
> | Post doc
> | McMaster University
> | School of Geography & Earth Sciences
> | 
> | ___
> | Rcpp-devel mailing list
> | Rcpp-devel@lists.r-forge.r-project.org
> | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> 
> -- 
> http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Romain Francois
Hi, 

that's not going to fly. 

A CharacterVector holds strings of arbitrary lengths, well technically it holds 
other R objects (SEXP) that hold pointers to strings. 

A RawVector holds unsigned char. 

Can you add some meat to your example, e.g. what you'd expect to go in, etc ... 

Romain

> Le 20 oct. 2014 à 21:17, Gustaf Granath  a écrit :
> 
> Hi
> Im trying to use some C++ functions in R. However, these functions are build 
> around unsigned char* variables (1D array). I have for example a large matrix 
> in R that represents black (e.g. 1-bit image, 0 and 1s). I cant find a 
> solution to convert a character vector into unsigned char* within Rcpp. Im 
> new to Rcpp and C++ so I might have missed something obvious here. Please 
> direct me to resources on this topic (google did not help much).
> 
> A start:
> 
> SEXP test(SEXP cM){
>  CharacterVector Vc(cM);
>  int n = Vr.size();
>  RawVector x(n); //is this the same as unsigned char* ?
>//I tried to fill it with char*(Mr) but I didnt 
> succeed
> }
> 
> Thanks,
> 
> Gustaf
> 
> -- 
> Gustaf Granath (PhD)
> Post doc
> McMaster University
> School of Geography & Earth Sciences
> 
> ___
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Re: [Rcpp-devel] convert to unsigned char* variable

2014-10-20 Thread Dirk Eddelbuettel

On 20 October 2014 at 23:09, Romain Francois wrote:
| > Le 20 oct. 2014 à 21:54, Dirk Eddelbuettel  a écrit :
| > No, RawVector is for R 'raw' types -- see help("raw") in R,
| 
| Guess what raw is !!!
| 
| > demangle( "RawVector::stored_type" )
| [1] "unsigned char"

Touche, but for all uses I have seen (eg around serialization) raw was not
meant as the type Gustaf implied in his question.  Then again Gustaf's post
was a little short on specifics ...

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
___
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel