This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fixed-point operations


--- Cristea Bogdan <cristeab@gmail.com> wrote:

>      I use an Athlon 64 double core processor under
> openSuSE 10.2 (gcc
> 4.2.2). The trouble is that implementing fixed point
> operations in C++
> seems to be very slow with respect to floating-point
> operations. I
> have hoped to find something faster.
>     Ideally I would like to have a data type in C++
> with all common
> operations in order to do some research with chaotic
> maps.

This doesn't make sense.  You may want to check your
math.  Chaos can exist only on the reals because only
with the reals can you have a bounded interval
containing an infinite number of points.  With all
other kinds of number, such as integers, you can at
most have long periodic orbits.  The closest thing you
will find, in a computer program, will be floating
point numbers, and that only as long as your
simulations are short enough to make the sequence, in
fact drawn from a periodic orbit with a very long
period, you generate statistically indistinguishable
from a chaotic sequence that could be drawn from your
map.  There is some interesting research into how well
one can obtain a chaotic sequence (limitations due in
part to finite representation and in part to
information production interacting with representation
error).  I can recall seeing results based on this
kind of analysis twenty odd years ago which place
upper and lower limits on how long your simulations
can be and still adequately represent a chaotic
sequence from the map you're interested in (a
sequence, at that, with a small, unknowable difference
delta between the numbers obtained in the computed
sequence and the actual values that would have been
drawn from the chaotic process).  The best you can say
is that the sequence you have represents a chaotic
sequence from this chaotic process with an initial
position X0+delta0, and the distance between the
computed sequence and the "real" sequence is always
less than delta1.  But I digress.

This fact of life in regard to the nature of chaos
means the most useful type for the study of chaos is
that floating point type with the greatest precision. 
The more precision you can get, the better!  Why you
would even begin to looking at fixed point is a
mystery, unless you're using a template for it and
routinely give it more precision than is possible for
the largest floating point type.  But then, I'd bet
you'd be getting it all in software anyway since
you're likely be working with numbers that won't fit
in the processor's registers anyway.  You have to make
a choice.  Either deal with slow performance
associated with arbitrarily high precision obtained
using software (you can make a numeric class that will
give you megabyte numbers, if you wanted, but that
would be silly overkill), or deal with the limitations
of the representations available with the greatest
possible precision from the largest floating point
number.  You have to make a choice since you can't
have both.

HTH

Ted


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]