TabulatedFunctionComplexLgAmpPhase.h
Go to the documentation of this file.
1 
9 #ifndef _utl_TabulatedFunctionComplexLgAmpPhase_h_
10 #define _utl_TabulatedFunctionComplexLgAmpPhase_h_
11 
12 #include <vector>
13 #include <algorithm>
14 #include <numeric>
15 #include <utl/ComplexLgAmpPhase.h>
16 #include <utl/TabulatedFunctionComplexLgAmpPhaseIterators.h>
17 
18 namespace utl {
19 
34 
35  public:
36  typedef std::vector<double> Array;
37  typedef std::vector<utl::ComplexLgAmpPhase> ArrayComplex;
40 
41  TabulatedFunctionComplexLgAmpPhase(const double boundaryTolerance = 1e-3)
42  : fBoundaryTolerance(boundaryTolerance) { }
43 
44  TabulatedFunctionComplexLgAmpPhase(const std::vector<double>& xValues,
45  const std::vector<utl::ComplexLgAmpPhase>& yValues,
46  const double boundaryTolerance = 1e-3) :
47  fBoundaryTolerance(boundaryTolerance)
48  {
49  FillTable(xValues, yValues);
50  }
51 
53 
54  unsigned int GetNPoints() const { return fX.size(); }
55 
57  PairComplexLgAmpPhase operator[](const int idx) const { return PairComplexLgAmpPhase(fX[idx], fY[idx]); }
58 
59  void Clear() { fX.clear(); fY.clear(); }
60 
61  void PushBack(const double x, const utl::ComplexLgAmpPhase& y);
62 
64  { return Iterator(fX.begin(), fY.begin()); }
65 
67  { return Iterator(fX.end(), fY.end()); }
68 
70  { return ConstIterator(fX.begin(), fY.begin()); }
71 
73  { return ConstIterator(fX.end(), fY.end()); }
74 
76  Array::iterator XBegin() { return fX.begin(); }
77 
79  Array::const_iterator XBegin() const { return fX.begin(); }
80 
82  ArrayComplex::iterator YBegin() { return fY.begin(); }
83 
85  ArrayComplex::const_iterator YBegin() const { return fY.begin(); }
86 
88  Array::iterator XEnd() { return fX.end(); }
89 
91  Array::const_iterator XEnd() const { return fX.end(); }
92 
94  ArrayComplex::iterator YEnd() { return fY.end(); }
95 
97  ArrayComplex::const_iterator YEnd() const { return fY.end(); }
98 
100  Array::const_reference XFront() const { return fX.front(); }
101 
103  ArrayComplex::const_reference YFront() const { return fY.front(); }
104 
106  Array::const_reference XBack() const { return fX.back(); }
107 
109  ArrayComplex::const_reference YBack() const { return fY.back(); }
110 
111  Iterator Insert(const double x, const utl::ComplexLgAmpPhase& y);
112 
113  //ConstIterator Find(const double x, const double y) const;
114 
115  ConstIterator FindX(const double x) const;
116 
118 
120  utl::ComplexLgAmpPhase Y(const double x) const;
121 
123  //utl::ComplexLgAmpPhase InterpolateY(const double x, const int polyDegree) const;
124 
125  // get/set the \p idx-th value of the Ys
126  const utl::ComplexLgAmpPhase& GetY(const unsigned int idx) const { return fY[idx]; }
127 
128  // get/set the \p idx-th value of the Xs
129  const double& GetX(const unsigned int idx) const { return fX[idx]; }
130 
131  double& GetX(const unsigned int idx) { return fX[idx]; }
132  utl::ComplexLgAmpPhase& GetY(const unsigned int idx) { return fY[idx]; }
133 
135  double SumX() const { return std::accumulate(fX.begin(), fX.end(), 0.); }
136 
137  bool IsInValidRange(const double x) const;
138 
140  { return fX == t.fX && fY == t.fY; }
141 
143  { return !operator==(t); }
144 
145  double GetBoundaryTolerance() const { return fBoundaryTolerance; }
146 
147  void SetBoundaryTolerance(const double tolerance) { fBoundaryTolerance = tolerance; }
148 
149  //TabulatedFunctionComplexLgAmpPhase operator*(const TabulatedFunctionComplexLgAmpPhase& rhs) const;
150 
153 
155  void Pow(const double power);
156 
157  protected:
158  void FillTable(const std::vector<double>& xValues,
159  const std::vector<utl::ComplexLgAmpPhase >& yValues);
160 
164 
165  };
166 
167 }
168 
169 
170 #endif
171 
172 // Configure (x)emacs for this file ...
173 // Local Variables:
174 // mode: c++
175 // compile-command: "make -C .. -k"
176 // End:
TabulatedFunctionComplexLgAmpPhaseIterator Iterator
Array::const_iterator XEnd() const
end of array of X
ArrayComplex::const_reference YBack() const
read-only reference to back of array of Y
ArrayComplex::const_iterator YBegin() const
begin of array of Y
bool operator==(const TabulatedFunctionComplexLgAmpPhase &t) const
ConstIterator FindY(const utl::ComplexLgAmpPhase &y) const
Iterator Insert(const double x, const utl::ComplexLgAmpPhase &y)
double SumX() const
return the sum of X values
TabulatedFunctionComplexLgAmpPhase(const double boundaryTolerance=1e-3)
ArrayComplex::iterator YBegin()
begin of array of Y
void Pow(const double power)
calculate the power of a TabulatedFunctionComplexLgAmpPhase (correctly treating amplitude and phase) ...
const utl::ComplexLgAmpPhase & GetY(const unsigned int idx) const
Interpolate the Y value with a polyDegree polynomial.
TabulatedFunctionComplexLgAmpPhase(const std::vector< double > &xValues, const std::vector< utl::ComplexLgAmpPhase > &yValues, const double boundaryTolerance=1e-3)
ArrayComplex::const_reference YFront() const
read-only reference to front of array of Y
const phoenix::function< PowerToImpl > power
Definition: UnitGrammar.h:47
void FillTable(const std::vector< double > &xValues, const std::vector< utl::ComplexLgAmpPhase > &yValues)
Array::const_reference XBack() const
read-only reference to back of array of X
Class to hold collection (x,y) points and provide interpolation between them, where y are complex num...
A class to store complex numbers which are internally represented by log10(amplitude) and phase (and ...
utl::ComplexLgAmpPhase Y(const double x) const
Get or interpolate the Y value that corresponds to parameter x.
Array::const_iterator XBegin() const
begin of array of X
ArrayComplex::const_iterator YEnd() const
end of array of Y
void PushBack(const double x, const utl::ComplexLgAmpPhase &y)
TabulatedFunctionComplexLgAmpPhase & operator*=(const TabulatedFunctionComplexLgAmpPhase &rhs)
multiply the current TabulatedFunctionComplexLgAmpPhase with another one
const double & GetX(const unsigned int idx) const
std::vector< utl::ComplexLgAmpPhase > ArrayComplex
bool operator!=(const TabulatedFunctionComplexLgAmpPhase &t) const
ArrayComplex::iterator YEnd()
end of array of Y
ConstTabulatedFunctionComplexLgAmpPhaseIterator ConstIterator
Array::const_reference XFront() const
read-only reference to front of array of X
utl::ComplexLgAmpPhase & GetY(const unsigned int idx)
PairComplexLgAmpPhase operator[](const int idx) const
Note: cannot be used in assignment.

, generated on Tue Sep 26 2023.