From luke@stat.umn.edu  Tue Jun  3 16:28:37 1997
From: luke@stat.umn.edu (Luke Tierney)
Date: Tue, 3 Jun 1997 10:28:37 -0500 (CDT)
Subject: R-alpha: unif_rand() again
In-Reply-To: <x2yb8r4t31.fsf@bush.kubism.ku.dk> from "Peter Dalgaard BSA" at Jun 3, 97 05:14:09 pm
Message-ID: <9706031528.AA15627@nokomis.stat.umn.edu>

Peter Dalgaard BSA wrote:
> 
> 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.
> 
> -- 
>    O__  ---- Peter Dalgaard             Blegdamsvej 3  
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> 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
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> 


This may not be an issue here but it is something to keep in mind for
call_S in S and R:

You need to be careful about making lots of call_S's that return large
amounts of data within a single call to .C. The reason is that the
call_S mechanism provides no way to mark the returned result as no
longer needed, so it cannot be reclaimed. Allocations made in the
process of executing the function called with call_S should be freed
just fine, but the result can't be. So if you produce lots of results,
you will consume lots of memory. For most uses of call_S this isn't an
issue, but if you were doing the loop of a long simulation is C and
it could become an issue.

-- 
Luke Tierney
University of Minnesota                      Phone:           612-625-7843
School of Statistics                         Fax:             612-624-8868
206 Church Street                            email:      luke@stat.umn.edu
Minneapolis, MN 55455 USA                    WWW:  http://www.stat.umn.edu
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


R-alpha: unif_rand() again
Luke Tierney