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/test/averager_test.cc

    r1275 r1295  
    6969    suite.add(false);
    7070    suite.err() << "error: add\n";
     71  }
     72  Averager b(a);
     73  b.add(5,-1);
     74  if (b.n()!=2 || b.mean()!=2 || b.sum_xx()!=10){
     75    suite.add(false);
     76    suite.err() << "error: add with negative n\n";
     77  }
     78  b.add(5,-4);
     79  if (b.n()!=-2 || b.mean()!=8 || b.sum_xx()!=-90){
     80    suite.add(false);
     81    suite.err() << "error: add with negatibe n\n";
    7182  }
    7283
     
    198209  delete ap2;
    199210
     211  for (int i=0; i<8; i++)
     212    ap.add(static_cast<double>(i),i,-1);
     213  if (std::abs(ap.correlation()-1)>tol) {
     214    suite.add(false);
     215    suite.err() << "correlation after removal of data: " << ap.correlation()
     216                << std::endl;
     217    suite.err() << "error: correlation between identical vectors is unity"
     218                << std::endl;
     219  }
     220  ap.add(static_cast<double>(1),1,-4);
     221  if (std::abs(ap.correlation()+1)>tol || ap.n()!=-2) {
     222    suite.add(false);
     223    suite.err() << "AveragerPair error: add with negatibe n\n";
     224  }
     225
     226
    200227  suite.out() << "testing AveragerPairWeighted" << std::endl;
    201228  AveragerPairWeighted apw;
Note: See TracChangeset for help on using the changeset viewer.