statistics.hh (7462:0c61c3cf7639) statistics.hh (7504:ad631c296c9b)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 387 unchanged lines hidden (view full) ---

396
397 info->y_subnames.resize(self.y);
398 for (off_type i = 0; i < self.y; ++i)
399 info->y_subnames[i] = names[i];
400 return self;
401 }
402
403 Derived &
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 387 unchanged lines hidden (view full) ---

396
397 info->y_subnames.resize(self.y);
398 for (off_type i = 0; i < self.y; ++i)
399 info->y_subnames[i] = names[i];
400 return self;
401 }
402
403 Derived &
404 ysubname(off_type index, const std::string subname)
404 ysubname(off_type index, const std::string &subname)
405 {
406 Derived &self = this->self();
407 Info *info = this->info();
408
409 assert(index < self.y);
410 info->y_subnames.resize(self.y);
411 info->y_subnames[index] = subname.c_str();
412 return self;
413 }
405 {
406 Derived &self = this->self();
407 Info *info = this->info();
408
409 assert(index < self.y);
410 info->y_subnames.resize(self.y);
411 info->y_subnames[index] = subname.c_str();
412 return self;
413 }
414
415 std::string
416 ysubname(off_type i) const
417 {
418 return this->info()->y_subnames[i];
419 }
420
414};
415
416//////////////////////////////////////////////////////////////////////
417//
418// Simple Statistics
419//
420//////////////////////////////////////////////////////////////////////
421

--- 770 unchanged lines hidden (view full) ---

1192 for (off_type i = 0; i < _size; ++i)
1193 new (&storage[i]) Storage(info);
1194
1195 this->setInit();
1196
1197 return self;
1198 }
1199
421};
422
423//////////////////////////////////////////////////////////////////////
424//
425// Simple Statistics
426//
427//////////////////////////////////////////////////////////////////////
428

--- 770 unchanged lines hidden (view full) ---

1199 for (off_type i = 0; i < _size; ++i)
1200 new (&storage[i]) Storage(info);
1201
1202 this->setInit();
1203
1204 return self;
1205 }
1206
1200 std::string ysubname(off_type i) const { return (*this->y_subnames)[i]; }
1201
1202 Proxy
1203 operator[](off_type index)
1204 {
1205 off_type offset = index * y;
1206 assert (index >= 0 && offset + index < size());
1207 return Proxy(this->self(), offset, y);
1208 }
1209

--- 498 unchanged lines hidden (view full) ---

1708 size() const
1709 {
1710 return _size;
1711 }
1712
1713 bool
1714 zero() const
1715 {
1207 Proxy
1208 operator[](off_type index)
1209 {
1210 off_type offset = index * y;
1211 assert (index >= 0 && offset + index < size());
1212 return Proxy(this->self(), offset, y);
1213 }
1214

--- 498 unchanged lines hidden (view full) ---

1713 size() const
1714 {
1715 return _size;
1716 }
1717
1718 bool
1719 zero() const
1720 {
1716 return false;
1717#if 0
1718 for (off_type i = 0; i < size(); ++i)
1719 if (!data(i)->zero())
1720 return false;
1721 return true;
1721 for (off_type i = 0; i < size(); ++i)
1722 if (!data(i)->zero())
1723 return false;
1724 return true;
1722#endif
1723 }
1724
1725 void
1726 prepare()
1727 {
1728 Info *info = this->info();
1729 size_type size = this->size();
1730 info->data.resize(size);

--- 56 unchanged lines hidden (view full) ---

1787 return data()->zero();
1788 }
1789
1790 /**
1791 * Proxy has no state. Nothing to reset.
1792 */
1793 void reset() { }
1794};
1725 }
1726
1727 void
1728 prepare()
1729 {
1730 Info *info = this->info();
1731 size_type size = this->size();
1732 info->data.resize(size);

--- 56 unchanged lines hidden (view full) ---

1789 return data()->zero();
1790 }
1791
1792 /**
1793 * Proxy has no state. Nothing to reset.
1794 */
1795 void reset() { }
1796};
1795/*
1796template <class Derived, class Stor>
1797inline typename VectorDistBase<Derived, Stor>::Proxy
1798VectorDistBase<Derived, Stor>::operator[](off_type index)
1799{
1800 assert (index >= 0 && index < size());
1801 typedef typename VectorDistBase<Derived, Stor>::Proxy Proxy;
1802 return Proxy(this->self(), index);
1803}
1804*/
1805
1797
1806#if 0
1807template <class Storage>
1808Result
1809VectorDistBase<Storage>::total(off_type index) const
1810{
1811 Result total = 0.0;
1812 for (off_type i = 0; i < x_size(); ++i)
1813 total += data(i)->result();
1814}
1815#endif
1816
1817//////////////////////////////////////////////////////////////////////
1818//
1819// Formula Details
1820//
1821//////////////////////////////////////////////////////////////////////
1822
1823/**
1824 * Base class for formula statistic node. These nodes are used to build a tree

--- 461 unchanged lines hidden (view full) ---

2286class StandardDeviation : public DistBase<StandardDeviation, SampleStor>
2287{
2288 public:
2289 /**
2290 * Construct and initialize this distribution.
2291 */
2292 StandardDeviation()
2293 {
1798//////////////////////////////////////////////////////////////////////
1799//
1800// Formula Details
1801//
1802//////////////////////////////////////////////////////////////////////
1803
1804/**
1805 * Base class for formula statistic node. These nodes are used to build a tree

--- 461 unchanged lines hidden (view full) ---

2267class StandardDeviation : public DistBase<StandardDeviation, SampleStor>
2268{
2269 public:
2270 /**
2271 * Construct and initialize this distribution.
2272 */
2273 StandardDeviation()
2274 {
2275 SampleStor::Params *params = new SampleStor::Params;
2294 this->doInit();
2276 this->doInit();
2277 this->setParams(params);
2295 }
2296};
2297
2298/**
2299 * Calculates the per tick mean and variance of the samples.
2300 * @sa DistBase, AvgSampleStor
2301 */
2302class AverageDeviation : public DistBase<AverageDeviation, AvgSampleStor>
2303{
2304 public:
2305 /**
2306 * Construct and initialize this distribution.
2307 */
2308 AverageDeviation()
2309 {
2278 }
2279};
2280
2281/**
2282 * Calculates the per tick mean and variance of the samples.
2283 * @sa DistBase, AvgSampleStor
2284 */
2285class AverageDeviation : public DistBase<AverageDeviation, AvgSampleStor>
2286{
2287 public:
2288 /**
2289 * Construct and initialize this distribution.
2290 */
2291 AverageDeviation()
2292 {
2293 AvgSampleStor::Params *params = new AvgSampleStor::Params;
2310 this->doInit();
2294 this->doInit();
2295 this->setParams(params);
2311 }
2312};
2313
2314/**
2315 * A vector of distributions.
2316 * @sa VectorDistBase, DistStor
2317 */
2318class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>

