Boost logo

Boost Users :

Subject: Re: [Boost-users] [math] finding c such that w1/c+...+wn/c < math::tools::max_value<T>()
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-04-19 10:44:08


AMDG

er wrote:
> A little while back the following code was suggested to find c such that
> (x/c)+(y/c) <= C = math::tools::max_value<T>()
>
> <snip>
>
> I'm now trying to generalize this i.e. find c such that w1/c+...+wn/c
> <= C:
> 1) split w1,..,wn into maximal size, sum less than C, subgroups.
> 2) apply scale_to_max iteratively over adjacent groups.
> This does not always suceed (see example at the bottom). Any
> suggestion would be appreciated.

You'll have to be really careful because floating point addition is not
associative.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net