[pure-lang-users] ANN: Pure 0.7 released (a.k.a. Pure gets Octave-like matrix support)
Status: Beta
Brought to you by:
agraef
From: Albert G. <Dr....@t-...> - 2008-09-27 23:03:33
|
New in this release (you guessed it): GSL (GNU Scientific Library) matrix support. As usual, you can grab the new release here: http://sourceforge.net/project/showfiles.php?group_id=226193 The release notes are here: http://sourceforge.net/project/shownotes.php?group_id=226193&release_id=628859 Note that to enjoy the full GSL matrix support, of course you need to have GSL installed, which is available here: http://www.gnu.org/software/gsl/ (Forgot to update the INSTALL instructions on that. Will fix that asap.) I also updated the pure-mingw.zip file on the website, which now includes GSL 1.11 for those of you who want to roll their own Windows version. (Of course a ready-made msi package with a GSL-enabled version of the interpreter is available, too.) You can still build Pure without GSL, but then the interpreter will lack all the numeric matrix goodness, and only symbolic matrices will work. Backward compatibility issues: The introduction of the matrix syntax called for some changes in the comprehension syntax as well as in the arithmetic sequence notation: - The pipe symbol '|' is now used to separate the template expression and the generator and filter clauses. For consistency, this applies to both list and matrix comprehensions. The old [x;...] syntax is still supported in list comprehensions, but is flagged with a "deprecated" warning by the compiler. - Arithmetic sequences with arbitrary stepsize are now written x:y..z instead of x,y..z. This made it possible to give the .. operator a lower precedence than the ',' operator, which makes writing matrix slices like x!!(i..j,k..l) much more convenient. (Actually, considering how sequences are defined in Pure, you'll find that the new x:y..z notation actually makes *more* sense in Pure than the old syntax.) The matrix stuff: You can find some matrix examples in the examples folder (linalg.pure, gauss.pure), and in the manual. If you know Octave matrices then you should feel right at home. Here's a brief summary of the most important operations: - #x total number of elements - dim x number of rows and columns (as a pair) - x' transpose of a matrix - x!i ith matrix element in row-major order (zero-based) - x!(i,j) jth element in ith row of the matrix (zero-based) - x!!is, x!!(is,js) slicing (is and js are lists of machine ints) - x==y, x!=y matrix comparisons The curly braces construct matrices (using pretty much the same notation as in Octave, i.e., ',' separates columns, ';' rows), e.g.: - {1,2,3} a row vector consisting of machine ints - {1.0;2.0;3.0} a column vector of double values - {1.0+:0.0,0.0+:1.0} a complex vector (this requires math.pure, of course) - {1,2;3,4} a 2x2 int matrix - {1L,y+1;foo,bar} a symbolic matrix Like in Octave, the elements in curly braces can also be submatrices, provided that the dimensions match up. In addition, Pure also offers non-GSL, "symbolic" matrices which can contain any combination of Pure objects. We also have matrix comprehensions, which work pretty much like list comprehensions: > eye n = {i==j|i=1..n;j=1..n}; > eye 3; {1,0,0;0,1,0;0,0,1} (That's something which Octave doesn't have, instead you use 'for' loops in Octave which are *much* slower than Pure's comprehensions.) Note that only basic matrix operations are built into Pure or provided by the prelude; Pure isn't Octave after all. The usual linear algebra stuff can either be done using the Pure operations or by interfacing to GSL (a simple example of that can be found in the C INTERFACE section of the manpage). Marshalling of GSL matrices is handled transparently in the C interface so that you can pass Pure matrices to C without much ado. A full GSL wrapper will hopefully become available in the not so distant future. Eddie and I will work on this together, as time permits (I have some stuff to prepare for the upcoming semester, and Eddie is also quite busy right now, so don't hold your breath just yet). If anyone else wants to give a helping hand in that, please let us know so that we can coordinate our efforts. Well, you can probably imagine that the changes in both the interpreter and the library were again quite substantial this time, so please report any bugs that you find. Thanks. Enjoy! :) Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag |