* Boston, MA 02110-1301, USA.
*/
-#ifndef _GRI_AGC_CC_H_
-#define _GRI_AGC_CC_H_
+#ifndef INCLUDED_GRI_AGC_CC_H
+#define INCLUDED_GRI_AGC_CC_H
#include <math.h>
class gri_agc_cc {
public:
- gri_agc_cc (float rate = 1e-4, float reference = 1.0, float gain = 1.0, float max_gain = 0.0)
- : _rate(rate), _reference(reference), _gain(gain), _max_gain(max_gain) {};
+ gri_agc_cc (float rate = 1e-4, float reference = 1.0,
+ float gain = 1.0, float max_gain = 0.0)
+ : _rate(rate), _reference(reference),
+ _gain(gain), _max_gain(max_gain) {};
float rate () const { return _rate; }
float reference () const { return _reference; }
void set_reference (float reference) { _reference = reference; }
void set_gain (float gain) { _gain = gain; }
void set_max_gain(float max_gain) { _max_gain = max_gain; }
-
+
gr_complex scale (gr_complex input){
gr_complex output = input * _gain;
- _gain += (_reference - sqrt(output.real()*output.real()+output.imag()*output.imag())) * _rate; //use abs or cabs to get approximation by absolute value,
- //note that abs is computationally more intensive then norm for a complex number
+
+ _gain += _rate * (_reference - sqrt(output.real()*output.real() +
+ output.imag()*output.imag()));
if (_max_gain > 0.0 && _gain > _max_gain)
_gain = _max_gain;
return output;
float _max_gain; // max allowable gain
};
-#endif /* _GRI_AGC_CC_H_ */
+#endif /* INCLUDED_GRI_AGC_CC_H */