Merged changes from eb/digital-wip into trunk.
[debian/gnuradio] / gnuradio-core / src / lib / general / gri_agc_cc.h
index f68eec4cfa8441d25885b3036971a4d3f1ddbf30..5ebd67ccf98653dcb46fb3087e356dc0c0a2e26f 100644 (file)
@@ -20,8 +20,8 @@
  * 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; }
@@ -46,11 +48,12 @@ class gri_agc_cc {
   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;
@@ -68,4 +71,4 @@ class gri_agc_cc {
   float _max_gain;             // max allowable gain
 };
 
-#endif /* _GRI_AGC_CC_H_ */
+#endif /* INCLUDED_GRI_AGC_CC_H */