"Michael Braun" <[EMAIL PROTECTED]> 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:

>
>       dyn.load("mvnorm-logpdf.so")
>
>       x<-c(0,0,0,0,0,0)
>       mu<-c(0,0,0,0,0,0)
>       sig<-diag(6)
>       print(sig)
>       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
lines (untested):

   SEXP sigma_copy;
   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.

+ seth

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to