[Rd] Parameter changes and segfault when calling C code through .Call
sfalcon at fhcrc.org
Thu Jan 4 22:31:01 CET 2007
"Michael Braun" <braunm at MIT.EDU> writes:
> Suppose I want to compute the log density of a multivariate normal
> distribution using C code and the gsl library. My R program is:
> w<-.Call("R_mvnorm_logpdf",as.double(x),as.double(mu),sig, as.integer(6))
> print(sig) # sig has changed after .Call
Arguments sent via the .Call interface are not copied. In almost all
cases, they should be treated as read-only data.
You can copy a given SEXP using duplicate. Something along these
PROTECT(sigma_copy = duplicate(sigmax));
But it seems pretty clear that sigmaView is holding a pointer to
sigmaAr which in turn points to the data in sigmax.
More information about the R-devel