Hello everyone!

First of all, please note that  I'm working under Windows 7.

I have written a Gibbs sampler in R and I'm now in the process of translating 
it in C++ to increase the speed.  I'm relatively new to C++ and this question 
may be trivial, but my search so far have been unsuccessful.  In my Gibbs 
sampler I am using some basic R functions (like the rep function for example) 
and I was wondering if it was possible to call the R rep function (or any other 
existing R function) from within my C++ code.   (There may be an equivalent of 
the rep function already in C++ but my main interest here is to learn if there 
is a way to call the R function within C/C++)

I'm aware that you can call R random number generators as well as probability 
distribution functions with the  GetRNGstate() but what about other functions?

The sample of the C code below reveals what I would like to do regarding the 
rep function.

extern "C" {
   void Gibbs_Sampler (double *vect.PI, int *iteration)
    {
                int i;
                for (int i=0; i<*iteration; i++)
                {
                  ...

                  PI.rep = rep(vec.PI,times=n)   // Can we call the R rep 
function such that this line of code (or any equivalent code) is valid?

                  ...
                 }
    }
}

Thanks,


******************************************************************************************************************************

IAN SCHILLER, M.Sc.



Statistical research assistant,

Division of Clinical Epidemiology, McGill University Health Center Assistant de 
recherche en statistiques, Département d'Épidémiologie Clinique, Centre 
Universitaire de Santé Mcgill



Tel: 514 934 1934 ext. 36925

Email: ian.schil...@clinepi.mcgill.ca<mailto:ian.schil...@clinepi.mcgill.ca>


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to