--- 32 unchanged lines hidden (view full) ---

2351 /**
2352 * Initialize storage for this distribution.
2353 * @param size The size of the vector.
2354 * @return A reference to this distribution.
2355 */
2356 VectorStandardDeviation &
2357 init(size_type size)
2358 {
2296 }
2297};
2298
2299/**
2300 * A vector of distributions.
2301 * @sa VectorDistBase, DistStor
2302 */
2303class VectorDistribution : public VectorDistBase<VectorDistribution, DistStor>

--- 32 unchanged lines hidden (view full) ---

2336 /**
2337 * Initialize storage for this distribution.
2338 * @param size The size of the vector.
2339 * @return A reference to this distribution.
2340 */
2341 VectorStandardDeviation &
2342 init(size_type size)
2343 {
2344 SampleStor::Params *params = new SampleStor::Params;
2359 this->doInit(size);
2345 this->doInit(size);
2346 this->setParams(params);
2360 return this->self();
2361 }
2362};
2363
2364/**
2365 * This is a vector of AverageDeviation stats.
2366 * @sa VectorDistBase, AvgSampleStor
2367 */

--- 4 unchanged lines hidden (view full) ---

2372 /**
2373 * Initialize storage for this distribution.
2374 * @param size The size of the vector.
2375 * @return A reference to this distribution.
2376 */
2377 VectorAverageDeviation &
2378 init(size_type size)
2379 {
2347 return this->self();
2348 }
2349};
2350
2351/**
2352 * This is a vector of AverageDeviation stats.
2353 * @sa VectorDistBase, AvgSampleStor
2354 */

--- 4 unchanged lines hidden (view full) ---

2359 /**
2360 * Initialize storage for this distribution.
2361 * @param size The size of the vector.
2362 * @return A reference to this distribution.
2363 */
2364 VectorAverageDeviation &
2365 init(size_type size)
2366 {
2367 AvgSampleStor::Params *params = new AvgSampleStor::Params;
2380 this->doInit(size);
2368 this->doInit(size);
2369 this->setParams(params);
2381 return this->self();
2382 }
2383};
2384
2385template <class Stat>
2386class FormulaInfoProxy : public InfoProxy<Stat, FormulaInfo>
2387{
2388 protected:

--- 378 unchanged lines hidden ---
2370 return this->self();
2371 }
2372};
2373
2374template <class Stat>
2375class FormulaInfoProxy : public InfoProxy<Stat, FormulaInfo>
2376{
2377 protected:

--- 378 unchanged lines hidden ---