Relacs Numerics Library  0.9.8
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
CyclicSampleData< T > Class Template Reference

#include <cyclicsampledata.h>

Inheritance diagram for CyclicSampleData< T >:
Inheritance graph
[legend]
Collaboration diagram for CyclicSampleData< T >:
Collaboration graph
[legend]

Public Types

typedef double range_type
 
typedef LinearRangeIterator const_range_iterator
 
- Public Types inherited from CyclicArray< T >
typedef T value_type
 
typedef T * pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef int size_type
 

Public Member Functions

 CyclicSampleData (void)
 
 CyclicSampleData (int n, double stepsize=1.0)
 
 CyclicSampleData (int n, double offset, double stepsize)
 
 CyclicSampleData (double duration, double stepsize=1.0)
 
 CyclicSampleData (double duration, double offset, double stepsize)
 
 CyclicSampleData (CyclicSampleData< T > *csd)
 
 CyclicSampleData (const CyclicSampleData< T > &csd)
 
 ~CyclicSampleData (void)
 
const CyclicSampleData< T > & operator= (const CyclicSampleData< T > &a)
 
const CyclicSampleData< T > & assign (const CyclicSampleData< T > &a)
 
const CyclicSampleData< T > & assign (const CyclicSampleData< T > *a)
 
virtual int minIndex (void) const
 
virtual double minPos (void) const
 
virtual void resize (int n, const T &val=0)
 
virtual void resize (double duration, const T &val=0)
 
virtual void reserve (int n)
 
virtual void reserve (double duration)
 
double offset (void) const
 
void setOffset (double offset)
 
double stepsize (void) const
 
void setStepsize (double stepsize)
 
void setRange (const T &offset, const T &stepsize)
 
double length (void) const
 
double rangeFront (void) const
 
double rangeBack (void) const
 
void shift (double val)
 
void scale (double scale)
 
double pos (int i) const
 
double interval (int indices) const
 
int index (double pos) const
 
int indices (double iv) const
 
bool contains (double p) const
 
const CyclicArray< T > & array (void) const
 
CyclicArray< T > & array (void)
 
LinearRange range (void)
 
min (int from, int upto) const
 
min (double from, double upto) const
 
min (double from) const
 
max (int from, int upto) const
 
max (double from, double upto) const
 
max (double from) const
 
void minMax (T &min, T &max, int from, int upto) const
 
void minMax (T &min, T &max, double from, double upto) const
 
void minMax (T &min, T &max, double from) const
 
minAbs (int from, int upto) const
 
minAbs (double from, double upto) const
 
minAbs (double from) const
 
maxAbs (int from, int upto) const
 
maxAbs (double from, double upto) const
 
maxAbs (double from) const
 
numerical_traits< T >::mean_type mean (int from, int upto) const
 
numerical_traits< T >::mean_type mean (double from, double upto) const
 
template<typename R >
void mean (double time, SampleData< R > &d, double width=0.0) const
 
numerical_traits< T >
::variance_type 
variance (int from, int upto) const
 
numerical_traits< T >
::variance_type 
variance (double from, double upto) const
 
template<typename R >
void variance (double time, SampleData< R > &d, double width=0.0) const
 
numerical_traits< T >
::variance_type 
stdev (int from, int upto) const
 
numerical_traits< T >
::variance_type 
stdev (double from, double upto) const
 
template<typename R >
void stdev (double time, SampleData< R > &d, double width=0.0) const
 
numerical_traits< T >
::variance_type 
rms (int from, int upto) const
 
numerical_traits< T >
::variance_type 
rms (double from, double upto) const
 
template<typename R >
void rms (double time, SampleData< R > &d, double width=0.0) const
 
template<typename S >
void hist (SampleData< S > &h, int from, int upto) const
 
template<typename S >
void hist (SampleData< S > &h, double from, double upto) const
 
template<typename S >
void hist (SampleData< S > &h) const
 
- Public Member Functions inherited from CyclicArray< T >
 CyclicArray (void)
 
 CyclicArray (int n)
 
 CyclicArray (CyclicArray< T > *ca)
 
 CyclicArray (const CyclicArray< T > &ca)
 
virtual ~CyclicArray (void)
 
const CyclicArray< T > & operator= (const CyclicArray< T > &a)
 
