From: Michael Braun <braunm_at_MIT.EDU>

Date: Sun 24 Dec 2006 - 23:58:50 GMT

}

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Dec 25 11:03:47 2006

Date: Sun 24 Dec 2006 - 23:58:50 GMT

Thank you to everyone who responded to my previous post regarding the integration into R of C programs that use external libraries. I have another issue that I simply have not been able to figure out using documentation, list archives, and so forth.

I have data that is stored in R lists. I would like to pass the list to C code using the .Call function, perform mathematical operations on the elements of the lists (which might be other lists), and return results in a new list.

Thanks again for any help you can provide.

Michael Braun

MIT Sloan School of Management

braunm@mit.edu

SEXP r = PROTECT(allocVector(VECSXP,n)); double rm[k][k]; for (i=0; i<n; i=i+1) { for (a=0; a<k; ++a){ // convert to gsl matrix for (b=0; b<k; ++b){ ind = b*k + a; m = REAL(VECTOR_ELT(list,i))[ind]; gsl_matrix_set(mat, b, a, m);

}

} // end conversion loops gsl_linalg_LU_decomp(mat, p, &s); gsl_linalg_LU_invert(mat, p, inv); for (a=0; a<k; ++a){ // convert from gsl matrix for (b=0; b<k; ++b){ rm[b][a] = gsl_matrix_get(inv,b,a);

}

} SET_VECTOR_ELT(r, i, rm); } UNPROTECT(1); return (r);

}

R-devel@r-project.org mailing list

https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Dec 25 11:03:47 2006

Archive maintained by Robert King, hosted by
the discipline of
statistics at the
University of Newcastle,
Australia.

Archive generated by hypermail 2.1.8, at Mon 25 Dec 2006 - 04:30:57 GMT.

*
Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel.
Please read the posting
guide before posting to the list.
*