Ignore:
Timestamp:
May 12, 2008, 10:35:10 AM (13 years ago)
Author:
Jari Häkkinen
Message:

Fixes #361. Averager and AveragerPair? accepts negative n for data removal.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/statistics/Averager.cc

    r1275 r1295  
    44  Copyright (C) 2004, 2005 Jari Häkkinen, Peter Johansson
    55  Copyright (C) 2006 Jari Häkkinen, Markus Ringnér
    6   Copyright (C) 2007 Jari Häkkinen, Peter Johansson
    7   Copyright (C) 2008 Peter Johansson
     6  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
    87
    98  This file is part of the yat library, http://trac.thep.lu.se/yat
     
    3938  }
    4039
    41   Averager::Averager(double x, double xx, unsigned long n)
     40  Averager::Averager(double x, double xx, long n)
    4241    : n_(n), x_(x), xx_(xx)
    4342  {
     
    4948  }
    5049
    51   void Averager::add(double d, unsigned long n)
     50  void Averager::add(double d, long n)
    5251  {
    5352    assert(!std::isnan(d));
    5453    n_  += n;
     54    assert(n>-1);
    5555    x_  += n*d;
    5656    xx_ += n*d*d;
     
    6767  }
    6868
    69   unsigned long Averager::n(void) const
     69  long Averager::n(void) const
    7070  {
    7171    return n_;
Note: See TracChangeset for help on using the changeset viewer.