Version 1 of Ideas for a numerical analysis package

Updated 2004-03-12 09:02:40

Arjen Markus This page is meant for collecting ideas on how to deal with numerical analysis in Tcl.

The rationale

There are quite a few attempts to implement numerical analysis methods in Tcl, but so far there is no framework (conceptual or otherwise) that you can readily use. Everybody tries to do it in his or her own way.

If we look at our Perl and Python colleagues, they have PDL (Perl Data Language) and Numpy (or Numarray it seems to be called nowadays). There is no equivalent to my knowledge in Tcl, though there are quite extensive packages like la and NAP that might classify as such.

The basic problem

Numerical methods often deal with collections of data:

  • Arrays (in the C or Fortran sense) of numbers
  • Vectors in an N-dimensional space
  • Matrices (square or rectangular)
  • Higher-dimensional structures (but these tend to be used mainly in specialised areas)

One could think of nested lists (see Playing APL for an example) to represent them, but the la package uses plain lists for good reasons:

  • More efficient
  • The possibility to represent row and column vectors, important for a linear algebra package

Standard libraries exist in both C and Fortran for many problems (think of: Lapack and FFT libraries for instance). We can access these via small wrappers, generated via SWIG or Critcl and in fact a few such wrappers already exist.

The solution?

We should decide what the best methods are for dealing with numerical data and create an easy to use framework out of this. The design issues are:

  • Comfortable use from within Tcl
  • Acceptable performance, even with large sets of data
  • Easy to pass to and from binary extensions

My first guess is that we need a hybrid solution:

  • For small sets of data, a nested list may be the easiest way
  • For large sets of data, the LA approach or even an approach with binary strings (these are opaque to the scripting side but easy to pass to binary extensions) can be used

[ Category Numerical Analysis ]