source: trunk/src/Utils/Statistics.cc @ 221

Last change on this file since 221 was 221, checked in by Matthew Whiting, 17 years ago

More documentation being added to source code, with a new file (src/Utils/Hanning.cc) added as well.

File size: 3.9 KB
Line 
1#include <iostream>
2#include <Utils/Statistics.hh>
3#include <Utils/utils.hh>
4
5namespace Statistics
6{
7  template <class T> Statistics::StatsContainer<T>::StatsContainer(const StatsContainer<T>& s)
8  {
9    this->defined    = s.defined;
10    this->mean       = s.mean;
11    this->stddev     = s.stddev;
12    this->median     = s.median;
13    this->madfm      = s.madfm;
14    this->threshold  = s.threshold;
15    this->pThreshold = s.pThreshold;
16    this->useRobust  = s.useRobust;
17    this->useFDR     = s.useFDR;
18  }
19  template StatsContainer<int>::StatsContainer(const StatsContainer<int>& s);
20  template StatsContainer<long>::StatsContainer(const StatsContainer<long>& s);
21  template StatsContainer<float>::StatsContainer(const StatsContainer<float>& s);
22  template StatsContainer<double>::StatsContainer(const StatsContainer<double>& s);
23  //--------------------------------------------------------------------
24
25  template <class T> Statistics::StatsContainer<T>& StatsContainer<T>::operator= (const StatsContainer<T>& s)
26  {
27    this->defined    = s.defined;
28    this->mean       = s.mean;
29    this->stddev     = s.stddev;
30    this->median     = s.median;
31    this->madfm      = s.madfm;
32    this->threshold  = s.threshold;
33    this->pThreshold = s.pThreshold;
34    this->useRobust  = s.useRobust;
35    this->useFDR     = s.useFDR;
36  }
37  template StatsContainer<int>& StatsContainer<int>::operator= (const StatsContainer<int>& s);
38  template StatsContainer<long>& StatsContainer<long>::operator= (const StatsContainer<long>& s);
39  template StatsContainer<float>& StatsContainer<float>::operator= (const StatsContainer<float>& s);
40  template StatsContainer<double>& StatsContainer<double>::operator= (const StatsContainer<double>& s);
41  //--------------------------------------------------------------------
42
43  template <class T> void Statistics::StatsContainer<T>::calculate(T *array, long size)
44  {
45    findNormalStats(array, size, this->mean, this->stddev);
46    findMedianStats(array, size, this->median, this->madfm);
47    this->defined = true;
48  }
49  template void Statistics::StatsContainer<int>::calculate(int *array, long size);
50  template void Statistics::StatsContainer<long>::calculate(long *array, long size);
51  template void Statistics::StatsContainer<float>::calculate(float *array, long size);
52  template void Statistics::StatsContainer<double>::calculate(double *array, long size);
53  //--------------------------------------------------------------------
54
55  template <class T>
56  void Statistics::StatsContainer<T>::calculate(T *array, long size, bool *isGood)
57  {
58    findNormalStats(array, size, isGood, this->mean, this->stddev);
59    findMedianStats(array, size, isGood, this->median, this->madfm);
60    this->defined = true;
61  }
62  template void Statistics::StatsContainer<int>::calculate(int *array, long size, bool *isGood);
63  template void Statistics::StatsContainer<long>::calculate(long *array, long size, bool *isGood);
64  template void Statistics::StatsContainer<float>::calculate(float *array, long size, bool *isGood);
65  template void Statistics::StatsContainer<double>::calculate(double *array, long size, bool *isGood);
66  //--------------------------------------------------------------------
67
68  template <class T>
69  std::ostream& operator<< (std::ostream& theStream, StatsContainer<T> &s)
70  {
71    /**
72     * Prints out the four key statistics to the requested stream.
73     */
74    theStream << "Mean   = "   << s.mean   << "\t"
75              << "Std.Dev. = " << s.stddev << "\n"
76              << "Median = "   << s.median << "\t"
77              << "MADFM    = " << s.madfm  << "\n";
78  }
79  template std::ostream& operator<<<int> (std::ostream& theStream, StatsContainer<int> &s);
80  template std::ostream& operator<<<long> (std::ostream& theStream, StatsContainer<long> &s);
81  template std::ostream& operator<<<float> (std::ostream& theStream, StatsContainer<float> &s);
82  template std::ostream& operator<<<double> (std::ostream& theStream, StatsContainer<double> &s);
83
84
85
86}  // matches:  namespace Statistics {
Note: See TracBrowser for help on using the repository browser.