|
Boost : |
From: John (EBo) David (ebo_at_[hidden])
Date: 2000-11-29 05:34:14
Paul Moore wrote:
>
> From: mdrinto_at_[hidden] [mailto:mdrinto_at_[hidden]]On
> > To be harsher, who the heck is using this class? Probably only
> > people who specifically need rationals and whose universe doesn't
> > include floating point numbers. Generally, the two don't mix well
> > in applications.
>
> That was my original view. The indications from people asking for
> conversions from double seem to imply that there are other views...
examples? Ok, this is one that I am thinking about -- and you may all
fee free to tell me I'm being stupid if you think that it is so.
Part of what I've been doing over the last several years is ecological
fragmentation modeling and analysis. The are a couple of publicly
available software packages that computes a number of spatial
statistical metrics. One in particular which is probably the most
commonly available and used is a program named FRAGSTATS (for
FRAGmentation STATisticS). It was written with no consideration of
numerical analytic methods and implements most, if not all, the
statistical metrics in a strait forward manner (and yes their
implementation of the nearest neighbor distance is a brute force N^2
approach and not the N log N one). Unless I am being totally nieve,
using exact arithmetic sidesteps several problems of error propagation,
etc. and implementing several of the classic algorithms (like computing
the Voronoi Diagram) is a reasonable place to start. But all of my
input data (point locations, etc.) come to me in floating point format
(and I often have no idea as to the intrinsic measurement error). If I
am ever to use rationals in this contest I have to have some way to
convert Geodedic/UTM/etc. coordinates, height measurements, etc., into
the rational representation. Once inside, I'm good to go, but when done
most will want to see a mean nearest neighbor distance of 0.1 meters and
not 1/10 or GACK! 7205759403792793/72057594037927936 (Thanks Paul and
Matt for interjecting that bit of humor ;-)
Next, another projects is the spread of disease in a forest as modeled
in 3+ dimensions. For example, picture a tree in a forest that is
infected with mistletoe. The mistletoe produces seeds and the seed
disperse bullistically to adjacent trees. For the sake of argument
let's say that this is a rare event and we want to model individual
seeds (not realistic, but bare with me). The question of whether the
seed lands on the tree or not is analogous to the classic question of
"Dos [this] object touching the table". Using integer arithmetic gives
a clear answer, but as I recall can break down near the machine
precision.
In both cases all my data (patch vertices, stem maps, canopy dimensions,
seed size and dispersal trajectories) are all given to me in floating
point format. I have no options on this one.
So at this point I would ask the assembled crew: Isn't using rationals
appropriate at this point, and if so what is the best method of
converting to rational.
gain, after thinking about it for some time, my original suggestion of
providing a rational(double) constructor is not a good idea, and I think
that a helper function (or something similar) is probably a much better
way to go.
That is my 3 cents worth ;-)
EBo --
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk