Modify

Ticket #8262 (closed Bugs: fixed)

Opened 14 months ago

Last modified 8 months ago

numeric::average gives incorrect result

Reported by: james.hirschorn@… Owned by: eric_niebler
Milestone: To Be Determined Component: accumulator
Version: Boost 1.53.0 Severity: Problem
Keywords: average Cc:

Description

Apparently boost::numeric::average was incorrectly implemented as numeric::divides.

The following code, computes average(2, 3) = 0.666667:

#include <iostream>
#include <boost/accumulators/numeric/functional.hpp>

int main(int argc, char * argv[])
{
    using namespace boost::numeric;

    auto avg = average(2, 3);

    std::cout << avg << std::endl;
}

Attachments

functional.hpp Download (21.9 KB) - added by james.hirschorn@… 14 months ago.
patch giving correct average
average_fix.patch Download (1.1 KB) - added by james.hirschorn@… 14 months ago.
patch correcting numeric::average

Change History

Changed 14 months ago by james.hirschorn@…

patch giving correct average

Changed 14 months ago by james.hirschorn@…

patch correcting numeric::average

comment:1 Changed 14 months ago by james.hirschorn@…

The first attachment was by accident. functional.hpp is the modified source.

comment:2 Changed 11 months ago by eric_niebler

  • Status changed from new to closed
  • Resolution set to invalid

Looks right to me.

comment:3 Changed 11 months ago by eric_niebler

  • Status changed from closed to reopened
  • Resolution invalid deleted

Oops, I see what you mean. Sory 'bout that. I'll have a look.

comment:4 Changed 9 months ago by eric_niebler

(In [85124]) rename average to fdiv, refs #8262

comment:5 Changed 9 months ago by eric_niebler

Fixed on trunk. I'll merge to release after tests have cycled. The function isn't incorrect per se; it's just very, very badly named.

comment:6 Changed 8 months ago by eric_niebler

  • Status changed from reopened to closed
  • Resolution set to fixed

(In [85424]) merge [85122],[85123],[85124] from trunk to release; fixes #7915, fixes #8850, fixes #8262

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.