[Numpy-discussion] Fixed-point arithemetic...any solution yet?

Ruben Salvador rsalvador.wk@gmail....
Thu Dec 10 04:22:18 CST 2009

On Wed, Dec 9, 2009 at 8:26 PM, Neal Becker <ndbecker2@gmail.com> wrote:

> Ruben Salvador wrote:
> > Hello everybody.
> >
> > I've seen this question arise sometimes on the list, but don't know if
> > something has "happened" yet or not. I mean, any solution feasible to use
> > more or less right out of the box?
> >
> > I'm just a hardware engineer, so it would be difficult for me to create
> my
> > own class for this, since my knowledge of python/numpy is very limited,
> > and, just don't have the time/knowledge to be more than a simple user of
> > the language, not a developer.
> >
> > I have just come across this:
> > http://www.dilloneng.com/documents/downloads/demodel/ but haven't used
> it
> > yet. I'll give it a try and see how it works and come back to the list to
> > report somehow. But, is there any "official" plans for this within the
> > numpy developers? Is there any code around that may be used? I just need
> > to test my code with fixed point arithmetic (I'm modelling hardware....)
> >
> > Thanks for the good work to all the Python/Numpy developers (and all the
> > projects related, matplotlib and so on....) and for the possiblity of
> > freeing from matlab!!! I'm determined to do research with as many free
> > software design tools as possible....though this fixed-point arithmetic
> > issue is still a chain!
> >
> > Regards!
> I've done some experiments with adding a fixed-pt type to numpy, but in the
> end abandoned the effort.  For now, I use integer arrays to store the data,
> and then just keep variables for the #bits and position of the binary
> point.
> For actual signal processing, I use c++ code.  I have a class that is based
> on boost::constrained_value (unreleased) that gives me the behavior I want
> from fixed point scalars.
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

Well...I think I may also try this way. This FIXED_POINT_FACTOR scaling is
what is actually done implicitly in hardware to align bit vectors. And if I
over-dimension the bit length, I "won't need to take care" of the number of
bits after arithmetic operations...

I'll try and see...but, if anybody has a quicker solution....I'm actually in
a hurry :S

I had a look at the code I mentioned in my first email. It does the trick
someway, but from my point of view, needs some more tweaking to be usable in
a wider context. It only supports some operations and I just guess it will
fail in many numpy.array routines, if data is not cast previously (maybe not
since the actual numerical value is floating point, and the fixed point is
an internal representation of the class)...will try and report back....

Anyway, don't you people think we should boost this fixed-point issue in
numpy? We should make some kind of roadmap for the implementation, I think
it's a *MUST*.

Rubén Salvador
PhD student @ Centro de Electrónica Industrial (CEI)
Blog: http://aesatcei.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20091210/e00fe815/attachment.html 

More information about the NumPy-Discussion mailing list