A combination of some frequently used filters

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CIRCULAR_BUFFER_VECTOR.h Source File

CIRCULAR_BUFFER_VECTOR.h

00001 #ifndef CIRCULAR_BUFFER_VECTOR_H
00002 #define CIRCULAR_BUFFER_VECTOR_H
00003 //
00004 #include <vector>
00005 
00006 using std::vector;
00007 
00008 
00009 class CIRCULAR_BUFFER_VECTOR{
00010 public:
00011     // Dimensions
00012     size_t buffer_size;
00013     size_t vector_size;
00014 
00015     //
00016     CIRCULAR_BUFFER_VECTOR(void);
00017     CIRCULAR_BUFFER_VECTOR(size_t buffer_size_in, size_t vector_size_in);
00018     // Initiate and reset the data in the buffer
00019     void Init(size_t buffer_size_in, const vector<float> &initial_value); // If using the first type of constructer, this function helps
00020     void Reset(const vector<float> &value); // Reset all the elements without changeing the buffer size
00021     // Element-wise operation
00022     vector<float> Get(int i); // Get the element that is i samples ago
00023     void Set(int i, const vector<float> &value); // Set the element that is i samples ago to the "value"
00024     void Increase(int i, const vector<float> &increase_value, bool is_minus); // vi += (or -=) increase_value
00025     // Iterate the buffer
00026     void Insert(const vector<float> &x_new); // Pop the oldest element and push a new element
00027 
00028 private:
00029     int idx; // The index of the current data in the buffer
00030 
00031     vector<vector<float> > buffer;
00032 
00033     // Utilities
00034     // Increment
00035     void Get_VectorIncrement(vector<float> &v_a, const vector<float> &v_b, bool is_minus); // v_a += (or -=) v_b
00036 
00037 };
00038 
00039 #endif