CARMA C++
CorrelatorStats.h
Go to the documentation of this file.
1 #ifndef CORRELATORSTATS_H
2 #define CORRELATORSTATS_H
3 
4 #include <complex>
6 
12 namespace carma {
13 namespace correlator {
14 namespace lib {
15 
20  public:
21 
25  explicit CorrelatorStats( );
26 
30  CorrelatorStats( const CorrelatorStats & rhs );
31 
35  virtual ~CorrelatorStats();
36 
40  void swap( CorrelatorStats & rhs );
41 
45  void mySerialize( char * byteArray, int * offset ) const;
46 
50  void deserializeVer0( const char * byteArray,
51  int * offset,
52  int byteArraySize );
53 
54  void deserializeVer1( const char * byteArray,
55  int * offset,
56  int byteArraySize );
57 
61  void deserializeSwapVer0( const char * byteArray,
62  int * offset,
63  int byteArraySize );
64 
65  void deserializeSwapVer1( const char * byteArray,
66  int * offset,
67  int byteArraySize );
68 
72  int getSizeInBytes() const;
73 
77  float getIntegrationTime() const;
78 
82  int getNumberOfSamples() const;
83 
87  std::complex<float> getAvg() const;
88 
92  std::complex<float> getVariance() const;
93 
97  std::complex<float> getStandardDeviation() const;
98 
102  void setNumberOfSamples(int numberOfSamples);
103 
107  void setIntegrationTime(float integTime);
108 
112  void setAvg(std::complex<float> avg);
113 
117  void setVariance(std::complex<float> var);
118 
122  void setStandardDeviation(std::complex<float> sd);
123 
127  CorrelatorStats & operator=( const CorrelatorStats & rhs );
128 
132  void addInIntegrationTime( const CorrelatorStats & rhs );
133 
137  std::string getSummary( ) const;
138 
139  private:
140  float integrationTime_;
141  int numberOfSamples_; // number of samples used(ie. data.size())
142  // these quantities represent averages over the number of
143  // elemets in the data vector
144  std::complex<float> avg_;
145  std::complex<float> var_;
146  std::complex<float> sd_;
147 
148  }; // End class CorrelatorStats
149 
150 } // End namespace lib
151 } // End namespace correlator
152 } // End namespace carma
153 
154 
155 inline
157 integrationTime_( 0.0 ),
158 numberOfSamples_( 0 ),
159 avg_( 0.0, 0.0 ),
160 var_( 0.0, 0.0 ),
161 sd_( 0.0, 0.0 )
162 {
163 }
164 
165 
166 inline
168  const CorrelatorStats & rhs ) :
169 integrationTime_( rhs.integrationTime_ ),
170 numberOfSamples_( rhs.numberOfSamples_ ),
171 avg_( rhs.avg_ ),
172 var_( rhs.var_ ),
173 sd_( rhs.sd_ )
174 {
175 }
176 
177 
178 inline void
180 {
181  ::std::swap( integrationTime_, rhs.integrationTime_ );
182  ::std::swap( numberOfSamples_, rhs.numberOfSamples_ );
183  ::std::swap( avg_, rhs.avg_ );
184  ::std::swap( var_, rhs.var_ );
185  ::std::swap( sd_, rhs.sd_ );
186 }
187 
188 
189 inline
190 carma::correlator::lib::CorrelatorStats::CorrelatorStats::~CorrelatorStats( )
191 {
192 }
193 
194 
195 inline float
197 {
198  return integrationTime_;
199 }
200 
201 
202 inline int
204 {
205  return numberOfSamples_;
206 }
207 
208 
209 inline ::std::complex< float >
211 {
212  return avg_;
213 }
214 
215 
216 inline ::std::complex< float >
218 {
219  return var_;
220 }
221 
222 
223 inline ::std::complex< float >
225 {
226  return sd_;
227 }
228 
229 
230 inline void
232  const float integTime )
233 {
234  integrationTime_ = integTime;
235 }
236 
237 
238 inline void
240  const int ns )
241 {
242  numberOfSamples_ = ns;
243 }
244 
245 
246 inline void
248  const ::std::complex< float > avg )
249 {
250  avg_ = avg;
251 }
252 
253 
254 inline void
256  const ::std::complex< float > var )
257 {
258  var_ = var;
259 }
260 
261 
262 inline void
264  const ::std::complex< float > sd )
265 {
266  sd_ = sd;
267 }
268 
269 
270 inline void
273 {
274  integrationTime_ += rhs.getIntegrationTime();
275 }
276 
277 
281 {
282  integrationTime_ = rhs.integrationTime_;
283  numberOfSamples_ = rhs.numberOfSamples_;
284  avg_ = rhs.avg_;
285  var_ = rhs.var_;
286  sd_ = rhs.sd_;
287 
288  return *this;
289 }
290 
291 
292 #endif
std::complex< float > getAvg() const
Get Average.
void swap(CorrelatorStats &rhs)
Swap this instance with another CorrelatorStats instance.
Abstract Class used to allow object to serialize themselves into a byte array.
Definition: Serializable.h:32
void setIntegrationTime(float integTime)
Set Integration time in msec.
Class to hold some statistics related to Sideband data.
CorrelatorStats & operator=(const CorrelatorStats &rhs)
Assignment.
void mySerialize(char *byteArray, int *offset) const
Called when object is serialized.
float getIntegrationTime() const
Get Integration time in msec.
std::string getSummary() const
Provide a string summary of the contents.
void setAvg(std::complex< float > avg)
Set Average.
std::complex< float > getVariance() const
Get Variance.
void deserializeSwapVer0(const char *byteArray, int *offset, int byteArraySize)
Called when object is de-serialized.
void setVariance(std::complex< float > var)
Set Variance.
void deserializeVer0(const char *byteArray, int *offset, int byteArraySize)
Called when object is de-serialized.
void setStandardDeviation(std::complex< float > sd)
Set Standard Deviation.
virtual ~CorrelatorStats()
Destructor.
std::complex< float > getStandardDeviation() const
Get Standard Deviation.
int getSizeInBytes() const
Return size in bytes.
int getNumberOfSamples() const
Get the number of samples in integration.
void setNumberOfSamples(int numberOfSamples)
Set the number of samples in integration.
void addInIntegrationTime(const CorrelatorStats &rhs)
Add in integration time from a CorrelatorStats.