Displaying 8 results from an estimated 8 matches for "rndend".
2005 Jun 14
3
Calling C from Fortran
...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_rand(); }
neither how I should compile it.
Could anyone explain how...
2005 Jun 14
1
Calling C from Fortran
...s 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_rand(); }
neither how I should compile it.
Could anyone explain how...
2006 Jan 20
3
Troubles with the function rmultinom.c of the R's Random Number Generator
...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")
n=1
prob=c(0.6,0.1,0.3)
K=3
rN=c(1,0,0...
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
...uggestion 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);}
double F77_SUB(ggrunif)(double *a, double *b)...
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
...) 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(); }
> double F77_SUB(normrnd)(void) { return norm_rand(); }
>
> As a further suggestion, it w...