Cheetah Software  1.0
moving_average_filter< T > Class Template Reference

#include <filters.h>

+ Inheritance diagram for moving_average_filter< T >:
+ Collaboration diagram for moving_average_filter< T >:

Public Member Functions

 moving_average_filter (int num_data)
 
virtual ~moving_average_filter ()
 
virtual void input (T input_value)
 
virtual T output (void)
 
virtual void clear (void)
 
- Public Member Functions inherited from filter< T >
 filter (void)
 
virtual ~filter (void)
 

Private Attributes

T * buffer_
 
int num_data_
 
int idx_
 
sum_
 

Detailed Description

template<typename T>
class moving_average_filter< T >

Definition at line 49 of file filters.h.

Constructor & Destructor Documentation

template<typename T >
moving_average_filter< T >::moving_average_filter ( int  num_data)

Definition at line 10 of file filters.cpp.

References moving_average_filter< T >::buffer_, and moving_average_filter< T >::num_data_.

11  : num_data_(num_data), idx_(0), sum_(0.0) {
12  buffer_ = new T[num_data_];
13  memset((void *)buffer_, 0.0, sizeof(T) * num_data_);
14 }
template<typename T >
moving_average_filter< T >::~moving_average_filter ( )
virtual

Definition at line 37 of file filters.cpp.

References moving_average_filter< T >::buffer_.

37  {
38  delete[] buffer_;
39 }

Member Function Documentation

template<typename T >
void moving_average_filter< T >::clear ( void  )
virtual

Implements filter< T >.

Definition at line 31 of file filters.cpp.

References moving_average_filter< T >::buffer_, moving_average_filter< T >::num_data_, and moving_average_filter< T >::sum_.

31  {
32  sum_ = 0.0;
33  memset((void *)buffer_, 0.0, sizeof(T) * num_data_);
34 }

+ Here is the caller graph for this function:

template<typename T >
void moving_average_filter< T >::input ( input_value)
virtual
template<typename T >
T moving_average_filter< T >::output ( void  )
virtual

Implements filter< T >.

Definition at line 26 of file filters.cpp.

References moving_average_filter< T >::num_data_, and moving_average_filter< T >::sum_.

26  {
27  return sum_ / num_data_;
28 }

Member Data Documentation

template<typename T >
T* moving_average_filter< T >::buffer_
private

Definition at line 58 of file filters.h.

template<typename T >
int moving_average_filter< T >::idx_
private

Definition at line 60 of file filters.h.

template<typename T >
int moving_average_filter< T >::num_data_
private

Definition at line 59 of file filters.h.

template<typename T >
T moving_average_filter< T >::sum_
private

Definition at line 61 of file filters.h.


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