const CyclicArray< T > & assign (const CyclicArray< T > &a)
 
const CyclicArray< T > & assign (const CyclicArray< T > *a)
 
int size (void) const
 
virtual int accessibleSize (void) const
 
bool empty (void) const
 
virtual void clear (void)
 
int capacity (void) const
 
void update (const CyclicArray< T > *a)
 
const T & operator[] (int i) const
 
T & operator[] (int i)
 
const T & at (int i) const
 
T & at (int i)
 
const T & front (void) const
 
T & front (void)
 
const T & back (void) const
 
T & back (void)
 
void push (const T &val)
 
pop (void)
 
int maxPush (void) const
 
T * pushBuffer (void)
 
void push (int n)
 
virtual int readSize (void) const
 
int readIndex (void) const
 
read (void)
 
min (int from, int upto) const
 
max (int from, int upto) const
 
void minMax (T &min, T &max, int from, int upto) const
 
minAbs (int from, int upto) const
 
maxAbs (int from, int upto) const
 
numerical_traits< T >::mean_type mean (int from, int upto) const
 
numerical_traits< T >
::variance_type 
variance (int from, int upto) const
 
numerical_traits< T >
::variance_type 
stdev (int from, int upto) const
 
numerical_traits< T >
::variance_type 
rms (int from, int upto) const
 
template<typename S >
void hist (SampleData< S > &h, int from, int upto) const
 
template<typename S >
void hist (SampleData< S > &h) const
 
const T * readBuffer (int index, int &maxn) const
 
int saveBinary (ostream &os, int index) const
 
int loadBinary (istream &is, int index)
 

Protected Attributes

double Offset
 
double Stepsize
 
- Protected Attributes inherited from CyclicArray< T >
bool Own
 
T * Buffer
 
int NBuffer
 
int RCycles
 
int R
 
int LCycles
 
int L
 
Val
 
Dummy
 

Friends

template<typename S >
ostream & operator<< (ostream &str, const CyclicSampleData< S > &a)
 

Detailed Description

template<typename T = double>
class relacs::CyclicSampleData< T >

A template defining an one-dimensional cyclic array of periodically sampled data.

Author
Jan Benda

This class is very similar to SampleData, in that it is a random access container of objects of type T that were sampled with stepsize(). The size() of CyclicSampleData, however, can exceed its capacity(). Data elements below size()-capacity() are therefore not accessible.

Member Typedef Documentation

typedef double range_type

The type of an element of the range.

Const iterator used to iterate through the range.

Constructor & Destructor Documentation

CyclicSampleData ( void  )

Creates an empty CyclicSampleData with offset() at zero and unit stepsize().

CyclicSampleData ( int  n,
double  stepsize = 1.0 
)

Creates an empty CyclicSampleData with capacity() n data elements, zero offset(), and stepsize() set to stepsize.

CyclicSampleData ( int  n,
double  offset,
double  stepsize 
)

Creates an empty CyclicSampleData with capacity() n data elements, offset() set to offset, and stepsize() set to stepsize.

CyclicSampleData ( double  duration,
double  stepsize = 1.0 
)

Creates an empty CyclicSampleData with its capacity() set to duration / stepsize data elements, zero offset(), and stepsize() set to stepsize.

CyclicSampleData ( double  duration,
double  offset,
double  stepsize 
)

Creates an empty CyclicSampleData with its capacity() set to duration / stepsize data elements, offset() set to offset, and stepsize() set to stepsize.

Creates a CyclicSampleData with the same size, content, and range as csd that shares the buffer with the one of csd.

CyclicSampleData ( const CyclicSampleData< T > &  csd)

Copy constructor. Creates a CyclicSampleData with the same size, content, and range as csd.

~CyclicSampleData ( void  )

The destructor.

Member Function Documentation

const CyclicSampleData< T > & operator= ( const CyclicSampleData< T > &  a)

Assigns a to *this by copying the content.

const CyclicSampleData< T > & assign ( const CyclicSampleData< T > &  a)

Assigns a to *this by copying the content.

References CyclicArray< T >::assign(), CyclicSampleData< T >::Offset, and CyclicSampleData< T >::Stepsize.

const CyclicSampleData< T > & assign ( const CyclicSampleData< T > *  a)

