Jpp  18.3.0-rc.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JComplexPhase.hh
Go to the documentation of this file.
1 #ifndef __JOSCPROB__JCOMPLEXPHASE__
2 #define __JOSCPROB__JCOMPLEXPHASE__
3 
4 #include "JLang/JException.hh"
5 
6 #include "JTools/JGrid.hh"
7 
9 
10 
11 /**
12  * \author bjung, mdejong
13  */
14 
15 namespace JOSCPROB {}
16 namespace JPP { using namespace JOSCPROB; }
17 
18 namespace JOSCPROB {
19 
20  using JTOOLS::JGrid;
21 
22 
23  /**
24  * Implementation of oscillation complex phase.
25  */
26  template<class T = double>
27  struct JComplexPhase :
28  public JOscParameter<T>
29  {
32 
35 
36 
37  /**
38  * Default constructor.
39  */
42  {}
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param value complex phase value [rad]
49  */
50  explicit JComplexPhase(argument_type value) :
51  JOscParameter_t(value)
52  {
53  using namespace JPP;
54 
55  if (!is_valid()) {
56  THROW(JValueOutOfRange, "JComplexPhase::JComplexPhase(): Invalid complex phase " << value);
57  }
58  }
59 
60 
61  /**
62  * Assignment operator.
63  *
64  * \param value complex phase value [rad]
65  * \return complex phase
66  */
68  {
69  this->setValue(value);
70 
71  return *this;
72  }
73 
74 
75  /**
76  * Check validity of oscillation parameter.
77  *
78  * \return true if valid; else false
79  */
80  bool is_valid() const override
81  {
82  const T& phase = this->getValue();
83 
84  return this->isDefined() ? !(phase < 0.0 || phase > 2 * M_PI) : true;
85  }
86 
87 
88  /**
89  * Auxiliary function to create a complex phase parameter grid.
90  *
91  * \param value complex phase value [rad]
92  * \return complex phase parameter
93  */
95  {
96  return JComplexPhase_t(value);
97  }
98  };
99 
100 
101  /**
102  * Template specialization for parameter grid.
103  */
104  template<>
105  struct JComplexPhase<JGrid<double> > :
106  public JOscParameter<JGrid<double> >
107  {
111 
114 
116 
117 
118  /**
119  * Default constructor.
120  */
122  {}
123 
124 
125  /**
126  * Constructor.
127  *
128  * \param grid complex phase parameter grid [rad]
129  */
130  explicit JComplexPhase(argument_type grid) :
131  JOscParameter_t(grid)
132  {
133  using namespace JPP;
134 
135  if (!is_valid()) {
136  THROW(JValueOutOfRange, "JComplexPhase::JComplexPhase(): Invalid complex phase grid " << grid);
137  }
138  }
139 
140 
141  /**
142  * Constructor.
143  *
144  * \param nx number of elements
145  * \param Xmin lower limit [rad]
146  * \param Xmax upper limit [rad]
147  */
148  JComplexPhase(const int nx,
149  const abscissa_type& xmin,
150  const abscissa_type& xmax) :
151  JOscParameter_t(JGrid_t(nx, xmin, xmax))
152  {}
153 
154 
155  /**
156  * Constructor.
157  *
158  * \param value complex phase value [rad]
159  */
160  explicit JComplexPhase(const abscissa_type& value) :
161  JComplexPhase(1, value, value)
162  {}
163 
164 
165  /**
166  * Assignment operator.
167  *
168  * \param value complex phase parameter grid [rad]
169  * \return complex phase
170  */
172  {
173  this->setValue(grid);
174 
175  return *this;
176  }
177 
178 
179  /**
180  * Check validity of oscillation parameter.
181  *
182  * \return true if valid; else false
183  */
184  bool is_valid() const override
185  {
186  const abscissa_type minPhase = this->getValue().getXmin();
187  const abscissa_type maxPhase = this->getValue().getXmax();
188 
189  return (this->isDefined() ? !(minPhase < 0.0 || minPhase > 2 * M_PI ||
190  maxPhase < 0.0 || maxPhase > 2 * M_PI) : true);
191  }
192 
193 
194  /**
195  * Auxiliary function to create a complex phase parameter grid.
196  *
197  * \param value complex phase value [rad]
198  * \return complex phase parameter
199  */
201  {
202  return JComplexPhase_t(value);
203  }
204  };
205 }
206 
207 #endif
JOscParameter_t::JParameter_t JParameter_t
const double xmax
Definition: JQuadrature.cc:24
Abstract base class for oscillation parameter.
Exceptions.
JComplexPhase(argument_type grid)
Constructor.
static JComplexPhase_t make_parameter(const abscissa_type &value)
Auxiliary function to create a complex phase parameter grid.
Parameter class.
Definition: JParameter.hh:34
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
JComplexPhase< T > JComplexPhase_t
JComplexPhase()
Default constructor.
static JComplexPhase_t make_parameter(argument_type value)
Auxiliary function to create a complex phase parameter grid.
void setValue(argument_type value)
Set parameter.
JOscParameter_t::argument_type argument_type
Implementation of oscillation complex phase.
JOscParameter< T > JOscParameter_t
JComplexPhase(argument_type value)
Constructor.
const bool isDefined() const
Get status of parameter.
Definition: JParameter.hh:137
JParameter_t::argument_type argument_type
bool is_valid() const override
Check validity of oscillation parameter.
do set_variable OUTPUT_DIRECTORY $WORKDIR T
JClass< T >::argument_type argument_type
Definition: JParameter.hh:39
JComplexPhase(const int nx, const abscissa_type &xmin, const abscissa_type &xmax)
Constructor.
const double xmin
Definition: JQuadrature.cc:23
JAbstractCollection< JAbscissa_t >::abscissa_type abscissa_type
Definition: JGrid.hh:41
bool is_valid() const override
Check validity of oscillation parameter.
Simple data structure for an abstract collection of equidistant abscissa values.
Definition: JGrid.hh:38
JOscParameter_t::JParameter_t JParameter_t
JOscParameter_t::argument_type argument_type
const T & getValue() const
Get value of parameter.
Definition: JParameter.hh:81
JComplexPhase(const abscissa_type &value)
Constructor.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:178
JComplexPhase_t & operator=(argument_type value)
Assignment operator.
JComplexPhase_t & operator=(argument_type grid)
Assignment operator.