R-alpha: unif_rand() again
Kurt Hornik
Kurt.Hornik@ci.tuwien.ac.at
Tue, 3 Jun 1997 17:17:29 +0200
>>>>> Peter Dalgaard BSA writes:
> Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:
>>
>> Just out of curiosity, here is a question that might be embarrasingly
>> stupid. Hmm ...
>>
>> What I need is to call runif() (more precisely, `runif(1, 0, 1)') from
>> inside a C function. Is this possible using call_S? If so, how?
> Hmm ... Stupid counter-question: Did you study the zfun() function in
> $RHOME/demos/dynload/zero.c ? Looks pretty straightforward to me,
> except that I have no offhand guess what the 0L argument to call_S is
> good for. Peeking at the source should cure that.
I did. I hoped that something like
static char *func = "runif";
double unif_rand() {
void *in[3];
char *modes[] = { "integer", "integer", "integer" };
long lengths[] = { 1, 1, 1 };
void *out[1];
double *result;
in[0] = (void *)1L;
in[1] = (void *)0L;
in[2] = (void *)1L;
call_S((void *)func, 3L, in, modes, lengths, 0L, 1L, out);
result = (double *)out[0];
return(result[0]);
}
might work, but it does not ...
-k
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-devel 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-devel-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-