21 #define GRT_DLL_EXPORTS
30 classType =
"LeakyIntegrator";
31 preProcessingType = classType;
32 debugLog.setProceedingText(
"[DEBUG LeakyIntegrator]");
33 errorLog.setProceedingText(
"[ERROR LeakyIntegrator]");
34 warningLog.setProceedingText(
"[WARNING LeakyIntegrator]");
35 init(leakRate,numDimensions);
40 classType =
"LeakyIntegrator";
41 preProcessingType = classType;
42 debugLog.setProceedingText(
"[DEBUG LeakyIntegrator]");
43 errorLog.setProceedingText(
"[ERROR LeakyIntegrator]");
44 warningLog.setProceedingText(
"[WARNING LeakyIntegrator]");
67 if( preProcessing == NULL )
return false;
81 errorLog <<
"clone(const PreProcessing *preProcessing) - PreProcessing Types Do Not Match!" << std::endl;
89 errorLog <<
"process(const VectorFloat &inputVector) - Not initialized!" << std::endl;
93 if( inputVector.size() != numInputDimensions ){
94 errorLog <<
"process(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
100 if( processedData.size() == numOutputDimensions )
return true;
105 if( initialized )
return init(
leakRate, numInputDimensions);
111 if( !file.is_open() ){
112 errorLog <<
"save(fstream &file) - The file is not open!" << std::endl;
116 file <<
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" << std::endl;
119 errorLog <<
"savePreProcessingSettingsToFile(fstream &file) - Failed to save preprocessing settings to file!" << std::endl;
123 file <<
"LeakRate: " <<
leakRate << std::endl;
130 if( !file.is_open() ){
131 errorLog <<
"load(fstream &file) - The file is not open!" << std::endl;
140 if( word !=
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" ){
141 errorLog <<
"load(fstream &file) - Invalid file format!" << std::endl;
146 errorLog <<
"loadPreProcessingSettingsFromFile(fstream &file) - Failed to load preprocessing settings from file!" << std::endl;
152 if( word !=
"LeakRate:" ){
153 errorLog <<
"load(fstream &file) - Failed to read LeakRate header!" << std::endl;
159 return init(leakRate,numInputDimensions);
166 if( leakRate < 0 || leakRate > 1 ){
167 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - leakRate must be between [0 1]!" << std::endl;
171 if( numDimensions == 0 ){
172 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - NumDimensions must be greater than 0!" << std::endl;
177 this->numInputDimensions = numDimensions;
178 this->numOutputDimensions = numDimensions;
181 processedData.clear();
182 processedData.
resize(numDimensions,0);
189 if( numInputDimensions != 1 ){
190 errorLog <<
"update(const Float x) - The Number Of Input Dimensions is not 1! NumInputDimensions: " << numInputDimensions << std::endl;
196 if(
y.size() == 0 )
return 0 ;
204 errorLog <<
"update(const VectorFloat &x) - Not Initialized!" << std::endl;
208 if( x.size() != numInputDimensions ){
209 errorLog <<
"update(const VectorFloat &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << std::endl;
213 for(UINT n=0; n<numInputDimensions; n++){
218 return processedData;
222 if( leakRate >= 0 && leakRate <= 1 ){
224 if( initialized )
init(leakRate, numInputDimensions);
227 errorLog <<
"setLeakRate(const Float leakRate) - The leak rate must be between [0 1]!" << std::endl;
LeakyIntegrator & operator=(const LeakyIntegrator &rhs)
virtual ~LeakyIntegrator()
bool savePreProcessingSettingsToFile(std::fstream &file) const
bool loadPreProcessingSettingsFromFile(std::fstream &file)
virtual bool save(std::fstream &file) const
virtual bool resize(const unsigned int size)
Float update(const Float x)
LeakyIntegrator(const Float leakRate=0.99, const UINT numDimensions=1)
VectorFloat y
A buffer holding the previous input value(s)
virtual bool deepCopyFrom(const PreProcessing *preProcessing)
bool setLeakRate(const Float leakRate)
std::string getPreProcessingType() const
bool copyBaseVariables(const PreProcessing *preProcessingModule)
The LeakyIntegrator class computes the following signal: y = y*z + x, where x is the input...
virtual bool process(const VectorFloat &inputVector)
virtual bool load(std::fstream &file)
Float leakRate
The current leak rate.