CHistogram Class Reference

#include <Histogram.h>

Public Member Functions

 CHistogram (const double First, const double Interval, const int nPoints)
 ~CHistogram ()
void Update (const double Val)
void Print (ofstream *out, const char *Str)

Private Attributes

int m_n
unsigned int * m_Vector
double m_First
double m_Interval

Detailed Description

Definition at line 28 of file Histogram.h.


Constructor & Destructor Documentation

CHistogram::CHistogram ( const double  First,
const double  Interval,
const int  nPoints 
)

Definition at line 35 of file Histogram.cpp.

00038 {
00039   m_n = nPoints;
00040   m_First = First;
00041   m_Interval = Interval;
00042   m_Vector = new unsigned int[nPoints];
00043   for(int i=0; i<nPoints; i++)
00044   {
00045     m_Vector[i] = 0;
00046   }
00047 }

CHistogram::~CHistogram (  ) 

Definition at line 50 of file Histogram.cpp.

00051 {
00052   delete[] m_Vector;
00053 }


Member Function Documentation

void CHistogram::Print ( ofstream *  out,
const char *  Str 
)

Definition at line 72 of file Histogram.cpp.

00073 {
00074   if(Str != 0)
00075     *out << Str;
00076 
00077   *out << m_n << endl;
00078   for(int i=0; i<m_n; i++)
00079   {
00080     if(Str != 0)
00081       *out << Str;
00082     *out << m_First + i * m_Interval << " " << m_Vector[i] << endl;
00083   }
00084 
00085 }

void CHistogram::Update ( const double  Val  ) 

Definition at line 56 of file Histogram.cpp.

00057 {
00058   int ind;
00059 
00060   if(Val <= m_First)
00061     ind = 0;
00062   else
00063     ind = (int) (( (Val - m_First)/m_Interval ) + 0.5 );
00064 
00065   if(ind >= m_n)
00066     ind = m_n-1;
00067 
00068   m_Vector[ind]++;
00069 }


Field Documentation

double CHistogram::m_First [private]

Definition at line 38 of file Histogram.h.

double CHistogram::m_Interval [private]

Definition at line 39 of file Histogram.h.

int CHistogram::m_n [private]

Definition at line 36 of file Histogram.h.

unsigned int* CHistogram::m_Vector [private]

Definition at line 37 of file Histogram.h.


The documentation for this class was generated from the following files:
Generated on Wed Jul 4 16:03:31 2012 for RIO by  doxygen 1.6.3