19 Apr
2009
19 Apr
'09
2:44 p.m.
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