search for: rndstart

Displaying 9 results from an estimated 9 matches for "rndstart".

2005 Jun 14
3
Calling C from Fortran
I would like to call C routines from Fortran under linux as suggested in section 5.6 of the "Writing R extensions" documentation. I'm familiar with Fortran but not with C. I understand the example provided in Fortran: subroutine testit() double precision normrnd, x call rndstart() x = normrnd() call dblepr("X was", 5, x, 1) call rndend() end but I don't understand the purpose of this C wrapper: #include <R.h> void F77_SUB(rndstart)(void) { GetRNGstate(); } void F77_SUB(rndend)(void) { PutRNGstate(); } double F77_SUB(normrnd)(void) { return norm_r...
2005 Jun 14
1
Calling C from Fortran
I would like to call C routines from Fortran as suggested in section 5.6 of the "Writing R extensions" documentation. I'm familiar with Fortran but not with C. I understand the example provided in Fortran: subroutine testit() double precision normrnd, x call rndstart() x = normrnd() call dblepr("X was", 5, x, 1) call rndend() end but I don't understand the purpose of this C wrapper: #include <R.h> void F77_SUB(rndstart)(void) { GetRNGstate(); } void F77_SUB(rndend)(void) { PutRNGstate(); } double F77_SUB(normrnd)(void) { return norm_r...
2006 Jan 20
3
Troubles with the function rmultinom.c of the R's Random Number Generator
...oid F77_SUB(sarmultinom)(int n, double* prob, int K, int* rN){ rmultinom(n, prob, K, rN);} My fortran program is: subroutine testsarmultinom(n,prob,K,rN) implicit none integer n,K,rN(K) double precision prob(K) call rndstart() call sarmultinom(n,prob,K,rN) call rndend() end In order to understand better how the function rmultinom.c works, I have written an R code which calls this fortran subroutine as follows: system("R CMD SHLIB test-multinom.f wrapper.c") dyn.load("~/Package/test/test-multinom.so&qu...
2005 Nov 30
2
R binomial RNG stuck at 1 via Fortran call
Hi, I have some trouble with the result of a fortran function calling the R binomial RNG: The C function rbinom is wrapped as in the file attached. My main fortran program starts as call rndstart() and ends as call rndend() I happen to call the binomial RNG within a loop as b = ggrbinom(1.d0,0.5d0) write(*,*) 'b=',b In certain cases, after a few iterations in the loop, b get stuck at 1 Any hint to explain that would help. Gilles -- ?????????????????????????????????????...
2009 Dec 29
2
how can I use R functions in Fortran 90
Hi all, Is there a way that I can import R functions into Fortran? Especially, I want to generate random numbers from some not-so-common distributions (e.g. inverted chi square) but did not find any routines written in Fortran that deal with distributions other than uniform and normal. Thanks. Anny [[alternative HTML version deleted]]
2005 Nov 30
1
RNG stuck via Fortran call
...for all the following interations. Is there any suggestion of explanation for this strange fact ? Thanks in advance Gilles R Version 2.2.0 compiled under Mandrake 10.1 #include <R.h> #include <Rmath.h> /******************/ /* random numbers */ /******************/ void F77_SUB(rndstart)(void) { GetRNGstate(); } void F77_SUB(rndend)(void) { PutRNGstate(); } double F77_SUB(ggrnorm)(double *mu, double *sigma) { return rnorm(*mu, *sigma); } double F77_SUB(ggrexp)(double *scale) {return rexp(*scale);} double F77_SUB(ggrgam)(double *a, double *scale) {return rgamma(*a, *scale);}...
2002 Jul 03
1
Calling qnorm from Fortran
The R-exts may explicitly state this but I missed it. How do I call qnorm or pnorm from Fortran? Thanks -Frank -- Frank E Harrell Jr Prof. of Biostatistics & Statistics Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
2009 Nov 16
2
(Parallel) Random number seed question...
Hi All, I have k identical parallel pieces of code running, each using n.rand random numbers.? I would like to use the same RNG (for now), and set the seeds so that I can guarantee that there are no overlaps in the random numbers sampled by the k pieces of code.? Another side goal is to have reproducibility of my results.? In?the past I have used C with SPRNG for this task, but I'm hoping
2009 Jan 15
2
Interface to open source Reporting tools
...g the .c and the .f file the same base name > (causing "multiple definitions of symbol") I suggest that the docu > should provide file names for the two example programs, e.g.: > > frand.f: > > subroutine testit() > double precision normrnd, x > call rndstart() > x = normrnd() > call dblepr("X was", 5, x, 1) > call rndend() > end > > frand-helper.c: > > #include <R.h> > > /* Fortran */ > void F77_SUB(rndstart)(void) { GetRNGstate(); } > void F77_SUB(rndend)(void) { PutRNGstate(); }...