Saturday, May 23, 2009

announcing latex-table

Latex-table is a simple Common Lisp library for writing vectors and matrices into LaTeX tables. It won't allow you to do anything magical that you could not do in LaTeX otherwise, but it simplifies formatting (mostly numerical) tables. Floats are aligned on the decimal dot. Some examples:
(with-open-file (stream "/tmp/horizontal.table" :direction :output
   :if-exists :overwrite :if-does-not-exist :create)
  (labeled-vector-horizontal stream 
        (vector "foo" pi -42)
        (vector "$\\alpha$" "bar" "baz")
        :significant-digits 3))
(with-open-file (stream "/tmp/matrix.table" :direction :output
   :if-exists :overwrite :if-does-not-exist :create)
  (labeled-matrix stream #2A((11.1 112.55 3)
        (9 1345.79 14.72))
    (vector "foo" "bar" "baz")
    (vector "first" "second")
    :hlines '(1 2 -1 1)))
All of these functions use the "raw" interface below, which you can also use directly.
(with-open-file (stream "/tmp/raw.table" :direction :output
   :if-exists :overwrite :if-does-not-exist :create)
  (raw-tabular stream #2A(((:aligned "foo" ""))
     ((:aligned "bar" "baz"))
     ((:aligned "" ".19"))
     ((:left "left"))
     ((:right "right"))
     ((:center "center")))
        #(:aligned)  ; column types
        #(0 0)   ; vertical lines
        #(1 2 0 0 0 0 3))) ; horizontal lines

cl-cairo2 interface poll

It seems that what I considered a wart is a feature to some people. I would like to make the users of cl-cairo2 happy, so I am considering reverting to the older interface. Also, I experimented with some other code I am using, and I think that wrapping my code in (let ((*context* context1)) ...) is not too much of a hassle anyway. So I am conducting an informal poll: please comment below. If you like the
(move-to context ...)
interface, say explicit, if you prefer the
(move-to ... &key (context *context*))
interface, say global. If you are indifferent, just state that. You can also tell me if you have code that already uses either interface, and whether you it would be a great inconvenience to change that (but I can't imagine that very many people have a lot of code using the explicit interface at this stage). I have listened to your arguments, so you won't need to repeat them, unless you feel that you have something crucual to add. I will take a look at the results on Tuesday, May 26, and update the library (and cl-2d) if necessary. I would rather complete the transition quickly, as I want the API to be relatively stable. I do know that in the previous post I said that there will be no more changes, guess I am dynamically inconsistent :-P

Thursday, May 21, 2009

cl-numlib, array-operations and cl-colors migrated to Github; my packages are asdf-installable again

Looks like I goofed up when releasing cl-2d: it used a few routines which were sitting on my hard disk but not made public yet. I think I corrected that, and pushed the new versions to Github. Also, I think I figured out how to link to tarballs on Github. Using entries like
:(package "")
ASDF goes to Github, where is it redirected to the latest master tarball, and appears to work fine. If not, let me know and it will be fixed. Still, I would suggest that you use git to keep updating the libraries if you can. Thanks to Peter Mikula for reporting the missing library code.

ffa: complex numbers, license change, migration to Github

I have done a few minor updates to my FFA library. It now handles complex numbers (to be precise, arrays of (complex simple-float) and (complex double-float)). Because of the extra complexity (haha), I also added some unit tests that use simple C functions to check that FFA does what it claims to do. I have also changed the license to LLGPL (was GPL). And finally, I have migrated the library to Github. Github is proving really user-friendly and reliable, in the long run I plan to put all my libraries there. Thanks to William Halliburton for reminding me that the previous repo was out of date.

Tuesday, May 19, 2009

announcing cl-2d

Cl-2d is a two-dimensional graph library for Common Lisp. It builds on cl-cairo2 and thus uses the Cairo library, which provides various backends, including pixel-based (eg PNG, X11) and vector-based (PDF, SVG, PS) ones. It is meant solely for 2-dimensional plotting (hence the name). Cl-2d is available from Github. The license is LLGPL. Cl-2d is designed to be extensible instead of providing a plethora of "canned" functions - the latter of course exist, but the emphasis is on flexibility. Most plots used in scientific visualization are customized, and the purpose of this library is to make customization easy. Plotting happens on frames, which are rectangular areas. A DSL is available for splitting frames. A frame combined with a mapping from plot coordinates to Cairo coordinates is a drawing area. Functions named plot-* take a frame, set up and return a drawing area (on which you can continue drawing), while draw-* functions draw on an existing drawing area. This library is still under development, suggestions and contributions are welcome. I mean to clear up the axes code and add contour plots soon. See the example/ directory for a wide variety of examples. Some of the example plots, converted from PDF, are shown below.

Friday, May 15, 2009

cl-cairo2 *context* wart fixed

I pushed an updated version of cl-cairo2 to the repository today. The most important change is the fixing of a major design wart that was the result of a bad initial design choice. Originally, cl-cairo2 functions had an optional context argument as the last argument, which defaulted to *context*. This seemed to make sense at the time, it saved typing, but later on I realized it is very unLispy. So now context is the first argument, and is never optional, *context* is gone. I realize that this might break some code for people who are using cl-cairo2, and for this I apologize. But it had to be done sooner or later, I kept putting it off but finally could not bear it any more. Since I was using macros to generate most of the function definitions, effecting the change was a matter of minutes. I also cleaned up the documentation a bit.

Wednesday, May 13, 2009

cl-cairo2 migrated to

I have migrated cl-cairo2 to If you want to install it, just clone from the repository:
git clone git://
You might have to create a symlink to the asd file in your ASDF systems directory. This is just a migration, no new code added. The package is no longer ASDF-installable. I have began to hate ASDF-install, it is more trouble than it is worth. For those who insist, it is possible to download a tar.gz file from Github, but the name of the link changes with updates, so I can't put one on Believe me, you are just better off pulling it from the git repository. Eventually, I plan to add support for Mudballs, but not soon.