NumPy and Octave (question and discussion)

neelk at cswcasa.com neelk at cswcasa.com
Fri May 26 15:38:41 EDT 2000


Konrad Hinsen wrote:
>
> > Can NumPy be modified to look similar to octave? I bet there would be a 
> > lot [...]
>
> No, because all the syntax elements you want to use for arrays are 
> already used for something else in Python. 
>
> What can be done is implementing "matrix" and "vector" classes which 
> behave like Matlab's, using NumPy arrays as an internal representation. 
> There even was an early attempt at such a set of classes in the first 
> NumPy releases, but it wasn't maintained (probably due to lack of 
> interest!) and finally dropped. 

I actually tried to use the Matrix classes for a while before giving
up. The problem wasn't a lack of interest, it was just that the code 
to use it was so completely nasty. I needed to make a subclass of 
them to allow me to work with transparently with sparse arrays, and
found that I just couldn't get it to work right no matter what. 

The basic problem was there I needed to do binary dispatch to get 
my class to interoperate properly with regular Matrix instances, and 
that meant that I would have had to modify the Matrix class code as well 
as my subclass -- yucky. And the existence of __rmul__ turned the code
from merely rather nasty into pure evil. I eventually gave up and went 
back to using Gauss. It sucks, but not hard. :(

--
Neel Krishnaswami
neelk at cswcasa.com




More information about the Python-list mailing list