Displaying 20 results from an estimated 1000 matches similar to: "double pointer matrix"
2006 Feb 21
4
simple C function segfaults
Hello,
I use the simplest of examples that somebody can think
of in order to generate a matrix of random numbers
from within C, calling appropriate R functions. The
concrete example is below:
--- file pico.c
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <R.h>
#include <Rmath.h>
#define COLM( i, j, m ) ( m*j + i)
void pico ( double *y, int n,
2005 Jun 28
1
GetRNGstate() crashes in Windows
Hi,
Has anyone managed to successfully call GetRNGstate() / PutRNGstate()
without crashing in a Windows environment (spec. XP)? I've compiled
successfully using both the latest Cygwin, latest Mingw, and the version
of Mingw suggested in "Building R for Windows" website, but when the
executable runs, it crashes; the functions themselves can run when I omit
2004 Mar 03
1
generating normal numbers: GetRNGstate, PutRNGstate
Hi
I'd like to generate thousands of normal numbers from my C function using
the C API functions provided R. I have two options:
1. double norm_rand(); (page 61 of R extension 1.8.1)
2. double rnorm(double mu, double sigma); (page 58 of R extension 1.8.1)
If my understanding of R-exts is correct, then I only need to call
GetRNGstate once, and then call 1000 norm_rand, and then call
2008 Jul 03
1
GetRNGstate and PutRNGstate
Hi,
I've got a simulation function, written in C and called from R, that
uses the R random number functions. It's not a very complicated
simulation - 280 lines total, with the main function (the one called
with .C) repeatedly calling another function, with multiple calls to
unif_rand() in both functions. At the beginning of the main function I
call GetRNGstate(), and the last thing I do
2009 Jun 30
3
Matrix with random number
Hello!
I have a program in Fortran and would like to build a matrix with random numbers, I have a function in C.
However, I have problems with the use of function in R.
Code to compile: R CMD SHLIB mat.f myrbeta.c -o func.so
Code in C.
#include <R.h>
#include <Rmath.h>
void F77_SUB(fseedi)(void){
GetRNGstate();
}
void F77_SUB(fseedo)(void){
PutRNGstate();
}
void
2002 Jan 24
2
random number generation issues with r and compiled C code
Dear People,
I have been writing a simulation routine that is currently entirely
written in c++. I've been using the R standalone math library to give me
random number generation for this. However, I have had to set the seed
myself, and I am using
set_seed(time(NULL), clock)
for every call to unif_rand().
However, this works really badly. The random numbers aren't uniform at
all. Does
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
2006 Jan 05
2
random seed question
Greetings,
I am trying to write a C++ subroutine of my random number generator. Based
on tutorial in Writing R Extensions, one should call GetRNGstate() before
and PutRNGstate() after calling R's random variate generation routines. Now
suppose my function would generate n(n>1) numbers by a loop, do I need to
call these two functions at each iteration? This certainly increases
computation
2002 Jan 14
1
trouble using R Mathlib as standalone
Dear People,
I am trying to use R's Math library as standalone, as documented in
/src/nmath/standalone. I am using C++ in Debian testing, and the versions
are as follows:
ii g++-3.0 3.0.3-1 The GNU C++ compiler.
ii r-mathlib 1.4.0-1 `GNU S' - Standalone R math library
I have a file (rand.cc) as follows. I don't think that lattice.hh or mh.hh
are very
2016 Jul 01
2
Calling C implementations of rnorm and friends
Gabriel,
Thanks for that! I guess I really should have figured that one out sooner,
huh?
I understand why that wouldn't be CRAN-compliant. But then, what *is* the
proper way to do it? Is there any way I can call unexported functions from
another package and have it accepted by CRAN?
Also, if I instead re-write the random variable generating functions, do
you have any idea of where the
2009 Nov 13
2
random numbers in C
I need some random numbers in my C program. Here a small example:
////////////////////////////////////////////////////////////////////////////////
#include <R.h>
void rand (int* n)
{
int len = *n;
for (int i = 0; i < len; i++)
Rprintf("%1.5f ", unif_rand());
}
dyn.load("rand.dll")
.C("rand", as.integer(10))
dyn.unload("rand.dll")
2010 Jun 15
1
Error when callin g C-Code
Hi
when I call the function below in R, i get the error: Object 'pairlist'
can't be converted to 'double'.
#include <R.h>
#include <Rdefines.h>
#include <Rmath.h>
SEXP CSimPoisson(SEXP lambda, SEXP tgrid, SEXP T2M, SEXP Ni, SEXP NT)
{
double sign, EVar;
double *xlambda, *xtgrid, *xT2M, *xNi, *xNT, *xtau;
SEXP tau;
int ltgrid =0;
int i = 0;
int j = 0;
2005 Nov 30
1
RNG stuck via Fortran call
Having not much success with my previous question I try to reformulate it:
I'm simulating a Markow chain in Fortran interfaced with R.
Each loop of my Fortran calls various functions of the R RNG through
the wrapper given below.
In a run of 100 iterations of the Markov kernel,
after 20 iterations, the RNG seems like frozen.
For example, the first call to the RNG in my loop is:
2006 Jun 27
2
UTF-8 and .Rd files
I have been converting to utf8 from latin1, and this gives me
problems, some solved, but here is one unsolved: In my .Rd files, I
have included '\encoding{UTF-8}' at the top. Despite this, the HTML
help pages contains 'content="text/html; charset=iso-8859-1"', and my
name is mangled. What can I do about this?
I'm on Ubuntu (latest), R-2.3.1
Thanks,
G?ran
2006 Feb 25
2
R-Project build system: DESTDIR support
Hello,
I am writing you about the GNU R-Project,
as part of by effort to help GNU projects provide a better, more
consistent build system.
Currently, your project does not support the DESTDIR variable in
generated Makefiles (marked as optional in the GNU coding policies, make and
automake manual).
In my opinion, DESTDIR support can be very helpful for the user, the
distribution-specific
2007 May 12
2
Problem with rnorm ?
Hi,
I couldn't get the rnorm() work right in C, for example, the following code produce strange results.
#include <stdio.h>
#include <Rmath.h>
int main(void){
double x[3];
for(int i=0;i<3;i++) x[i]=rnorm(0,1);
printf("%lf,%lf,%lf",x[0],x[1],x[2]);
return 0;
}
output : -8.773321,-8.773321,-8.773321
compiling script: gcc -std=gnu99 -Wall
2016 Jul 01
1
Calling C implementations of rnorm and friends
Well,
For this particular use case why not just transform the parameters at the R
level and then call the existing function? Is there not a closed form
mapping?
~G
On Jul 1, 2016 2:50 PM, "Joshua Ulrich" <josh.m.ulrich at gmail.com> wrote:
> On Fri, Jul 1, 2016 at 6:13 AM, Luis Usier
> <luis.henrique.usier at gmail.com> wrote:
> > Gabriel,
> >
> >
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
2010 Jul 20
1
Call to rgamma using .C causes R to hang
Hi,
I've been trying to get this working for ages, but it causes R to hang.
Here is my C code saved as test1.c
# include <R.h>
# include <Rmath.h>
void test1 (double *x, double *result)
{
result[0] = rgamma(*x, 2.0);
}
This was compiled using R CMD SHLIB test1.c & loaded in R using:
dyn.load("test1.dll")
out <-
2010 Jan 28
1
Problem with R math library.
Hello.
I've been working on my OCaml-R binding, and I quite pleased to see that
it is functional, though far from being perfect or polished. You can
find the gitweb webpage and the interface documentation at
http://yziquel.homelinux.org/gitweb/?p=ocaml-r.git;a=tree
http://yziquel.homelinux.org/topos/api/ocaml-r/index.html
I'm having unexpected trouble with the math library, though.