General Purpose Geodetic Library
SgPwlStorage.h
Go to the documentation of this file.
1 /*
2  *
3  * This file is a part of Space Geodetic Library. The library is used by
4  * nuSolve, a part of CALC/SOLVE system, and designed to make analysis of
5  * geodetic VLBI observations.
6  * Copyright (C) 2010-2020 Sergei Bolotin.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef SG_EST_PWL_STORAGE_H
24 #define SG_EST_PWL_STORAGE_H
25 
26 
27 #ifdef HAVE_CONFIG_H
28 # include <config.h>
29 #endif
30 
31 
32 #include <QtCore/QString>
33 
34 #include <SgParameter.h>
35 
36 
37 
38 class SgTaskConfig;
39 class SgUtMatrix;
40 /***===================================================================================================*/
47 {
48 public:
49  //
50  // constructors/destructors:
51  //
55  inline SgPwlStorage();
56 
60  inline virtual ~SgPwlStorage();
61 
62 
63  //
64  // Interfaces:
65  //
68  virtual SgPwlStorage& operator=(const SgPwlStorage&);
69 
72  inline int getNumOfNodes() const;
73 
76  inline int getNumOfPolynomials() const;
77 
78  inline double step() const;
79 
80  inline const SgMJD& tStart() const;
81 
82  inline const SgMJD& tFinis() const;
83 
84  inline const SgMJD& tRefer() const;
85 
86  inline SgMJD tMean() const;
87 
90  inline SgParameter* getP_Ai(int);
91 
94  inline SgParameter* getP_Bi(int);
95 
96  inline SgParameter* getPOrig();
97 
98  inline void setNumOfPolynomials(int);
99 
100  inline double trace() const {return trace_;};
101 
102  //
103  // Functions:
104  //
107  static const QString className();
108 
112  const SgMJD& tStart, const SgMJD& tFinis, const SgMJD& tRefer,
113  const SgTaskConfig*) = 0;
114 
117  virtual void propagatePartials(const SgMJD& t) = 0;
118 
119  inline int calcCurrentIdx(const SgMJD& t);
120 
121  virtual int getNumOfActiveParameters(const SgMJD& t) = 0;
122 
123  virtual int getNumOfSegments() = 0;
124 
125  virtual void getListOfActiveParameters(const SgMJD& t, QList<SgParameter*>& pars) = 0;
126 
127 
130  void zerofy();
131 
132  virtual double calcAX(const SgMJD&, bool) = 0;
133 
134  virtual double calc_P_a(const SgSymMatrix&, int, const SgMJD&) = 0;
135 
136  virtual double calc_aT_P_a(const SgVector&, const SgMJD&) = 0;
137 
138  virtual double calcRateRms4Sfo();
139 
140  void collectTraces4Sfo(const QList<SgParameter*> *listX, const SgSymMatrix& mPx);
141 
142  double calcPolySolution(const SgMJD&);
143 
144  virtual double calcRateSolution(const SgMJD&) = 0;
145 
146  virtual double calcSolution(const SgMJD&);
147 
148  virtual double calcRateSigma(const SgMJD&);
149 
150  inline double calcMean();
151 
152  inline double calcWRMS();
153 
154  //
155  // Friends:
156  //
157 
158  //
159  // I/O:
160  //
161  // ...
162 
163 protected:
164  // original/external parameter:
166 
174  double step_;
175  // for statistics/spoolfile outputs:
176  double sumP2_;
177  double sumX1P2_;
178  double sumX2P2_;
179  double sumT1P2_;
181  // exercise:
182  double trace_;
183 
184 };
185 /*=====================================================================================================*/
186 
187 
188 
189 
190 
191 
192 
193 
194 /*=====================================================================================================*/
195 /* */
196 /* SgPwlStorage inline members: */
197 /* */
198 /*=====================================================================================================*/
199 //
200 //
201 // CONSTRUCTORS:
202 //
203 // An empty constructor:
205  tStart_(tZero),
206  tFinis_(tZero),
207  tRefer_(tZero)
208 {
209  pOrig_ = NULL;
210  pAi_ = NULL;
211  pBi_ = NULL;
212  numOfNodes_ = 0;
213  numOfPolynomials_ = 0;
214  sumP2_ = 0.0;
215  sumX1P2_ = 0.0;
216  sumX2P2_ = 0.0;
217  sumT1P2_ = 0.0;
218  isPOrigOwner_ = false;
219  trace_ = 0.0;
220 };
221 
222 
223 
224 // A destructor:
226 {
227  if (isPOrigOwner_)
228  delete pOrig_;
229  pOrig_ = NULL; // not an owner
230  if (pAi_)
231  {
232  delete[] pAi_;
233  pAi_ = NULL;
234  };
235  if (pBi_)
236  {
237  delete[] pBi_;
238  pBi_ = NULL;
239  };
240  numOfNodes_ = 0;
241  numOfPolynomials_ = 0;
242 };
243 
244 
245 
246 //
247 // INTERFACES:
248 //
249 //
250 //
251 inline int SgPwlStorage::getNumOfNodes() const
252 {
253  return numOfNodes_;
254 };
255 
256 
257 
258 //
260 {
261  return numOfPolynomials_;
262 };
263 
264 
265 
266 //
267 inline double SgPwlStorage::step() const
268 {
269  return step_;
270 };
271 
272 
273 
274 //
275 inline const SgMJD& SgPwlStorage::tStart() const
276 {
277  return tStart_;
278 };
279 
280 
281 
282 //
283 inline const SgMJD& SgPwlStorage::tFinis() const
284 {
285  return tFinis_;
286 };
287 
288 
289 
290 //
291 inline const SgMJD& SgPwlStorage::tRefer() const
292 {
293  return tRefer_;
294 };
295 
296 
297 
298 //
300 {
301  return sumP2_>0.0 ? SgMJD(sumT1P2_/sumP2_) : tZero;
302 };
303 
304 
305 
306 //
308 {
309  int i = (-1<idx && idx<numOfNodes_) ? idx : 0;
310  return &pBi_[i];
311 };
312 
313 
314 
315 //
317 {
318  int i = (-1<idx && idx<numOfPolynomials_) ? idx : 0;
319  return &pAi_[i];
320 };
321 
322 
323 
324 //
326 {
327  return pOrig_;
328 };
329 
330 
331 // sets:
332 //
333 //
335 {
336  numOfPolynomials_ = n;
337 };
338 
339 
340 //
341 // FUNCTIONS:
342 //
343 //
344 //
346 {
347  int idx;
348  idx = floor((t - tStart_)/step_);
349  if (idx < 0)
350  idx = 0;
351  if (numOfNodes_ <= idx)
352  idx = numOfNodes_ - 1;
353  return idx;
354 };
355 
356 
357 
358 //
359 inline double SgPwlStorage::calcMean()
360 {
361  return sumP2_>0.0 ? sumX1P2_/sumP2_ : 0.0;
362 };
363 
364 
365 
366 //
367 inline double SgPwlStorage::calcWRMS()
368 {
369  return sumP2_>0.0 ? sqrt((sumX2P2_ - sumX1P2_*sumX1P2_/sumP2_)/sumP2_) : 0.0;
370 };
371 
372 
373 
374 //
375 // FRIENDS:
376 //
377 //
378 //
379 
380 
381 /*=====================================================================================================*/
382 
383 
384 
385 
386 
387 /*=====================================================================================================*/
388 //
389 // aux functions:
390 //
391 /*=====================================================================================================*/
392 #endif //SG_EST_PWL_STORAGE_H
const SgMJD tZero(1957, 10, 4)
Definition: SgMJD.h:59
double calcMean()
Definition: SgPwlStorage.h:359
int getNumOfPolynomials() const
Definition: SgPwlStorage.h:259
double sumT1P2_
Definition: SgPwlStorage.h:179
const SgMJD & tStart() const
Definition: SgPwlStorage.h:275
SgParameter * getP_Bi(int)
Definition: SgPwlStorage.h:307
int numOfPolynomials_
Definition: SgPwlStorage.h:169
virtual void getListOfActiveParameters(const SgMJD &t, QList< SgParameter * > &pars)=0
SgParameter * getPOrig()
Definition: SgPwlStorage.h:325
bool isPOrigOwner_
Definition: SgPwlStorage.h:180
int getNumOfNodes() const
Definition: SgPwlStorage.h:251
virtual double calcAX(const SgMJD &, bool)=0
void collectTraces4Sfo(const QList< SgParameter * > *listX, const SgSymMatrix &mPx)
virtual ~SgPwlStorage()
Definition: SgPwlStorage.h:225
SgMJD tMean() const
Definition: SgPwlStorage.h:299
static const QString className()
virtual double calcSolution(const SgMJD &)
const SgMJD & tRefer() const
Definition: SgPwlStorage.h:291
virtual SgPwlStorage & operator=(const SgPwlStorage &)
virtual int getNumOfSegments()=0
SgParameter * getP_Ai(int)
Definition: SgPwlStorage.h:316
double step() const
Definition: SgPwlStorage.h:267
double sumX2P2_
Definition: SgPwlStorage.h:178
virtual double calcRateRms4Sfo()
virtual double calc_P_a(const SgSymMatrix &, int, const SgMJD &)=0
double calcWRMS()
Definition: SgPwlStorage.h:367
SgParameter * pOrig_
Definition: SgPwlStorage.h:165
double calcPolySolution(const SgMJD &)
virtual double calcRateSolution(const SgMJD &)=0
int calcCurrentIdx(const SgMJD &t)
Definition: SgPwlStorage.h:345
const SgMJD & tFinis() const
Definition: SgPwlStorage.h:283
virtual void propagatePartials(const SgMJD &t)=0
SgParameter * pAi_
Definition: SgPwlStorage.h:167
virtual void deployParameters(SgParameter *, const SgMJD &tStart, const SgMJD &tFinis, const SgMJD &tRefer, const SgTaskConfig *)=0
void setNumOfPolynomials(int)
Definition: SgPwlStorage.h:334
virtual int getNumOfActiveParameters(const SgMJD &t)=0
double sumX1P2_
Definition: SgPwlStorage.h:177
double trace() const
Definition: SgPwlStorage.h:100
virtual double calcRateSigma(const SgMJD &)
virtual double calc_aT_P_a(const SgVector &, const SgMJD &)=0
SgParameter * pBi_
Definition: SgPwlStorage.h:168