Dan King <dan_k_10017@yahoo.com> writes:
> Hi, all,
>
> In Splus, how does one pass a 2 dimentional array to a
> C subroutine?
>
> For example, I have a matrix in Splus:
>
> > dim(data)
> [1] 845 13
>
> The C function is declared as follows:
> void Foo ( float ** something, int *Nrow, int * Ncol,
> float * result)
>
> So I call "Foo" this way:
>
> > .C("Foo",as(data,"single"),as(845,"integer"),
> as(13,"integer"),as(result,"single"))
>
> Will this work? Is the 'something' variable in the C
> routine an array of pointers, or is it just a array
> with length (Nrow * Ncol)?
The latter. Also note that the array is in column major order. That
is, the elements are in the order data[1,1], data[2,1], ...,
data[845,1], data[1,2], ..., data[845, 15]
> Any suggesting/reference will be greatly appreciated.
Chapter 6 of Venables and Ripley, "S Programming".
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
|