On Fri, Oct 22, 2010 at 4:30 AM, Nick Sabbe <nick.sa...@ugent.be> wrote: > Hello all.
> I'm developing a package for R holding a Gibbs sampler, which tends to have > better performance when written in C than in R. > During each iteration in the Gibbs sampler, I need the inverse of a > symmetric matrix. You may want to check that. The first rule of numerical linear algebra is that you hardly ever need to invert a matrix. If you need to solve a linear system, you use a factorization, as below and then use one of the solvers based on that factorization. If the matrix is small calculating the inverse is not a big problem. If it is large and you do so within each iteration of your sampler then you are probably wasting time. > For this, I wish to use lapack, as is concisely suggested in "Writing R > extensions", since this will have better performance than I could ever write > myself. > > After some twiddling I have got my code to compile by including > "R_ext/Lapack.h" and using "F77_CALL(dpotrf)", but unfortunately, I don't > get this to link properly. > I get this message: " testc.o:testc.c:(.text+0x255): undefined reference to > `dpotrf_'" which seems logical to me as far as my understanding of C > reaches, but I don't know how to resolve it. I'm quite sure I need some > extra parameters in my makefile, but as I come from a world where all these > complexities are happily abstracted away for me by an IDE, I have no actual > clue on how to surmount this. Go back to section 1.2.1 of "Writing R Extensions" that deals with "Using Makevars". > However: when I'm done with all my code, I wish to build a package for > publication on CRAN, so I want to be sure that not only I can build it on my > system, but it will also work well when distributed to other computers (if I > understand the package process well, source files are compiled and linked > during installation of the package), so I would also like to know how to do > this. > > It should not be relevant, but either way: I'm doing all this on a Windows 7 > machine, though the package will probably be used on Linux-based servers > eventually. > > Finally: I have found no comprehensive list of the functions available to an > R package developer, nor, strangely, questions about that. Does such a thing > exist, or are we up to hoping we find what we are looking for in the header > files? If it does not exist already, I would surely be willing to work on > it. Do you mean other than the section on "The R API" in the "Writing R Extensions" manual? > Thanks for any input. > > Nick Sabbe > -- > ping: nick.sa...@ugent.be > link: http://biomath.ugent.be > wink: A1.056, Coupure Links 653, 9000 Gent > ring: 09/264.59.36 > > -- Do Not Disapprove > > ______________________________________________ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel