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