Assigns a to *this by only copying a pointer to the data.

References CyclicArray< T >::assign(), CyclicSampleData< T >::Offset, and CyclicSampleData< T >::Stepsize.

int minIndex ( void  ) const
virtual

The index of the first accessible data element.

See Also
minPos(), accessibleSize()

Reimplemented from CyclicArray< T >.

References CyclicArray< T >::minIndex().

double minPos ( void  ) const
virtual

The position of the first accessible data element.

See Also
minIndex(), accessibleSize()

References relacs::minIndex().

void resize ( int  n,
const T &  val = 0 
)
virtual

Resize the CyclicSampleData to n data elements such that the size() of the array equals n. Data values are preserved and new data values are initialized with val. The capacity is not changed! If, however, the capacity() of the CyclicSampleData is zero, then memory for n data elements is allocated and initialized with val.

Reimplemented from CyclicArray< T >.

References CyclicArray< T >::resize().

void resize ( double  duration,
const T &  val = 0 
)
virtual

Resize the CyclicSampleData to duration / stepsize() data elements such that the size() of the array equals n. Data values are preserved and new data values are initialized with val. The capacity is not changed! If, however, the capacity() of the CyclicSampleData is zero, then memory for n data elements is allocated and initialized with val.

References relacs::ceil(), and CyclicArray< T >::resize().

void reserve ( int  n)
virtual

If n is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to n; otherwise, capacity() is unchanged. In either case, size() is unchanged and the content of the array is preserved.

Reimplemented from CyclicArray< T >.

References CyclicArray< T >::reserve().

void reserve ( double  duration)
virtual

If duration / stepsize() is less than or equal to capacity(), this call has no effect. Otherwise, it is a request for allocation of additional memory. If the request is successful, then capacity() is greater than or equal to duration / stepsize(); otherwise, capacity() is unchanged. In either case, size() is unchanged and the content of the array is preserved.

References relacs::ceil(), and CyclicArray< T >::reserve().

double offset ( void  ) const

The offset of the range.

void setOffset ( double  offset)

Set the offset of the range to offset.

double stepsize ( void  ) const

The stepsize of the range.

void setStepsize ( double  stepsize)

Set the stepsize of the range to stepsize.

void setRange ( const T &  offset,
const T &  stepsize 
)

Set the offset and the stepsize of the range to offset and stepsize, respectively.

double length ( void  ) const

The length of the range, i.e. abs( stepsize() * size() )

double rangeFront ( void  ) const

Returns the first range element, i.e. the offset.

See Also
offset()
double rangeBack ( void  ) const

Returns the last range element.

void shift ( double  val)

Add val to the offset of the range, i.e. shift the range by val.

void scale ( double  scale)

Multiply the offset and the stepsize of the range with scale, i.e. rescale the range by scale.

double pos ( int  i) const

Returns the range element at index i.

double interval ( int  indices) const

Returns the interval covered by indices indices.

int index ( double  pos) const

The index of the range corresponding to pos.

References relacs::floor().

int indices ( double  iv) const

The number of indices corresponding to an interval iv.

References relacs::floor().

bool contains ( double  p) const

True if pos is within the range.

const CyclicArray< T > & array ( void  ) const

Returns a reference to the data array.

CyclicArray< T > & array ( void  )

Returns a reference to the data array.

LinearRange range ( void  )

Returns a copy of the range.

T min ( int  from,
int  upto 
) const

Return the minimum value of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::min().

T min ( double  from,
double  upto 
) const

Return the minimum value of the data during duration seconds starting at time time seconds.

References relacs::min().

T min ( double  from) const

Return the minimum value of the data since time time seconds.

References relacs::min().

T max ( int  from,
int  upto 
) const

Return the maximum value of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::max().

T max ( double  from,
double  upto 
) const

Return the maximum value of the data during duration seconds starting at time time seconds.

References relacs::max().

T max ( double  from) const

Return the maximum value of the data since time time seconds.

References relacs::max().

void minMax ( T &  min,
T &  max,
int  from,
int  upto 
) const

Return the minimum and maximum value, min and max, of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::minMax().

void minMax ( T &  min,
T &  max,
double  from,
double  upto 
) const

Return the minimum and maximum value, min and max, of the data during duration seconds starting at time time seconds.

References relacs::minMax().

