
Boost : 
Subject: Re: [boost] GSOC 2013
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 20130423 19:05:11
On 4/23/13 5:24 PM, Vicente J. Botet Escriba wrote:
> Michael, I was not aware that you have already a fixedpoint library in
> http://code.google.com/p/libfixmath/.
>
> Could you give us pointer where this file cross/math/fixed/fixed.hpp is
> located?
>
Sure I had necro'd a thread a while back but it probably got missed.
Reposting:
On 2/1/13 11:09 PM, Michael Marcin wrote:>
> Missed this thread, only just came across it while catching up on things.
>
> I think fixedpoint is a very worthwhile thing although in past
> discussions it seems like the functionality that everyone agrees upon is
> a very small subset of what people need in their fixed point types.
>
> I worked with fixedpoint numbers for embedded systems without FPUs for
> a few years. Mostly doing real time 3d software rendering with fixed
> point numbers.
>
> I always imagined a boost fixed point library would use some expression
> template patterns probably built on boost proto and be a drop in
> replacement for float with no abstraction penalty. That way you could
> preserve full precision until the end of the full expression.
> Unfortunately I had neither the time or the TMP expertise to pull it
> off. Trig functions should be implemented with CORDICbased algorithms.
>
> Here's the fixed point abstraction I used for reference.
>
> http://www.mikemarcin.com/media/programming/fixed.7z
>
> The main class acts as a drop in replacement for float.
>
> template< std::size_t MagnitudeBits, std::size_t FractionalBits >
> class fixed;
>
> The fixed class includes:
>  various converting constructors from integers, floating point, and
> different precision fixedpoint types
>  comparison operators
>  arithmetic operators
>  some mixed type arithmetic operators (like fixed * int)
>  some really simple expression templates for multiplication
>
> as_fixed() function which takes an integral type and returns a type
> convertible to a fixedpoint type
> i.e.
> fixed<16,16> a = as_fixed( 1<<16 );
> assert( a == fixed<16,16>(1) );
>
> numeric_limits is specialized for fixed types
>
> some math functions:
>  abs
>  fmod
>  floor
>  ceil
>  ceil_int
>  sqrt
>  sign_equal
>  sign_not_equal
>  *missing* true fixedpoint trig functions
>
> conversion functions:
>  to_integer
>  to_float
>  to_double
>
> lame stream operators (convert to/from float):
>  std::istream& operator>>(std::istream& stream, fixed<M,F>& x)
>  std::ostream& operator<<(std::ostream& stream, const fixed<M,F>& x)
>
>
> Here's some interesting fixedpoint resources
>
> Anthony Williams wrote an interesting article on fixedpoint math.
>
http://www.justsoftwaresolutions.co.uk/news/optimizingapplicationswithfixedpointarithmetic.html
>
>
> Nils Pipenbrinck wrote an interesting article of fixedpoint math which
> all but disappeared unfortunately.
>
http://web.archive.org/web/20080704062813/http://www.devmaster.net/articles/fixedpointoptimizations
>
> Discussion:
>
http://web.archive.org/web/20071220190103/http://www.devmaster.net/forums/showthread.php?t=9531
>
>
> Ken Turkowski's fixedpoint square root algorithm
> http://www.realitypixels.com/turk/computergraphics/FixedSqrt.pdf
>
> ARM code inverse square root routines
> http://www.finesse.demon.co.uk/steven/invsqrt.html
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk