Changeset 2444


Ignore:
Timestamp:
Mar 19, 2011, 12:30:51 AM (11 years ago)
Author:
Peter
Message:

fixes #660

Location:
branches/0.7-stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/0.7-stable/test/statistics.cc

    r2370 r2444  
    4646void test_mad(test::Suite&);
    4747
     48void test_median_empty(test::Suite&);
    4849void test_percentiler(test::Suite&);
    4950void test_percentiler_nan(test::Suite&);
     
    124125           
    125126  }
     127  test_median_empty(suite);
    126128  return suite.return_value();
    127129}
     
    150152            boost::random_access_iterator_archetype<utility::DataWeight>());
    151153  }
     154}
     155
     156
     157// test for ticket #660
     158void test_median_empty(test::Suite& suite)
     159{
     160  std::vector<double> x;
     161  double m = 0;
     162  m = statistics::median(x.begin(), x.end(), true);
    152163}
    153164
  • branches/0.7-stable/yat/statistics/Percentiler.h

    r2263 r2444  
    3434#include <algorithm>
    3535#include <cmath>
     36#include <limits>
    3637#include <numeric>
    3738#include <stdexcept>
     
    99100      BOOST_CONCEPT_ASSERT((boost::RandomAccessIterator<RandomAccessIterator>));
    100101      BOOST_CONCEPT_ASSERT((utility::DataIteratorConcept<RandomAccessIterator>));
     102      if (first==last)
     103        return std::numeric_limits<double>::quiet_NaN();
    101104      return calculate(first, last, sorted_,
    102105       typename utility::weighted_iterator_traits<RandomAccessIterator>::type());
Note: See TracChangeset for help on using the changeset viewer.