s-news
[Top] [All Lists]

Re: [S] splus to c

To: Dan King <dan_k_10017@yahoo.com>
Subject: Re: [S] splus to c
From: Douglas Bates <bates@stat.wisc.edu>
Date: 25 Sep 2000 12:08:17 -0500
Cc: s-news@wubios.wustl.edu
In-reply-to: Dan King's message of "Mon, 25 Sep 2000 09:37:31 -0700 (PDT)"
References: <20000925163731.14426.qmail@web4805.mail.yahoo.com>
Sender: owner-s-news@wubios.wustl.edu
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7
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

<Prev in Thread] Current Thread [Next in Thread>