void minMax ( T &  min,
T &  max,
double  from 
) const

Return the minimum and maximum value, min and max, of the data since time time seconds.

References relacs::minMax().

T minAbs ( int  from,
int  upto 
) const

Return the minimum absolute value of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::minAbs().

T minAbs ( double  from,
double  upto 
) const

Return the minimum absolute value of the data during duration seconds starting at time time seconds.

References relacs::minAbs().

T minAbs ( double  from) const

Return the minimum absolute value of the data since time time seconds.

References relacs::minAbs().

T maxAbs ( int  from,
int  upto 
) const

Return the maximum absolute value of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::maxAbs().

T maxAbs ( double  from,
double  upto 
) const

Return the maximum absolute value of the data during duration seconds starting at time time seconds.

References relacs::maxAbs().

T maxAbs ( double  from) const

Return the maximum absolute value of the data since time time seconds.

References relacs::maxAbs().

numerical_traits< T >::mean_type mean ( int  from,
int  upto 
) const

Return the mean value of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::mean().

numerical_traits< T >::mean_type mean ( double  from,
double  upto 
) const

Return the mean value of the data during times from and upto.

References relacs::mean().

void mean ( double  time,
SampleData< R > &  d,
double  width = 0.0 
) const

Returns in d the mean values of the data calculated during width long time windows starting at the times time + d.pos(i) (moving average). If width equals zero it is set to the stepsize defined by d.

References relacs::mean(), relacs::minIndex(), SampleData< T >::pos(), SampleData< T >::size(), and SampleData< T >::stepsize().

numerical_traits< T >::variance_type variance ( int  from,
int  upto 
) const

Return the variance of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::variance().

numerical_traits< T >::variance_type variance ( double  from,
double  upto 
) const

Return the variance of the data during times from and upto.

References relacs::variance().

void variance ( double  time,
SampleData< R > &  d,
double  width = 0.0 
) const

Returns in d the variance calculated during width long time windows starting at the times time + d.pos(i). If width equals zero it is set to the stepsize defined by d.

References relacs::mean(), relacs::minIndex(), SampleData< T >::pos(), SampleData< T >::size(), and SampleData< T >::stepsize().

numerical_traits< T >::variance_type stdev ( int  from,
int  upto 
) const

Return the standard deviation of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::stdev().

numerical_traits< T >::variance_type stdev ( double  from,
double  upto 
) const

Return the standard deviation of the data during times from and upto.

References relacs::stdev().

void stdev ( double  time,
SampleData< R > &  d,
double  width = 0.0 
) const

Returns in d the standard deviation calculated during width long time windows starting at the times time + d.pos(i). If width equals zero it is set to the stepsize defined by d.

References relacs::mean(), relacs::minIndex(), SampleData< T >::pos(), SampleData< T >::size(), relacs::sqrt(), and SampleData< T >::stepsize().

numerical_traits< T >::variance_type rms ( int  from,
int  upto 
) const

Return the root-mean-square of the data between index from inclusively and index upto exclusively.

References CyclicArray< T >::rms().

numerical_traits< T >::variance_type rms ( double  from,
double  upto 
) const

Return the root-mean-square of the data during times from and upto.

References relacs::rms().

void rms ( double  time,
SampleData< R > &  d,
double  width = 0.0 
) const

Returns in d the root-mean-square calculated during width long time windows starting at the times time + d.pos(i). If width equals zero it is set to the stepsize defined by d.

References relacs::minIndex(), SampleData< T >::pos(), SampleData< T >::size(), relacs::sqrt(), and SampleData< T >::stepsize().

void hist ( SampleData< S > &  h,
int  from,
int  upto 
) const

Compute histogram h of all data elements between index from inclusively and index upto exclusively.

References CyclicArray< T >::hist().

void hist ( SampleData< S > &  h,
double  from,
double  upto 
) const

Compute histogram h of all data elements during times from and upto.

void hist ( SampleData< S > &  h) const

Compute histogram h of all data elements currently stored in the array.

References CyclicArray< T >::hist().

Friends And Related Function Documentation

ostream& operator<< ( ostream &  str,
const CyclicSampleData< S > &  a 
)
friend

Member Data Documentation

double Offset
protected
double Stepsize
protected

The documentation for this class was generated from the following file: