Displaying 2 results from an estimated 2 matches for "gsl_matrix_free".
2005 Dec 25
4
Portability and Memory Issues for R-package
.... I have noticed similar issues in the past when calling Winbugs repeatedly using Gelmans functions, so it is likely not an issue that is coming just from my code.
I suspect that the memory issues could have something to do with the fact that my C code makes repeated use of the gsl_matrix_alloc and gsl_matrix_free functions rather than the R_alloc function (I suspect that the memory is not Garbage collected). I searched the web and found the following suggestion from Bryan Gouch in response to a similar question posted on the gsl discussion forum.
"If you want to return an R object containing a gsl_ma...
2007 Jan 04
1
Parameter changes and segfault when calling C code through .Call
...y = gsl_vector_alloc(k);
gsl_vector_memcpy(y,x);
gsl_blas_dtrsv(CblasLower, CblasNoTrans, CblasNonUnit, sigmaChol, y); // y = inv(chol)*x from BLAS
gsl_blas_ddot(y,y,kern); // kern = y'y
// compute log density
res = -k*M_LN_SQRT_2PI - 0.5*(logdetSigma + *kern);
// release space
gsl_matrix_free(sigmaChol);
gsl_vector_free(x);
gsl_vector_free(y);
return(res);
} // end gsl_mvnorm_pdf
The problem is that after I make the .Call in R, the value of the sig matrix changes (the 1 in the upper left corner changes from a 1 to a 0). Since I don't make changes to the sigma object direct...