[R] passing a matrix to C++ with .C()?
Timothy H. Keitt
tklistaddr at keittlab.bio.sunysb.edu
Tue May 7 17:35:21 CEST 2002
Take a look at the ".Call" documentation in the "writing R extensions"
manual. If you mean passing an R matrix to C++, then you will have to
pass the SEXP structure containing the matrix into your C++ code and
manipulate it with internal R functions. If you mean passing a C++
matrix into R, you will have to wrap the pointer and return it from your
C++ code. Note that R will have no idea what to do with the pointer
unless you provide appropriate functions/methods to manipulate it in R.
(I believe the "Matrix" package does just that.)
Tim
On Tue, 2002-05-07 at 01:05, Francisco J Molina wrote:
> It seems that it is possible to pass a matrix to C++ by using .C()
>
> The R part of the interface should be something like:
>
> ('C++function', matrix, numberRows, numberColumns )
>
> ...I guess.
>
> The C++ part of the interface could be something like
>
> void C++( double matrix[][], int numberRows, numberColumns )
>
> but C++ requires to indicate the number of columns, that is, instead of
> matrix[][], it should be double matrix[][ numberColumns ]...
>
> This does not look like the right thing to do though.
>
> Can anyone help me with this?
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list