equivalent of NULL or OM in Python

Tim Rowe digitig at cix.co.uk
Sun Feb 25 16:17:00 EST 2001


In article <L1bj6.16746$GA5.260574 at e420r-atl1.usenetserver.com>, 
sholden at holdenweb.com (Steve Holden) wrote:

<snip>

> Choice of data representation can be critical in algorithm design, and 
> this
> is quite a good example. However, I have not fully considered the 
> symbolic
> manipulations you want to perform, so I may be putting my foot in my 
> mouth
> here. That's how I know I have a size 10 mouth: the foot fits perfectly.
> 
> It would appear to be more regular to represent absent terms as a
> coefficient of zero. Furthermore, if you reverse the order of the terms,
> putting x^0 at the left, you can then use the index into the list as the
> power. So your examples could be represented as follows:
> 
> 3X^2+4X+4 : [4, 4, 3]
> 3x^2+4: [4, 0, 3]

It depends what he wants to do. If he's doing things like CRC calculations 
the lists are likely to have a lot of zeroes. 

I think it would be worth considering numpy, as polynomial conversions are 
easily represented as array operations, and ISTR numpy is clued up on 
sparse arrays.



More information about the Python-list mailing list