Thursday, June 26, 2008

changes in cl-cairo2

Johann Korndoerfer kindly submitted a patch that adds patterns to cl-cairo2, and also includes some code cleanup. Here is the example Johann contributed to the tutorial, a rainbow created with patterns: Thanks for the nice work, Johann! I am happy that others also find cl-cairo2 useful. cl-cairo2 still suffers from the elusive floating point bug (possibly in libcairo), I am still working on that. In the meantime, you can work around that by not generating PS files directly, but converting them from PDF or SVG files. Since common-lisp.net appears to be down, I took the opportunity to migrate the repository to git, which I am now hosting on my webpage. I find git to be much more convenient than SVN, especially when it comes to ease of distribution. As before, the package remains ASDF-installable. Update: the GIT repository is here, but can also be found from the cliki page for cl-cairo2.

announcement: minpack package

I have been using a simple solver (based on Broyden's method) to finds roots of systems of nonlinear equation, but I encountered an ill-behaving class of problems that required heavier artillery. Numerical methods have made a lot of progress in the last 50 years. Methods presented in introductory textbooks are quite straightforward and very simple to code, but do not cut the mustard when it comes to more difficult situations (eg when you don't have a good initial guess, your function looks like the fjords of Norway, etc). State of the art methods are powerful, but they are tricky to program: the main idea is easy to grasp, but one has to cover a lot of special cases (eg line-search, niceties of trust-region methods) so implementing them from scratch takes a lot of time (and debugging). This is why most researchers rely on Fortran (or most recently, C) packages of these methods. Common Lisp users generally have two alternatives if they don't want to implement these methods from scratch. They can use the foreign code directly via the FFI, or translate the code using f2cl, which is available as part of CLOCC. I found the second option more appealing, for the following reasons:
  • fewer dependencies (no need to install/compile foreign libraries)
  • no need to have callbacks (which are a pain in the neck)
  • better integration into Lisp (eg you can use the condition system)
This is the first time I used f2cl, but it was quite easy to do, especially as CLOCC already has things set up for MINPACK. I think that translating from Fortran is the way to go for some libraries, even though I recognize that for libraries like LAPACK where pure performance matters, FFI is the better option, especially as the functions there have simpler interfaces and don't need callbacks and complex condition handling. MINPACK has already been available as part of CLOCC, but I had a hard time getting the whole thing work in SBCL, and it doesn't use ASDF, so I decided to package it to make it self-contained and ASDF-installable. The extended version of the project I am working on will probably need homotopy methods, and I am looking forward to packaging that too.