Python linear algebra module -- requesting comments on interface

C. Barnes connellybarnes at
Fri Sep 9 13:58:43 CEST 2005

Hi, I'm in the process of writing a Python linear
algebra module.

The current targeted interface is:

The interface was originally based on Raymond
Matfunc [1].  However, it has evolved so that now it
nearly identical to JAMA [2], the Java matrix library.

I am soliticing comments on this interface.

Please post up any criticism that you have.  Even
things -- if something isn't right, it's better to fix
it now than later.

I have not made source code available yet, since the
current code is missing the decompositions and doesn't
match the new interface.  I'm in the process of
rewritting the code to match the new interface.  You
can e-mail me and ask for the old code if you're
or skeptical.


Brief comparison with Numeric

Numeric and linalg serve different purposes.

Numeric is intended to be a general purpose array
extension.  It takes a "kitchen sink" approach,
and includes every function which could potentially
be useful for array manipulations.

Linalg is intended to handle real/complex vectors
and matrices, for scientific and 3D applications.
It has a more restricted scope.  Because it is
intended for 3D applications, it is optimized
for dimension 2, 3, 4 operations.

For the typical matrix operations, the linalg
interface is much intuitive than Numeric's.  Real
and imaginary components are always cast to
doubles, so no headaches are created if a matrix
is instantiated from a list of integers.  Unlike
Numeric, the * operator performs matrix
multiplication, A**-1 computes the matrix inverse,
A == B returns True or False, and the 2-norm and
cross product functions exist.

As previously stated, linalg is optimized for
matrix arithmetic with small matrices (size 2, 3, 4).

A (somewhat out of date) set of microbenchmarks [3]
show that linalg is roughly an order of magnitude
faster than Numeric for dimension 3 vectors and

Microbenchmarks without psyco:

Microbenchmarks with psyco:

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Python-list mailing list