Displaying 2 results from an estimated 2 matches for "gsl_matrix_alloc".
2005 Dec 25
4
Portability and Memory Issues for R-package
...virtually no progress. 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...
2007 Jan 04
1
Parameter changes and segfault when calling C code through .Call
...beta, gsl_vector * betaMean, gsl_matrix * sigma, int k) {
// computes density of multivariate normal vector at vector beta, with mean betaMean and cov sigma
double logdetSigma = 0;
double res;
double * kern;
int i, err;
// pointer to Cholesky decomp of sigma
gsl_matrix * sigmaChol = gsl_matrix_alloc(k, k); // define matrix that will store Chol decomp
gsl_matrix_memcpy(sigmaChol, sigma);
gsl_linalg_cholesky_decomp(sigmaChol);
// compute logdet of sigma by 2*sum of log of diagomal elements of chol decomp
for (i=0; i<k; i++) {
logdetSigma = logdetSigma + log(gsl_matrix_get(sigmaCho...