NumPy and Octave (qestion and discussion)
hzhu at rocket.knowledgetrack.com
Fri May 26 18:23:08 EDT 2000
Quick question first: Where are the matrix and vector classes?
Are they usable?
Now the discussion. I appreciate the comments made:
(1) Phython is more general so it cannot have special syntax for matrix
(2) NumPy was designed for general arrays instead of 2d arrays (ie.,
multilinear algebra instead of linear algebra).
However, linear algebra is not just another application domain. It is one
of the foundations of numerical computation. It would be a pity that it
could not be expressed efficiently in an otherwise almost perfect language.
To counter the above two comments where the "application domain" is really
(1) floating point calculation is built into languages instead of regarded
as a collection of binary operations.
(2) even though complex numbers are available and more general, one does not
have to use them for real number calculations.
A language with binary and complex operations but without real number
arithmatics is not generally convenient even though real numbers are neither
most basic in implementational sense nor most general in conceptual sense.
So my point is that perhaps the importance of numerical computation warrant
an (expressional) syntax that's more convenient. I think this can be done
without conflict with python's general syntax. It just need to be different
from NumPy's special choices.
To see why one would want this, consider an example. Suppose one wants to
build a learning machine that learns to play chess. Python would be a very
good language to write the overall structure, like players, the world, etc.
But the actual learning algorithm (neural network, statistics, etc) needs
lots of numerical computation which are very well expressed in matlab/
octave. Can this be done efficiently in python? Right now writing these in
NumPy is just too tedious and error-prone.
I would say that at the moment python is excellent in "comp sci" structures
but not so good in "comp math" structures. If it can overcome the latter,
many people would be pleasantly surprised to see many difficult problems
easily expressed in well-understood mathematical objects.
Regarding "rolling your own", I think most people doing numerical
computations (me included) are not those who are good at writing compilers
or interpretors. Maybe the wrapper class is a feasible approach.
It would be a wonderful thing if octave could have more OO structures that
are compatible with python. However I wouldn't hold my breath for that.
More information about the Python-list