25 #include <queso/SequenceOfVectors.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
32 template <
class V,
class M>
35 unsigned int subSequenceSize,
36 const std::string& name)
39 m_seq (subSequenceSize,NULL)
40 #ifdef UQ_CODE_HAS_MONITORS
42 m_subMeanMonitorPosSeq (NULL),
43 m_subMeanVecSeq (NULL),
44 m_subMeanCltStdSeq (NULL),
45 m_subMeanInter0MonitorPosSeq (NULL),
46 m_subMeanInter0Mean (NULL),
47 m_subMeanInter0Clt95 (NULL),
48 m_subMeanInter0Empirical90 (NULL),
49 m_subMeanInter0Min (NULL),
50 m_subMeanInter0Max (NULL),
51 m_unifiedMeanMonitorPosSeq (NULL),
52 m_unifiedMeanVecSeq (NULL),
53 m_unifiedMeanCltStdSeq (NULL)
67 template <
class V,
class M>
70 #ifdef UQ_CODE_HAS_MONITORS
71 if (m_subMeanMonitorPosSeq)
delete m_subMeanMonitorPosSeq;
72 if (m_subMeanVecSeq )
delete m_subMeanVecSeq;
73 if (m_subMeanCltStdSeq )
delete m_subMeanCltStdSeq;
75 if (m_subMeanInter0MonitorPosSeq)
delete m_subMeanInter0MonitorPosSeq;
76 if (m_subMeanInter0Mean )
delete m_subMeanInter0Mean;
77 if (m_subMeanInter0Clt95 )
delete m_subMeanInter0Clt95;
78 if (m_subMeanInter0Empirical90 )
delete m_subMeanInter0Empirical90;
79 if (m_subMeanInter0Min )
delete m_subMeanInter0Min;
80 if (m_subMeanInter0Max )
delete m_subMeanInter0Max;
82 if (m_unifiedMeanMonitorPosSeq)
delete m_unifiedMeanMonitorPosSeq;
83 if (m_unifiedMeanVecSeq )
delete m_unifiedMeanVecSeq;
84 if (m_unifiedMeanCltStdSeq )
delete m_unifiedMeanCltStdSeq;
87 for (
unsigned int i = 0; i < (
unsigned int) m_seq.size(); ++i) {
88 if (m_seq[i])
delete m_seq[i];
92 template <
class V,
class M>
101 template <
class V,
class M>
108 template <
class V,
class M>
112 if (newSubSequenceSize != this->subSequenceSize()) {
113 if (newSubSequenceSize < this->subSequenceSize()) {
114 this->resetValues(newSubSequenceSize,this->subSequenceSize()-newSubSequenceSize);
116 m_seq.resize(newSubSequenceSize,NULL);
117 std::vector<const V*>(m_seq).swap(m_seq);
124 template <
class V,
class M>
128 bool bRC = ((initialPos < this->subSequenceSize()) &&
130 ((initialPos+numPos) <= this->subSequenceSize()));
131 if ((bRC ==
false) && (m_env.subDisplayFile())) {
132 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::resetValues()"
133 <<
", initialPos = " << initialPos
134 <<
", this->subSequenceSize() = " << this->subSequenceSize()
135 <<
", numPos = " << numPos
140 for (
unsigned int j = 0; j < numPos; ++j) {
141 if (m_seq[initialPos+j] != NULL) {
142 delete m_seq[initialPos+j];
143 m_seq[initialPos+j] = NULL;
152 template <
class V,
class M>
156 bool bRC = ((initialPos < this->subSequenceSize()) &&
158 ((initialPos+numPos) <= this->subSequenceSize()));
161 for (
unsigned int j = 0; j < numPos; ++j) {
162 if (m_seq[initialPos+j] != NULL) {
163 delete m_seq[initialPos+j];
164 m_seq[initialPos+j] = NULL;
169 if (initialPos < this->subSequenceSize()) std::advance(posIteratorBegin,initialPos);
170 else posIteratorBegin = m_seq.end();
172 unsigned int posEnd = initialPos + numPos - 1;
174 if (posEnd < this->subSequenceSize()) std::advance(posIteratorEnd,posEnd);
175 else posIteratorEnd = m_seq.end();
177 unsigned int oldSubSequenceSize = this->subSequenceSize();
178 m_seq.erase(posIteratorBegin,posIteratorEnd);
179 queso_require_equal_to_msg((oldSubSequenceSize - numPos), this->subSequenceSize(),
"(oldSubSequenceSize - numPos) != this->subSequenceSize()");
186 template <
class V,
class M>
199 vec = *(m_seq[posId]);
204 template <
class V,
class M>
212 if (m_seq[posId] != NULL)
delete m_seq[posId];
213 m_seq[posId] =
new V(vec);
225 template <
class V,
class M>
228 const V& numEvaluationPointsVec,
232 V minDomainValues(m_vectorSpace.zeroVector());
233 V maxDomainValues(m_vectorSpace.zeroVector());
237 unsigned int numParams = this->vectorSizeLocal();
238 for (
unsigned int i = 0; i < numParams; ++i) {
239 this->extractScalarSeq(0,
245 std::vector<double> aCdf(0);
246 data.subUniformlySampledCdf((
unsigned int) numEvaluationPointsVec[i],
260 template <
class V,
class M>
263 const V& numEvaluationPointsVec,
267 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
268 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::unifiedUniformlySampledCdf()"
272 V unifiedMinDomainValues(m_vectorSpace.zeroVector());
273 V unifiedMaxDomainValues(m_vectorSpace.zeroVector());
277 unsigned int numParams = this->vectorSizeLocal();
278 for (
unsigned int i = 0; i < numParams; ++i) {
279 this->extractScalarSeq(0,
285 std::vector<double> aCdf(0);
286 data.unifiedUniformlySampledCdf(m_vectorSpace.numOfProcsForStorage() == 1,
287 (
unsigned int) numEvaluationPointsVec[i],
288 unifiedMinDomainValues[i],
289 unifiedMaxDomainValues[i],
295 unifiedMinDomainValues,
296 unifiedMaxDomainValues);
298 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
299 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::unifiedUniformlySampledCdf()"
306 template <
class V,
class M>
309 unsigned int initialPos,
313 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
314 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::subMeanExtra()"
315 <<
": initialPos = " << initialPos
316 <<
", numPos = " << numPos
317 <<
", sub sequence size = " << this->subSequenceSize()
321 bool bRC = ((initialPos < this->subSequenceSize()) &&
323 ((initialPos+numPos) <= this->subSequenceSize()) &&
324 (this->vectorSizeLocal() == meanVec.sizeLocal() ));
325 if ((bRC ==
false) && (m_env.subDisplayFile())) {
326 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::subMeanExtra()"
327 <<
", initialPos = " << initialPos
328 <<
", this->subSequenceSize() = " << this->subSequenceSize()
329 <<
", numPos = " << numPos
330 <<
", this->vectorSizeLocal() = " << this->vectorSizeLocal()
331 <<
", meanVec.sizeLocal() = " << meanVec.sizeLocal()
338 unsigned int numParams = this->vectorSizeLocal();
339 for (
unsigned int i = 0; i < numParams; ++i) {
340 this->extractScalarSeq(initialPos,
349 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
350 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::subMeanExtra()"
351 <<
": initialPos = " << initialPos
352 <<
", numPos = " << numPos
353 <<
", sub sequence size = " << this->subSequenceSize()
354 <<
", meanVec = " << meanVec
361 template <
class V,
class M>
364 unsigned int initialPos,
366 V& unifiedMeanVec)
const
368 unsigned int tmpUnif = this->unifiedSequenceSize();
369 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
370 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::unifiedMeanExtra()"
371 <<
": initialPos = " << initialPos
372 <<
", numPos = " << numPos
373 <<
", sub sequence size = " << this->subSequenceSize()
374 <<
", unified sequence size = " << tmpUnif
378 bool bRC = ((initialPos < this->subSequenceSize() ) &&
380 ((initialPos+numPos) <= this->subSequenceSize() ) &&
381 (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()));
382 if ((bRC ==
false) && (m_env.subDisplayFile())) {
383 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedMeanExtra()"
384 <<
", initialPos = " << initialPos
385 <<
", this->subSequenceSize() = " << this->subSequenceSize()
386 <<
", numPos = " << numPos
387 <<
", this->vectorSizeLocal() = " << this->vectorSizeLocal()
388 <<
", unifiedMeanVec.sizeLocal() = " << unifiedMeanVec.sizeLocal()
395 unsigned int numParams = this->vectorSizeLocal();
396 for (
unsigned int i = 0; i < numParams; ++i) {
397 this->extractScalarSeq(initialPos,
402 unifiedMeanVec[i] = data.
unifiedMeanExtra(m_vectorSpace.numOfProcsForStorage() == 1,
407 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
408 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::unifiedMeanExtra()"
409 <<
": initialPos = " << initialPos
410 <<
", numPos = " << numPos
411 <<
", sub sequence size = " << this->subSequenceSize()
412 <<
", unified sequence size = " << tmpUnif
413 <<
", unifiedMeanVec = " << unifiedMeanVec
420 template <
class V,
class M>
423 unsigned int initialPos,
427 if (this->subSequenceSize() == 0)
return;
429 bool bRC = ((initialPos < this->subSequenceSize()) &&
431 ((initialPos+numPos) <= this->subSequenceSize()));
433 std::cerr <<
"In SequenceOfVectors<V,M>::subMedianExtra()"
434 <<
": ERROR at fullRank " << m_env.fullRank()
435 <<
", initialPos = " << initialPos
436 <<
", numPos = " << numPos
437 <<
", this->subSequenceSize() = " << this->subSequenceSize()
439 if (m_env.subDisplayFile()) {
440 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::subMedianExtra()"
441 <<
": ERROR at fullRank " << m_env.fullRank()
442 <<
", initialPos = " << initialPos
443 <<
", numPos = " << numPos
444 <<
", this->subSequenceSize() = " << this->subSequenceSize()
452 unsigned int numParams = this->vectorSizeLocal();
453 for (
unsigned int i = 0; i < numParams; ++i) {
454 this->extractScalarSeq(initialPos,
463 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
464 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::subMedianExtra()"
465 <<
": initialPos = " << initialPos
466 <<
", numPos = " << numPos
467 <<
", sub sequence size = " << this->subSequenceSize()
468 <<
", medianVec = " << medianVec
475 template <
class V,
class M>
478 unsigned int initialPos,
480 V& unifiedMedianVec)
const
482 unsigned int tmpUnif = this->unifiedSequenceSize();
483 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
484 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::unifiedMedianExtra()"
485 <<
": initialPos = " << initialPos
486 <<
", numPos = " << numPos
487 <<
", sub sequence size = " << this->subSequenceSize()
488 <<
", unified sequence size = " << tmpUnif
492 bool bRC = ((initialPos < this->subSequenceSize() ) &&
494 ((initialPos+numPos) <= this->subSequenceSize() ) &&
495 (this->vectorSizeLocal() == unifiedMedianVec.sizeLocal()));
496 if ((bRC ==
false) && (m_env.subDisplayFile())) {
497 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedMedianExtra()"
498 <<
", initialPos = " << initialPos
499 <<
", this->subSequenceSize() = " << this->subSequenceSize()
500 <<
", numPos = " << numPos
501 <<
", this->vectorSizeLocal() = " << this->vectorSizeLocal()
502 <<
", unifiedMedianVec.sizeLocal() = " << unifiedMedianVec.sizeLocal()
509 unsigned int numParams = this->vectorSizeLocal();
510 for (
unsigned int i = 0; i < numParams; ++i) {
511 this->extractScalarSeq(initialPos,
516 unifiedMedianVec[i] = data.
unifiedMedianExtra(m_vectorSpace.numOfProcsForStorage() == 1,
521 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
522 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::unifiedMedianExtra()"
523 <<
": initialPos = " << initialPos
524 <<
", numPos = " << numPos
525 <<
", sub sequence size = " << this->subSequenceSize()
526 <<
", unified sequence size = " << tmpUnif
527 <<
", unifiedMedianVec = " << unifiedMedianVec
534 template <
class V,
class M>
537 unsigned int initialPos,
542 bool bRC = ((initialPos < this->subSequenceSize()) &&
544 ((initialPos+numPos) <= this->subSequenceSize()) &&
545 (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
546 (this->vectorSizeLocal() == samVec.sizeLocal() ));
551 unsigned int numParams = this->vectorSizeLocal();
552 for (
unsigned int i = 0; i < numParams; ++i) {
553 this->extractScalarSeq(initialPos,
566 template <
class V,
class M>
569 unsigned int initialPos,
571 const V& unifiedMeanVec,
572 V& unifiedSamVec)
const
574 bool bRC = ((initialPos < this->subSequenceSize() ) &&
576 ((initialPos+numPos) <= this->subSequenceSize() ) &&
577 (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
578 (this->vectorSizeLocal() == unifiedSamVec.sizeLocal() ));
583 unsigned int numParams = this->vectorSizeLocal();
584 for (
unsigned int i = 0; i < numParams; ++i) {
585 this->extractScalarSeq(initialPos,
599 template <
class V,
class M>
602 unsigned int initialPos,
607 bool bRC = ((initialPos < this->subSequenceSize()) &&
609 ((initialPos+numPos) <= this->subSequenceSize()) &&
610 (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
611 (this->vectorSizeLocal() == stdvec.sizeLocal() ));
616 unsigned int numParams = this->vectorSizeLocal();
617 for (
unsigned int i = 0; i < numParams; ++i) {
618 this->extractScalarSeq(initialPos,
631 template <
class V,
class M>
634 unsigned int initialPos,
636 const V& unifiedMeanVec,
637 V& unifiedStdVec)
const
639 bool bRC = ((initialPos < this->subSequenceSize() ) &&
641 ((initialPos+numPos) <= this->subSequenceSize() ) &&
642 (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
643 (this->vectorSizeLocal() == unifiedStdVec.sizeLocal() ));
648 unsigned int numParams = this->vectorSizeLocal();
649 for (
unsigned int i = 0; i < numParams; ++i) {
650 this->extractScalarSeq(initialPos,
655 unifiedStdVec[i] = data.
unifiedSampleStd(m_vectorSpace.numOfProcsForStorage() == 1,
664 template <
class V,
class M>
667 unsigned int initialPos,
672 bool bRC = ((initialPos < this->subSequenceSize()) &&
674 ((initialPos+numPos) <= this->subSequenceSize()) &&
675 (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
676 (this->vectorSizeLocal() == popVec.sizeLocal() ));
681 unsigned int numParams = this->vectorSizeLocal();
682 for (
unsigned int i = 0; i < numParams; ++i) {
683 this->extractScalarSeq(initialPos,
696 template <
class V,
class M>
699 unsigned int initialPos,
701 const V& unifiedMeanVec,
702 V& unifiedPopVec)
const
704 bool bRC = ((initialPos < this->subSequenceSize() ) &&
706 ((initialPos+numPos) <= this->subSequenceSize() ) &&
707 (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
708 (this->vectorSizeLocal() == unifiedPopVec.sizeLocal() ));
713 unsigned int numParams = this->vectorSizeLocal();
714 for (
unsigned int i = 0; i < numParams; ++i) {
715 this->extractScalarSeq(initialPos,
729 template <
class V,
class M>
732 unsigned int initialPos,
738 bool bRC = ((initialPos < this->subSequenceSize()) &&
740 ((initialPos+numPos) <= this->subSequenceSize()) &&
741 (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
743 (this->vectorSizeLocal() == covVec.sizeLocal() ));
748 unsigned int numParams = this->vectorSizeLocal();
749 for (
unsigned int i = 0; i < numParams; ++i) {
750 this->extractScalarSeq(initialPos,
764 template <
class V,
class M>
767 unsigned int initialPos,
772 bool bRC = ((initialPos < this->subSequenceSize()) &&
774 ((initialPos+numPos) <= this->subSequenceSize()) &&
776 (this->vectorSizeLocal() == corrVec.sizeLocal() ));
781 unsigned int numParams = this->vectorSizeLocal();
782 for (
unsigned int i = 0; i < numParams; ++i) {
783 this->extractScalarSeq(initialPos,
796 template <
class V,
class M>
799 unsigned int initialPos,
801 const std::vector<unsigned int>& lags,
802 std::vector<V*>& corrVecs)
const
804 bool bRC = ((initialPos < this->subSequenceSize()) &&
806 ((initialPos+numPos) <= this->subSequenceSize()) &&
807 (0 < lags.size() ) &&
808 (lags[lags.size()-1] < numPos ));
811 for (
unsigned int j = lags.size(); j < corrVecs.size(); ++j) {
812 if (corrVecs[j] != NULL) {
817 corrVecs.resize(lags.size(),NULL);
818 for (
unsigned int j = 0; j < corrVecs.size(); ++j) {
819 if (corrVecs[j] == NULL) corrVecs[j] =
new V(m_vectorSpace.zeroVector());
823 unsigned int maxLag = lags[lags.size()-1];
824 std::vector<double> autoCorrs(maxLag+1,0.);
826 unsigned int numParams = this->vectorSizeLocal();
827 for (
unsigned int i = 0; i < numParams; ++i) {
828 this->extractScalarSeq(initialPos,
847 for (
unsigned int j = 0; j < lags.size(); ++j) {
848 (*(corrVecs[j]))[i] = autoCorrs[lags[j]];
855 template <
class V,
class M>
858 unsigned int initialPos,
861 V& autoCorrsSumVec)
const
863 bool bRC = ((initialPos < this->subSequenceSize()) &&
865 ((initialPos+numPos) <= this->subSequenceSize()) &&
867 (numSum <= numPos ) &&
868 (autoCorrsSumVec.sizeLocal() == this->vectorSizeLocal()));
873 unsigned int numParams = this->vectorSizeLocal();
874 for (
unsigned int i = 0; i < numParams; ++i) {
875 this->extractScalarSeq(initialPos,
890 template <
class V,
class M>
893 unsigned int initialPos,
898 bool bRC = ((0 < numPos ) &&
899 ((initialPos+numPos) <= this->subSequenceSize()) &&
900 (this->vectorSizeLocal() == minVec.sizeLocal() ) &&
901 (this->vectorSizeLocal() == maxVec.sizeLocal() ));
905 unsigned int numParams = this->vectorSizeLocal();
908 for (
unsigned int i = 0; i < numParams; ++i) {
909 this->extractScalarSeq(initialPos,
920 template <
class V,
class M>
923 unsigned int initialPos,
926 V& unifiedMaxVec)
const
928 bool bRC = ((0 < numPos ) &&
929 ((initialPos+numPos) <= this->subSequenceSize() ) &&
930 (this->vectorSizeLocal() == unifiedMinVec.sizeLocal()) &&
931 (this->vectorSizeLocal() == unifiedMaxVec.sizeLocal()));
935 unsigned int numParams = this->vectorSizeLocal();
938 for (
unsigned int i = 0; i < numParams; ++i) {
939 this->extractScalarSeq(initialPos,
954 template <
class V,
class M>
957 unsigned int initialPos,
960 std::vector<V*>& centersForAllBins,
961 std::vector<V*>& quanttsForAllBins)
const
963 bool bRC = ((initialPos < this->subSequenceSize() ) &&
964 (this->vectorSizeLocal() == minVec.sizeLocal() ) &&
965 (this->vectorSizeLocal() == maxVec.sizeLocal() ) &&
966 (0 < centersForAllBins.size()) &&
967 (centersForAllBins.size() == quanttsForAllBins.size()));
970 for (
unsigned int j = 0; j < quanttsForAllBins.size(); ++j) {
971 centersForAllBins[j] =
new V(m_vectorSpace.zeroVector());
972 quanttsForAllBins [j] =
new V(m_vectorSpace.zeroVector());
975 unsigned int dataSize = this->subSequenceSize() - initialPos;
976 unsigned int numParams = this->vectorSizeLocal();
977 for (
unsigned int i = 0; i < numParams; ++i) {
979 for (
unsigned int j = 0; j < dataSize; ++j) {
980 data[j] = (*(m_seq[initialPos+j]))[i];
983 std::vector<double > centers(centersForAllBins.size(),0.);
984 std::vector<unsigned int> quantts(quanttsForAllBins.size(), 0 );
991 for (
unsigned int j = 0; j < quantts.size(); ++j) {
992 (*(centersForAllBins[j]))[i] = centers[j];
993 (*(quanttsForAllBins[j]))[i] = (double) quantts[j];
1000 template <
class V,
class M>
1003 unsigned int initialPos,
1004 const V& unifiedMinVec,
1005 const V& unifiedMaxVec,
1006 std::vector<V*>& unifiedCentersForAllBins,
1007 std::vector<V*>& unifiedQuanttsForAllBins)
const
1009 bool bRC = ((initialPos < this->subSequenceSize() ) &&
1010 (this->vectorSizeLocal() == unifiedMinVec.sizeLocal() ) &&
1011 (this->vectorSizeLocal() == unifiedMaxVec.sizeLocal() ) &&
1012 (0 < unifiedCentersForAllBins.size()) &&
1013 (unifiedCentersForAllBins.size() == unifiedQuanttsForAllBins.size()));
1016 for (
unsigned int j = 0; j < unifiedQuanttsForAllBins.size(); ++j) {
1017 unifiedCentersForAllBins[j] =
new V(m_vectorSpace.zeroVector());
1018 unifiedQuanttsForAllBins [j] =
new V(m_vectorSpace.zeroVector());
1021 unsigned int dataSize = this->subSequenceSize() - initialPos;
1022 unsigned int numParams = this->vectorSizeLocal();
1023 for (
unsigned int i = 0; i < numParams; ++i) {
1025 for (
unsigned int j = 0; j < dataSize; ++j) {
1026 data[j] = (*(m_seq[initialPos+j]))[i];
1029 std::vector<double > unifiedCenters(unifiedCentersForAllBins.size(),0.);
1030 std::vector<unsigned int> unifiedQuantts(unifiedQuanttsForAllBins.size(), 0 );
1038 for (
unsigned int j = 0; j < unifiedQuantts.size(); ++j) {
1039 (*(unifiedCentersForAllBins[j]))[i] = unifiedCenters[j];
1040 (*(unifiedQuanttsForAllBins[j]))[i] = (double) unifiedQuantts[j];
1047 template <
class V,
class M>
1050 unsigned int initialPos,
1053 bool bRC = ((initialPos < this->subSequenceSize()) &&
1054 (this->vectorSizeLocal() == iqrVec.sizeLocal() ));
1057 unsigned int numPos = this->subSequenceSize() - initialPos;
1060 unsigned int numParams = this->vectorSizeLocal();
1061 for (
unsigned int i = 0; i < numParams; ++i) {
1062 this->extractScalarSeq(initialPos,
1073 template <
class V,
class M>
1076 unsigned int initialPos,
1077 V& unifiedIqrVec)
const
1079 bool bRC = ((initialPos < this->subSequenceSize() ) &&
1080 (this->vectorSizeLocal() == unifiedIqrVec.sizeLocal()));
1083 unsigned int numPos = this->subSequenceSize() - initialPos;
1086 unsigned int numParams = this->vectorSizeLocal();
1087 for (
unsigned int i = 0; i < numParams; ++i) {
1088 this->extractScalarSeq(initialPos,
1100 template <
class V,
class M>
1103 unsigned int initialPos,
1105 unsigned int kdeDimension,
1108 bool bRC = ((initialPos < this->subSequenceSize()) &&
1109 (this->vectorSizeLocal() == iqrVec.sizeLocal() ) &&
1110 (this->vectorSizeLocal() == scaleVec.sizeLocal() ));
1113 unsigned int numPos = this->subSequenceSize() - initialPos;
1116 unsigned int numParams = this->vectorSizeLocal();
1117 for (
unsigned int i = 0; i < numParams; ++i) {
1118 this->extractScalarSeq(initialPos,
1131 template <
class V,
class M>
1134 unsigned int initialPos,
1135 const V& unifiedIqrVec,
1136 unsigned int kdeDimension,
1137 V& unifiedScaleVec)
const
1139 bool bRC = ((initialPos < this->subSequenceSize() ) &&
1140 (this->vectorSizeLocal() == unifiedIqrVec.sizeLocal() ) &&
1141 (this->vectorSizeLocal() == unifiedScaleVec.sizeLocal()));
1144 unsigned int numPos = this->subSequenceSize() - initialPos;
1147 unsigned int numParams = this->vectorSizeLocal();
1148 for (
unsigned int i = 0; i < numParams; ++i) {
1149 this->extractScalarSeq(initialPos,
1154 unifiedScaleVec[i] = data.
unifiedScaleForKde(m_vectorSpace.numOfProcsForStorage() == 1,
1163 template <
class V,
class M>
1166 unsigned int initialPos,
1168 const std::vector<V*>& evalParamVecs,
1169 std::vector<V*>& densityVecs)
const
1171 bool bRC = ((initialPos < this->subSequenceSize()) &&
1172 (this->vectorSizeLocal() == scaleVec.sizeLocal() ) &&
1173 (0 < evalParamVecs.size() ) &&
1174 (evalParamVecs.size() == densityVecs.size() ));
1177 unsigned int numPos = this->subSequenceSize() - initialPos;
1180 unsigned int numEvals = evalParamVecs.size();
1181 for (
unsigned int j = 0; j < numEvals; ++j) {
1182 densityVecs[j] =
new V(m_vectorSpace.zeroVector());
1184 std::vector<double> evalParams(numEvals,0.);
1185 std::vector<double> densities (numEvals,0.);
1187 unsigned int numParams = this->vectorSizeLocal();
1188 for (
unsigned int i = 0; i < numParams; ++i) {
1189 this->extractScalarSeq(initialPos,
1195 for (
unsigned int j = 0; j < numEvals; ++j) {
1196 evalParams[j] = (*evalParamVecs[j])[i];
1204 for (
unsigned int j = 0; j < numEvals; ++j) {
1205 (*densityVecs[j])[i] = densities[j];
1212 template <
class V,
class M>
1215 unsigned int initialPos,
1216 const V& unifiedScaleVec,
1217 const std::vector<V*>& unifiedEvalParamVecs,
1218 std::vector<V*>& unifiedDensityVecs)
const
1220 bool bRC = ((initialPos < this->subSequenceSize() ) &&
1221 (this->vectorSizeLocal() == unifiedScaleVec.sizeLocal()) &&
1222 (0 < unifiedEvalParamVecs.size()) &&
1223 (unifiedEvalParamVecs.size() == unifiedDensityVecs.size() ));
1226 unsigned int numPos = this->subSequenceSize() - initialPos;
1229 unsigned int numEvals = unifiedEvalParamVecs.size();
1230 for (
unsigned int j = 0; j < numEvals; ++j) {
1231 unifiedDensityVecs[j] =
new V(m_vectorSpace.zeroVector());
1233 std::vector<double> unifiedEvalParams(numEvals,0.);
1234 std::vector<double> unifiedDensities (numEvals,0.);
1236 unsigned int numParams = this->vectorSizeLocal();
1237 for (
unsigned int i = 0; i < numParams; ++i) {
1238 this->extractScalarSeq(initialPos,
1244 for (
unsigned int j = 0; j < numEvals; ++j) {
1245 unifiedEvalParams[j] = (*unifiedEvalParamVecs[j])[i];
1254 for (
unsigned int j = 0; j < numEvals; ++j) {
1255 (*unifiedDensityVecs[j])[i] = unifiedDensities[j];
1262 template <
class V,
class M>
1265 unsigned int initialPos,
1266 unsigned int numPos,
1267 const std::string& fileName,
1268 const std::string& fileType,
1269 const std::set<unsigned int>& allowedSubEnvIds)
const
1274 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1275 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::subWriteContents()"
1276 <<
": about to try to open file '" << fileName <<
"." << fileType
1278 <<
", initialPos = " << initialPos
1279 <<
", numPos = " << numPos
1282 if (m_env.openOutputFile(fileName,
1288 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1289 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::subWriteContents()"
1290 <<
": successfully opened file '" << fileName <<
"." << fileType
1294 this->subWriteContents(initialPos,
1298 m_env.closeFile(filePtrSet,fileType);
1300 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1301 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::subWriteContents()"
1302 <<
": before Barrier()"
1305 m_env.subComm().Barrier();
1310 template <
class V,
class M>
1313 unsigned int initialPos,
1314 unsigned int numPos,
1316 const std::string& fileType)
const
1321 this->subWriteContents(initialPos,
1336 template <
class V,
class M>
1339 unsigned int initialPos,
1340 unsigned int numPos,
1342 const std::string& fileType)
const
1346 if (fileType.c_str()) {};
1348 if (initialPos == 0) {
1349 ofs << m_name <<
"_sub" << m_env.subIdString() <<
" = zeros(" << this->subSequenceSize()
1350 <<
"," << this->vectorSizeLocal()
1353 ofs << m_name <<
"_sub" << m_env.subIdString() <<
" = [";
1356 for (
unsigned int j = initialPos; j < initialPos+numPos; ++j) {
1357 bool savedVectorPrintScientific = m_seq[j]->getPrintScientific();
1358 bool savedVectorPrintState = m_seq[j]->getPrintHorizontally();
1359 m_seq[j]->setPrintScientific (
true);
1360 m_seq[j]->setPrintHorizontally(
true);
1365 m_seq[j]->setPrintHorizontally(savedVectorPrintState);
1366 m_seq[j]->setPrintScientific (savedVectorPrintScientific);
1368 if ((initialPos+numPos) == this->subSequenceSize()) {
1375 template <
class V,
class M>
1378 const std::string& fileName,
1379 const std::string& inputFileType)
const
1381 std::string fileType(inputFileType);
1382 #ifdef QUESO_HAS_HDF5
1386 if (m_env.subDisplayFile()) {
1387 *m_env.subDisplayFile() <<
"WARNING in SequenceOfVectors<V,M>::unifiedWriteContents()"
1389 <<
"' has been requested, but this QUESO library has not been built with 'hdf5'"
1394 if (m_env.subRank() == 0) {
1395 std::cerr <<
"WARNING in SequenceOfVectors<V,M>::unifiedWriteContents()"
1397 <<
"' has been requested, but this QUESO library has not been built with 'hdf5'"
1409 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1410 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::unifiedWriteContents()"
1411 <<
": worldRank " << m_env.worldRank()
1412 <<
", fullRank " << m_env.fullRank()
1413 <<
", subEnvironment " << m_env.subId()
1414 <<
", subRank " << m_env.subRank()
1415 <<
", inter0Rank " << m_env.inter0Rank()
1417 <<
", fileName = " << fileName
1421 if (m_env.inter0Rank() >= 0) {
1422 for (
unsigned int r = 0; r < (
unsigned int) m_env.inter0Comm().NumProc(); ++r) {
1423 if (m_env.inter0Rank() == (int) r) {
1425 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1426 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedWriteContents()"
1427 <<
": worldRank " << m_env.worldRank()
1428 <<
", fullRank " << m_env.fullRank()
1429 <<
", subEnvironment " << m_env.subId()
1430 <<
", subRank " << m_env.subRank()
1431 <<
", inter0Rank " << m_env.inter0Rank()
1433 <<
", fileName = " << fileName
1434 <<
", about to open file for r = " << r
1439 bool writeOver =
false;
1442 if (m_env.openUnifiedOutputFile(fileName,
1445 unifiedFilePtrSet)) {
1446 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1447 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedWriteContents()"
1448 <<
": worldRank " << m_env.worldRank()
1449 <<
", fullRank " << m_env.fullRank()
1450 <<
", subEnvironment " << m_env.subId()
1451 <<
", subRank " << m_env.subRank()
1452 <<
", inter0Rank " << m_env.inter0Rank()
1454 <<
", fileName = " << fileName
1455 <<
", just opened file for r = " << r
1459 unsigned int chainSize = this->subSequenceSize();
1462 *unifiedFilePtrSet.
ofsVar << m_name <<
"_unified" <<
" = zeros(" << this->subSequenceSize()*m_env.inter0Comm().NumProc()
1463 <<
"," << this->vectorSizeLocal()
1466 *unifiedFilePtrSet.
ofsVar << m_name <<
"_unified" <<
" = [";
1469 for (
unsigned int j = 0; j < chainSize; ++j) {
1482 bool savedVectorPrintScientific = m_seq[j]->getPrintScientific();
1483 bool savedVectorPrintState = m_seq[j]->getPrintHorizontally();
1484 m_seq[j]->setPrintScientific (
true);
1485 m_seq[j]->setPrintHorizontally(
true);
1487 *unifiedFilePtrSet.
ofsVar << *(m_seq[j])
1490 m_seq[j]->setPrintHorizontally(savedVectorPrintState);
1491 m_seq[j]->setPrintScientific (savedVectorPrintScientific);
1494 #ifdef QUESO_HAS_HDF5
1496 unsigned int numParams = m_vectorSpace.dimLocal();
1498 hid_t datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
1501 dimsf[0] = numParams;
1502 dimsf[1] = chainSize;
1503 hid_t dataspace = H5Screate_simple(2, dimsf, NULL);
1505 hid_t dataset = H5Dcreate2(unifiedFilePtrSet.h5Var,
1514 struct timeval timevalBegin;
1516 iRC = gettimeofday(&timevalBegin,NULL);
1520 std::vector<double*> dataOut((
size_t) numParams,NULL);
1521 dataOut[0] = (
double*) malloc(numParams*chainSize*
sizeof(
double));
1522 for (
unsigned int i = 1; i < numParams; ++i) {
1523 dataOut[i] = dataOut[i-1] + chainSize;
1526 for (
unsigned int j = 0; j < chainSize; ++j) {
1527 V tmpVec(*(m_seq[j]));
1528 for (
unsigned int i = 0; i < numParams; ++i) {
1529 dataOut[i][j] = tmpVec[i];
1535 status = H5Dwrite(dataset,
1540 (
void*) dataOut[0]);
1545 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1546 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedWriteContents()"
1547 <<
": worldRank " << m_env.worldRank()
1548 <<
", fullRank " << m_env.fullRank()
1549 <<
", subEnvironment " << m_env.subId()
1550 <<
", subRank " << m_env.subRank()
1551 <<
", inter0Rank " << m_env.inter0Rank()
1552 <<
", fileName = " << fileName
1553 <<
", numParams = " << numParams
1554 <<
", chainSize = " << chainSize
1555 <<
", writeTime = " << writeTime <<
" seconds"
1561 H5Sclose(dataspace);
1566 for (
unsigned int tmpIndex = 0; tmpIndex < dataOut.size(); tmpIndex++) {
1567 free (dataOut[tmpIndex]);
1571 queso_error_msg(
"hdf file type not supported for multiple sub-environments yet");
1579 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1580 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedWriteContents()"
1581 <<
": worldRank " << m_env.worldRank()
1582 <<
", fullRank " << m_env.fullRank()
1583 <<
", subEnvironment " << m_env.subId()
1584 <<
", subRank " << m_env.subRank()
1585 <<
", inter0Rank " << m_env.inter0Rank()
1587 <<
", fileName = " << fileName
1588 <<
", about to close file for r = " << r
1592 m_env.closeFile(unifiedFilePtrSet,fileType);
1594 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1595 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedWriteContents()"
1596 <<
": worldRank " << m_env.worldRank()
1597 <<
", fullRank " << m_env.fullRank()
1598 <<
", subEnvironment " << m_env.subId()
1599 <<
", subRank " << m_env.subRank()
1600 <<
", inter0Rank " << m_env.inter0Rank()
1602 <<
", fileName = " << fileName
1603 <<
", just closed file for r = " << r
1608 m_env.inter0Comm().Barrier();
1611 if (m_env.inter0Rank() == 0) {
1614 if (m_env.openUnifiedOutputFile(fileName,
1617 unifiedFilePtrSet)) {
1618 *unifiedFilePtrSet.
ofsVar <<
"];\n";
1619 m_env.closeFile(unifiedFilePtrSet,fileType);
1631 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1632 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::unifiedWriteContents()"
1633 <<
", fileName = " << fileName
1641 template <
class V,
class M>
1644 const std::string& fileName,
1645 const std::string& inputFileType,
1646 const unsigned int subReadSize)
1648 std::string fileType(inputFileType);
1649 #ifdef QUESO_HAS_HDF5
1653 if (m_env.subDisplayFile()) {
1654 *m_env.subDisplayFile() <<
"WARNING in SequenceOfVectors<V,M>::unifiedReadContents()"
1656 <<
"' has been requested, but this QUESO library has not been built with 'hdf5'"
1661 if (m_env.subRank() == 0) {
1662 std::cerr <<
"WARNING in SequenceOfVectors<V,M>::unifiedReadContents()"
1664 <<
"' has been requested, but this QUESO library has not been built with 'hdf5'"
1674 if (m_env.subDisplayFile()) {
1675 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::unifiedReadContents()"
1676 <<
": worldRank " << m_env.worldRank()
1677 <<
", fullRank " << m_env.fullRank()
1678 <<
", subEnvironment " << m_env.subId()
1679 <<
", subRank " << m_env.subRank()
1680 <<
", inter0Rank " << m_env.inter0Rank()
1682 <<
", fileName = " << fileName
1683 <<
", subReadSize = " << subReadSize
1688 this->resizeSequence(subReadSize);
1690 if (m_env.inter0Rank() >= 0) {
1691 double unifiedReadSize = subReadSize*m_env.inter0Comm().NumProc();
1694 unsigned int idOfMyFirstLine = 1 + m_env.inter0Rank()*subReadSize;
1695 unsigned int idOfMyLastLine = (1 + m_env.inter0Rank())*subReadSize;
1696 unsigned int numParams = this->vectorSizeLocal();
1698 for (
unsigned int r = 0; r < (
unsigned int) m_env.inter0Comm().NumProc(); ++r) {
1699 if (m_env.inter0Rank() == (int) r) {
1702 if (m_env.openUnifiedInputFile(fileName,
1704 unifiedFilePtrSet)) {
1709 std::string tmpString;
1712 *unifiedFilePtrSet.
ifsVar >> tmpString;
1716 *unifiedFilePtrSet.
ifsVar >> tmpString;
1721 *unifiedFilePtrSet.
ifsVar >> tmpString;
1723 unsigned int posInTmpString = 6;
1727 std::string nPositionsString((
size_t) (tmpString.size()-posInTmpString+1),
' ');
1728 unsigned int posInPositionsString = 0;
1731 nPositionsString[posInPositionsString++] = tmpString[posInTmpString++];
1732 }
while (tmpString[posInTmpString] !=
',');
1733 nPositionsString[posInPositionsString] =
'\0';
1738 std::string nParamsString((
size_t) (tmpString.size()-posInTmpString+1),
' ');
1739 unsigned int posInParamsString = 0;
1742 nParamsString[posInParamsString++] = tmpString[posInTmpString++];
1743 }
while (tmpString[posInTmpString] !=
')');
1744 nParamsString[posInParamsString] =
'\0';
1747 unsigned int sizeOfChainInFile = (
unsigned int) strtod(nPositionsString.c_str(),NULL);
1748 unsigned int numParamsInFile = (
unsigned int) strtod(nParamsString.c_str(), NULL);
1749 if (m_env.subDisplayFile()) {
1750 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedReadContents()"
1751 <<
": worldRank " << m_env.worldRank()
1752 <<
", fullRank " << m_env.fullRank()
1753 <<
", sizeOfChainInFile = " << sizeOfChainInFile
1754 <<
", numParamsInFile = " << numParamsInFile
1762 queso_require_equal_to_msg(numParamsInFile, numParams,
"number of parameters of chain in file is different than number of parameters in this chain object");
1766 unsigned int maxCharsPerLine = 64*numParams;
1768 unsigned int lineId = 0;
1769 while (lineId < idOfMyFirstLine) {
1770 unifiedFilePtrSet.
ifsVar->ignore(maxCharsPerLine,
'\n');
1777 std::string tmpString;
1780 *unifiedFilePtrSet.
ifsVar >> tmpString;
1784 *unifiedFilePtrSet.
ifsVar >> tmpString;
1789 std::streampos tmpPos = unifiedFilePtrSet.
ifsVar->tellg();
1790 unifiedFilePtrSet.
ifsVar->seekg(tmpPos+(std::streampos)2);
1793 V tmpVec(m_vectorSpace.zeroVector());
1794 while (lineId <= idOfMyLastLine) {
1795 for (
unsigned int i = 0; i < numParams; ++i) {
1796 *unifiedFilePtrSet.
ifsVar >> tmpVec[i];
1798 this->setPositionValues(lineId - idOfMyFirstLine, tmpVec);
1802 #ifdef QUESO_HAS_HDF5
1805 hid_t dataset = H5Dopen2(unifiedFilePtrSet.h5Var,
1808 hid_t datatype = H5Dget_type(dataset);
1809 H5T_class_t t_class = H5Tget_class(datatype);
1811 hid_t dataspace = H5Dget_space(dataset);
1812 int rank = H5Sget_simple_extent_ndims(dataspace);
1816 status_n = H5Sget_simple_extent_dims(dataspace, dims_in, NULL);
1825 struct timeval timevalBegin;
1827 iRC = gettimeofday(&timevalBegin,NULL);
1830 unsigned int chainSizeIn = (
unsigned int) dims_in[1];
1832 std::vector<double*>
dataIn((
size_t) numParams,NULL);
1833 dataIn[0] = (
double*) malloc(numParams*chainSizeIn*
sizeof(
double));
1834 for (
unsigned int i = 1; i < numParams; ++i) {
1835 dataIn[i] = dataIn[i-1] + chainSizeIn;
1839 status = H5Dread(dataset,
1847 V tmpVec(m_vectorSpace.zeroVector());
1848 for (
unsigned int j = 0; j < subReadSize; ++j) {
1849 for (
unsigned int i = 0; i < numParams; ++i) {
1850 tmpVec[i] = dataIn[i][j];
1852 this->setPositionValues(j, tmpVec);
1856 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1857 *m_env.subDisplayFile() <<
"In SequenceOfVectors<V,M>::unifiedReadContents()"
1858 <<
": worldRank " << m_env.worldRank()
1859 <<
", fullRank " << m_env.fullRank()
1860 <<
", subEnvironment " << m_env.subId()
1861 <<
", subRank " << m_env.subRank()
1862 <<
", inter0Rank " << m_env.inter0Rank()
1863 <<
", fileName = " << fileName
1864 <<
", numParams = " << numParams
1865 <<
", chainSizeIn = " << chainSizeIn
1866 <<
", subReadSize = " << subReadSize
1867 <<
", readTime = " << readTime <<
" seconds"
1871 H5Sclose(dataspace);
1875 for (
unsigned int tmpIndex = 0; tmpIndex < dataIn.size(); tmpIndex++) {
1876 free (dataIn[tmpIndex]);
1880 queso_error_msg(
"hdf file type not supported for multiple sub-environments yet");
1887 m_env.closeFile(unifiedFilePtrSet,fileType);
1890 m_env.inter0Comm().Barrier();
1894 V tmpVec(m_vectorSpace.zeroVector());
1895 for (
unsigned int i = 1; i < subReadSize; ++i) {
1896 this->setPositionValues(i,tmpVec);
1900 if (m_env.subDisplayFile()) {
1901 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::unifiedReadContents()"
1902 <<
", fileName = " << fileName
1910 template <
class V,
class M>
1916 if (&idsOfUniquePositions) {};
1921 template <
class V,
class M>
1924 unsigned int initialPos,
1925 unsigned int spacing)
1927 if (m_env.subDisplayFile()) {
1928 *m_env.subDisplayFile() <<
"Entering SequenceOfVectors<V,M>::filter()"
1929 <<
": initialPos = " << initialPos
1930 <<
", spacing = " << spacing
1931 <<
", subSequenceSize = " << this->subSequenceSize()
1936 unsigned int j = initialPos;
1937 unsigned int originalSubSequenceSize = this->subSequenceSize();
1938 while (j < originalSubSequenceSize) {
1942 m_seq[i] =
new V(*(m_seq[j]));
1948 this->resetValues(i,originalSubSequenceSize-i);
1949 this->resizeSequence(i);
1951 if (m_env.subDisplayFile()) {
1952 *m_env.subDisplayFile() <<
"Leaving SequenceOfVectors<V,M>::filter()"
1953 <<
": initialPos = " << initialPos
1954 <<
", spacing = " << spacing
1955 <<
", subSequenceSize = " << this->subSequenceSize()
1962 template <
class V,
class M>
1965 unsigned int initialPos,
1966 unsigned int numPos)
const
1974 double convMeasure = -1.0;
1978 if( m_env.inter0Rank() >= 0 )
1984 V psi_j_dot = m_vectorSpace.zeroVector();
1985 V psi_dot_dot = m_vectorSpace.zeroVector();
1986 V
work = m_vectorSpace.zeroVector();
1990 int m = m_env.numSubEnvironments();
1993 this->subMeanExtra ( initialPos, numPos, psi_j_dot );
1994 this->unifiedMeanExtra( initialPos, numPos, psi_dot_dot );
1997 std::cout <<
"psi_j_dot = " << psi_j_dot << std::endl;
1998 std::cout <<
"psi_dot_dot = " << psi_dot_dot << std::endl;
2004 M* W_local = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2005 M* W = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2006 V psi_j_t = m_vectorSpace.zeroVector();
2009 for(
unsigned int t = initialPos; t < initialPos+numPos; ++t )
2011 psi_j_t = *(m_seq[t]);
2013 work = psi_j_t - psi_j_dot;
2020 W_local->mpiSum( m_env.inter0Comm(), (*W) );
2022 (*W) = 1.0/(double(m)*(double(n)-1.0)) * (*W);
2025 std::cout <<
"n, m = " << n <<
", " << m << std::endl;
2026 std::cout <<
"W_local = " << *W_local << std::endl;
2027 std::cout <<
"W = " << *W << std::endl;
2037 M* B_over_n_local = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2038 M* B_over_n = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2040 work = psi_j_dot - psi_dot_dot;
2043 B_over_n_local->mpiSum( m_env.inter0Comm(), (*B_over_n) );
2046 delete B_over_n_local;
2048 (*B_over_n) = 1.0/(double(m)-1.0) * (*B_over_n);
2051 std::cout <<
"B_over_n = " << *B_over_n << std::endl;
2057 M* A = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2059 W->invertMultiply( *B_over_n, *A );
2062 std::cout <<
"A = " << *A << std::endl;
2070 V eigenVector = m_vectorSpace.zeroVector();
2072 A->largestEigen( eigenValue, eigenVector );
2078 convMeasure = (double(n)-1.0)/double(n) + (double(m)+1.0)/double(m)*eigenValue;
2089 template <
class V,
class M>
2092 unsigned int initialPos,
2093 unsigned int spacing,
2094 unsigned int numPos,
2095 unsigned int paramId,
2100 for (
unsigned int j = 0; j < numPos; ++j) {
2101 scalarSeq[j] = (*(m_seq[initialPos+j ]))[paramId];
2105 for (
unsigned int j = 0; j < numPos; ++j) {
2106 scalarSeq[j] = (*(m_seq[initialPos+j*spacing]))[paramId];
2113 template <
class V,
class M>
2118 for (
unsigned int i = 0; i < (
unsigned int) m_seq.size(); ++i) {
2125 for (
unsigned int i = 0; i < m_seq.size(); ++i) {
2126 m_seq[i] =
new V(*(src.
m_seq[i]));
2132 template <
class V,
class M>
2135 unsigned int initialPos,
2136 unsigned int spacing,
2137 unsigned int numPos,
2138 unsigned int paramId,
2139 std::vector<double>& rawData)
const
2141 rawData.resize(numPos);
2143 for (
unsigned int j = 0; j < numPos; ++j) {
2144 rawData[j] = (*(m_seq[initialPos+j ]))[paramId];
2148 for (
unsigned int j = 0; j < numPos; ++j) {
2149 rawData[j] = (*(m_seq[initialPos+j*spacing]))[paramId];
2160 #ifdef UQ_SEQ_VEC_USES_OPERATOR
2161 template <
class V,
class M>
2167 return (
const V*) (m_seq[posId]);
2170 template <
class V,
class M>
2172 SequenceOfVectors<V,M>::operator[](
unsigned int posId)
2176 return m_seq[posId];
2184 #ifdef UQ_ALSO_COMPUTE_MDFS_WITHOUT_KDE
2185 template <
class V,
class M>
2187 SequenceOfVectors<V,M>::subUniformlySampledMdf(
2188 const V& numEvaluationPointsVec,
2189 ArrayOfOneDGrids <V,M>& mdfGrids,
2190 ArrayOfOneDTables<V,M>& mdfValues)
const
2192 V minDomainValues(m_vectorSpace.zeroVector());
2193 V maxDomainValues(m_vectorSpace.zeroVector());
2195 ScalarSequence<double> data(m_env,0,
"");
2197 unsigned int numParams = this->vectorSizeLocal();
2198 for (
unsigned int i = 0; i < numParams; ++i) {
2199 this->extractScalarSeq(0,
2205 std::vector<double> aMdf(0);
2206 data.subUniformlySampledMdf((
unsigned int) numEvaluationPointsVec[i],
2210 mdfValues.setOneDTable(i,aMdf);
2213 mdfGrids.setUniformGrids(numEvaluationPointsVec,
2225 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
2226 template <
class V,
class M>
2228 SequenceOfVectors<V,M>::subMeanCltStd(
2229 unsigned int initialPos,
2230 unsigned int numPos,
2234 bool bRC = ((initialPos < this->subSequenceSize()) &&
2236 ((initialPos+numPos) <= this->subSequenceSize()) &&
2237 (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
2238 (this->vectorSizeLocal() == stdVec.sizeLocal() ));
2241 ScalarSequence<double> data(m_env,0,
"");
2243 unsigned int numParams = this->vectorSizeLocal();
2244 for (
unsigned int i = 0; i < numParams; ++i) {
2245 this->extractScalarSeq(initialPos,
2250 stdVec[i] = data.subMeanCltStd(0,
2258 template <
class V,
class M>
2260 SequenceOfVectors<V,M>::unifiedMeanCltStd(
2261 unsigned int initialPos,
2262 unsigned int numPos,
2263 const V& unifiedMeanVec,
2264 V& unifiedSamVec)
const
2266 bool bRC = ((initialPos < this->subSequenceSize() ) &&
2268 ((initialPos+numPos) <= this->subSequenceSize() ) &&
2269 (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
2270 (this->vectorSizeLocal() == unifiedSamVec.sizeLocal() ));
2273 ScalarSequence<double> data(m_env,0,
"");
2275 unsigned int numParams = this->vectorSizeLocal();
2276 for (
unsigned int i = 0; i < numParams; ++i) {
2277 this->extractScalarSeq(initialPos,
2282 unifiedSamVec[i] = data.unifiedMeanCltStd(m_vectorSpace.numOfProcsForStorage() == 1,
2291 template <
class V,
class M>
2293 SequenceOfVectors<V,M>::bmm(
2294 unsigned int initialPos,
2295 unsigned int batchLength,
2298 bool bRC = ((initialPos < this->subSequenceSize() ) &&
2299 (batchLength < (this->subSequenceSize()-initialPos)) &&
2300 (this->vectorSizeLocal() == bmmVec.sizeLocal() ));
2303 ScalarSequence<double> data(m_env,0,
"");
2305 unsigned int numParams = this->vectorSizeLocal();
2306 for (
unsigned int i = 0; i < numParams; ++i) {
2307 this->extractScalarSeq(initialPos,
2309 this->subSequenceSize()-initialPos,
2312 bmmVec[i] = data.bmm(0,
2319 template <
class V,
class M>
2321 SequenceOfVectors<V,M>::fftForward(
2322 unsigned int initialPos,
2323 unsigned int fftSize,
2324 unsigned int paramId,
2325 std::vector<std::complex<double> >& fftResult)
const
2327 bool bRC = ((initialPos < this->subSequenceSize()) &&
2328 (paramId < this->vectorSizeLocal()) &&
2330 ((initialPos+fftSize) <= this->subSequenceSize()) &&
2331 (fftSize < this->subSequenceSize()));
2334 std::vector<double> rawData(fftSize,0.);
2335 this->extractRawData(initialPos,
2341 m_fftObj->forward(rawData,fftSize,fftResult);
2346 template <
class V,
class M>
2348 SequenceOfVectors<V,M>::psd(
2349 unsigned int initialPos,
2350 unsigned int numBlocks,
2351 double hopSizeRatio,
2352 unsigned int paramId,
2353 std::vector<double>& psdResult)
const
2355 bool bRC = ((initialPos < this->subSequenceSize()) &&
2356 (paramId < this->vectorSizeLocal()));
2359 ScalarSequence<double> data(m_env,0,
"");
2361 this->extractScalarSeq(initialPos,
2363 this->subSequenceSize()-initialPos,
2374 template <
class V,
class M>
2376 SequenceOfVectors<V,M>::psdAtZero(
2377 unsigned int initialPos,
2378 unsigned int numBlocks,
2379 double hopSizeRatio,
2382 bool bRC = ((initialPos < this->subSequenceSize()) &&
2383 (this->vectorSizeLocal() == psdVec.sizeLocal()));
2386 ScalarSequence<double> data(m_env,0,
"");
2387 std::vector<double> psdResult(0,0.);
2389 unsigned int numParams = this->vectorSizeLocal();
2390 for (
unsigned int i = 0; i < numParams; ++i) {
2391 this->extractScalarSeq(initialPos,
2393 this->subSequenceSize()-initialPos,
2400 psdVec[i] = psdResult[0];
2407 template <
class V,
class M>
2409 SequenceOfVectors<V,M>::geweke(
2410 unsigned int initialPos,
2415 bool bRC = ((initialPos < this->subSequenceSize()) &&
2416 (this->vectorSizeLocal() == gewVec.sizeLocal() ));
2419 unsigned int numPos = this->subSequenceSize() - initialPos;
2420 ScalarSequence<double> data(m_env,0,
"");
2422 unsigned int numParams = this->vectorSizeLocal();
2423 for (
unsigned int i = 0; i < numParams; ++i) {
2424 this->extractScalarSeq(initialPos,
2429 gewVec[i] = data.geweke(0,
2437 template <
class V,
class M>
2439 SequenceOfVectors<V,M>::meanStacc(
2440 unsigned int initialPos,
2441 V& meanStaccVec)
const
2443 bool bRC = ((initialPos < this->subSequenceSize() ) &&
2444 (this->vectorSizeLocal() == meanStaccVec.sizeLocal()));
2447 unsigned int numPos = this->subSequenceSize() - initialPos;
2448 ScalarSequence<double> data(m_env,0,
"");
2450 unsigned int numParams = this->vectorSizeLocal();
2451 for (
unsigned int i = 0; i < numParams; ++i) {
2452 this->extractScalarSeq(initialPos,
2457 meanStaccVec[i] = data.meanStacc(0);
2463 template <
class V,
class M>
2465 SequenceOfVectors<V,M>::subCdfPercentageRange(
2466 unsigned int initialPos,
2467 unsigned int numPos,
2472 bool bRC = ((0 < numPos ) &&
2473 ((initialPos+numPos) <= this->subSequenceSize()) &&
2474 (this->vectorSizeLocal() == lowerVec.sizeLocal() ) &&
2475 (this->vectorSizeLocal() == upperVec.sizeLocal() ));
2478 unsigned int numParams = this->vectorSizeLocal();
2479 ScalarSequence<double> data(m_env,0,
"");
2481 for (
unsigned int i = 0; i < numParams; ++i) {
2482 this->extractScalarSeq(initialPos,
2487 data.subCdfPercentageRange(0,
2497 template <
class V,
class M>
2499 SequenceOfVectors<V,M>::unifiedCdfPercentageRange(
2500 unsigned int initialPos,
2501 unsigned int numPos,
2506 bool bRC = ((0 < numPos ) &&
2507 ((initialPos+numPos) <= this->subSequenceSize()) &&
2508 (this->vectorSizeLocal() == lowerVec.sizeLocal() ) &&
2509 (this->vectorSizeLocal() == upperVec.sizeLocal() ));
2512 unsigned int numParams = this->vectorSizeLocal();
2513 ScalarSequence<double> data(m_env,0,
"");
2515 for (
unsigned int i = 0; i < numParams; ++i) {
2516 this->extractScalarSeq(initialPos,
2521 data.unifiedCdfPercentageRange(m_vectorSpace.numOfProcsForStorage() == 1,
2532 template <
class V,
class M>
2534 SequenceOfVectors<V,M>::subCdfStacc(
2535 unsigned int initialPos,
2536 std::vector<V*>& cdfStaccVecs,
2537 std::vector<V*>& cdfStaccVecsUp,
2538 std::vector<V*>& cdfStaccVecsLow,
2539 std::vector<V*>& sortedDataVecs)
const
2541 bool bRC = (initialPos < this->subSequenceSize());
2544 unsigned int numPos = this->subSequenceSize() - initialPos;
2545 unsigned int numEvals = numPos;
2546 for (
unsigned int j = 0; j < numEvals; ++j) {
2547 cdfStaccVecs [j] =
new V(m_vectorSpace.zeroVector());
2548 cdfStaccVecsUp [j] =
new V(m_vectorSpace.zeroVector());
2549 cdfStaccVecsLow[j] =
new V(m_vectorSpace.zeroVector());
2550 sortedDataVecs [j] =
new V(m_vectorSpace.zeroVector());
2552 std::vector<double> cdfStaccs (numEvals,0.);
2553 std::vector<double> cdfStaccsup (numEvals,0.);
2554 std::vector<double> cdfStaccslow(numEvals,0.);
2556 ScalarSequence<double> data (m_env,0,
"");
2557 ScalarSequence<double> sortedData(m_env,0,
"");
2558 unsigned int numParams = this->vectorSizeLocal();
2559 for (
unsigned int i = 0; i < numParams; ++i) {
2560 this->extractScalarSeq(initialPos,
2566 data.subSort(initialPos,sortedData);
2567 data.subCdfStacc(initialPos,
2573 for (
unsigned int j = 0; j < numEvals; ++j) {
2574 (*sortedDataVecs [j])[i] = sortedData [j];
2575 (*cdfStaccVecs [j])[i] = cdfStaccs [j];
2576 (*cdfStaccVecsUp [j])[i] = cdfStaccsup [j];
2577 (*cdfStaccVecsLow[j])[i] = cdfStaccslow[j];
2584 template <
class V,
class M>
2586 SequenceOfVectors<V,M>::subCdfStacc(
2587 unsigned int initialPos,
2588 const std::vector<V*>& evalPositionsVecs,
2589 std::vector<V*>& cdfStaccVecs)
const
2591 bool bRC = ((initialPos < this->subSequenceSize() ) &&
2592 (0 < evalPositionsVecs.size()) &&
2593 (evalPositionsVecs.size() == cdfStaccVecs.size() ));
2596 unsigned int numPos = this->subSequenceSize() - initialPos;
2597 ScalarSequence<double> data(m_env,0,
"");
2599 unsigned int numEvals = evalPositionsVecs.size();
2600 for (
unsigned int j = 0; j < numEvals; ++j) {
2601 cdfStaccVecs[j] =
new V(m_vectorSpace.zeroVector());
2603 std::vector<double> evalPositions(numEvals,0.);
2604 std::vector<double> cdfStaccs (numEvals,0.);
2606 unsigned int numParams = this->vectorSizeLocal();
2607 for (
unsigned int i = 0; i < numParams; ++i) {
2608 this->extractScalarSeq(initialPos,
2614 for (
unsigned int j = 0; j < numEvals; ++j) {
2615 evalPositions[j] = (*evalPositionsVecs[j])[i];
2622 for (
unsigned int j = 0; j < numEvals; ++j) {
2623 (*cdfStaccVecs[j])[i] = cdfStaccs[j];
2629 #endif // #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
2635 #ifdef UQ_CODE_HAS_MONITORS
2636 template <
class V,
class M>
2638 SequenceOfVectors<V,M>::subMeanMonitorAlloc(
unsigned int numberOfMonitorPositions)
2640 m_subMeanMonitorPosSeq =
new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+
"_subMeanMonitorPosSeq").c_str());
2641 m_subMeanVecSeq =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanVecSeq").c_str() );
2642 m_subMeanCltStdSeq =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanCltStdSeq").c_str() );
2647 template <
class V,
class M>
2649 SequenceOfVectors<V,M>::subMeanInter0MonitorAlloc(
unsigned int numberOfMonitorPositions)
2651 m_subMeanInter0MonitorPosSeq =
new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+
"_subMeanInter0MonitorPosSeq").c_str() );
2652 m_subMeanInter0Mean =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanInter0MeanSeq").c_str() );
2653 m_subMeanInter0Clt95 =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanInter0Clt95Seq").c_str() );
2654 m_subMeanInter0Empirical90 =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanInter0Empirical90Seq").c_str());
2655 m_subMeanInter0Min =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanInter0MinSeq").c_str() );
2656 m_subMeanInter0Max =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_subMeanInter0MaxSeq").c_str() );
2661 template <
class V,
class M>
2663 SequenceOfVectors<V,M>::unifiedMeanMonitorAlloc(
unsigned int numberOfMonitorPositions)
2665 m_unifiedMeanMonitorPosSeq =
new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+
"_unifiedMeanMonitorPosSeq").c_str());
2666 m_unifiedMeanVecSeq =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_unifiedMeanVecSeq").c_str() );
2667 m_unifiedMeanCltStdSeq =
new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+
"_unifiedMeanCltStdSeq").c_str() );
2672 template <
class V,
class M>
2674 SequenceOfVectors<V,M>::subMeanMonitorRun(
unsigned int monitorPosition,
2678 this->subMeanExtra(0,
2682 this->subMeanCltStd(0,
2690 template <
class V,
class M>
2692 SequenceOfVectors<V,M>::subMeanInter0MonitorRun(
unsigned int monitorPosition,
2693 V& subMeanInter0Mean,
2694 V& subMeanInter0Clt95,
2695 V& subMeanInter0Empirical90,
2696 V& subMeanInter0Min,
2697 V& subMeanInter0Max)
2699 V subMeanVec(m_vectorSpace.zeroVector());
2700 this->subMeanExtra(0,
2704 subMeanVec.mpiAllReduce(
RawValue_MPI_SUM,m_env.inter0Comm(),subMeanInter0Mean);
2705 subMeanInter0Mean /= ((double) m_env.inter0Comm().NumProc());
2707 V subMeanInter0CltVariance = subMeanVec-subMeanInter0Mean;
2708 subMeanInter0CltVariance *= subMeanInter0CltVariance;
2709 subMeanInter0CltVariance.mpiAllReduce(
RawValue_MPI_SUM,m_env.inter0Comm(),subMeanInter0Clt95);
2710 subMeanInter0Clt95 /= ((double) (m_env.inter0Comm().NumProc()-1));
2711 subMeanInter0Clt95 /= ((double) (m_env.inter0Comm().NumProc()-1));
2712 subMeanInter0Clt95.cwSqrt();
2713 subMeanInter0Clt95 *= 3.;
2715 V subMeanInter0Quantile5(m_vectorSpace.zeroVector());
2716 subMeanVec.mpiAllQuantile(.05,m_env.inter0Comm(),subMeanInter0Quantile5);
2717 V subMeanInter0Quantile95(m_vectorSpace.zeroVector());
2718 subMeanVec.mpiAllQuantile(.95,m_env.inter0Comm(),subMeanInter0Quantile95);
2719 subMeanInter0Empirical90 = subMeanInter0Quantile95 - subMeanInter0Quantile5;
2721 subMeanVec.mpiAllReduce(
RawValue_MPI_MIN,m_env.inter0Comm(),subMeanInter0Min);
2723 subMeanVec.mpiAllReduce(
RawValue_MPI_MAX,m_env.inter0Comm(),subMeanInter0Max);
2728 template <
class V,
class M>
2730 SequenceOfVectors<V,M>::unifiedMeanMonitorRun(
unsigned int monitorPosition,
2732 V& unifiedMeanCltStd)
2734 this->unifiedMeanExtra(0,
2738 this->unifiedMeanCltStd(0,
2745 template <
class V,
class M>
2747 SequenceOfVectors<V,M>::subMeanMonitorStore(
unsigned int i,
2748 unsigned int monitorPosition,
2749 const V& subMeanVec,
2750 const V& subMeanCltStd)
2752 (*m_subMeanMonitorPosSeq)[i] = monitorPosition;
2753 m_subMeanVecSeq->setPositionValues(i,subMeanVec);
2754 m_subMeanCltStdSeq->setPositionValues(i,subMeanCltStd);
2759 template <
class V,
class M>
2761 SequenceOfVectors<V,M>::subMeanInter0MonitorStore(
unsigned int i,
2762 unsigned int monitorPosition,
2763 const V& subMeanInter0Mean,
2764 const V& subMeanInter0Clt95,
2765 const V& subMeanInter0Empirical90,
2766 const V& subMeanInter0Min,
2767 const V& subMeanInter0Max)
2769 (*m_subMeanInter0MonitorPosSeq)[i] = monitorPosition;
2770 m_subMeanInter0Mean->setPositionValues(i,subMeanInter0Mean);
2771 m_subMeanInter0Clt95->setPositionValues(i,subMeanInter0Clt95);
2772 m_subMeanInter0Empirical90->setPositionValues(i,subMeanInter0Empirical90);
2773 m_subMeanInter0Min->setPositionValues(i,subMeanInter0Min);
2774 m_subMeanInter0Max->setPositionValues(i,subMeanInter0Max);
2779 template <
class V,
class M>
2781 SequenceOfVectors<V,M>::unifiedMeanMonitorStore(
unsigned int i,
2782 unsigned int monitorPosition,
2784 V& unifiedMeanCltStd)
2786 (*m_unifiedMeanMonitorPosSeq)[i] = monitorPosition;
2787 m_unifiedMeanVecSeq->setPositionValues(i,unifiedMeanVec);
2788 m_unifiedMeanCltStdSeq->setPositionValues(i,unifiedMeanCltStd);
2793 template <
class V,
class M>
2795 SequenceOfVectors<V,M>::subMeanMonitorWrite(std::ofstream& ofs)
2804 template <
class V,
class M>
2806 SequenceOfVectors<V,M>::subMeanInter0MonitorWrite(std::ofstream& ofs)
2818 template <
class V,
class M>
2820 SequenceOfVectors<V,M>::unifiedMeanMonitorWrite(std::ofstream& ofs)
2831 template <
class V,
class M>
2833 SequenceOfVectors<V,M>::subMeanMonitorFree()
2835 delete m_subMeanMonitorPosSeq;
2836 m_subMeanMonitorPosSeq = NULL;
2837 delete m_subMeanVecSeq;
2838 m_subMeanVecSeq = NULL;
2839 delete m_subMeanCltStdSeq;
2840 m_subMeanCltStdSeq = NULL;
2845 template <
class V,
class M>
2847 SequenceOfVectors<V,M>::subMeanInter0MonitorFree()
2849 delete m_subMeanInter0MonitorPosSeq;
2850 m_subMeanInter0MonitorPosSeq = NULL;
2851 delete m_subMeanInter0Mean;
2852 m_subMeanInter0Mean = NULL;
2853 delete m_subMeanInter0Clt95;
2854 m_subMeanInter0Clt95 = NULL;
2855 delete m_subMeanInter0Empirical90;
2856 m_subMeanInter0Empirical90 = NULL;
2857 delete m_subMeanInter0Min;
2858 m_subMeanInter0Min = NULL;
2859 delete m_subMeanInter0Max;
2860 m_subMeanInter0Max = NULL;
2865 template <
class V,
class M>
2867 SequenceOfVectors<V,M>::unifiedMeanMonitorFree()
2869 delete m_unifiedMeanMonitorPosSeq;
2870 m_unifiedMeanMonitorPosSeq = NULL;
2871 delete m_unifiedMeanVecSeq;
2872 m_unifiedMeanVecSeq = NULL;
2873 delete m_unifiedMeanCltStdSeq;
2874 m_unifiedMeanCltStdSeq = NULL;
2878 #endif // #ifdef UQ_CODE_HAS_MONITORS
Class to accommodate arrays of one-dimensional grid.
T autoCorrViaDef(unsigned int initialPos, unsigned int numPos, unsigned int lag) const
Calculates the autocorrelation via definition.
void autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
Calculates the autocovariance.
void unifiedPopulationVariance(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedPopVec) const
Finds the population variance of the unified sequence, considering numPos positions starting at posit...
void subMeanExtra(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
void subScalesForKde(unsigned int initialPos, const V &iqrVec, unsigned int kdeDimension, V &scaleVec) const
Selects the scales (bandwidth, scaleVec) for the kernel density estimation, considering only the sub-...
void unifiedGaussian1dKde(unsigned int initialPos, const V &unifiedScaleVec, const std::vector< V * > &unifiedEvalParamVecs, std::vector< V * > &unifiedDensityVecs) const
Gaussian kernel for the KDE estimate of the unified sequence.
SequenceOfVectors< V, M > & operator=(const SequenceOfVectors< V, M > &rhs)
Copies values from rhs to this.
void setOneDTable(unsigned int rowId, const std::vector< double > &values)
Sets the one-dimensional table.
void subMinMaxExtra(unsigned int initialPos, unsigned int numPos, V &minVec, V &maxVec) const
Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting a...
T subInterQuantileRange(unsigned int initialPos) const
Returns the interquartile range of the values in the sub-sequence.
SequenceOfVectors(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
std::vector< const V * > m_seq
Sequence of vectors.
T unifiedMeanExtra(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int localNumPos) const
Finds the mean value of the unified sequence of numPos positions starting at position initialPos...
void subHistogram(unsigned int initialPos, const T &minHorizontalValue, const T &maxHorizontalValue, std::vector< T > ¢ers, std::vector< unsigned int > &bins) const
Calculates the histogram of the sub-sequence.
T autoCovariance(unsigned int initialPos, unsigned int numPos, const T &meanValue, unsigned int lag) const
Calculates the autocovariance.
#define UQ_FILE_EXTENSION_FOR_HDF_FORMAT
void deleteStoredVectors()
Deletes all the stored vectors.
T subMeanExtra(unsigned int initialPos, unsigned int numPos) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
void resizeSequence(unsigned int newSequenceSize)
Resizes the size of the sequence of scalars.
void filter(unsigned int initialPos, unsigned int spacing)
Filters positions in the sequence of vectors.
void unifiedReadContents(const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)
Reads the unified sequence from a file.
std::ofstream * ofsVar
Provides a stream interface to write data to files.
Struct for handling data input and output from files.
void subMinMaxExtra(unsigned int initialPos, unsigned int numPos, T &minValue, T &maxValue) const
Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting a...
#define queso_require_less_equal_msg(expr1, expr2, msg)
T unifiedPopulationVariance(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int numPos, const T &unifiedMeanValue) const
Finds the population variance of the unified sequence, considering numPos positions starting at posit...
#define queso_error_msg(msg)
T subMedianExtra(unsigned int initialPos, unsigned int numPos) const
Finds the median value of the sub-sequence, considering numPos positions starting at position initial...
void subSampleVarianceExtra(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
Finds the sample variance of the sub-sequence, considering numPos positions starting at position init...
void subInterQuantileRange(unsigned int initialPos, V &iqrVec) const
Returns the interquartile range of the values in the sub-sequence.
T unifiedScaleForKde(bool useOnlyInter0Comm, unsigned int initialPos, const T &unifiedIqrValue, unsigned int kdeDimension) const
Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence...
~SequenceOfVectors()
Destructor.
void autoCorrViaFft(unsigned int initialPos, unsigned int numPos, unsigned int maxLag, std::vector< T > &autoCorrs) const
Calculates the autocorrelation via Fast Fourier transforms (FFT).
void select(const std::vector< unsigned int > &idsOfUniquePositions)
TODO: It shall select positions in the sequence of vectors.
T subSampleStd(unsigned int initialPos, unsigned int numPos, const T &meanValue) const
Finds the sample standard deviation of the unified sequence, considering numPos positions starting at...
void resetValues(unsigned int initialPos, unsigned int numPos)
Resets a total of numPos values of the sequence starting at position initialPos.
void unifiedUniformlySampledCdf(const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &unifiedCdfGrids, ArrayOfOneDTables< V, M > &unifiedCdfValues) const
Uniformly samples from the CDF from the sub-sequence.
T subScaleForKde(unsigned int initialPos, const T &iqrValue, unsigned int kdeDimension) const
Selects the scales (output value) for the kernel density estimation, considering only the sub-sequenc...
void unifiedMeanExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
Finds the mean value of the unified sequence, considering numPos positions starting at position initi...
void subPopulationVariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &popVec) const
Finds the population variance of the sub-sequence, considering numPos positions starting at position ...
void subSampleStd(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &stdVec) const
Finds the sample standard deviation of the sub-sequence, considering numPos positions starting at pos...
#define queso_require_equal_to_msg(expr1, expr2, msg)
void subUniformlySampledCdf(const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &cdfGrids, ArrayOfOneDTables< V, M > &cdfValues) const
Uniformly samples from the CDF from the sub-sequence.
void autoCorrViaDef(unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const
Calculates the autocorrelation via definition.
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
void setPositionValues(unsigned int posId, const V &vec)
Set the values in vec at position posId of the sequence.
double MiscGetEllapsedSeconds(struct timeval *timeval0)
#define queso_require_msg(asserted, msg)
void unifiedMinMaxExtra(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int numPos, T &unifiedMinValue, T &unifiedMaxValue) const
Finds the minimum and the maximum values of the unified sequence, considering numPos positions starti...
double estimateConvBrooksGelman(unsigned int initialPos, unsigned int numPos) const
Estimates convergence rate using Brooks & Gelman method.
std::vector< const V * >::iterator seqVectorPositionIteratorTypedef
#define queso_require_less_msg(expr1, expr2, msg)
T unifiedInterQuantileRange(bool useOnlyInter0Comm, unsigned int initialPos) const
Returns the interquartile range of the values in the unified sequence.
void unifiedSampleVarianceExtra(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const
Finds the sample variance of the unified sequence, considering numPos positions starting at position ...
void unifiedHistogram(bool useOnlyInter0Comm, unsigned int initialPos, const T &unifiedMinHorizontalValue, const T &unifiedMaxHorizontalValue, std::vector< T > &unifiedCenters, std::vector< unsigned int > &unifiedBins) const
Calculates the histogram of the unified sequence.
T unifiedSampleStd(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int localNumPos, const T &unifiedMeanValue) const
Finds the sample standard deviation of the unified sequence, considering localnumPos positions starti...
GslMatrix matrixProduct(const GslVector &v1, const GslVector &v2)
void unifiedGaussian1dKde(bool useOnlyInter0Comm, unsigned int initialPos, double unifiedScaleValue, const std::vector< T > &unifiedEvaluationPositions, std::vector< double > &unifiedDensityValues) const
Gaussian kernel for the KDE estimate of the unified sequence.
#define UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT
T unifiedSampleVarianceExtra(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int localNumPos, const T &unifiedMeanValue) const
Finds the sample variance of the unified sequence, considering numPos positions starting at position ...
void unifiedScalesForKde(unsigned int initialPos, const V &unifiedIqrVec, unsigned int kdeDimension, V &unifiedScaleVec) const
Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence...
Class to accommodate arrays of one-dimensional tables.
void extractRawData(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
Extracts the raw data.
void setUniformGrids(const V &sizesVec, const V &minPositionsVec, const V &maxPositionsVec)
Sets an array of uniform grids.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void subMedianExtra(unsigned int initialPos, unsigned int numPos, V &medianVec) const
Finds the median value of the sub-sequence, considering numPos positions starting at position initial...
void getPositionValues(unsigned int posId, V &vec) const
Gets the values of the sequence at position posId and stores them at vec.
void unifiedInterQuantileRange(unsigned int initialPos, V &unifiedIqrVec) const
Returns the interquartile range of the values in the unified sequence.
void unifiedHistogram(unsigned int initialPos, const V &unifiedMinVec, const V &unifiedMaxVec, std::vector< V * > &unifiedCentersForAllBins, std::vector< V * > &unifiedQuanttsForAllBins) const
Calculates the histogram of the unified sequence.
#define queso_require_greater_equal_msg(expr1, expr2, msg)
std::ifstream * ifsVar
Provides a stream interface to read data from files.
void resizeSequence(unsigned int newSubSequenceSize)
Resizes the sequence.
void subGaussian1dKde(unsigned int initialPos, double scaleValue, const std::vector< T > &evaluationPositions, std::vector< double > &densityValues) const
Gaussian kernel for the KDE estimate of the sub-sequence.
T subPopulationVariance(unsigned int initialPos, unsigned int numPos, const T &meanValue) const
Finds the population variance of the sub-sequence, considering numPos positions starting at position ...
void copy(const BaseVectorSequence< V, M > &src)
Copies vector sequence src to this.
A class representing a vector space.
void unifiedMedianExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMedianVec) const
Finds the median value of the unfed sequence, considering numPos positions starting at position initi...
void subHistogram(unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > ¢ersForAllBins, std::vector< V * > &quanttsForAllBins) const
Calculates the histogram of the sub-sequence.
void erasePositions(unsigned int initialPos, unsigned int numPos)
Erases numPos elements of the sequence starting at position initialPos.
void unifiedMinMaxExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMinVec, V &unifiedMaxVec) const
Finds the minimum and the maximum values of the unified sequence, considering numPos positions starti...
Class for handling vector samples (sequence of vectors).
void subGaussian1dKde(unsigned int initialPos, const V &scaleVec, const std::vector< V * > &evalParamVecs, std::vector< V * > &densityVecs) const
Gaussian kernel for the KDE estimate of the sub-sequence.
the intent is to exercise the right to control the distribution of derivative or collective works based on the Library In mere aggregation of another work not based on the Library with the you must alter all the notices that refer to this so that they refer to the ordinary GNU General Public instead of to this it is irreversible for that so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy This option is useful when you wish to copy part of the code of the Library into a program that is not a library You may copy and distribute the which must be distributed under the terms of Sections and above on a medium customarily used for software interchange If distribution of object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source even though third parties are not compelled to copy the source along with the object code A program that contains no derivative of any portion of the but is designed to work with the Library by being compiled or linked with is called a work that uses the Library Such a work
T subSampleVarianceExtra(unsigned int initialPos, unsigned int numPos, const T &meanValue) const
Finds the sample variance of the sub-sequence, considering numPos positions starting at position init...
and that you are informed that you can do these things To protect your we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it For if you distribute copies of the whether gratis or for a you must give the recipients all the rights that we gave you You must make sure that receive or can get the source code If you link other code with the you must provide complete object files to the so that they can relink them with the library after making changes to the library and recompiling it And you must show them these terms so they know their rights We protect your rights with a two step which gives you legal permission to copy
T unifiedMedianExtra(bool useOnlyInter0Comm, unsigned int initialPos, unsigned int localNumPos) const
Finds the median value of the unified sequence, considering numPos positions starting at position ini...
Base class for handling vector and array samples (sequence of vectors or arrays). ...
void unifiedSampleStd(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedStdVec) const
Finds the sample standard deviation of the unified sequence, considering numPos positions starting at...
void unifiedWriteContents(const std::string &fileName, const std::string &fileType) const
void copy(const SequenceOfVectors< V, M > &src)
Copies vector sequence src to this.
void autoCorrViaFft(unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const
Calculates the autocorrelation via Fast Fourier transforms (FFT).