[R] allocating memory in C, not in R
Sigal Blay
sblay at sfu.ca
Thu Sep 2 01:41:36 CEST 2004
Thank you for the fast reply.
Below is a simplified version of my c function that I am
currenctly using with a .C() call.
The values that has to be returned to R are the three outVectors.
If I need to convert .C to .Call,
How do I do it based on myFunction below?
Thank you for your help.
void myFunction(char **argv, int *inputVector,
int *RoutVector1, double *RoutVector2, char **RoutVector3) {
int *outVector1;
double *outVector2;
char **outVector3;
int roof = 0;
roof = calculate_values ( argv[0],
inputVector,
&outVector1,
&outVector2,
&outVector3 )
for(i=0;i<roof;i++) {
RoutVector1[i] = outVector1[i];
RoutVector2[i] = outVector2[i];
}
return;
}
On Wed, Sep 01, 2004 at 10:16:59PM +0100, Prof Brian Ripley wrote:
> On Wed, 1 Sep 2004, S. Blay wrote:
>
> > I need to retrieve several vectors of various types from a call
> > to .C(), but I don't know their length in advance.
> > Is there a way to do this without allocating an excessive amount
> > of memory?
> > If so, an example would be very helpful.
>
> It would be very much easier to use .Call rather than .C.
>
> Alternatively, generate and allocate in C on one C call and retrieve on a
> second, as rpart does.
>
> --
> Brian D. Ripley, ripley at stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list