File: statisticalvalue.h

package info (click to toggle)
aoflagger 2.13.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,232 kB
  • sloc: cpp: 61,805; python: 60; sh: 23; makefile: 8
file content (60 lines) | stat: -rw-r--r-- 1,588 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef MSIO_STATISTICAL_VALUE_H
#define MSIO_STATISTICAL_VALUE_H

#include <complex>

class StatisticalValue {
	public:
		explicit StatisticalValue(unsigned _polarizationCount) :
			_polarizationCount(_polarizationCount),
			_kindIndex(0),
			_values(new std::complex<float>[_polarizationCount])
		{
		}
		
		StatisticalValue(const StatisticalValue &source) :
			_polarizationCount(source._polarizationCount),
			_kindIndex(source._kindIndex),
			_values(new std::complex<float>[source._polarizationCount])
		{
			for(unsigned i=0;i<_polarizationCount;++i)
				_values[i] = source._values[i];
		}
		
		~StatisticalValue()
		{
			delete[] _values;
		}
		
		StatisticalValue& operator=(const StatisticalValue &source)
		{
			if(_polarizationCount != source._polarizationCount)
			{
				_polarizationCount = source._polarizationCount;
				delete[] _values;
				_values = new std::complex<float>[_polarizationCount];
			}
			_kindIndex = source._kindIndex;
			for(unsigned i=0;i<_polarizationCount;++i)
				_values[i] = source._values[i];
			return *this;
		}
		
		unsigned PolarizationCount() const { return _polarizationCount; }
		
		unsigned KindIndex() const { return _kindIndex; }
		void SetKindIndex(unsigned kindIndex) { _kindIndex = kindIndex; }
		
		std::complex<float> Value(unsigned polarizationIndex) const { return _values[polarizationIndex]; }
		void SetValue(unsigned polarizationIndex, std::complex<float> newValue)
		{
			_values[polarizationIndex] = newValue;
		}
	
	private:
		unsigned _polarizationCount;
		unsigned _kindIndex;
		std::complex<float> *_values;
};

#endif