21 #define GRT_DLL_EXPORTS 27 const std::string LeakyIntegrator::id =
"LeakyIntegrator";
35 init(leakRate,numDimensions);
58 if( preProcessing == NULL )
return false;
72 errorLog <<
"deepCopyFrom(const PreProcessing *preProcessing) - PreProcessing Types Do Not Match!" << std::endl;
80 errorLog <<
"process(const VectorFloat &inputVector) - Not initialized!" << std::endl;
84 if( inputVector.size() != numInputDimensions ){
85 errorLog <<
"process(const VectorFloat &inputVector) - The size of the inputVector (" << inputVector.size() <<
") does not match that of the filter (" << numInputDimensions <<
")!" << std::endl;
91 if( processedData.size() == numOutputDimensions )
return true;
96 if( initialized )
return init(
leakRate, numInputDimensions);
102 if( !file.is_open() ){
103 errorLog <<
"save(fstream &file) - The file is not open!" << std::endl;
107 file <<
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" << std::endl;
110 errorLog <<
"savePreProcessingSettingsToFile(fstream &file) - Failed to save preprocessing settings to file!" << std::endl;
114 file <<
"LeakRate: " <<
leakRate << std::endl;
121 if( !file.is_open() ){
122 errorLog <<
"load(fstream &file) - The file is not open!" << std::endl;
131 if( word !=
"GRT_LEAKY_INTEGRATOR_FILE_V1.0" ){
132 errorLog <<
"load(fstream &file) - Invalid file format!" << std::endl;
137 errorLog <<
"loadPreProcessingSettingsFromFile(fstream &file) - Failed to load preprocessing settings from file!" << std::endl;
143 if( word !=
"LeakRate:" ){
144 errorLog <<
"load(fstream &file) - Failed to read LeakRate header!" << std::endl;
150 return init(leakRate,numInputDimensions);
157 if( leakRate < 0 || leakRate > 1 ){
158 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - leakRate must be between [0 1]!" << std::endl;
162 if( numDimensions == 0 ){
163 errorLog <<
"init(const Float leakRate,const UINT numDimensions) - NumDimensions must be greater than 0!" << std::endl;
168 this->numInputDimensions = numDimensions;
169 this->numOutputDimensions = numDimensions;
172 processedData.clear();
173 processedData.
resize(numDimensions,0);
180 if( numInputDimensions != 1 ){
181 errorLog <<
"update(const Float x) - The Number Of Input Dimensions is not 1! NumInputDimensions: " << numInputDimensions << std::endl;
187 if(
y.size() == 0 )
return 0 ;
195 errorLog <<
"update(const VectorFloat &x) - Not Initialized!" << std::endl;
199 if( x.size() != numInputDimensions ){
200 errorLog <<
"update(const VectorFloat &x) - The Number Of Input Dimensions (" << numInputDimensions <<
") does not match the size of the input vector (" << x.size() <<
")!" << std::endl;
204 for(UINT n=0; n<numInputDimensions; n++){
209 return processedData;
213 if( leakRate >= 0 && leakRate <= 1 ){
215 if( initialized )
init(leakRate, numInputDimensions);
218 errorLog <<
"setLeakRate(const Float leakRate) - The leak rate must be between [0 1]!" << std::endl;
std::string getId() const
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 getLeakRate() const
static std::string getId()
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)
bool copyBaseVariables(const PreProcessing *preProcessingModule)
virtual bool process(const VectorFloat &inputVector)
The LeakyIntegrator class computes the following signal: y = y*z + x, where x is the input...
virtual bool load(std::fstream &file)
Float leakRate
The current leak rate.