General Purpose Geodetic Library
SgEstimator.cpp
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 #include <SgEstimator.h>
24 
25 #include <SgVector.h>
26 #include <SgSymMatrix.h>
27 #include <SgUtMatrix.h>
28 
29 #include <SgLogger.h>
30 
31 #include <SgParameter.h>
32 #include <SgArcStorage.h>
33 #include <SgPwlStorage.h>
34 #include <SgPwlStorageBSplineL.h>
35 #include <SgPwlStorageBSplineQ.h>
36 #include <SgPwlStorageIncRates.h>
37 #include <SgTaskConfig.h>
38 
39 //#include <SgTaskManager.h>
40 
41 
42 //#define LOCDEB
43 
44 #include <pthread.h>
45 #include <signal.h>
46 #include <unistd.h>
47 
48 
49 const char* nsNumOfThreads = "NUSOLVE_NUM_THREADS";
50 
51 struct arg4Prc_01
52 {
53  int column_;
54  int thread_;
55  int num_;
56  int nZ_;
57  double **ppRx_;
58  double **ppAx_;
59  double *pZx_;
60  double *pZ_;
61  double *pU_;
62  pthread_mutex_t *pthMutexes_;
63  pthread_mutex_t *pthMutL_;
65 };
66 
67 struct arg4Prc_02
68 {
69  int column_;
70  int thread_;
71  int nP_;
72  int nX_;
73  int nZ_;
74  double **ppRp_;
75  double **ppRpx_;
76  double **ppAp_;
77  double **ppAx_;
78  double *pZp_;
79  double *pZ_;
80  double *pU_;
81  pthread_mutex_t *pthMutexes_;
82  pthread_mutex_t *pthMutL_;
84 };
85 
86 void* thPrc_01(void *);
87 void* thPrc_02(void *);
88 
89 
90 //pthread_mutex_t *pthMutexes;
91 //pthread_mutex_t pthMutL;
92 //int lastPrcColumn;
93 
94 
95 
96 void * thPrc_01(void *pArg)
97 {
98  struct arg4Prc_01 *a=(struct arg4Prc_01*)pArg;
99  int l=a->column_;
100 //int m=a->thread_;
101  int num=a->num_;
102  int nZ=a->nZ_;
103  double **ppRx=a->ppRx_;
104  double **ppAx=a->ppAx_;
105  double *pZx=a->pZx_;
106  double *pZ=a->pZ_;
107  double *pU=a->pU_;
108  //
109  pthread_mutex_t *pthMutexes = a->pthMutexes_;
110  pthread_mutex_t *pthMutL = a->pthMutL_;
111  int *lastPrcColumn = a->lastPrcColumn_;
112  //
113  double ul=0.0, s=0.0, g=0.0;
114  double *p, *q;
115  int i,j;
116  //
117 //printf(" ++ begin: m=%d, l=%d\n", m, l);
118  //
119  pthread_mutex_lock(pthMutL);
120  l = *lastPrcColumn + 1;
121  /* check for previous threads:*/
122 /*
123  for (i=l-numOfThreads; i<l; i++)
124  {
125  if (-1 < i)
126  {
127  pthread_mutex_lock (pthMutexes + i);
128  pthread_mutex_unlock(pthMutexes + i);
129  };
130  };
131 */
132  // processing column l:
133  pthread_mutex_lock(pthMutexes + l);
134  //
135  //
136  s = *(*(ppRx+l)+l)**(*(ppRx+l)+l);
137  p = *(ppAx+l);
138  for (i=0; i<nZ; i++, p++)
139  s += *p**p;
140  //
141  if (s>0.0)
142  {
143  s = -signum(*(*(ppRx+l)+l))*sqrt(s);
144  //
145  ul = *(*(ppRx+l)+l) - s; // U_l
146  memcpy((void*)(pU), (void*)(*(ppAx+l)), sizeof(double)*(nZ));
147 
148  *(*(ppRx+l)+l) = s; // Rx_(l,l)
149  s = 1.0/(s*ul); // betta
150  // // |
151  // lock next column: // |
152  pthread_mutex_lock (pthMutexes + l + 1); // |
153  // update and unlock lastPrcColumn:
154  (*lastPrcColumn)++;
155  pthread_mutex_unlock(pthMutL);
156 
157  pthread_mutex_unlock(pthMutexes + l); // |
158  // processing l+1 ... n columns: // |
159  for (j=l+1; j<num; j++) // |<-- processing "Rx/Ax"-block
160  { // |
161  g = ul**(*(ppRx+j)+l); // |
162  p = *(ppAx+j); // |
163  q = pU; // |
164  for (i=0; i<nZ; i++, p++, q++) // |
165  g += *q**p; // |
166  // |
167  *(*(ppRx+j)+l) += s*g*ul; // |
168  p = *(ppAx+j); // |
169  q = pU; // |
170  for (i=0; i<nZ; i++, p++, q++) // |
171  *p += s*g**q; // |
172  pthread_mutex_lock (pthMutexes + j + 1); // |
173  pthread_mutex_unlock(pthMutexes + j); // |
174  }; // |_________________________
175  // // |
176  g = ul**(pZx+l); // |--
177  p = pZ; // |
178  q = pU; // |
179  for (i=0; i<nZ; i++, p++, q++) // |
180  g += *q**p; // | dealing with the vectors Zx
181  // // |
182  *(pZx+l) += s*g*ul; // | and Z
183  p = pZ; // |
184  q = pU; // |
185  for (i=0; i<nZ; i++, p++, q++) // |
186  *p += s*g**q; // |--
187 
188  pthread_mutex_unlock(pthMutexes + num);
189  }
190  else // unlock resources:
191  {
192  (*lastPrcColumn)++;
193  pthread_mutex_unlock(pthMutL);
194  pthread_mutex_unlock(pthMutexes + l); // |
195  };
196 //printf(" ++ end: m=%d, l=%d\n", m, l);
197  return NULL;
198 };
199 
200 
201 
202 
203 
204 void * thPrc_02(void *pArg)
205 {
206  struct arg4Prc_02 *a=(struct arg4Prc_02*)pArg;
207  int l = a->column_;
208 //int m=a->thread_;
209  int nP = a->nP_;
210  int nX = a->nX_;
211  int nZ = a->nZ_;
212  double **ppRp = a->ppRp_;
213  double **ppRpx = a->ppRpx_;
214  double **ppAp = a->ppAp_;
215  double **ppAx = a->ppAx_;
216  double *pZp = a->pZp_;
217  double *pZ = a->pZ_;
218  double *pU = a->pU_;
219  //
220  pthread_mutex_t *pthMutexes = a->pthMutexes_;
221  pthread_mutex_t *pthMutL = a->pthMutL_;
222  int *lastPrcColumn = a->lastPrcColumn_;
223  //
224  double ul=0.0, s=0.0, g=0.0;
225  double *p, *q;
226  int i,j;
227  //
228  //
229 //printf(" ++ begin: m=%d, l=%d\n", m, l);
230  pthread_mutex_lock(pthMutL);
231  l = *lastPrcColumn + 1;
232 //printf(" ++ m=%d l=%d (Get Access to lastPrcColumn)\n", m, l);
233 
234  // processing column l:
235  pthread_mutex_lock(pthMutexes + l);
236 //printf(" ++ : m=%d, l=%d locked(0): %d\n", m, l, l);
237  //
238  //
239  s = *(*(ppRp+l)+l)**(*(ppRp+l)+l);
240  p = *(ppAp+l);
241  for (i=0; i<nZ; i++, p++)
242  s += *p**p;
243  //
244  if (s>0.0)
245  {
246  s = -signum(*(*(ppRp+l)+l))*sqrt(s);
247  //
248  ul = *(*(ppRp+l)+l) - s; // U_l
249  memcpy((void*)(pU), (void*)(*(ppAp+l)), sizeof(double)*(nZ));
250 
251  *(*(ppRp+l)+l) = s; // Rx_(l,l)
252  s = 1.0/(s*ul); // betta
253  // // |
254  // lock next column: // |
255  pthread_mutex_lock (pthMutexes + l + 1); // |
256 //printf(" ++ : m=%d, l=%d locked(1): %d\n", m, l, l + 1);
257  // update and unlock lastPrcColumn:
258  (*lastPrcColumn)++;
259  pthread_mutex_unlock(pthMutL);
260 //printf(" ++ m=%d l=%d (Released Access to lastPrcColumn)\n", m, l);
261 
262  pthread_mutex_unlock(pthMutexes + l); // |
263 //printf(" ++ : m=%d, l=%d unlocked(1): %d\n", m, l, l);
264  // processing l+1 ... nP columns: // |
265  for (j=l+1; j<nP; j++) // |<-- processing "Rp/Ap"-block
266  { // |
267  g = ul**(*(ppRp+j)+l); // |
268  p = *(ppAp+j); // |
269  q = pU; // |
270  for (i=0; i<nZ; i++, p++, q++) // |
271  g += *q**p; // |
272  // |
273  *(*(ppRp+j)+l) += s*g*ul; // |
274  p = *(ppAp+j); // |
275  q = pU; // |
276  for (i=0; i<nZ; i++, p++, q++) // |
277  *p += s*g**q; // |
278  pthread_mutex_lock (pthMutexes + j + 1); // |
279 //printf(" ++ : m=%d, l=%d locked(2): %d\n", m, l, j + 1);
280  pthread_mutex_unlock(pthMutexes + j); // |
281 //printf(" ++ : m=%d, l=%d unlocked(2): %d\n", m, l, j);
282  }; // |_________________________
283  // processing nP+1 ... nX columns: // |
284  for (j=0; j<nX; j++) // |<-- processing "Rpx/Ax"-block
285  { // |
286  g = ul**(*(ppRpx+j)+l); // |
287  p = *(ppAx+j); // |
288  q = pU; // |
289  for (i=0; i<nZ; i++, p++, q++) // |
290  g += *q**p; // |
291  // |
292  *(*(ppRpx+j)+l) += s*g*ul; // |
293  p = *(ppAx+j); // |
294  q = pU; // |
295  for (i=0; i<nZ; i++, p++, q++) // |
296  *p += s*g**q; // |
297  pthread_mutex_lock (pthMutexes + nP + j + 1); // |
298 //printf(" ++ : m=%d, l=%d locked(3): %d\n", m, l, nP + j + 1);
299  pthread_mutex_unlock(pthMutexes + nP + j); // |
300 //printf(" ++ : m=%d, l=%d unlocked(3): %d\n", m, l, nP + j);
301  }; // |_________________________
302  // // |
303  g = ul**(pZp+l); // |--
304  p = pZ; // |
305  q = pU; // |
306  for (i=0; i<nZ; i++, p++, q++) // |
307  g += *q**p; // | dealing with the vectors Zp
308  // // |
309  *(pZp+l) += s*g*ul; // | and Z
310  p = pZ; // |
311  q = pU; // |
312  for (i=0; i<nZ; i++, p++, q++) // |
313  *p += s*g**q; // |--
314 
315  pthread_mutex_unlock(pthMutexes + nP + nX);
316 //printf(" ++ : m=%d, l=%d unlocked(4): %d\n", m, l, nP + nX);
317  }
318  else // unlock resources:
319  {
320  (*lastPrcColumn)++;
321  pthread_mutex_unlock(pthMutL);
322 //printf(" ++ m=%d l=%d (Released Access to lastPrcColumn, s==0)\n", m, l);
323 
324  pthread_mutex_unlock(pthMutexes + l); // |
325 //printf(" ++ : m=%d, l=%d unlocked(0): %d, s==0\n", m, l, l);
326  };
327 
328 //printf(" -- end: m=%d, l=%d\n", m, l);
329  return NULL;
330 };
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 /*=======================================================================================================
341 *
342 * METHODS:
343 *
344 *======================================================================================================*/
345 //
346 // static first:
347 const QString SgEstimator::className()
348 {
349  return "SgEstimator";
350 };
351 
352 
353 
354 //
356  tLastProcessed_(tZero),
357  tNextLeft_(tZero),
358  tNextRight_(tInf)
359 {
360  config_ = config;
361  // regular parameters:
363  xAllByName_ = new QMap<QString, SgParameter*>;
364  //
366  xByName_ = new QMap<QString, SgParameter*>;
367  nX_ = 0;
368  x_ = NULL;
369  zx_ = NULL;
370  Rx_ = NULL;
371  Px_ = NULL;
372 
373  // stochastic parameters:
375  pByName_ = new QMap<QString, SgParameter*>;
376  nP_ = 0;
377  p_ = NULL;
378  zp_ = NULL;
379  Rp_ = NULL;
380  Rpx_ = NULL;
381  Pp_ = NULL;
382  SR_ = NULL;
383  //
384  // stochastic smoothing:
385  Rp_s_ = NULL;
386  Rpp_s_ = NULL;
387  Rpx_s_ = NULL;
388  zp_s_ = NULL;
389 
390  // arc parameters' specials:
392  aByName_ = new QMap<QString, SgParameter*>;
394 
395  // PWL parameters' specials:
397  pwlParByName_ = new QMap<QString, SgParameter*>;
398  pwlStorageByName_ = new QMap<QString, SgPwlStorage*>;
400 
401  // data:
402  nZ_ = 0;
403  z_ = NULL;
404  Ap_ = NULL;
405  Ax_ = NULL;
406  u_ = NULL;
407  //
408  u4pth_ = NULL;
409  //
410  numOfProcessedObs_ = 0;
411  maxConditionNumber_ = 0.0;
412 
413  numOfThreads_ = sysconf(_SC_NPROCESSORS_ONLN);
414  pthread_attr_init(&pthreadAttr_);
415  pthread_attr_setscope(&pthreadAttr_, PTHREAD_SCOPE_SYSTEM);
416  //
417 // pthread_attr_setschedpolicy(&pthreadAttr_, SCHED_FIFO);
418 // pthread_attr_setschedpolicy(&pthreadAttr_, SCHED_RR);
419 // pthread_attr_setschedpolicy(&pthreadAttr_, SCHED_OTHER);
420 
421  QString str(getenv(nsNumOfThreads));
422  if (str.size())
423  {
424  int n;
425  bool is;
426  n = str.toInt(&is);
427  if (is)
428  {
429  if (0 <= n)
430  {
431  numOfThreads_ = n;
433  "::SgEstimator(): the number of threads is set to " + QString("").setNum(numOfThreads_) +
434  " form the environmental variable \"" + nsNumOfThreads + "\"");
435  }
436  else
437  {
439  "::SgEstimator(): the the environmental variable \"" + nsNumOfThreads +
440  "\" is set incorrectly: cannot convert \"" + str + "\" to number of threads");
442  "::SgEstimator(): the number of threads is " + QString("").setNum(numOfThreads_));
443  };
444  }
445  else
446  {
448  "::SgEstimator(): the the environmental variable \"" + nsNumOfThreads +
449  "\" is set incorrectly: cannot convert \"" + str + "\" to int");
451  "::SgEstimator(): the number of threads is " + QString("").setNum(numOfThreads_));
452  };
453  }
454  else
456  "::SgEstimator(): using the default number of threads " + QString("").setNum(numOfThreads_));
457 };
458 
459 
460 
461 // A destructor:
463 {
464  // threads:
465  // free attrs:
466  pthread_attr_destroy(&pthreadAttr_);
468  "::SgEstimator(): " + QString("").setNum(numOfThreads_) + " thread attributes were released");
469 
470 
471  // regular:
472  if (xAllByName_)
473  {
474  xAllByName_->clear();
475  delete xAllByName_;
476  xAllByName_ = NULL;
477  };
478  if (listXAll_)
479  {
480  listXAll_->clear();
481  delete listXAll_;
482  listXAll_ = NULL;
483  };
484  if (xByName_)
485  {
486  xByName_->clear();
487  delete xByName_;
488  xByName_ = NULL;
489  };
490  if (listX_)
491  {
492  listX_->clear();
493  delete listX_;
494  listX_ = NULL;
495  };
496  if (x_)
497  {
498  delete x_;
499  x_ = NULL;
500  };
501  if (zx_)
502  {
503  delete zx_;
504  zx_ = NULL;
505  };
506  if (Rx_)
507  {
508  delete Rx_;
509  Rx_ = NULL;
510  };
511  if (PxAll_)
512  {
513  delete PxAll_;
514  PxAll_ = NULL;
515  };
516 
517  // stochastics:
518  if (pByName_)
519  {
520  pByName_->clear();
521  delete pByName_;
522  pByName_ = NULL;
523  };
524  if (listP_)
525  {
526 /*
527  for (int i=0; i<listP_->size(); i++)
528  delete listP_->at(i);
529 */
530  listP_->clear();
531  delete listP_;
532  listP_ = NULL;
533  };
534  if (p_)
535  {
536  delete p_;
537  p_ = NULL;
538  };
539  if (zp_)
540  {
541  delete zp_;
542  zp_ = NULL;
543  };
544  if (Rp_)
545  {
546  delete Rp_;
547  Rp_ = NULL;
548  };
549  if (Rpx_)
550  {
551  delete Rpx_;
552  Rpx_ = NULL;
553  };
554  if (SR_)
555  {
556  delete SR_;
557  SR_ = NULL;
558  };
559  if (Rp_s_)
560  {
561  delete Rp_s_;
562  Rp_s_ = NULL;
563  };
564  if (Rpp_s_)
565  {
566  delete Rpp_s_;
567  Rpp_s_ = NULL;
568  };
569  if (Rpx_s_)
570  {
571  delete Rpx_s_;
572  Rpx_s_ = NULL;
573  };
574  if (zp_s_)
575  {
576  delete zp_s_;
577  zp_s_ = NULL;
578  };
579  //
580  for (QMap<QString, StochasticSolutionCarrier>::iterator it=stcSolutions_.begin();
581  it!=stcSolutions_.end(); ++it)
582  {
583  StochasticSolutionCarrier &stcSol=it.value();
584  for (int i=0; i<stcSol.list_->size(); i++)
585  delete stcSol.list_->at(i);
586  delete stcSol.list_;
587  delete stcSol.x_;
588  delete stcSol.P_;
589  stcSol.list_ = NULL;
590  stcSol.x_ = NULL;
591  stcSol.P_ = NULL;
592  };
593  stcSolutions_.clear();
594  //
595 
596  // arc parameters:
597  if (listA_)
598  {
599  listA_->clear();
600  delete listA_;
601  listA_ = NULL;
602  };
603  if (aByName_)
604  {
605  aByName_->clear();
606  delete aByName_;
607  aByName_ = NULL;
608  };
609  if (arcStorage_)
610  {
611  for (int i=0; i<arcStorage_->size(); i++)
612  delete arcStorage_->at(i); // here we are an owner of these parameters
613  delete arcStorage_;
614  arcStorage_ = NULL;
615  };
616 
617  // PWL parameters:
618  if (listPwl_)
619  {
620  listPwl_->clear();
621  delete listPwl_;
622  listPwl_ = NULL;
623  };
624  if (pwlParByName_)
625  {
626  pwlParByName_->clear();
627  delete pwlParByName_;
628  pwlParByName_ = NULL;
629  };
630  if (pwlStorageByName_)
631  {
632  pwlStorageByName_->clear();
633  delete pwlStorageByName_;
634  pwlStorageByName_ = NULL;
635  };
636  if (pwlStorage_)
637  {
638  for (int i=0; i<pwlStorage_->size(); i++)
639  delete pwlStorage_->at(i); // here we are an owner of these parameters
640  delete pwlStorage_;
641  pwlStorage_ = NULL;
642  };
643 
644  // data:
645  if (z_)
646  {
647  delete z_;
648  z_ = NULL;
649  };
650  if (Ap_)
651  {
652  delete Ap_;
653  Ap_ = NULL;
654  };
655  if (Ax_)
656  {
657  delete Ax_;
658  Ax_ = NULL;
659  };
660  if (u_)
661  {
662  delete u_;
663  u_ = NULL;
664  };
665  if (u4pth_)
666  {
667  delete u4pth_;
668  u4pth_ = NULL;
669  };
670 
671 };
672 
673 
674 
675 //
676 void SgEstimator::addParameter(SgParameter* p, bool isSpecial)
677 {
678  if (!p)
679  {
681  ": addParameter(): the parameter is NULL");
682  return;
683  };
684  if (xAllByName_->contains(p->getName()))
685  {
687  ": addParameter(): the parameter [" + p->getName() +
688  "] is already in the regular parameters map");
689  return;
690  };
691  if (pByName_->contains(p->getName()))
692  {
694  ": addParameter(): the parameter [" + p->getName() +
695  "] is already in the stochastic parameters map");
696  return;
697  };
698  if (aByName_->contains(p->getName()))
699  {
701  ": addParameter(): the parameter [" + p->getName() +
702  "] is already in the arc parameters map");
703  return;
704  };
705  if (pwlParByName_->contains(p->getName()))
706  {
708  ": addParameter(): the parameter [" + p->getName() +
709  "] is already in the PWL parameters map");
710  return;
711  };
712  if (nZ_) // we will fix it latter
713  {
715  ": addParameter(): nZ_!=0; the parameter [" + p->getName() +
716  "]");
717  return;
718  };
720  QMap<QString, SgParameter*> *m=xAllByName_;
721  if (p->getPMode() == SgParameterCfg::PM_STC)
722  {
723  l = listP_;
724  m = pByName_;
725  }
726  else if (p->getPMode() == SgParameterCfg::PM_ARC)
727  {
728  l = listA_;
729  m = aByName_;
730  }
731  else if (p->getPMode() == SgParameterCfg::PM_PWL)
732  {
733  l = listPwl_;
734  m = pwlParByName_;
735  }
736  if (isSpecial)
738  l->append(p);
739  m->insert(p->getName(), p);
740 };
741 
742 
743 
744 //
746 {
747  if (!l)
748  {
750  ": addParametersList(): the parameters list is NULL");
751  return;
752  };
753  for (int i=0; i<l->size(); i++)
754  {
755  SgParameter* p=l->at(i);
756  addParameter(p, isSpecial);
757  };
758 };
759 
760 
761 
762 //
764 {
765  if (!p)
766  {
768  ": removeParameter(): the parameter is NULL");
769  return;
770  };
771  if (!xAllByName_->contains(p->getName()) && p->getPMode() == SgParameterCfg::PM_LOC)
772  {
774  ": removeParameter(): the parameter [" + p->getName() +
775  "] is not in the regular parameters map");
776  return;
777  };
778  if (!pByName_->contains(p->getName()) && p->getPMode() == SgParameterCfg::PM_STC)
779  {
781  ": removeParameter(): the parameter [" + p->getName() +
782  "] is not in the stochastic parameters map");
783  return;
784  };
785  if (!aByName_->contains(p->getName()) && p->getPMode() == SgParameterCfg::PM_ARC)
786  {
788  ": removeParameter(): the parameter [" + p->getName() +
789  "] is not in the arc parameters map");
790  return;
791  };
792  if (pwlParByName_->contains(p->getName()) && p->getPMode() == SgParameterCfg::PM_PWL)
793  {
795  ": removeParameter(): the parameter [" + p->getName() +
796  "] is not in the PWL parameters map");
797  return;
798  };
799  if (nZ_) // we will fix it latter too
800  {
802  ": removeParameter(): nZ_!=0; the parameter [" + p->getName() +
803  "]");
804  return;
805  };
807  QMap<QString, SgParameter*> *m=xAllByName_;
808  if (p->getPMode() == SgParameterCfg::PM_STC)
809  {
810  l = listP_;
811  m = pByName_;
812  }
813  else if (p->getPMode() == SgParameterCfg::PM_ARC)
814  {
815  l = listA_;
816  m = aByName_;
817  }
818  else if (p->getPMode() == SgParameterCfg::PM_PWL)
819  {
820  l = listPwl_;
821  m = pwlParByName_;
822  };
823  int idx=0;
824  while (p->getName() != l->at(idx)->getName())
825  idx++;
826  if (idx<l->size())
827  {
828  l->removeAt(idx);
829  m->remove(p->getName());
830  }
831  else
832  {
834  ": removeParameter(): the parameter [" + p->getName() +
835  "] is not in the parameters list");
836  return;
837  };
838 };
839 
840 
841 
842 //
844 {
845  if (!l)
846  {
848  ": removeParametersList(): the parameters list is NULL");
849  return;
850  };
851  for (int i=0; i<l->size(); i++)
852  {
853  SgParameter* p=l->at(i);
854  removeParameter(p);
855  };
856 };
857 
858 
859 
860 //
861 void SgEstimator::prepare2Run(int numOfExpectedObs,
862  const SgMJD& tFirst, const SgMJD& tLast, const SgMJD& tRefer)
863 {
864  //
865  // check consistency:
866  if (listXAll_->size() != xAllByName_->size())
868  ": prepare2Run(): size of the regular parameters list and its dictionary mismatch");
869  if (listP_->size() != pByName_->size())
871  ": prepare2Run(): size of the stochastic parameters list and its dictionary mismatch");
872  if (listA_->size() != aByName_->size())
874  ": prepare2Run(): size of the arc parameters list and its dictionary mismatch");
875  if (listPwl_->size() != pwlParByName_->size())
877  ": prepare2Run(): size of the PWL parameters list and its dictionary mismatch");
878  //
879  deployArcParameters(tFirst, tLast, tRefer);
880  //
881  deployPwlParameters(tFirst, tLast, tRefer);
883  ": prepare2Run(): the size of the XAll parameters list is " + QString().setNum(listXAll_->size()));
884  //
885  // at this point we assume that parmaters lists are defined and fixed.
887  for (int i=0; i<listXAll_->size(); i++)
888  {
889  SgParameter *p=listXAll_->at(i);
890  p->setIdx(i);
892  if (p->getTLeft() <= tZero)
893  listX_->append(p);
894  if (p->getTRight()<tNextRight_)
895  tNextRight_ = p->getTRight();
896  if (p->getTLeft()!=tZero && (tNextLeft_==tZero || p->getTLeft()<tNextLeft_))
897  tNextLeft_ = p->getTLeft();
898  };
899 
900  // sort the lists:
901  qSort(listX_->begin(), listX_->end(), lessThan4_ParameterByTRightSortingOrder);
902  qSort(listP_->begin(), listP_->end(), lessThan4_ParameterByNameSortingOrder);
903  qSort(listA_->begin(), listA_->end(), lessThan4_ParameterByNameSortingOrder);
905  //
906  //
907  // regular parameters:
908  nX_ = listX_->size();
909  Rx_ = new SgUtMatrix(nX_);
910  zx_ = new SgVector(nX_);
911  for (unsigned int i=0; i<nX_; i++)
912  {
913  Rx_->setElement(i,i, 1.0/listX_->at(i)->getSigmaAPriori());
914 /*
915  std::cout << qPrintable(listX_->at(i)->getName()) << " ("
916  << qPrintable(SgParameterCfg::mode2String(listX_->at(i)->getPMode())) << "): "
917  << listX_->at(i)->getSigmaAPriori()*listX_->at(i)->getScale() << "\n";
918 */
919  };
920  rpStack_.clear();
921  PxAll_ = new SgSymMatrix(listXAll_->size());
922  //
923  //
924  // stochastic parameters:
925  nP_ = listP_->size();
926  Rp_ = new SgUtMatrix(nP_);
927  Rpx_= new SgMatrix(nP_, nX_);
928  zp_ = new SgVector(nP_);
929  for (unsigned int i=0; i<nP_; i++)
930  Rp_->setElement(i,i, 1.0/listP_->at(i)->getSigmaAPriori());
932  //
933  // 4smoothing:
934  Rp_s_ = new SgUtMatrix(nP_);
935  Rpp_s_= new SgMatrix(nP_, nP_);
936  Rpx_s_= new SgMatrix(nP_, nX_);
937  SR_ = new SgMatrix(2*nP_, 2*nP_ + nX_ + 1);
938  zp_s_ = new SgVector(nP_);
939  scStack_.clear();
940  for (QMap<QString, StochasticSolutionCarrier>::iterator it=stcSolutions_.begin();
941  it!=stcSolutions_.end(); ++it)
942  {
943  StochasticSolutionCarrier &stcSol=it.value();
944  for (int i=0; i<stcSol.list_->size(); i++)
945  delete stcSol.list_->at(i);
946  delete stcSol.list_;
947  delete stcSol.x_;
948  delete stcSol.P_;
949  stcSol.x_ = NULL;
950  stcSol.P_ = NULL;
951  };
952  stcSolutions_.clear();
953 // regSolutions_.clear();
954  //
955  //
956  // data:
957  nZ_ = numOfExpectedObs + 16; // ok, "16" here are reserved for constrains
958  z_ = new SgVector(nZ_);
959  Ap_ = new SgMatrix(nZ_, nP_);
960  Ax_ = new SgMatrix(nZ_, nX_);
961  u_ = new SgVector(nZ_ + 1);
962  //
963  // threads: Proc01:
964  u4pth_= new SgMatrix(nZ_ + 1, numOfThreads_);
965  //
966  /* init threads: */
967  // proc #1:
968  th4Prc_01_ = (pthread_t*) calloc(numOfThreads_, sizeof(pthread_t));
969  args4Prc_01_ = (struct arg4Prc_01*) calloc(numOfThreads_, sizeof(struct arg4Prc_01));
970  for (int thIdx=0; thIdx<numOfThreads_; thIdx++)
971  {
972  (args4Prc_01_+thIdx)->thread_ = thIdx;
973  (args4Prc_01_+thIdx)->pZ_ = z_->base();
974  (args4Prc_01_+thIdx)->pU_ = *(u4pth_->base() + thIdx);
976  };
977  // proc #2:
978  th4Prc_02_ = (pthread_t*) calloc(numOfThreads_, sizeof(pthread_t));
979  args4Prc_02_ = (struct arg4Prc_02*) calloc(numOfThreads_, sizeof(struct arg4Prc_02));
980  for (int thIdx=0; thIdx<numOfThreads_; thIdx++)
981  {
982  (args4Prc_02_+thIdx)->thread_ = thIdx;
983  (args4Prc_02_+thIdx)->pZ_ = z_->base();
984  (args4Prc_02_+thIdx)->pU_ = *(u4pth_->base() + thIdx);
986  };
987  //
988  // tmp:
989  time4DataUpdate_ = 0.0;
990  time4PropagateStc_ = 0.0;
991  time4SaveStc_ = 0.0;
992  time4ProcObs_ = 0.0;
993 
994 
995  //
996  //
997  nZ_ = 0; // from here nZ_ is a count of processed observations
998  numOfProcessedObs_ = 0;
999  maxConditionNumber_ = 0.0;
1000 };
1001 
1002 
1003 
1004 //
1005 void SgEstimator::processObs(const SgMJD& t, const SgVector& o_c, const SgVector& sigma)
1006 {
1007  QString str;
1008  unsigned int i;
1009  SgPartial *d=NULL;
1010 
1012 
1013  // is it a new epoch?
1015  {
1017  if (0 < numOfThreads_)
1018  dataUpdate_th();
1019  else
1020  dataUpdate();
1022 time4DataUpdate_ += (tWall_ - tWall0_)*86400.0;
1023 
1024 tWall0_ = tWall_;
1025  if (0 < numOfThreads_)
1027  else
1030 time4PropagateStc_ += (tWall_ - tWall0_)*86400.0;
1031 
1032 tWall0_ = tWall_;
1035 time4SaveStc_ += (tWall_ - tWall0_)*86400.0;
1036 tWall0_ = tWall_;
1037 
1038  for (i=0; i<nP_; i++)
1039  listP_->at(i)->resetStatistics();
1040 
1041  };
1042  // check for finished parameters:
1043  if (tNextRight_ <= t)
1044  {
1045 /*----
1046  for (i=0; i<nX_; i++)
1047  {
1048  SgParameter *p=listX_->at(i);
1049  if (p->isAttr(SgPartial::Attr_IS_SPECIAL) && p->getNumObs())
1050  {
1051  Ax_->setElement(nZ_,i, 1.0/p->getSigmaAPrioriAux());
1052  z_->setElement (nZ_, 0.0);
1053  nZ_++;
1054 // std::cout << " Constrained: " << qPrintable(p->getName()) << " ("
1055 // << qPrintable(SgParameterCfg::mode2String(p->getPMode())) << "): "
1056 // << p->getSigmaAPriori()*p->getScale() << ", aux= "
1057 // << p->getSigmaAPrioriAux()*p->getScale() << ", num= "
1058 // << p->getNumObs()
1059 // << "\n";
1060  };
1061  };
1062 ----*/
1063  if (nZ_)
1064  {
1066  if (0 < numOfThreads_)
1067  dataUpdate_th();
1068  else
1069  dataUpdate();
1071 time4DataUpdate_ += (tWall_ - tWall0_)*86400.0;
1072  };
1074  };
1075  // check for new parameters:
1076  if (tZero<tNextLeft_ && tNextLeft_<=t)
1077  {
1078  if (nZ_)
1079  {
1080 
1082  if (0 < numOfThreads_)
1083  dataUpdate_th();
1084  else
1085  dataUpdate();
1087 time4DataUpdate_ += (tWall_ - tWall0_)*86400.0;
1088 
1089  };
1091  };
1092  //
1093  // ---- fill the nZ_'th row of the information array:
1094  //
1095  // first, update partials of arc and PWL parameters:
1098  //
1099  // fill local parameters:
1100  for (i=0; i<nX_; i++)
1101  {
1102  d = listX_->at(i);
1103  Ax_->setElement(nZ_, i, d->getD()/sigma.getElement(0));
1104  d->updateStatistics(t, 1.0/sigma.getElement(0)/sigma.getElement(0));
1105  d->zerofy();
1106  };
1107  //
1108  //
1109  for (int ii=0; ii<listA_->size(); ii++)
1110  listA_->at(ii)->zerofy();
1111  for (int ii=0; ii<listPwl_->size(); ii++)
1112  listPwl_->at(ii)->zerofy();
1113  //
1114  //
1115  // fill stochastic parameters:
1116  for (i=0; i<nP_; i++)
1117  {
1118  d = listP_->at(i);
1119  Ap_->setElement(nZ_, i, d->getD()/sigma.getElement(0));
1120  d->updateStatistics(t, 1.0/sigma.getElement(0)/sigma.getElement(0));
1121  d->zerofy();
1122  };
1123  //
1124  // vector Z:
1125  z_->setElement(nZ_, o_c.getElement(0)/sigma.getElement(0));
1126  nZ_++;
1128  // ---- end of filling
1129  tLastProcessed_ = t;
1130 
1131 
1134 };
1135 
1136 
1137 
1138 //
1139 void SgEstimator::processConstraint(double o_c, double sigma)
1140 {
1141  unsigned int i;
1142  SgPartial *d=NULL;
1143  //
1144  // local parameters:
1146  for (i=0; i<nX_; i++)
1147  {
1148  d = listX_->at(i);
1149  Ax_->setElement(nZ_,i, d->getD()/sigma);
1150  d->zerofy();
1151  };
1152  for (int ii=0; ii<listA_->size(); ii++)
1153  listA_->at(ii)->zerofy();
1154  for (int ii=0; ii<listPwl_->size(); ii++)
1155  listPwl_->at(ii)->zerofy();
1156  //
1157  // stochastic parameters:
1158  for (i=0; i<nP_; i++)
1159  {
1160  d = listP_->at(i);
1161  Ap_->setElement(nZ_,i, d->getD()/sigma);
1162  d->zerofy();
1163  };
1164  // vector Z:
1165  z_->setElement(nZ_, o_c/sigma);
1166  nZ_++;
1167 
1169  if (0 < numOfThreads_)
1170  dataUpdate_th();
1171  else
1172  dataUpdate();
1174 time4DataUpdate_ += (tWall_ - tWall0_)*86400.0;
1175 };
1176 
1177 
1178 
1179 //
1181 {
1182 #ifdef LOCDEB
1183  std::cout << "\n\n++++++ Saving processed parameters at epoch: "
1184  << qPrintable(t.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1185  << ", Obs Idx " << numOfProcessedObs_ << "\n tNextLeft: "
1187  << "; tNextRight: " << qPrintable(tNextRight_.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1188  << "\n";
1189 #endif
1190  RPCarrier carrier;
1191  SgMJD tL(tInf), tR(tZero);
1192  int mRow, mCol;
1193  SgParameter *p;
1194  SgVector *z, *zx_New;
1195  SgUtMatrix *R, *Rx_New;
1196  SgMatrix *Rxx;
1197  // fill the list of parameters that will be stored:
1201  tNextRight_ = tInf;
1202  //
1203  for (int i=0; i<listX_->size(); i++)
1204  {
1205  p=listX_->at(i);
1206  if (p->getTRight() <= t)
1207  {
1208  l->append(new SgParameter(*p));
1209  if (p->getTLeft() < tL)
1210  tL = p->getTLeft();
1211  if (tR < p->getTRight())
1212  tR = p->getTRight();
1213  }
1214  else
1215  {
1216  aux->append(new SgParameter(*p));
1217  r->append(p);
1218  if (p->getTRight() < tNextRight_)
1219  tNextRight_ = p->getTRight();
1220  };
1221  };
1222  //
1223  // copy the vector and the matrices:
1224  mRow = l->size();
1225  mCol = listX_->size() - mRow;
1226 #ifdef LOCDEB
1227  std::cout << "new tNextRight: " << qPrintable(tNextRight_.toString()) << "\n";
1228  std::cout << "saving processed parameters : splitted: " << mRow << " by " << mCol << "\n";
1229 #endif
1230  z = new SgVector(mRow);
1231  R = new SgUtMatrix(mRow);
1232  Rxx = new SgMatrix(mRow, mCol);
1233  // that what is rest:
1234  zx_New = new SgVector(mCol);
1235  Rx_New = new SgUtMatrix(mCol);
1236  // copy the data to save:
1237  for (int i=0; i<mRow; i++)
1238  {
1239  z->setElement(i, zx_->getElement(i));
1240  for (int j=i; j<mRow; j++)
1241  R->setElement(i,j, Rx_->getElement(i,j));
1242  for (int j=0; j<mCol; j++)
1243  Rxx->setElement(i,j, Rx_->getElement(i, mRow+j));
1244  };
1245  // copy the data to continue with:
1246  for (int i=0; i<mCol; i++)
1247  {
1248  zx_New->setElement(i, zx_->getElement(mRow+i));
1249  for (int j=i; j<mCol; j++)
1250  Rx_New->setElement(i,j, Rx_->getElement(mRow+i, mRow+j));
1251  };
1252  // fill carrier's fields:
1253  carrier.tLeft_ = tL;
1254  carrier.tRight_ = tR;
1255  carrier.list_ = l;
1256  carrier.listOthers_ = aux;
1257  carrier.zx_ = z;
1258  carrier.Rx_ = R;
1259  carrier.Rxx_ = Rxx;
1260 #ifdef LOCDEB
1261  QString str;
1262  std::cout << "\n";
1263  for (int i=0; i<listX_->size(); i++)
1264  {
1265  SgParameter *p=listX_->at(i);
1266  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1267  std::cout << " X(before saving): " << qPrintable(str)
1268  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1269  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1270  << "\n";
1271  };
1272  std::cout << "matrix before:\n" << *Rx_ << "\n";
1273  for (int i=0; i<l->size(); i++)
1274  {
1275  SgParameter *p=l->at(i);
1276  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1277  std::cout << " X(l): " << qPrintable(str)
1278  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1279  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1280  << "\n";
1281  };
1282  std::cout << " __saved: Rx_:\n" << *carrier.Rx_ << "\n";
1283  std::cout << " __saved: Rxx_:\n" << *carrier.Rxx_ << "\n";
1284  std::cout << " __saved: zx_:\n" << *carrier.zx_ << "\n";
1285 #endif
1286  // and push it into the stack:
1287  rpStack_.push(carrier);
1288 #ifdef LOCDEB
1289  std::cout << " pushed epoch: " << qPrintable(carrier.tRight_.toString()) << "\n";
1290 #endif
1291  // reset the main list and its info.array:
1292  listX_->clear();
1293  delete listX_;
1294  delete zx_;
1295  delete Rx_;
1296  zx_ = zx_New;
1297  Rx_ = Rx_New;
1298  listX_ = r;
1299  nX_ = listX_->size();
1300  delete Ax_;
1301  Ax_ = new SgMatrix(z_->n(), nX_);
1302 #ifdef LOCDEB
1303  std::cout << "\n";
1304  for (int i=0; i<listX_->size(); i++)
1305  {
1306  SgParameter *p=listX_->at(i);
1307  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1308  std::cout << " X(after saving): " << qPrintable(str)
1309  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1310  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1311  << "\n";
1312  };
1313  std::cout << "matrix after:\n" << *Rx_ << "\n";
1314 #endif
1315 };
1316 
1317 
1318 
1319 //
1321 {
1322 #ifdef LOCDEB
1323  QString str;
1324  std::cout << "\n\n++++++ Inserting new parameters at epoch: "
1325  << qPrintable(t.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1326  << ", Obs Idx " << numOfProcessedObs_ << "\n tNextLeft: "
1328  << "; tNextRight: " << qPrintable(tNextRight_.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1329  << "\n";
1330 #endif
1331  SgUtMatrix *Rx_New;
1332  SgVector *zx_New;
1333  SgParameter *p;
1334  int idx, n;
1336  //spec. case:
1337  if (listX_->size()==0)
1338  tNextRight_ = tInf;
1339  // form new X-list:
1340  for (idx=0; idx<listXAll_->size(); idx++)
1341  {
1342  p = listXAll_->at(idx);
1343  if (p->getTLeft()<=t && t<p->getTRight())
1344  {
1345  l->append(p);
1346  if (p->getTRight() < tNextRight_)
1347  tNextRight_ = p->getTRight();
1348  if (idx+1 < listXAll_->size())
1349  tNextLeft_ = listXAll_->at(idx+1)->getTLeft();
1350  else if (idx+1 == listXAll_->size())
1351  tNextLeft_ = tZero;
1352  };
1353  };
1354  // sort it in tRight-order:
1355  qSort(l->begin(), l->end(), lessThan4_ParameterByTRightSortingOrder);
1356  n = l->size();
1357 #ifdef LOCDEB
1358  std::cout << "\n";
1359  for (int i=0; i<listX_->size(); i++)
1360  {
1361  SgParameter *p=listX_->at(i);
1362  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1363  std::cout << " list X_: " << qPrintable(str)
1364  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1365  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1366  << "\n";
1367  };
1368  std::cout << "\n";
1369  for (int i=0; i<n; i++)
1370  {
1371  SgParameter *p=l->at(i);
1372  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1373  std::cout << " list l: " << qPrintable(str)
1374  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1375  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1376  << "\n";
1377  };
1378  std::cout << " l size: " << n
1379  << ", new nextTLeft: " << qPrintable(tNextLeft_.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1380  << ", new nextTRight: " << qPrintable(tNextRight_.toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1381  << "\n";
1382 #endif
1383  Rx_New = new SgUtMatrix(n);
1384  zx_New = new SgVector(n);
1385  // create reference indexes:
1386  int *idxs=new int[nX_];
1387  QMap<QString, int> idxByName;
1388  for (int i=0; i<n; i++)
1389  {
1390  idxByName.insert(l->at(i)->getName(), i);
1391  Rx_New->setElement(i,i, 1.0/l->at(i)->getSigmaAPriori());
1392  };
1393  for (unsigned int i=0; i<nX_; i++)
1394  {
1395  if (idxByName.contains(listX_->at(i)->getName()))
1396  {
1397  idx = idxByName.find(listX_->at(i)->getName()).value();
1398  *(idxs+i) = idx;
1399  }
1400  else std::cout << "cannot find " << qPrintable(listX_->at(i)->getName()) << "\n";
1401  };
1402  // fill the matrices and vectors:
1403  for (unsigned int i=0; i<nX_; i++)
1404  {
1405  zx_New->setElement(*(idxs+i), zx_->getElement(i));
1406  for (unsigned int j=i; j<nX_; j++)
1407  Rx_New->setElement(*(idxs+i),*(idxs+j), Rx_->getElement(i,j));
1408  };
1409 #ifdef LOCDEB
1410  std::cout << "\n";
1411  for (int i=0; i<listX_->size(); i++)
1412  {
1413  SgParameter *p=listX_->at(i);
1414  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1415  std::cout << " X(before inserting): " << qPrintable(str)
1416  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1417  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1418  << "\n";
1419  };
1420  std::cout << "matrix before:\n" << *Rx_ << "\n";
1421 #endif
1422  // reset the main list and its info.array:
1423  listX_->clear();
1424  delete[] idxs;
1425  delete listX_;
1426  delete zx_;
1427  delete Rx_;
1428  zx_ = zx_New;
1429  Rx_ = Rx_New;
1430  listX_ = l;
1431  nX_ = listX_->size();
1432  delete Ax_;
1433  Ax_ = new SgMatrix(z_->n(), nX_);
1434 #ifdef LOCDEB
1435  std::cout << "\n";
1436  for (int i=0; i<listX_->size(); i++)
1437  {
1438  SgParameter *p=listX_->at(i);
1439  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1440  std::cout << " X(after inserting): " << qPrintable(str)
1441  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1442  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1443  << "\n";
1444  };
1445  std::cout << "matrix after:\n" << *Rx_ << "\n";
1446 #endif
1447 };
1448 
1449 
1450 
1451 //
1453 {
1454  double fNormOfR, fNormOfInv, k_F;
1455  int n;
1456  fNormOfR = fNormOfInv = 0.0;
1457  n = R.n();
1458  // calculate Frobenius norm for the upper triangular matrix and its inverse matrix:
1459  for (int i=0; i<n; i++)
1460  for (int j=i; j<n; j++)
1461  {
1462  fNormOfR += R. getElement(i, j)*R. getElement(i, j);
1463  fNormOfInv+= RInv.getElement(i, j)*RInv.getElement(i, j);
1464  };
1465  fNormOfR = sqrt(fNormOfR);
1466  fNormOfInv= sqrt(fNormOfInv);
1467  k_F = fNormOfR*fNormOfInv;
1469  ": calcConditionNumber(): condition number: " + QString("").sprintf("k_F=%.6e with n=%d", k_F, n));
1470  if (k_F > maxConditionNumber_)
1471  maxConditionNumber_ = k_F;
1472 
1473 };
1474 
1475 
1476 
1477 //
1479 {
1480 SgMJD tWall4finisRun0=SgMJD::currentMJD();
1481 SgMJD tWall4finisRun;
1482 
1483 
1485  if (0 < numOfThreads_)
1486  dataUpdate_th();
1487  else
1488  dataUpdate();
1490 time4DataUpdate_ += (tWall_ - tWall0_)*86400.0;
1491 
1492 
1493 
1494  // backward run:
1495  // solve:
1496  RPCarrier carrier;
1497  SgUtMatrix *RxInv=new SgUtMatrix(nX_);
1498  x_ = new SgVector(nX_);
1499  Px_ = new SgSymMatrix(nX_);
1500 #ifdef LOCDEB
1501  std::cout << "nX_= " << nX_ << ", rpStack_.size()=" << rpStack_.size() << "\n";
1502 #endif
1503  if (nX_ || rpStack_.size())
1504  {
1505 #ifdef LOCDEB
1506  std::cout << " === main sequence: Rx_:\n" << *Rx_ << "\n";
1507  std::cout << " === main sequence: zx_:\n" << *zx_ << "\n\n";
1508 #endif
1509  // solve the parameters:
1510  // Rx * x = zx
1511  solveEquation(*Rx_, *x_, *zx_);
1512  *RxInv = ~*Rx_;
1513  calcConditionNumber(*Rx_, *RxInv);
1514  calculateRRT(*Px_, *RxInv);
1519  // get proper tLeft:
1520  SgMJD tL(tInf);
1521  for (int i=0; i<listX_->size(); i++)
1522  if (listX_->at(i)->getTLeft() < tL)
1523  tL = listX_->at(i)->getTLeft();
1524  if (rpStack_.size())
1525  {
1526 #ifdef LOCDEB
1527  std::cout << "solving x, arc's stack size is: " << rpStack_.size() << "\n";
1528 #endif
1529  while (!rpStack_.isEmpty())
1530  {
1531  carrier = rpStack_.pop();
1532 #ifdef LOCDEB
1533  std::cout << " popped epoch: " << qPrintable(carrier.tRight_.toString()) << "\n";
1534 #endif
1535  SgVector *zxi = carrier.zx_;
1536  SgUtMatrix *Rxi = carrier.Rx_;
1537  SgMatrix *Rxxi= carrier.Rxx_;
1538  QList<SgParameter*> *l = carrier.list_;
1539  QList<SgParameter*> *r = carrier.listOthers_;
1540  SgMJD tL = carrier.tLeft_;
1541  SgMJD tR = carrier.tRight_;
1542  // "dependent" parameters (solved before):
1543 #ifdef LOCDEB
1544  std::cout << " r->size(): " << r->size() << "\n";
1545 #endif
1546  SgVector *xd = new SgVector(r->size());
1547  SgSymMatrix *Pd = new SgSymMatrix(r->size());
1548 #ifdef LOCDEB
1549  std::cout << " l->size(): " << l->size() << "\n";
1550 #endif
1551  if (l->size())
1552  {
1553 #ifdef LOCDEB
1554  QString str;
1555  std::cout << "Processing batch for tR: " << qPrintable(tR.toString()) << "\n";
1556  for (int i=0; i<l->size(); i++)
1557  {
1558  std::cout << "i=" << i << "\n";
1559  SgParameter *p=l->at(i);
1560  str.sprintf(": [%2d] %s ", i, qPrintable(p->getName()));
1561  std::cout << " l-list: " << qPrintable(str)
1562  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1563  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1564  << "\n";
1565  };
1566 
1567  std::cout << " __restored: Rx_:\n" << *carrier.Rx_ << "\n";
1568  std::cout << " __restored: Rxx_:\n" << *carrier.Rxx_ << "\n";
1569  std::cout << " __restored: zx_:\n" << *carrier.zx_ << "\n\n";
1570 #endif
1571  if (r->size())
1572  collectDependentInfArray(carrier, xd, Pd);
1573  nX_ = l->size();
1574  // free previously allocated memory:
1575  if (RxInv)
1576  delete RxInv;
1577  if (x_)
1578  delete x_;
1579  if (Px_)
1580  delete Px_;
1581  RxInv = new SgUtMatrix(nX_);
1582  x_ = new SgVector(nX_);
1583  Px_ = new SgSymMatrix(nX_);
1584  solveEquation(*Rxi, *x_, *zxi - *Rxxi**xd);
1585  *RxInv = ~*Rxi;
1586  calcConditionNumber(*Rxi, *RxInv);
1587  calculateRRT(*Px_, *RxInv);
1588  *Px_ += calcQForm(calcQForm(*Pd, *Rxxi), *RxInv);
1589  calcPwlTraces(l, *Px_);
1591  SgMatrix *Pxx = new SgMatrix(l->size(), r->size());
1592  *Pxx = -calcProduct_mat_x_mat(calcProduct_mat_x_mat(*RxInv, *Rxxi), *Pd);
1593  submittSolution2GlobalStore(Px_, l, Pxx, r);
1594 #ifdef LOCDEB
1595  std::cout << "\n";
1596  std::cout << " The list of l-parameters:\n";
1597  for (int i=0; i<l->size(); i++)
1598  {
1599  SgParameter *p=l->at(i);
1600  std::cout << " l-list: "
1601  << qPrintable(QString().sprintf(": [%2d] %s ", i, qPrintable(p->getName())))
1602  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1603  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1604  << "\n";
1605  };
1606  std::cout << " The list of r-parameters:\n";
1607  for (int i=0; i<r->size(); i++)
1608  {
1609  SgParameter *p=r->at(i);
1610  std::cout << " r-list: "
1611  << qPrintable(QString().sprintf(": [%2d] %s ", i, qPrintable(p->getName())))
1612  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1613  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1614  << "\n";
1615  };
1616  std::cout << "\n";
1617  std::cout << " RxInv:\n" << *RxInv << "\n";
1618  std::cout << "\n";
1619  std::cout << " Rxxi:\n" << *Rxxi << "\n";
1620  std::cout << "\n";
1621  std::cout << " RxInv*Rxxi:\n" << calcProduct_mat_x_mat(*RxInv, *Rxxi) << "\n";
1622  std::cout << "\n";
1623  std::cout << " Pd:\n" << *Pd << "\n";
1624  std::cout << "\n";
1625  std::cout << " Pxx:\n" << *Pxx << "\n";
1626  std::cout << "\n";
1627 #endif
1628  delete Pxx;
1629  reportParameterList(*l);
1630  };
1631  delete xd;
1632  delete Pd;
1633  //
1634  while (!carrier.list_->isEmpty())
1635  delete carrier.list_->takeFirst();
1636  delete carrier.list_;
1637  carrier.list_ = NULL;
1638  //
1639  while (!carrier.listOthers_->isEmpty())
1640  delete carrier.listOthers_->takeFirst();
1641  delete carrier.listOthers_;
1642  carrier.listOthers_ = NULL;
1643  //
1644  delete carrier.zx_;
1645  carrier.zx_ = NULL;
1646  delete carrier.Rx_;
1647  carrier.Rx_ = NULL;
1648  delete carrier.Rxx_;
1649  carrier.Rxx_ = NULL;
1650  };
1651  }
1652  else // solve stc parameters:
1653  {
1656 //printf(" ++ Time for solveStochasticParameters(1) : %8.4f\n", (SgMJD::currentMJD() - tWall0_)*86400.0);
1657  }
1658  }
1659  else // solve stc parameters:
1660  {
1663 //printf(" ++ Time for solveStochasticParameters(2) : %8.4f\n", (SgMJD::currentMJD() - tWall0_)*86400.0);
1664  };
1665 #ifdef LOCDEB
1666  std::cout << "\n";
1667  std::cout << " The list of all parameters:\n";
1668  for (int i=0; i<listXAll_->size(); i++)
1669  {
1670  SgParameter *p=listXAll_->at(i);
1671  std::cout << " XAll-list: "
1672  << qPrintable(QString().sprintf(": [%2d] %s ", i, qPrintable(p->getName())))
1673  << qPrintable(p-> getTLeft().toString(SgMJD::F_YYYYMMDDHHMMSSSS)) << " : "
1674  << qPrintable(p->getTRight().toString(SgMJD::F_YYYYMMDDHHMMSSSS))
1675  << "\n";
1676  };
1677  std::cout << "\n";
1678  std::cout << " Covariance matrix:\n" << *PxAll_ << "\n";
1679  std::cout << "\n";
1680 #endif
1681 
1682  // for threads:
1683  /* free threads: */
1684  free(th4Prc_01_);
1685  free(args4Prc_01_);
1686  free(th4Prc_02_);
1687  free(args4Prc_02_);
1688 
1689  if (u4pth_)
1690  {
1691  delete u4pth_;
1692  u4pth_ = NULL;
1693  };
1694 
1695  //
1696  // tmp:
1697 /*
1698 printf(" ++ Time for dataUpdate: %8.4f\n", time4DataUpdate_);
1699 printf(" ++ Time for propagate : %8.4f\n", time4PropagateStc_);
1700 printf(" ++ Time for savingStc : %8.4f\n", time4SaveStc_);
1701 printf(" ++ Time for processObs: %8.4f\n", time4ProcObs_);
1702 printf(" ++ Time for finishRun : %8.4f\n", (SgMJD::currentMJD() - tWall4finisRun0)*86400.0);
1703 */
1704 
1705 
1706  // freeing allocated memory:
1707  // local:
1708  if (x_)
1709  {
1710  delete x_;
1711  x_ = NULL;
1712  };
1713  if (zx_)
1714  {
1715  delete zx_;
1716  zx_ = NULL;
1717  };
1718  if (Rx_)
1719  {
1720  delete Rx_;
1721  Rx_ = NULL;
1722  };
1723  if (Px_)
1724  {
1725  delete Px_;
1726  Px_ = NULL;
1727  };
1728  if (RxInv)
1729  {
1730  delete RxInv;
1731  RxInv = NULL;
1732  };
1733 };
1734 
1735 
1736 
1737 //
1739 {
1741  SmoothCarrier carrier;
1742  p_ = new SgVector(nP_);
1743  Pp_ = new SgSymMatrix(nP_);
1744  SgUtMatrix *RpInv = new SgUtMatrix(nP_);
1745  if (nP_)
1746  {
1747  QList<SgParameter*> *listP_saved = listP_;
1748 //
1750  for (int i=0; i<listP_saved->size(); i++)
1751  listP_->append(new SgParameter(*listP_saved->at(i)));
1752 //
1753  // solve:
1754  // the last solution, ~ == *, smoothed equal to filtered,
1755  // so, calc filtered estimation (the last in the batch):
1756  // solve the parameters:
1757  // Rp * p = zp - Rpq*q - Rpx*x
1758 
1760 
1761  solveEquation(*Rp_,*p_, *zp_ - *Rpx_**x_);
1762  *RpInv = ~*Rp_;
1763  calculateRRT(*Pp_, *RpInv);
1764  // Pp + Rp^(-1) * (Rpx * Px * Rpx^T) * Rp^(-T)
1765  if (nX_)
1766  *Pp_ += calcQForm(calcQForm(*Px_, *Rpx_), *RpInv);
1767  // there are two small additional terms, should add them too.
1768 
1770  // put the latest solution in the container:
1771  stcSol.epoch_ = tLastProcessed_;
1772  stcSol.list_ = listP_;
1774  reportParameterList(*stcSol.list_);
1775  stcSol.x_ = new SgVector(*p_);
1776  stcSol.P_ = new SgSymMatrix(*Pp_);
1777  stcSolutions_.insert(stcSol.epoch_.toString(SgMJD::F_INTERNAL), stcSol);
1778  //
1779  // we move listP_ to the container stcSolutions_, no needs to delete it
1780  delete zp_s_;
1781  delete Rp_s_;
1782  delete Rpp_s_;
1783  delete Rpx_s_;
1784  // make a backward pass:
1785  SgVector *pPrev = new SgVector(*p_);
1786  SgSymMatrix *PpPrev = new SgSymMatrix(*Pp_);
1787  int stcIdx=0;
1788 
1789 //(" ++ Time for solveStochasticParameters phase 1 : %8.4f\n", (SgMJD::currentMJD() - tWall0_)*86400.0);
1790 
1791 SgMJD tWallLocal0 = SgMJD::currentMJD();
1792 double t4solveEquation=0.0;
1793 double t4inv=0.0;
1794 double tcalculateRRT=0.0;
1795 double tcalcQForm1=0.0;
1796 double tcalcQForm2=0.0;
1797 double trest=0.0;
1798 
1800  while (!scStack_.isEmpty())
1801  {
1802  // pop saved matrices from the stack:
1803  carrier = scStack_.pop();
1804  listP_ = carrier.p_s_;
1805  zp_s_ = carrier.zp_s_;
1806  Rp_s_ = carrier.Rp_s_;
1807  Rpp_s_ = carrier.Rpp_s_;
1808  Rpx_s_ = carrier.Rpx_s_;
1809 
1810  // obtain solution:
1811 tWallLocal0 = SgMJD::currentMJD();
1812  solveEquation(*Rp_s_,*p_, *zp_s_ - *Rpp_s_**pPrev - *Rpx_s_**x_);
1813 t4solveEquation += (SgMJD::currentMJD() - tWallLocal0)*86400.0;
1814  // evaluate covariance matrix:
1815 
1816 tWallLocal0 = SgMJD::currentMJD();
1817  *RpInv = ~*Rp_s_;
1818 t4inv += (SgMJD::currentMJD() - tWallLocal0)*86400.0;
1819 
1820 tWallLocal0 = SgMJD::currentMJD();
1821  // here to add a calculations for covariance matrix:
1822  // Pp = (Rp*)^(-1) * (Rp*)^(-T)
1823  calculateRRT(*Pp_, *RpInv);
1824  // Pp + (Rp*)^(-1) * ((Rpp*) * Pp_prev * (Rpp*)^T) * (Rp*)^(-T)
1825 tcalculateRRT +=(SgMJD::currentMJD() - tWallLocal0)*86400.0;
1826 
1827 tWallLocal0 = SgMJD::currentMJD();
1828  *Pp_ += calcQForm(calcQForm(*PpPrev, *Rpp_s_), *RpInv);
1829  // Pp + (Rp*)^(-1) * ((Rpx*) * Px * (Rpx*)^T) * (Rp*)^(-T)
1830 tcalcQForm1 += (SgMJD::currentMJD() - tWallLocal0)*86400.0;
1831 
1832 tWallLocal0 = SgMJD::currentMJD();
1833  if (nX_)
1834  *Pp_ += calcQForm(calcQForm(*Px_, *Rpx_s_), *RpInv);
1835 tcalcQForm2 += (SgMJD::currentMJD() - tWallLocal0)*86400.0;
1836 tWallLocal0 = SgMJD::currentMJD();
1837  // update list of parameters:
1839  *pPrev = *p_;
1840  *PpPrev = *Pp_;
1841  // and save them in the container:
1842  stcSol.epoch_ = carrier.epoch_;
1843  stcSol.list_ = listP_;
1845  reportParameterList(*stcSol.list_);
1846  stcSol.x_ = new SgVector(*p_);
1847  stcSol.P_ = new SgSymMatrix(*Pp_);
1848  stcSolutions_.insert(stcSol.epoch_.toString(SgMJD::F_INTERNAL), stcSol);
1849 
1850  // delete objects:
1851  delete zp_s_;
1852  delete Rp_s_;
1853  delete Rpp_s_;
1854  delete Rpx_s_;
1855  zp_s_ = NULL;
1856  Rp_s_ = NULL;
1857  Rpp_s_ = NULL;
1858  Rpx_s_ = NULL;
1859  stcIdx++;
1860 trest +=(SgMJD::currentMJD() - tWallLocal0)*86400.0;
1861  };
1862 
1863 /*
1864 printf(" ++ Time for solveStochasticParameters t4solveEquation : %8.4f\n", t4solveEquation);
1865 printf(" ++ Time for solveStochasticParameters t4inv : %8.4f\n", t4inv);
1866 printf(" ++ Time for solveStochasticParameters tcalculateRRT : %8.4f\n", tcalculateRRT);
1867 printf(" ++ Time for solveStochasticParameters tcalcQForm1 : %8.4f\n", tcalcQForm1);
1868 printf(" ++ Time for solveStochasticParameters tcalcQForm2 : %8.4f\n", tcalcQForm2);
1869 printf(" ++ Time for solveStochasticParameters trest : %8.4f\n", trest);
1870 //printf(" ++ Time for solveStochasticParameters t4solveEquation : %8.4f\n", t4solveEquation);
1871 
1872 printf(" ++ Time for solveStochasticParameters phase 2 : %8.4f\n", (SgMJD::currentMJD() - tWall0_)*86400.0);
1873 */
1874 
1876  // restore the pointer:
1877  listP_ = listP_saved;
1878 // -> listP_ = taskMgr_->stochasticParameters();
1879  if (PpPrev)
1880  {
1881  delete PpPrev;
1882  PpPrev = NULL;
1883  };
1884  if (pPrev)
1885  {
1886  delete pPrev;
1887  pPrev = NULL;
1888  };
1889  };
1890  // freeing allocated memory:
1891  // stochastics:
1892  if (p_)
1893  {
1894  delete p_;
1895  p_ = NULL;
1896  };
1897  if (zp_)
1898  {
1899  delete zp_;
1900  zp_ = NULL;
1901  };
1902  if (Rp_)
1903  {
1904  delete Rp_;
1905  Rp_ = NULL;
1906  };
1907  if (Rpx_)
1908  {
1909  delete Rpx_;
1910  Rpx_ = NULL;
1911  };
1912  if (SR_)
1913  {
1914  delete SR_;
1915  SR_ = NULL;
1916  };
1917  if (Rp_s_)
1918  {
1919  delete Rp_s_;
1920  Rp_s_ = NULL;
1921  };
1922  if (Rpp_s_)
1923  {
1924  delete Rpp_s_;
1925  Rpp_s_ = NULL;
1926  };
1927  if (Rpx_s_)
1928  {
1929  delete Rpx_s_;
1930  Rpx_s_ = NULL;
1931  };
1932  if (zp_s_)
1933  {
1934  delete zp_s_;
1935  zp_s_ = NULL;
1936  };
1937  if (Pp_)
1938  {
1939  delete Pp_;
1940  Pp_ = NULL;
1941  };
1942  if (RpInv)
1943  {
1944  delete RpInv;
1945  RpInv = NULL;
1946  };
1947 };
1948 
1949 
1950 
1951 //
1953 {
1954  // make a Householder transformation
1955  unsigned int i,j,l;
1956  double s,ul,g;
1957 
1958  // Part one: dealing with the "p" block:
1959  u_->clear(); // U-vector, + ul -- the first elementh of U
1960  for (l=0; l<nP_; l++)
1961  {
1962  s = Rp_->getElement(l,l)*Rp_->getElement(l,l);
1963  for (i=0; i<nZ_; i++)
1964  s += Ap_->getElement(i,l)*Ap_->getElement(i,l);
1965  if (s>0.0)
1966  {
1967  s = -signum(Rp_->getElement(l,l))*sqrt(s);
1968  ul = Rp_->getElement(l,l) - s; // U_l
1969  for (i=0; i<nZ_; i++)
1970  u_->setElement(i, Ap_->getElement(i,l)); // U_i (i=l+1, N)
1971  Rp_->setElement(l,l, s);
1972  s = 1.0/(s*ul); // betta
1973  for (j=l+1; j<nP_; j++) // |<-- processing "Rp/Ap"-block
1974  { // |
1975  g = ul*Rp_->getElement(l,j); // |
1976  for (i=0; i<nZ_; i++) // |
1977  g += u_->getElement(i)*Ap_->getElement(i,j); // |
1978  (*Rp_)(l,j) += s*g*ul; // |
1979  for (i=0; i<nZ_; i++) // |
1980  (*Ap_)(i,j) += s*g*u_->getElement(i); // |
1981  }; // |_________________________
1982  for (j=0; j<nX_; j++) // |<-- processing "Rpx/Ax"-block
1983  { // |
1984  g = ul*Rpx_->getElement(l,j); // |
1985  for (i=0; i<nZ_; i++) // |
1986  g += u_->getElement(i)*Ax_->getElement(i,j); // |
1987  (*Rpx_)(l,j) += s*g*ul; // |
1988  for (i=0; i<nZ_; i++) // |
1989  (*Ax_)(i,j) += s*g*u_->getElement(i); // |
1990  }; // |_________________________
1991  g = ul*zp_->getElement(l); // |--
1992  for (i=0; i<nZ_; i++) // |
1993  g += u_->getElement(i)*z_->getElement(i); // | dealing with the vectors Zp
1994  (*zp_)(l) += s*g*ul; // | and Z
1995  for (i=0; i<nZ_; i++) // |
1996  (*z_)(i) += s*g*u_->getElement(i); // |--
1997  };
1998  };
1999  //
2000  // Part two: dealing with the "x" block:
2001  u_->clear(); // U-vector, + ul -- the first elementh of U
2002  for (l=0; l<nX_; l++)
2003  {
2004  s = Rx_->getElement(l,l)*Rx_->getElement(l,l);
2005  for (i=0; i<nZ_; i++)
2006  s += Ax_->getElement(i,l)*Ax_->getElement(i,l);
2007  if (s>0.0)
2008  {
2009  s = -signum(Rx_->getElement(l,l))*sqrt(s);
2010  ul = Rx_->getElement(l,l) - s; // U_l
2011  for (i=0; i<nZ_; i++) //
2012  u_->setElement(i, Ax_->getElement(i,l)); // U_i (i=l+1, N)
2013  Rx_->setElement(l,l, s); //
2014  s = 1.0/(s*ul); // betta
2015  for (j=l+1; j<nX_; j++) // |<-- processing "Rx/Ax"-block
2016  { // |
2017  g = ul*Rx_->getElement(l,j); // |
2018  for (i=0; i<nZ_; i++) // |
2019  g += u_->getElement(i)*Ax_->getElement(i,j); // |
2020  (*Rx_)(l,j) += s*g*ul; // |
2021  for (i=0; i<nZ_; i++) // |
2022  (*Ax_)(i,j) += s*g*u_->getElement(i); // |
2023  }; // |_________________________
2024  g = ul*zx_->getElement(l); // |--
2025  for (i=0; i<nZ_; i++) // |
2026  g += u_->getElement(i)*z_->getElement(i); // | dealing with the vectors Zx
2027  (*zx_)(l) += s*g*ul; // | and Z
2028  for (i=0; i<nZ_; i++) // |
2029  (*z_)(i) += s*g*u_->getElement(i); // |--
2030  };
2031  };
2032  nZ_ = 0;
2033 };
2034 
2035 
2036 
2037 
2038 
2039 //
2041 {
2042  unsigned int l;
2043  int thIdx;
2044  int rc;
2045  pthread_mutex_t *m;
2046 
2047 
2048  if (nP_)
2049  {
2050  /* init mutexes: */
2051  pthMutexes4Prc_02_ = (pthread_mutex_t*) calloc(nP_+nX_+1, sizeof(pthread_mutex_t)); // +1 for vector zp/z
2052  for(l=0, m=pthMutexes4Prc_02_; l<nP_+nX_+1; l++, m++)
2053  pthread_mutex_init(m, NULL);
2054  pthread_mutex_init(&pthMutL4Prc_02_, NULL);
2055 
2056  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2057  {
2058  (args4Prc_02_+thIdx)->nP_ = nP_;
2059  (args4Prc_02_+thIdx)->nX_ = nX_;
2060  (args4Prc_02_+thIdx)->nZ_ = nZ_;
2061  (args4Prc_02_+thIdx)->ppRp_ = Rp_->base();
2062  (args4Prc_02_+thIdx)->ppRpx_ = Rpx_->base();
2063  (args4Prc_02_+thIdx)->ppAp_ = Ap_->base();
2064  (args4Prc_02_+thIdx)->ppAx_ = Ax_->base();
2065  (args4Prc_02_+thIdx)->pZp_ = zp_->base();
2068  };
2069  lastPrcColumn4Prc_02_ = -1;
2070  //
2071  // make a Householder transformation
2072  // Part one: dealing with the "p" block:
2073  l = 0;
2074  thIdx = 0;
2075  while (thIdx < numOfThreads_ && l < nP_)
2076  {
2077  rc = pthread_create(th4Prc_02_+thIdx, &pthreadAttr_, thPrc_02, (void *) (args4Prc_02_+thIdx));
2078  if (rc != 0)
2079  printf("create failed %d\n", rc);
2080  thIdx++;
2081  l++;
2082  };
2083  if (l == nP_)
2084  {
2085  for (int k=0; k<thIdx; k++)
2086  {
2087  rc = pthread_join(*(th4Prc_02_+k), NULL);
2088  if (rc != 0)
2089  printf("join failed %d\n", rc);
2090  };
2091  }
2092  else
2093  {
2094  thIdx = 0;
2095  while (l < nP_)
2096  {
2097  rc = pthread_join(*(th4Prc_02_+thIdx), NULL);
2098  if (rc != 0)
2099  printf("join failed %d\n", rc);
2100  rc = pthread_create(th4Prc_02_+thIdx, &pthreadAttr_, thPrc_02, (void *) (args4Prc_02_+thIdx));
2101  if (rc != 0)
2102  printf("create failed %d\n", rc);
2103  thIdx++;
2104  l++;
2105  thIdx %= numOfThreads_;
2106  };
2107  for (int k=0; k<numOfThreads_; k++)
2108  {
2109  rc = pthread_join(*(th4Prc_02_+thIdx), NULL);
2110  if (rc != 0)
2111  printf("join failed %d\n", rc);
2112  thIdx++;
2113  thIdx %= numOfThreads_;
2114  };
2115  };
2116 /*
2117  for (l=0; l<nP_; l+=numOfThreads_)
2118  {
2119  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2120  if (l+thIdx < nP_)
2121  {
2122  rc = pthread_create(th4Prc_02_+thIdx, &pthreadAttr_, thPrc_02, (void *) (args4Prc_02_+thIdx));
2123  if (rc != 0)
2124  printf("create failed %d\n", rc);
2125  };
2126  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2127  if (l+thIdx < nP_)
2128  {
2129  rc = pthread_join(*(th4Prc_02_+thIdx), NULL);
2130  if (rc != 0)
2131  printf("join failed %d\n", rc);
2132  };
2133  };
2134 */
2135  /* free mutexes: */
2136  pthread_mutex_destroy(&pthMutL4Prc_02_);
2137  for(l=0, m=pthMutexes4Prc_02_; l<nP_+nX_+1; l++, m++)
2138  pthread_mutex_destroy(m);
2139  free(pthMutexes4Prc_02_);
2140  };
2141  //
2142  // Part two: dealing with the "x" block:
2143  if (nX_)
2144  {
2145  //
2146  /* init mutexes: */
2147  pthMutexes4Prc_01_ = (pthread_mutex_t*) calloc(nX_ + 1, sizeof(pthread_mutex_t)); // +1 for vector zx/z
2148  for(l=0, m=pthMutexes4Prc_01_; l<nX_+1; l++, m++)
2149  pthread_mutex_init(m, NULL);
2150  pthread_mutex_init(&pthMutL4Prc_01_, NULL);
2151 
2152  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2153  {
2154  (args4Prc_01_+thIdx)->num_ = nX_;
2155  (args4Prc_01_+thIdx)->nZ_ = nZ_;
2156  (args4Prc_01_+thIdx)->ppRx_ = Rx_->base();
2157  (args4Prc_01_+thIdx)->ppAx_ = Ax_->base();
2158  (args4Prc_01_+thIdx)->pZx_ = zx_->base();
2161  };
2162  lastPrcColumn4Prc_01_ = -1;
2163 /*
2164  for (l=0; l<nX_; l+=numOfThreads_)
2165  {
2166  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2167  if (l+thIdx < nX_)
2168  {
2169  rc = pthread_create(th4Prc_01_+thIdx, &pthreadAttr_, thPrc_01, (void *) (args4Prc_01_+thIdx));
2170  if (rc != 0)
2171  printf("create failed %d\n", rc);
2172  };
2173  for (thIdx=0; thIdx<numOfThreads_; thIdx++)
2174  if (l+thIdx < nX_)
2175  {
2176  rc = pthread_join(*(th4Prc_01_+thIdx), NULL);
2177  if (rc != 0)
2178  printf("join failed %d\n", rc);
2179  };
2180  };
2181 */
2182  // this one looks faster:
2183  l = 0;
2184  thIdx = 0;
2185  while (thIdx < numOfThreads_ && l < nX_)
2186  {
2187  rc = pthread_create(th4Prc_01_+thIdx, &pthreadAttr_, thPrc_01, (void *) (args4Prc_01_+thIdx));
2188  if (rc != 0)
2189  printf("create failed %d\n", rc);
2190  thIdx++;
2191  l++;
2192  };
2193  if (l == nX_)
2194  {
2195  for (int k=0; k<thIdx; k++)
2196  {
2197  rc = pthread_join(*(th4Prc_01_+k), NULL);
2198  if (rc != 0)
2199  printf("join failed %d\n", rc);
2200  };
2201  }
2202  else
2203  {
2204  thIdx = 0;
2205  while (l < nX_)
2206  {
2207  rc = pthread_join(*(th4Prc_01_+thIdx), NULL);
2208  if (rc != 0)
2209  printf("join failed %d\n", rc);
2210  rc = pthread_create(th4Prc_01_+thIdx, &pthreadAttr_, thPrc_01, (void *) (args4Prc_01_+thIdx));
2211  if (rc != 0)
2212  printf("create failed %d\n", rc);
2213  thIdx++;
2214  l++;
2215  thIdx %= numOfThreads_;
2216  };
2217  for (int k=0; k<numOfThreads_; k++)
2218  {
2219  rc = pthread_join(*(th4Prc_01_+thIdx), NULL);
2220  if (rc != 0)
2221  printf("join failed %d\n", rc);
2222  thIdx++;
2223  thIdx %= numOfThreads_;
2224  };
2225  };
2226  /* free mutexes: */
2227  pthread_mutex_destroy(&pthMutL4Prc_01_);
2228  for(l=0, m=pthMutexes4Prc_01_; l<nX_+1; l++, m++)
2229  pthread_mutex_destroy(m);
2230  free(pthMutexes4Prc_01_);
2231  // pthreads done
2232  };
2233 
2234  nZ_ = 0;
2235 };
2236 
2237 
2238 
2239 
2240 //
2242 {
2243  // propagate the stochastic parameters from an epoch "T" to a new one "T+dT":
2244  unsigned int i,j,l;
2245  unsigned int n=2*nP_, m=2*nP_+nX_;
2246  double s,g;
2247  SR_->clear();
2248  u_ ->clear();
2249  //
2250  // fill the matrix SR:
2251  for (i=0; i<nP_; i++)
2252  {
2253  SgParameter *p = listP_->at(i);
2254  double mm = p->calcM(dT);
2255  double rwn= p->calcRW(dT);
2256 
2257  SR_->setElement(i, i, -mm*rwn);
2258  SR_->setElement(i, nP_+i, rwn);
2259  SR_->setElement(nP_+i, m, zp_->getElement(i));
2260 
2261  for (j=i; j<nP_; j++)
2262  SR_->setElement(nP_+i, j, Rp_ ->getElement(i, j));
2263  for (j=0; j<nX_; j++)
2264  SR_->setElement(nP_+i, n+j, Rpx_->getElement(i, j));
2265  };
2266  //
2267  // make a Householder transformation
2268  // this should be optimized...
2269  for (l=0; l<n; l++)
2270  {
2271  for (i=l, s=0.0; i<n; i++)
2272  s += SR_->getElement(i,l)*SR_->getElement(i,l);
2273  if (s>0.0)
2274  {
2275  s = -signum(SR_->getElement(l,l))*sqrt(s);
2276  u_->setElement(l, SR_->getElement(l,l) - s); // U_l
2277  for (i=l+1; i<n; i++) //
2278  u_->setElement(i, SR_->getElement(i,l)); // U_i (i=l+1, N)
2279  SR_->setElement(l,l, s); //
2280  s = 1.0/(s*u_->getElement(l)); // betta
2281  for (j=l+1; j<m+1; j++) // |-------------------------
2282  { // |
2283  for (i=l,g=0.0; i<n; i++) // |
2284  g += u_->getElement(i)*SR_->getElement(i,j); // |
2285  for (i=l; i<n; i++) // |
2286  (*SR_)(i,j) += s*g*u_->getElement(i); // |
2287  }; // |_________________________
2288  };
2289  };
2290  //
2291  // fill the matrices for smoothing and filtering:
2292  for (i=0; i<nP_; i++)
2293  {
2294  for (j=i; j<nP_; j++)
2295  {
2296  Rp_s_->setElement(i,j, SR_->getElement( i, j));
2297  Rp_ ->setElement(i,j, SR_->getElement(nP_+i, nP_+j));
2298  };
2299  for (j=0; j<nP_; j++)
2300  Rpp_s_->setElement(i,j, SR_->getElement(i, nP_+j));
2301  for (j=0; j<nX_; j++)
2302  {
2303  Rpx_s_->setElement(i,j, SR_->getElement( i, n+j));
2304  Rpx_ ->setElement(i,j, SR_->getElement(nP_+i, n+j));
2305  };
2306  zp_ ->setElement(i, SR_->getElement(nP_+i, m));
2307  zp_s_->setElement(i, SR_->getElement( i, m));
2308  };
2309 };
2310 
2311 
2312 
2313 
2314 //
2316 {
2317  // propagate the stochastic parameters from an epoch "T" to a new one "T+dT":
2318  unsigned int i,j,l;
2319  unsigned int n=2*nP_, m=2*nP_+nX_;
2320  double s,g;
2321  double mm;
2322  double rwn;
2323 
2324  SR_->clear();
2325  u_ ->clear();
2326  //
2327  double **ppSR = SR_->base();
2328  double **ppRp = Rp_->base();
2329  double **ppRpx = Rpx_->base();
2330  double *pZp = zp_->base();
2331  double *pU = u_->base();
2332  // 4 smoothing:
2333  double **ppRp_s = Rp_s_->base();
2334  double **ppRpp_s = Rpp_s_->base();
2335  double **ppRpx_s = Rpx_s_->base();
2336  double *pZp_s = zp_s_->base();
2337 
2338  double *p, *q;
2339  //
2340  // fill the matrix SR:
2341  for (i=0; i<nP_; i++)
2342  {
2343  SgParameter *p=listP_->at(i);
2344  mm = p->calcM(dT);
2345  rwn = p->calcRW(dT);
2346  SR_->setElement(i, i, -mm*rwn);
2347  SR_->setElement(i, nP_+i, rwn);
2348  };
2349  // vector zp:
2350  memcpy((void*)(*(ppSR+m)+nP_), (void*)(pZp), sizeof(double)*(nP_));
2351  // matrix Rp:
2352  for (j=0; j<nP_; j++)
2353  memcpy((void*)(*(ppSR+j)+nP_), (void*)(*(ppRp+j)), sizeof(double)*(j+1));
2354  // matrix Rpx:
2355  for (j=0; j<nX_; j++)
2356  memcpy((void*)(*(ppSR+n+j)+nP_), (void*)(*(ppRpx+j)), sizeof(double)*(nP_));
2357  //
2358  // make a Householder transformation
2359  // this should be optimized...
2360  for (l=0; l<n; l++)
2361  {
2362  s = 0.0;
2363  p = *(ppSR+l) + l;
2364  for (i=l; i<n; i++, p++)
2365  s += *p**p;
2366  if (s>0.0)
2367  {
2368  s = -signum(*(*(ppSR+l)+l))*sqrt(s);
2369  *(pU+l) = *(*(ppSR+l)+l) - s; // U_l
2370  memcpy((void*)(pU+l+1), (void*)(*(ppSR+l)+l+1), sizeof(double)*(n-l-1)); // U_i (i=l+1, N)
2371  *(*(ppSR+l)+l) = s; //
2372  s = 1.0/(s**(pU+l)); // betta
2373  for (j=l+1; j<m+1; j++) // |---------------------
2374  { // |
2375  g = 0.0; // |
2376  p = pU + l; // |
2377  q = *(ppSR+j) + l; // |
2378  for (i=l; i<n; i++, p++, q++) // |
2379  g += *p**q; // |
2380  p = pU + l; // |
2381  q = *(ppSR+j) + l; // |
2382  for (i=l; i<n; i++, p++, q++) // |
2383  *q += s*g**p; // |
2384  }; // |_____________________
2385  };
2386  };
2387  //
2388  // fill the vectors and matrices for smoothing and filtering:
2389  // vector zp:
2390  memcpy((void*)(pZp), (void*)(*(ppSR+m)+nP_), sizeof(double)*(nP_));
2391  // vector zps:
2392  memcpy((void*)(pZp_s), (void*)(*(ppSR+m) ), sizeof(double)*(nP_));
2393  for (j=0; j<nP_; j++)
2394  {
2395  // matrix Rp:
2396  memcpy((void*)(*(ppRp +j)), (void*)(*(ppSR+nP_+j)+nP_), sizeof(double)*(j+1));
2397  // matrix Rp_s:
2398  memcpy((void*)(*(ppRp_s +j)), (void*)(*(ppSR+j)), sizeof(double)*(j+1));
2399  // matrix Rpp_s:
2400  memcpy((void*)(*(ppRpp_s+j)), (void*)(*(ppSR+nP_+j)), sizeof(double)*(nP_));
2401  };
2402  //
2403  for (j=0; j<nX_; j++)
2404  {
2405  // matrix Rpx:
2406  memcpy((void*)(*(ppRpx+j)), (void*)(*(ppSR+n+j)+nP_), sizeof(double)*(nP_));
2407  // matrix Rpx_s:
2408  memcpy((void*)(*(ppRpx_s+j)), (void*)(*(ppSR+n+j)), sizeof(double)*(nP_));
2409  };
2410 };
2411 
2412 
2413 
2414 
2415 //
2417 {
2418  SmoothCarrier carrier;
2419  // make copies:
2420  carrier.epoch_ = t;
2421  carrier.p_s_ = new QList<SgParameter*>;
2422  for (int i=0; i<listP_->size(); i++)
2423  carrier.p_s_->append(new SgParameter(*listP_->at(i)));
2424  carrier.zp_s_ = new SgVector(*zp_s_);
2425  carrier.Rp_s_ = new SgUtMatrix(*Rp_s_);
2426  carrier.Rpp_s_ = new SgMatrix(*Rpp_s_);
2427  carrier.Rpx_s_ = new SgMatrix(*Rpx_s_);
2428  // and store them:
2429  scStack_.push(carrier);
2430 };
2431 
2432 
2433 
2434 // some estimator-specific calculations:
2435 //
2437 {
2438 #ifdef DEBUG
2439  if (x.n()!=z.n())
2441  ": solveEquation(): incompatible ranges of vectors x and z");
2442  if (R.nRow()!=x.n())
2444  ": solveEquation(): incompatible ranges of vector x and matrix R");
2445 #endif //DEBUG
2446 
2447  unsigned int i, j, n=x.n()-1;
2448  double s;
2449 
2450  if (!x.n())
2451  return x;
2452 
2453  if (R.getElement(n,n) != 0.0)
2454  x(n) = z.getElement(n)/R.getElement(n,n);
2455  else
2457  ": solveEquation(): division by zero caused by R[N,N]=0");
2458  for (i=n; i>0; i--) // i ==> (i+1)
2459  {
2460  for (j=i, s=0.0; j<x.n(); j++)
2461  s += R.getElement(i-1,j)*x(j);
2462  if (R.getElement(i-1,i-1) != 0.0)
2463  x(i-1) = (z.getElement(i-1) - s)/R.getElement(i-1,i-1);
2464  else
2466  ": solveEquation(): division by zero caused by R[j,j]=0");
2467  };
2468  return x;
2469 };
2470 
2471 
2472 
2473 //
2475 {
2476 #ifdef DEBUG
2477  if (M.nRow() != R.nRow())
2479  ": calculateRRT(): incompatible ranges of input matrices");
2480 #endif //DEBUG
2481  // double **m=M.B, **r=R.B;
2482  double v;
2483  unsigned int i, j, l;
2484 
2485  for (i=0; i<M.nRow(); i++)
2486  for (j=i; j<M.nCol(); j++)
2487  {
2488  for (v=0.0, l=j; l<R.nCol(); l++)
2489  v += R.getElement(i,l)*R.getElement(j,l);
2490  M(i,j) = v;
2491  };
2492  return M;
2493 };
2494 
2495 
2496 
2497 /*
2498 //
2499 SgSymMatrix SgEstimator::calcQForm(const SgSymMatrix& P, const SgMatrix& A)
2500 {
2501 #ifdef DEBUG
2502  if (A.nCol() != P.nRow())
2503  logger->write(SgLogger::ERR, SgLogger::MATRIX, className() +
2504  ": calcQForm: incompatible ranges of the matrices");
2505 #endif //DEBUG
2506 
2507  SgSymMatrix S(A.nRow(), false);
2508  SgMatrix T(A.nRow(), A.nCol());
2509  unsigned int i, j, l;
2510  double s;
2511 
2512  for (i=0; i<T.nRow(); i++)
2513  for (j=0; j<T.nCol(); j++)
2514  {
2515  for (l=0, s=0.0; l<A.nCol(); l++)
2516  s += A.getElement(i,l)*P.getElement(l,j);
2517  T(i,j) = s;
2518  };
2519  for (i=0; i<S.nRow(); i++)
2520  for (j=i; j<S.nCol(); j++)
2521  {
2522  for (l=0, s=0.0; l<T.nCol(); l++)
2523  s += T.getElement(i,l)*A.getElement(j,l);
2524  S(i,j) = s;
2525  };
2526  return S;
2527 };
2528 
2529 
2530 
2531 //
2532 SgSymMatrix SgEstimator::calcQForm(const SgSymMatrix& P, const SgUtMatrix& R)
2533 {
2534 #ifdef DEBUG
2535  if (R.nCol()!=P.nRow())
2536  logger->write(SgLogger::ERR, SgLogger::MATRIX, className() +
2537  ": calcQForm: incompatible ranges of the matrices");
2538 #endif //DEBUG
2539 
2540  SgSymMatrix S(R.nRow(), false);
2541  SgMatrix T(R.nRow(), R.nCol());
2542  unsigned int i, j, l;
2543  double s;
2544 
2545  for (i=0; i<T.nRow(); i++)
2546  for (j=0; j<T.nCol(); j++)
2547  {
2548  for (l=i, s=0.0; l<R.nCol(); l++)
2549  s += R.getElement(i,l)*P.getElement(l,j);
2550  T(i,j) = s;
2551  };
2552 
2553  for (i=0; i<S.nRow(); i++)
2554  for (j=i; j<S.nCol(); j++)
2555  {
2556  for (l=j, s=0.0; l<T.nCol(); l++)
2557  s += T.getElement(i,l)*R.getElement(j,l);
2558  S(i,j) = s;
2559  };
2560  return S;
2561 };
2562 */
2563 
2564 
2565 
2566 //
2568 {
2569 #ifdef DEBUG
2570  if (A.nCol() != P.nRow())
2572  ": calcQForm: incompatible ranges of the matrices");
2573 #endif //DEBUG
2574  int i, j, k;
2575  int aNrow=A.nRow();
2576  int aNcol=A.nCol();
2577  SgSymMatrix S(aNrow, false);
2578  SgMatrix T(aNrow, aNcol);
2579  double s;
2580  //
2581  if (0 < numOfThreads_)
2582  {
2583  const double *const * ppA=A.base_c();
2584  const double *const * ppP=P.base_c();
2585  double **ppT=T.base();
2586  double **ppS=S.base();
2587  const double *p;
2588  double *q;
2589  //
2590  for (j=0; j<aNcol; j++)
2591  {
2592  q = *(ppT+j);
2593  for (i=0; i<aNrow; i++, q++)
2594  {
2595  s = 0.0;
2596  p = *(ppP+j);
2597  for (k=0; k<j; k++, p++)
2598  s += *(*(ppA+k)+i)**p;
2599  for (k=j; k<aNcol; k++)
2600  s += *(*(ppA+k)+i)* *(*(ppP+k)+j);
2601  *q = s;
2602  };
2603  };
2604  for (j=0; j<aNrow; j++)
2605  {
2606  q = *(ppS+j);
2607  for (i=0; i<=j; i++, q++)
2608  {
2609  s = 0.0;
2610  for (k=0; k<aNcol; k++)
2611  s += *(*(ppT+k)+i)**(*(ppA+k)+j);
2612  *q = s;
2613  };
2614  };
2615  }
2616  else
2617  {
2618  for (i=0; i<aNrow; i++)
2619  for (j=0; j<aNcol; j++)
2620  {
2621  for (k=0, s=0.0; k<aNcol; k++)
2622  s += A.getElement(i,k)*P.getElement(k,j);
2623  T(i,j) = s;
2624  };
2625  for (i=0; i<aNrow; i++)
2626  for (j=i; j<aNrow; j++)
2627  {
2628  for (k=0, s=0.0; k<aNcol; k++)
2629  s += T.getElement(i,k)*A.getElement(j,k);
2630  S(i,j) = s;
2631  };
2632  };
2633  //
2634  return S;
2635 };
2636 
2637 
2638 
2639 
2640 //
2642 {
2643 #ifdef DEBUG
2644  if (R.nCol()!=P.nRow())
2646  ": calcQForm: incompatible ranges of the matrices");
2647 #endif //DEBUG
2648  int i, j, k;
2649  int n=R.nCol();
2650  SgSymMatrix S(n, false);
2651  SgMatrix T(n, n);
2652  double s;
2653  //
2654  if (0 < numOfThreads_)
2655  {
2656  const double *const * ppR=R.base_c();
2657  const double *const * ppP=P.base_c();
2658  double **ppT=T.base();
2659  double **ppS=S.base();
2660  const double *p;
2661  double *q;
2662  //
2663  for (j=0; j<n; j++)
2664  {
2665  q = *(ppT+j);
2666  for (i=0; i<n; i++, q++)
2667  {
2668  s = 0.0;
2669  p = *(ppP+j)+i;
2670  for (k=i; k<j; k++, p++)
2671  s += *(*(ppR+k)+i)**p;
2672  for (k=j; k<n; k++, p++)
2673  s += *(*(ppR+k)+i)**(*(ppP+k)+j);
2674  *q = s;
2675  };
2676  };
2677  //
2678  for (j=0; j<n; j++)
2679  {
2680  q = *(ppS+j);
2681  for (i=0; i<=j; i++, q++)
2682  {
2683  s = 0.0;
2684  for (k=j; k<n; k++)
2685  s += *(*(ppT+k)+i)**(*(ppR+k)+j);
2686  *q = s;
2687  };
2688  };
2689  }
2690  else
2691  {
2692  for (i=0; i<n; i++)
2693  for (j=0; j<n; j++)
2694  {
2695  for (k=i, s=0.0; k<n; k++)
2696  s += R.getElement(i,k)*P.getElement(k,j);
2697  T(i,j) = s;
2698  };
2699  for (i=0; i<n; i++)
2700  for (j=i; j<n; j++)
2701  {
2702  for (k=j, s=0.0; k<n; k++)
2703  s += T.getElement(i,k)*R.getElement(j,k);
2704  S(i,j) = s;
2705  };
2706  };
2707  //
2708  return S;
2709 };
2710 
2711 
2712 
2713 //
2715 {
2716  QString str;
2717  if (!stcSolutions_.size() || !stcPars) // nothing to do
2718  return;
2719 
2720  for (int i=0; i<stcPars->size(); i++)
2721  stcPars->at(i)->resetStatistics();
2722 
2724  QString tag = t.toString(SgMJD::F_INTERNAL);
2725  if (stcSolutions_.contains(tag))
2726  {
2727  stcSol = stcSolutions_.value(tag);
2728  for (int i=0; i<stcSol.list_->size(); i++)
2729  if (stcSol.list_->at(i)->getNumObs())
2730  {
2731  SgParameter *p=stcPars->at(i);
2732  p->setSolution(stcSol.list_->at(i)->getSolution());
2733  p->setSigma(stcSol.list_->at(i)->getSigma());
2734  p->setNumObs(stcSol.list_->at(i)->getNumObs());
2735  };
2736  };
2737 };
2738 
2739 
2740 
2741 //
2743 {
2744  unsigned int i;
2745  for (int i=0; i<listXAll_->size(); i++)
2746  listXAll_->at(i)->zerofy();
2747  for (i=0; i<nP_; i++)
2748  listP_->at(i)->zerofy();
2749  for (int i=0; i<listA_->size(); i++)
2750  listA_->at(i)->zerofy();
2751  for (int i=0; i<listPwl_->size(); i++)
2752  listPwl_->at(i)->zerofy();
2753 /*
2754  for (int i=0; i<arcStorage_->size(); i++)
2755  {
2756  SgArcStorage *arcP=arcStorage_->at(i);
2757  for (int j=0; j<arcP->getNum(); j++)
2758  arcP->getPi(j)->zerofy();
2759  };
2760  for (int i=0; i<pwlStorage_->size(); i++)
2761  pwlStorage_->at(i)->zerofy();
2762 */
2763 };
2764 
2765 
2766 
2767 //
2768 double SgEstimator::calcAX(const SgMJD& t, bool isWorkingBand)
2769 {
2770  unsigned int i;
2771  SgParameter *p;
2772  double sum = 0.0;
2773  //
2774  // regular parameters:
2775  for (int i=0; i<listX_->size(); i++)
2776  {
2777  p = listX_->at(i);
2779  sum += p->getD()*p->getSolution();
2780  };
2781  //
2782  // arc parameters:
2783  for (int i=0; i<arcStorage_->size(); i++)
2784  sum += arcStorage_->at(i)->calcAX(t, isWorkingBand);
2785  //
2786  // PWL parameters:
2787  for (int i=0; i<pwlStorage_->size(); i++)
2788  sum += pwlStorage_->at(i)->calcAX(t, isWorkingBand);
2789  //
2790  // stochastic parameters:
2791  for (i=0; i<nP_; i++)
2792  sum += listP_->at(i)->getD()*listP_->at(i)->getSolution();
2793 
2794  return sum;
2795 };
2796 
2797 
2798 
2799 //
2800 void SgEstimator::deployArcParameters(const SgMJD& tFirst, const SgMJD& tLast, const SgMJD& tRefer)
2801 {
2802  SgArcStorage *arcP=NULL;
2803  int num=0;
2804  for (int i=0; i<listA_->size(); i++)
2805  {
2806  SgParameter *p=listA_->at(i);
2807  arcP = new SgArcStorage;
2808  arcP->deployParameters(p, tFirst, tLast, tRefer);
2809  arcStorage_->append(arcP);
2810  };
2811  //
2812  for (int i=0; i<arcStorage_->size(); i++)
2813  {
2814  arcP = arcStorage_->at(i);
2815  for (int j=0; j<arcP->getNum(); j++)
2816  addParameter(arcP->getPi(j), true);
2817  num += arcP->getNum();
2818  };
2820  ": deployArcParameters: deployed " + QString("").sprintf("%d", num) + " single parameters");
2821 };
2822 
2823 
2824 
2825 //
2826 void SgEstimator::deployPwlParameters(const SgMJD& tFirst, const SgMJD& tLast, const SgMJD& tRefer)
2827 {
2828  SgPwlStorage *pwl=NULL;
2829  int num=0;
2830  for (int i=0; i<listPwl_->size(); i++)
2831  {
2832  SgParameter *p=listPwl_->at(i);
2833  switch (config_->getPwlMode())
2834  {
2835  default:
2837  pwl = new SgPwlStorageBSplineL;
2838  break;
2840  pwl = new SgPwlStorageBSplineQ;
2841  break;
2843  pwl = new SgPwlStorageIncRates;
2844  break;
2845  };
2846  pwl->deployParameters(p, tFirst, tLast, tRefer, config_);
2847  pwlStorage_->append(pwl);
2848  pwlStorageByName_->insert(p->getName(), pwl);
2849  };
2850  //
2851  for (int i=0; i<pwlStorage_->size(); i++)
2852  {
2853  pwl = pwlStorage_->at(i);
2854  for (int j=0; j<pwl->getNumOfPolynomials(); j++)
2855  addParameter(pwl->getP_Ai(j), true);
2856  num += pwl->getNumOfPolynomials();
2857  for (int j=0; j<pwl->getNumOfNodes(); j++)
2858  addParameter(pwl->getP_Bi(j), true);
2859  num += pwl->getNumOfNodes();
2860  };
2861  if (num)
2863  ": deployPwlParameters: deployed " + QString("").sprintf("%d", num) + " single parameters");
2864 };
2865 
2866 
2867 
2868 //
2870 {
2871  for (int i=0; i<arcStorage_->size(); i++)
2872  arcStorage_->at(i)->propagatePartials(t);
2873 };
2874 
2875 
2876 
2877 //
2879 {
2880  for (int i=0; i<pwlStorage_->size(); i++)
2881  pwlStorage_->at(i)->propagatePartials(t);
2882 };
2883 
2884 
2885 
2886 //
2888 {
2889  for (int i=0; i<pwlStorage_->size(); i++)
2890  pwlStorage_->at(i)->collectTraces4Sfo(listX, mPx);
2891 };
2892 
2893 
2894 
2895 //
2897 {
2899  int num=r->size();
2900  int *idxs=new int[num];
2901 
2902  for (int i=0; i<num; i++)
2903  idxs[i] = r->at(i)->getIdx();
2904 
2905  for (int i=0; i<num; i++)
2906  {
2907  SgParameter *p=r->at(i);
2908  if (listXAll_->at(idxs[i])->isAttr(SgParameter::Attr_IS_SOLVED))
2909  xd->setElement(i, listXAll_->at(idxs[i])->getSolution());
2910  else
2912  ": collectDependentInfArray: trying to get a parameter (" + p->getName() +
2913  ") that was not yet solved.");
2914  for (int j=i; j<num; j++)
2915  Pd->setElement(i,j, PxAll_->getElement(idxs[i], idxs[j]));
2916  };
2917  delete[] idxs;
2918 };
2919 
2920 
2921 
2922 //
2924  SgMatrix* Pxx, QList<SgParameter*>* others)
2925 {
2926  int *idxs_x, n=xList->size();
2927  idxs_x = new int[n];
2928  for (int i=0; i<n; i++)
2929  idxs_x[i] = xList->at(i)->getIdx();
2930 
2931  // the vector of parameters:
2932  for (int i=0; i<n; i++)
2933  {
2934  SgParameter *p=listXAll_->at(idxs_x[i]);
2937  ": submittSolution2GlobalStore: trying to set up a parameter (" + p->getName() +
2938  ") that was already solved.");
2939  else
2940  {
2941  SgParameter *p2copy=xList->at(i);
2942  p->setSolution(p2copy->getSolution());
2943  p->setSigma(p2copy->getSigma());
2944  p->setNumObs(p2copy->getNumObs());
2946  };
2947  };
2948  // the covariance matrix:
2949  for (int i=0; i<n; i++)
2950  for (int j=0; j<=i; j++)
2951  PxAll_->setElement(idxs_x[i], idxs_x[j], Px->getElement(i, j));
2952  if (!(Pxx && others))
2953  {
2954  delete[] idxs_x;
2955  return;
2956  };
2957  //
2958  int *idxs_o, m=others->size();
2959  idxs_o = new int[m];
2960  for (int i=0; i<m; i++)
2961  idxs_o[i] = others->at(i)->getIdx();
2962  for (int i=0; i<n; i++)
2963  for (int j=0; j<m; j++)
2964  PxAll_->setElement(idxs_x[i], idxs_o[j], Pxx->getElement(i, j));
2965  delete[] idxs_x;
2966  delete[] idxs_o;
2967 };
2968 
2969 
2970 
2971 //
2973 {
2974  double aT_P_a;
2977  int n=PxAll_->nCol();
2978  SgVector *a=new SgVector(n);
2979  for (int i=0; i<n; i++)
2980  a->setElement(i, listXAll_->at(i)->getD());
2981  aT_P_a = *a*(*PxAll_**a);
2982  // std::cout << " aTPa=" << aT_P_a << "\n";
2983  delete a;
2984  return aT_P_a;
2985 };
2986 
2987 
2988 
2989 //
2991 {
2992  double aT_P_a, sum;
2993  int numAll=listXAll_->size(), num=listX_->size();
2994  SgVector *vP_a = new SgVector(numAll);
2995  bool *usedRows = new bool[numAll];
2996 
2997  // init the array:
2998  for (int i=0; i<numAll; i++)
2999  usedRows[i] = false;
3000  // mark actually used rows:
3001  for (int i=0; i<num; i++)
3002  usedRows[listX_->at(i)->getIdx()] = true;
3003  for (int i=0; i<pwlStorage_->size(); i++)
3004  {
3005  SgPwlStorage *pwl=pwlStorage_->at(i);
3006  int idx=pwl->calcCurrentIdx(t);
3007  for (int j=0; j<idx+1; j++)
3008  usedRows[pwl->getP_Bi(j)->getIdx()] = true;
3009  for (int j=0; j<pwl->getNumOfPolynomials(); j++)
3010  usedRows[pwl->getP_Ai(j)->getIdx()] = true;
3011  };
3012  // calc the product only for actually used rows:
3013  for (int i=0; i<numAll; i++)
3014  if (usedRows[i])
3015  {
3016  sum = 0.0;
3017  // regular parameters:
3018  for (int j=0; j<num; j++)
3019  {
3020  SgParameter *p=listX_->at(j);
3022  sum += PxAll_->getElement(i, p->getIdx())*p->getD();
3023  };
3024  // arc parameters:
3025  for (int j=0; j<arcStorage_->size(); j++)
3026  sum += arcStorage_->at(j)->calc_P_a(*PxAll_, i, t);
3027  //
3028  // PWL parameters:
3029  for (int j=0; j<pwlStorage_->size(); j++)
3030  sum += pwlStorage_->at(j)->calc_P_a(*PxAll_, i, t);
3031  vP_a->setElement(i, sum);
3032  };
3033 
3034  aT_P_a = 0.0;
3035  //
3036  // regular parameters:
3037  for (int i=0; i<num; i++)
3038  {
3039  SgParameter *p=listX_->at(i);
3041  aT_P_a += p->getD()*vP_a->getElement(p->getIdx());
3042  };
3043  // arc parameters:
3044  for (int j=0; j<arcStorage_->size(); j++)
3045  aT_P_a += arcStorage_->at(j)->calc_aT_P_a(*vP_a, t);
3046  //
3047  // PWL parameters:
3048  for (int i=0; i<pwlStorage_->size(); i++)
3049  aT_P_a += pwlStorage_->at(i)->calc_aT_P_a(*vP_a, t);
3050  //
3051  delete[] usedRows;
3052  delete vP_a;
3053  return aT_P_a;
3054 };
3055 
3056 
3057 
3058 //
3060 {
3061  if (listP_->size()) // not implemented
3062  return 0.0;
3063 
3066  SgPwlStorage *pwl=NULL;
3067  //
3068  // have to add arcs here too...
3069  // SgArcStorage *arc=NULL;
3070  int num(0);
3071  // first, calculate the size of the vector a:
3072  for (int i=0; i<pars.size(); i++)
3073  {
3074  SgParameter *p=pars.at(i);
3075  // PWL:
3076  if (p->getPMode() == SgParameterCfg::PM_PWL)
3077  {
3078  pwl = pwlStorageByName_->value(p->getName());
3079  num += pwl->getNumOfActiveParameters(t);
3080  }
3081  // ARC:
3082  else if (p->getPMode() == SgParameterCfg::PM_ARC)
3083  {
3084  //aByName_
3085  // arc = arcStorageByName_->value(p->getName());
3086  // num += arc->getNum();
3087  }
3088  // regular:
3089  else
3090  num++;
3091  };
3092  //
3093  // then, fill the vector:
3094  SgVector *va=new SgVector(num);
3095  int *loc2glb, idx;
3096  loc2glb = new int[num];
3097  idx = 0;
3098  QList<SgParameter*> pwlActivePars;
3099  for (int i=0; i<pars.size(); i++)
3100  {
3101  SgParameter *p=pars.at(i);
3102  // PWL:
3103  if (p->getPMode() == SgParameterCfg::PM_PWL)
3104  {
3105  pwl = pwlStorageByName_->value(p->getName());
3106  pwl->getListOfActiveParameters(t, pwlActivePars);
3107  SgParameter *pp;
3108  for (int j=0; j<pwlActivePars.size(); j++)
3109  {
3110  pp = pwlActivePars.at(j);
3111  va->setElement(idx, pp->getD());
3112  loc2glb[idx] = pp->getIdx();
3113  pp->zerofy();
3114  idx++;
3115  };
3116  }
3117  // ARC:
3118  else if (p->getPMode() == SgParameterCfg::PM_ARC)
3119  {
3120  //aByName_
3121  // arc = arcStorageByName_->value(p->getName());
3122  // num += arc->getNum();
3123  }
3124  // regular:
3125  else// if (p->getPMode() != SgParameterCfg::PM_STC)
3126  {
3127  va->setElement(idx, p->getD());
3128  loc2glb[idx] = p->getIdx();
3129  p->zerofy();
3130  idx++;
3131  };
3132  };
3133  //
3134  double aT_P_a(0.0), sum(0.0);
3135  SgVector *vP_a=new SgVector(num);
3136  // first, calculate P*a:
3137  for (int i=0; i<num; i++)
3138  {
3139  //std::cout << " i=" << i << " va->getElement(i)=" << va->getElement(i) << "\n";
3140  sum = 0.0;
3141  for (int j=0; j<num; j++)
3142  {
3143 // if (pars.at(i)->getPMode() != SgParameterCfg::PM_STC &&
3144 // pars.at(j)->getPMode() != SgParameterCfg::PM_STC)
3145  sum += PxAll_->getElement(loc2glb[i], loc2glb[j])*va->getElement(j);
3146 //std::cout << " i=" << i << " j=" << j
3147 // << " PxAll_->getElement(loc2glb[i], loc2glb[j])=" << PxAll_->getElement(loc2glb[i], loc2glb[j]) << "\n";
3148  };
3149  vP_a->setElement(i, sum);
3150  };
3151  //std::cout << "\n";
3152  //
3153  // and then, evaluate aT*(P*a):
3154  aT_P_a = 0.0;
3155  for (int i=0; i<num; i++)
3156  aT_P_a += va->getElement(i)*vP_a->getElement(i);
3157  //
3158  //
3159  delete[] loc2glb;
3160  delete va;
3161  delete vP_a;
3162  return aT_P_a;
3163 };
3164 /*=====================================================================================================*/
3165 
3166 
3167 
3168 
3169 /*=======================================================================================================
3170 *
3171 * FRIENDS:
3172 *
3173 *======================================================================================================*/
3174 //
3175 
3176 
3177 
3178 /*=====================================================================================================*/
3179 //
3180 // aux functions:
3181 //
3182 
3183 
3184 // i/o:
3185 
3186 
3187 /*=====================================================================================================*/
3188 //
3189 // constants:
3190 //
3191 
3192 
3193 /*=====================================================================================================*/
const char * nsNumOfThreads
Definition: SgEstimator.cpp:49
void * thPrc_02(void *)
void * thPrc_01(void *)
Definition: SgEstimator.cpp:96
SgLogger * logger
Definition: SgLogger.cpp:231
const SgMJD tZero(1957, 10, 4)
const SgMJD tInf(2100, 1, 1)
double signum(const double x)
Definition: SgMathSupport.h:89
SgMatrix calcProduct_mat_x_mat(const SgMatrix &M1, const SgMatrix &M2)
Definition: SgMatrix.cpp:94
void reportParameterList(const QList< SgParameter * > &list, bool isShowTLeftRight)
bool lessThan4_ParameterByTRightSortingOrder(SgParameter *p1, SgParameter *p2)
void updateSolutionAtParameterList(QList< SgParameter * > &list, SgVector *x, SgSymMatrix *P)
bool lessThan4_ParameterByTLeftSortingOrder(SgParameter *p1, SgParameter *p2)
bool lessThan4_ParameterByNameSortingOrder(SgParameter *p1, SgParameter *p2)
int getNum() const
Definition: SgArcStorage.h:183
void deployParameters(SgParameter *, const SgMJD &tStart, const SgMJD &tFinis, const SgMJD &tRefer)
SgParameter * getPi(int)
Definition: SgArcStorage.h:191
bool isAttr(uint a) const
Definition: SgAttribute.h:226
void delAttr(uint a)
Definition: SgAttribute.h:210
void addAttr(uint a)
Definition: SgAttribute.h:202
void solveStochasticParameters()
int lastPrcColumn4Prc_01_
Definition: SgEstimator.h:293
SgEstimator(SgTaskConfig *)
SgMJD tNextLeft_
Definition: SgEstimator.h:220
void insertNewParameters(const SgMJD &)
struct arg4Prc_01 * args4Prc_01_
Definition: SgEstimator.h:289
pthread_mutex_t * pthMutexes4Prc_02_
Definition: SgEstimator.h:297
static const QString className()
int lastPrcColumn4Prc_02_
Definition: SgEstimator.h:299
QList< SgParameter * > * listPwl_
Definition: SgEstimator.h:268
pthread_t * th4Prc_02_
Definition: SgEstimator.h:296
SgVector * zx_
Definition: SgEstimator.h:232
double time4DataUpdate_
Definition: SgEstimator.h:308
SgVector * x_
Definition: SgEstimator.h:231
SgUtMatrix * Rx_
Definition: SgEstimator.h:233
void calcConditionNumber(const SgUtMatrix &R, const SgUtMatrix &RInv)
int numOfThreads_
Definition: SgEstimator.h:285
QStack< SmoothCarrier > scStack_
Definition: SgEstimator.h:253
SgVector * p_
Definition: SgEstimator.h:242
void dataUpdate()
unsigned int nZ_
Definition: SgEstimator.h:276
QList< SgPwlStorage * > * pwlStorage_
Definition: SgEstimator.h:271
SgUtMatrix * Rp_s_
Definition: SgEstimator.h:249
QMap< QString, SgParameter * > * xAllByName_
Definition: SgEstimator.h:226
SgMJD tLastProcessed_
Definition: SgEstimator.h:219
pthread_mutex_t * pthMutexes4Prc_01_
Definition: SgEstimator.h:291
QList< SgParameter * > * listP_
Definition: SgEstimator.h:240
SgMatrix * Rpp_s_
Definition: SgEstimator.h:250
double calcAX(const SgMJD &, bool)
void propagateStochasticParameters(double)
SgMatrix * SR_
Definition: SgEstimator.h:247
void removeParametersList(QList< SgParameter * > *)
void dataUpdate_th()
void submittSolution2GlobalStore(SgSymMatrix *, QList< SgParameter * > *, SgMatrix *=NULL, QList< SgParameter * > *=NULL)
SgMJD tWall4ProcObs0_
Definition: SgEstimator.h:305
void saveProcessedParameters(const SgMJD &)
SgVector * zp_
Definition: SgEstimator.h:243
QList< SgParameter * > * listA_
Definition: SgEstimator.h:264
unsigned int nP_
Definition: SgEstimator.h:239
SgVector * u_
Definition: SgEstimator.h:280
SgSymMatrix & calculateRRT(SgSymMatrix &, const SgUtMatrix &)
QList< SgArcStorage * > * arcStorage_
Definition: SgEstimator.h:266
SgVector * zp_s_
Definition: SgEstimator.h:252
SgMJD tNextRight_
Definition: SgEstimator.h:221
double time4PropagateStc_
Definition: SgEstimator.h:309
SgMJD tWall_
Definition: SgEstimator.h:304
void propagateStochasticParameters_th(double)
SgMatrix * Rpx_s_
Definition: SgEstimator.h:251
SgMJD tWall0_
Definition: SgEstimator.h:303
SgVector & solveEquation(const SgUtMatrix &R, SgVector &x, const SgVector &z)
SgSymMatrix calcQForm(const SgSymMatrix &, const SgMatrix &)
void prepareStochasticSolution4Epoch(const SgMJD &, QList< SgParameter * > *)
SgUtMatrix * Rp_
Definition: SgEstimator.h:244
SgMatrix * Rpx_
Definition: SgEstimator.h:245
double calc_aT_P_a(const SgMJD &)
void save4Smoothing(const SgMJD &)
void addParametersList(QList< SgParameter * > *, bool=false)
void propagateArcPartials(const SgMJD &)
SgMatrix * Ap_
Definition: SgEstimator.h:278
QList< SgParameter * > * listXAll_
Definition: SgEstimator.h:224
double time4SaveStc_
Definition: SgEstimator.h:310
QMap< QString, SgParameter * > * xByName_
Definition: SgEstimator.h:230
QMap< QString, SgParameter * > * pwlParByName_
Definition: SgEstimator.h:269
SgMatrix * u4pth_
Definition: SgEstimator.h:287
SgVector * z_
Definition: SgEstimator.h:277
void calcPwlTraces(const QList< SgParameter * > *listX, const SgSymMatrix &mPx)
void deployPwlParameters(const SgMJD &, const SgMJD &, const SgMJD &)
pthread_mutex_t pthMutL4Prc_01_
Definition: SgEstimator.h:292
void addParameter(SgParameter *, bool=false)
double calc_aT_P_a_opt(const SgMJD &)
SgMatrix * Ax_
Definition: SgEstimator.h:279
void prepare2Run(int numOfExpectedObs, const SgMJD &, const SgMJD &, const SgMJD &)
QMap< QString, SgParameter * > * pByName_
Definition: SgEstimator.h:241
double time4ProcObs_
Definition: SgEstimator.h:311
SgMJD tWall4ProcObs_
Definition: SgEstimator.h:306
double maxConditionNumber_
Definition: SgEstimator.h:282
QMap< QString, SgParameter * > * aByName_
Definition: SgEstimator.h:265
void collectDependentInfArray(const RPCarrier &, SgVector *, SgSymMatrix *)
pthread_mutex_t pthMutL4Prc_02_
Definition: SgEstimator.h:298
QMap< QString, SgPwlStorage * > * pwlStorageByName_
Definition: SgEstimator.h:270
unsigned int nX_
Definition: SgEstimator.h:228
QMap< QString, StochasticSolutionCarrier > stcSolutions_
Definition: SgEstimator.h:259
SgSymMatrix * Pp_
Definition: SgEstimator.h:246
void processConstraint(double o_c, double sigma)
void removeParameter(SgParameter *)
void deployArcParameters(const SgMJD &, const SgMJD &, const SgMJD &)
void processObs(const SgMJD &t, const SgVector &o_c, const SgVector &sigma)
QList< SgParameter * > * listX_
Definition: SgEstimator.h:229
void propagatePwlPartials(const SgMJD &)
pthread_attr_t pthreadAttr_
Definition: SgEstimator.h:286
SgSymMatrix * PxAll_
Definition: SgEstimator.h:225
int numOfProcessedObs_
Definition: SgEstimator.h:281
QStack< RPCarrier > rpStack_
Definition: SgEstimator.h:235
void clearPartials()
pthread_t * th4Prc_01_
Definition: SgEstimator.h:290
SgSymMatrix * Px_
Definition: SgEstimator.h:234
struct arg4Prc_02 * args4Prc_02_
Definition: SgEstimator.h:295
SgTaskConfig * config_
Definition: SgEstimator.h:216
virtual void write(LogLevel, quint32, const QString &, bool=false)
Definition: SgLogger.cpp:88
@ MATRIX
Definition: SgLogger.h:69
@ STOCH
Definition: SgLogger.h:92
@ ESTIMATOR
Definition: SgLogger.h:90
bool isEligible(LogLevel lvl, quint32 f) const
Definition: SgLogger.h:151
Definition: SgMJD.h:59
@ F_YYYYMMDDHHMMSSSS
Long verbose: Fri, the 2nd of Apr, 2010; 17hr 02min 43.6400sec.
Definition: SgMJD.h:67
@ F_INTERNAL
Digits, date and time: 20100402.71.
Definition: SgMJD.h:72
QString toString(Format format=F_Verbose) const
Definition: SgMJD.cpp:1008
static SgMJD currentMJD()
Definition: SgMJD.cpp:119
void clear()
Definition: SgMatrix.h:425
unsigned int nRow() const
Definition: SgMatrix.h:352
void setElement(unsigned int i, unsigned int j, double d)
Definition: SgMatrix.h:402
const double *const * base_c() const
Definition: SgMatrix.h:249
double getElement(unsigned int i, unsigned int j) const
Definition: SgMatrix.h:385
unsigned int nCol() const
Definition: SgMatrix.h:360
double **& base()
Definition: SgMatrix.h:247
double calcRW(double)
double getSolution() const
Definition: SgParameter.h:435
SgMJD getTRight() const
Definition: SgParameter.h:555
void setIdx(int idx)
Definition: SgParameter.h:707
SgMJD getTLeft() const
Definition: SgParameter.h:547
SgParameterCfg::PMode getPMode() const
Definition: SgParameter.h:459
void setSigma(double v)
Definition: SgParameter.h:587
double getSigma() const
Definition: SgParameter.h:443
int getIdx() const
Definition: SgParameter.h:563
void setSolution(double v)
Definition: SgParameter.h:579
@ Attr_IS_SOLVED
for estimator use
Definition: SgParameter.h:57
double calcM(double)
void updateStatistics(const SgMJD &t, double weight)
Definition: SgPartial.cpp:62
int getNumObs() const
Definition: SgPartial.h:299
const QString & getName() const
Definition: SgPartial.h:283
double getD() const
Definition: SgPartial.h:291
void setNumObs(int n)
Definition: SgPartial.h:356
void zerofy()
Definition: SgPartial.h:408
@ Attr_IS_SPECIAL
for estimator use
Definition: SgPartial.h:54
int getNumOfPolynomials() const
Definition: SgPwlStorage.h:259
SgParameter * getP_Bi(int)
Definition: SgPwlStorage.h:307
virtual void getListOfActiveParameters(const SgMJD &t, QList< SgParameter * > &pars)=0
int getNumOfNodes() const
Definition: SgPwlStorage.h:251
SgParameter * getP_Ai(int)
Definition: SgPwlStorage.h:316
int calcCurrentIdx(const SgMJD &t)
Definition: SgPwlStorage.h:345
virtual void deployParameters(SgParameter *, const SgMJD &tStart, const SgMJD &tFinis, const SgMJD &tRefer, const SgTaskConfig *)=0
virtual int getNumOfActiveParameters(const SgMJD &t)=0
double getElement(unsigned int i, unsigned int j) const
Definition: SgSymMatrix.h:274
const double *const * base_c() const
Definition: SgSymMatrix.h:100
void setElement(unsigned int i, unsigned int j, double d)
Definition: SgSymMatrix.h:291
double **& base()
Definition: SgSymMatrix.h:98
EstimatorPwlMode getPwlMode() const
Definition: SgTaskConfig.h:953
unsigned int n() const
Definition: SgUtMatrix.h:290
void setElement(unsigned int i, unsigned int j, double d)
Definition: SgUtMatrix.h:338
const double *const * base_c() const
Definition: SgUtMatrix.h:204
double getElement(unsigned int i, unsigned int j) const
Definition: SgUtMatrix.h:318
double **& base()
Definition: SgUtMatrix.h:201
unsigned int n() const
Definition: SgVector.h:327
void setElement(unsigned int i, double d)
Definition: SgVector.h:348
double *& base()
Definition: SgVector.h:247
void clear()
Definition: SgVector.h:389
double getElement(unsigned int i) const
Definition: SgVector.h:362
SgTaskConfig config
Definition: nuSolve.cpp:59
QList< SgParameter * > * listOthers_
Definition: SgEstimator.h:197
QList< SgParameter * > * list_
Definition: SgEstimator.h:196
QList< SgParameter * > * p_s_
Definition: SgEstimator.h:186
QList< SgParameter * > * list_
Definition: SgEstimator.h:70
double * pZ_
Definition: SgEstimator.cpp:60
pthread_mutex_t * pthMutexes_
Definition: SgEstimator.cpp:62
double * pU_
Definition: SgEstimator.cpp:61
double ** ppAx_
Definition: SgEstimator.cpp:58
double * pZx_
Definition: SgEstimator.cpp:59
int * lastPrcColumn_
Definition: SgEstimator.cpp:64
double ** ppRx_
Definition: SgEstimator.cpp:57
pthread_mutex_t * pthMutL_
Definition: SgEstimator.cpp:63
double ** ppRp_
Definition: SgEstimator.cpp:74
double ** ppAx_
Definition: SgEstimator.cpp:77
double ** ppRpx_
Definition: SgEstimator.cpp:75
double ** ppAp_
Definition: SgEstimator.cpp:76
double * pU_
Definition: SgEstimator.cpp:80
int * lastPrcColumn_
Definition: SgEstimator.cpp:83
double * pZ_
Definition: SgEstimator.cpp:79
pthread_mutex_t * pthMutexes_
Definition: SgEstimator.cpp:81
pthread_mutex_t * pthMutL_
Definition: SgEstimator.cpp:82
double * pZp_
Definition: SgEstimator.cpp:78