25 #include <queso/GpmsaComputerModel.h>
26 #include <queso/GenericScalarFunction.h>
27 #include <queso/SequentialVectorRealizer.h>
28 #include <queso/GslVector.h>
29 #include <queso/GslMatrix.h>
33 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
44 m_env (simulationStorage.env()),
45 m_optionsObj (alternativeOptionsValues),
54 m_thereIsExperimentalData ((experimentStorage != NULL) && (experimentModel != NULL) && (thetaPriorRv != NULL)),
55 m_allOutputsAreScalar (simulationStorage.outputSpace().dimLocal() == 1),
57 m_cMatIsRankDefficient (false),
58 m_likelihoodFunction (NULL),
62 *
m_env.
subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
63 <<
": prefix = " << prefix
64 <<
", alternativeOptionsValues = " << alternativeOptionsValues
70 if ((experimentStorage == NULL) &&
71 (experimentModel == NULL) &&
72 (thetaPriorRv == NULL)) {
78 else if ((experimentStorage != NULL) &&
79 (experimentModel != NULL) &&
80 (thetaPriorRv != NULL)) {
94 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
95 <<
": prefix = " << prefix
117 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
118 <<
": prefix = " << prefix
180 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
181 <<
": finished instantiating m_s"
182 <<
", experimentStorage = " << experimentStorage
183 <<
", experimentModel = " << experimentModel
184 <<
", thetaPriorRv = " << thetaPriorRv
192 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
193 <<
": about to instantiate m_e"
203 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
204 <<
": finished instantiating m_e"
213 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
214 <<
": finished instantiating m_j"
218 if (m_allOutputsAreScalar) {
231 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
232 <<
": finished instantiating m_z"
239 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
240 <<
": finished instantiating m_t"
246 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
247 <<
": about to instantiate m_z (no experiments)"
255 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
256 <<
": finished instantiating m_z (no experiments)"
262 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
263 <<
": finished instantiating m_t (no experiments)"
269 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
270 <<
": finished instantiating non-tilde auxiliary structures"
283 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
284 <<
": m_z->m_Cmat_rank = " <<
m_z->m_Cmat_rank
285 <<
", m_z->m_Cmat = " <<
m_z->m_Cmat
286 <<
", m_z->m_Cmat->numCols() = " <<
m_z->m_Cmat->numCols()
317 m_zt =
new GcmZTildeInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>(*gpmsaComputerModelOptions,*
m_j,*
m_z,*
m_st,*
m_jt);
320 queso_error_msg(
"incomplete code for the situation 'm_useTildeLogicForRankDefficientC == true' and 'm_thereIsExperimentalData == false'");
334 queso_error_msg(
"incomplete code for the situation 'm_useTildeLogicForRankDefficientC == false' and 'm_thereIsExperimentalData == false'");
346 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
347 <<
": finished instantiating tilde auxiliary structures"
377 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
378 <<
": finished generating prior sequence"
395 *
m_env.
subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
396 <<
": finished instantiating likelihood Function"
403 delete gpmsaComputerModelOptions;
409 *
m_env.
subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
415 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
418 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
419 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::destructor()..."
432 delete m_dataOutputFilePtrSet.ofsVar;
433 if (m_optionsObj)
delete m_optionsObj;
435 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
436 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::destructor()"
441 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
445 const P_V& totalInitialValues,
446 const P_M* totalInitialProposalCovMatrix)
448 struct timeval timevalBegin;
449 gettimeofday(&timevalBegin, NULL);
451 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
452 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMetropolisHastings()..."
453 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
454 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
455 <<
", my subRank = " << m_env.subRank()
456 <<
", totalInitialValues = " << totalInitialValues
460 m_env.fullComm().Barrier();
461 m_env.fullComm().syncPrintDebugMsg(
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMetropolisHastings()",1,3000000);
463 queso_require_equal_to_msg(m_t->m_totalPriorRv.imageSet().vectorSpace().dimLocal(), totalInitialValues.sizeLocal(),
"'m_totalPriorRv' and 'totalInitialValues' should have equal dimensions");
465 if (totalInitialProposalCovMatrix) {
466 queso_require_equal_to_msg(m_t->m_totalPriorRv.imageSet().vectorSpace().dimLocal(), totalInitialProposalCovMatrix->numRowsLocal(),
"'m_totalPriorRv' and 'totalInitialProposalCovMatrix' should have equal dimensions");
467 queso_require_equal_to_msg(totalInitialProposalCovMatrix->numCols(), totalInitialProposalCovMatrix->numRowsGlobal(),
"'totalInitialProposalCovMatrix' should be a square matrix");
471 P_V currPosition (totalInitialValues);
472 currPosition.cwSet(0.);
473 P_V epsilonVector (currPosition);
474 P_V plusVectorOfLnLikelihoods (currPosition);
475 P_V minusVectorOfLnLikelihoods(currPosition);
476 P_V deltaVectorOfLnLikelihoods(currPosition);
477 P_V vectorOfLnAbsGrads (currPosition);
479 currPosition = totalInitialValues;
480 double referenceValue = staticLikelihoodRoutine(currPosition,
487 for (
unsigned int paramId = 0; paramId < totalInitialValues.sizeLocal(); ++paramId) {
488 currPosition = totalInitialValues;
489 epsilonVector[paramId] = 1.e-8 * totalInitialValues[paramId];
490 if (epsilonVector[paramId] == 0.) epsilonVector[paramId] = 1.e-8;
492 currPosition[paramId] = totalInitialValues[paramId] + epsilonVector[paramId];
493 plusVectorOfLnLikelihoods[paramId] = staticLikelihoodRoutine(currPosition,
500 currPosition[paramId] = totalInitialValues[paramId] - epsilonVector[paramId];
501 minusVectorOfLnLikelihoods[paramId] = staticLikelihoodRoutine(currPosition,
508 deltaVectorOfLnLikelihoods[paramId] = plusVectorOfLnLikelihoods[paramId] - minusVectorOfLnLikelihoods[paramId];
509 if (deltaVectorOfLnLikelihoods[paramId] > 0.) {
510 vectorOfLnAbsGrads[paramId] = minusVectorOfLnLikelihoods[paramId] + std::log( std::exp( deltaVectorOfLnLikelihoods[paramId]) - 1. ) - std::log(2.*epsilonVector[paramId]);
512 else if (deltaVectorOfLnLikelihoods[paramId] == 0.) {
513 vectorOfLnAbsGrads[paramId] = -INFINITY;
516 vectorOfLnAbsGrads[paramId] = plusVectorOfLnLikelihoods [paramId] + std::log( std::exp(-deltaVectorOfLnLikelihoods[paramId]) - 1. ) - std::log(2.*epsilonVector[paramId]);
519 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
520 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMetropolisHastings()"
521 <<
": referenceValue = " << referenceValue
522 <<
"\n epsilonVector = " << epsilonVector
523 <<
"\n plusVectorOfLnLikelihoods = " << plusVectorOfLnLikelihoods
524 <<
"\n minusVectorOfLnLikelihoods = " << minusVectorOfLnLikelihoods
525 <<
"\n deltaVectorOfLnLikelihoods = " << deltaVectorOfLnLikelihoods
526 <<
"\n vectorOfLnAbsGrads = " << vectorOfLnAbsGrads
536 m_t->m_solutionDomain =
InstantiateIntersection(m_t->m_totalPriorRv.pdf().domainSet(),m_likelihoodFunction->domainSet());
543 m_t->m_totalPriorRv.pdf(),
544 *m_likelihoodFunction,
546 *(m_t->m_solutionDomain));
552 m_t->m_totalPostRv.setPdf(*(m_t->m_solutionPdf));
566 alternativeOptionsValues,
569 totalInitialProposalCovMatrix);
588 m_t->m_totalPostRv.setRealizer(*(m_t->m_solutionRealizer));
593 m_env.fullComm().Barrier();
596 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
597 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMetropolisHastings()..."
598 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
599 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
600 <<
", my subRank = " << m_env.subRank()
601 <<
", after " << totalTime
609 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
613 const P_V& totalInitialValues,
614 const P_M* totalInitialProposalCovMatrix)
616 struct timeval timevalBegin;
617 gettimeofday(&timevalBegin, NULL);
619 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
620 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithLanlMcmc()..."
621 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
622 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
623 <<
", my subRank = " << m_env.subRank()
624 <<
", totalInitialValues = " << totalInitialValues
628 m_env.fullComm().Barrier();
629 m_env.fullComm().syncPrintDebugMsg(
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithLanlMcmc()",1,3000000);
633 m_env.fullComm().syncPrintDebugMsg(
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithLanlMcmc()",1,3000000);
634 m_env.fullComm().Barrier();
637 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
638 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithLanlMcmc()..."
639 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
640 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
641 <<
", my subRank = " << m_env.subRank()
642 <<
", after " << totalTime
650 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
654 struct timeval timevalBegin;
655 gettimeofday(&timevalBegin, NULL);
657 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
658 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMLSampling()..."
659 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
660 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
661 <<
", my subRank = " << m_env.subRank()
665 m_env.fullComm().Barrier();
666 m_env.fullComm().syncPrintDebugMsg(
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMLSampling()",1,3000000);
669 m_t->m_solutionDomain =
InstantiateIntersection(m_t->m_totalPriorRv.pdf().domainSet(),m_likelihoodFunction->domainSet());
676 m_t->m_totalPriorRv.pdf(),
677 *m_likelihoodFunction,
679 *(m_t->m_solutionDomain));
685 m_t->m_totalPostRv.setPdf(*(m_t->m_solutionPdf));
700 *m_likelihoodFunction);
719 m_t->m_totalPostRv.setRealizer(*(m_t->m_solutionRealizer));
721 m_env.fullComm().syncPrintDebugMsg(
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMLSampling()",1,3000000);
722 m_env.fullComm().Barrier();
725 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
726 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::calibrateWithBayesMLSampling()..."
727 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
728 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
729 <<
", my subRank = " << m_env.subRank()
730 <<
", after " << totalTime
738 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
741 const S_V& newScenarioVec,
742 const P_V& newParameterVec,
750 struct timeval timevalBegin;
751 gettimeofday(&timevalBegin, NULL);
753 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
754 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
755 <<
", m_predVU_counter = " << m_j->m_predVU_counter
756 <<
", newScenarioVec = " << newScenarioVec
757 <<
", newParameterVec = " << newParameterVec
767 queso_require_equal_to_msg(vuCovMatrix.numRowsLocal(), (m_e->m_paper_p_delta + m_s->m_paper_p_eta),
"invalid 'vuCovMatrix.numRowsLocal()'");
769 queso_require_equal_to_msg(vuCovMatrix.numCols(), (m_e->m_paper_p_delta + m_s->m_paper_p_eta),
"invalid 'vuCovMatrix.numCols()'");
783 if (m_optionsObj->m_predVUsBySamplingRVs) {
786 if (m_optionsObj->m_predVUsBySummingRVs) {
787 unsigned int numSamples = (
unsigned int) ((
double) m_t->m_totalPostRv.realizer().subPeriod())/((
double) m_optionsObj->m_predLag);
788 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
789 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
790 <<
": m_t->m_totalPostRv.realizer().subPeriod() = " << m_t->m_totalPostRv.realizer().subPeriod()
791 <<
", m_optionsObj->m_predLag = " << m_optionsObj->m_predLag
796 P_M mean_of_unique_vu_covMatrices(m_j->m_unique_vu_space.zeroVector());
798 P_V totalSample(m_t->m_totalSpace.zeroVector());
799 P_V muVec1 (m_z->m_z_space.zeroVector());
800 P_V muVec2 (m_j->m_vu_space.zeroVector());
801 P_M sigmaMat11 (m_z->m_z_space.zeroVector());
802 P_M sigmaMat12 (m_env,muVec1.map(),muVec2.sizeGlobal());
803 P_M sigmaMat21 (m_env,muVec2.map(),muVec1.sizeGlobal());
804 P_M sigmaMat22 (m_j->m_vu_space.zeroVector());
806 P_M here_Smat_z_hat_v_asterisk (m_env, m_z->m_z_space.map(), m_e->m_paper_p_delta);
807 P_M here_Smat_z_hat_v_asterisk_t(m_env, m_e->m_unique_v_space.map(), m_z->m_z_size );
808 P_M here_Smat_z_hat_u_asterisk (m_env, m_z->m_z_space.map(), m_s->m_paper_p_eta );
809 P_M here_Smat_z_hat_u_asterisk_t(m_env, m_j->m_unique_u_space.map(), m_z->m_z_size );
811 std::vector<const P_M*> twoMats_uw(2,NULL);
812 std::vector<const P_M*> twoMats_12(2,NULL);
813 std::vector<const P_M*> twoMats_21(2,NULL);
814 std::vector<const P_M*> twoMats_22(2,NULL);
815 for (
unsigned int sampleId = 0; sampleId < numSamples; ++sampleId) {
816 m_j->m_predVU_counter++;
819 for (
unsigned int i = 1; i < m_optionsObj->m_predLag; ++i) {
820 m_t->m_totalPostRv.realizer().realization(totalSample);
823 m_t->m_totalPostRv.realizer().realization(totalSample);
825 unsigned int currPosition = 0;
826 totalSample.cwExtract(currPosition,m_s->m_tmp_1lambdaEtaVec);
827 currPosition += m_s->m_tmp_1lambdaEtaVec.sizeLocal();
828 totalSample.cwExtract(currPosition,m_s->m_tmp_2lambdaWVec);
829 currPosition += m_s->m_tmp_2lambdaWVec.sizeLocal();
830 totalSample.cwExtract(currPosition,m_s->m_tmp_3rhoWVec);
831 currPosition += m_s->m_tmp_3rhoWVec.sizeLocal();
832 totalSample.cwExtract(currPosition,m_s->m_tmp_4lambdaSVec);
833 currPosition += m_s->m_tmp_4lambdaSVec.sizeLocal();
834 totalSample.cwExtract(currPosition,m_e->m_tmp_5lambdaYVec);
835 currPosition += m_e->m_tmp_5lambdaYVec.sizeLocal();
836 totalSample.cwExtract(currPosition,m_e->m_tmp_6lambdaVVec);
837 currPosition += m_e->m_tmp_6lambdaVVec.sizeLocal();
838 totalSample.cwExtract(currPosition,m_e->m_tmp_7rhoVVec);
839 currPosition += m_e->m_tmp_7rhoVVec.sizeLocal();
840 totalSample.cwExtract(currPosition,m_e->m_tmp_8thetaVec);
841 currPosition += m_e->m_tmp_8thetaVec.sizeLocal();
842 queso_require_equal_to_msg(currPosition, totalSample.sizeLocal(),
"'currPosition' and 'totalSample.sizeLocal()' should be equal");
854 this->formSigma_z_hat(m_s->m_tmp_1lambdaEtaVec,
855 m_s->m_tmp_2lambdaWVec,
857 m_s->m_tmp_4lambdaSVec,
858 m_e->m_tmp_5lambdaYVec,
859 m_e->m_tmp_6lambdaVVec,
862 m_j->m_predVU_counter);
868 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
869 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
870 <<
", m_predVU_counter = " << m_j->m_predVU_counter
871 <<
": about to populate 'm_Smat_v_hat_v_asterisk'"
872 <<
", m_e->m_Smat_v_hat_v_asterisk_is.size() = " << m_e->m_Smat_v_hat_v_asterisk_is.size()
873 <<
", m_e->m_tmp_rho_v_vec.sizeLocal() = " << m_e->m_tmp_rho_v_vec.sizeLocal()
874 <<
", m_e->m_tmp_7rhoVVec.sizeLocal() = " << m_e->m_tmp_7rhoVVec.sizeLocal()
877 queso_require_equal_to_msg((m_e->m_Smat_v_hat_v_asterisk_is.size() * m_e->m_tmp_rho_v_vec.sizeLocal()), m_e->m_tmp_7rhoVVec.sizeLocal(),
"invalid size for 'v' variables");
878 unsigned int initialPos = 0;
879 for (
unsigned int i = 0; i < m_e->m_Smat_v_hat_v_asterisk_is.size(); ++i) {
880 m_e->m_tmp_7rhoVVec.cwExtract(initialPos,m_e->m_tmp_rho_v_vec);
881 initialPos += m_e->m_tmp_rho_v_vec.sizeLocal();
882 m_e->m_Rmat_v_hat_v_asterisk_is[i]->cwSet(0.);
883 this->fillR_formula2_for_Sigma_v_hat_v_asterisk(m_s->m_paper_xs_asterisks_standard,
884 m_s->m_paper_ts_asterisks_standard,
887 m_e->m_tmp_rho_v_vec,
888 *(m_e->m_Rmat_v_hat_v_asterisk_is[i]),
889 m_j->m_predVU_counter);
890 m_e->m_Smat_v_hat_v_asterisk_is[i]->cwSet(0.);
892 *(m_e->m_Smat_v_hat_v_asterisk_is[i]) = (1./m_e->m_tmp_6lambdaVVec[i]) * *(m_e->m_Rmat_v_hat_v_asterisk_is[i]);
894 m_e->m_Smat_v_hat_v_asterisk.cwSet(0.);
895 m_e->m_Smat_v_hat_v_asterisk.fillWithBlocksDiagonally(0,0,m_e->m_Smat_v_hat_v_asterisk_is,
true,
true);
896 m_e->m_Smat_v_hat_v_asterisk_t.fillWithTranspose(0,0,m_e->m_Smat_v_hat_v_asterisk,
true,
true);
898 here_Smat_z_hat_v_asterisk.cwSet(0.);
899 here_Smat_z_hat_v_asterisk.cwSet(0,0,m_e->m_Smat_v_hat_v_asterisk);
900 here_Smat_z_hat_v_asterisk_t.fillWithTranspose(0,0,here_Smat_z_hat_v_asterisk,
true,
true);
902 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
903 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
904 <<
", m_predVU_counter = " << m_j->m_predVU_counter
905 <<
": finished instantiating 'm_Smat_v_hat_v_asterisk'"
914 for (
unsigned int i = 0; i < m_j->m_Smat_u_hat_u_asterisk_is.size(); ++i) {
915 m_s->m_tmp_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
916 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
918 m_j->m_Rmat_u_hat_u_asterisk_is[i]->cwSet(0.);
919 this->fillR_formula1_for_Sigma_u_hat_u_asterisk(m_s->m_paper_xs_asterisks_standard,
920 m_s->m_paper_ts_asterisks_standard,
923 m_s->m_tmp_rho_w_vec,
924 *(m_j->m_Rmat_u_hat_u_asterisk_is[i]),
925 m_j->m_predVU_counter);
926 m_j->m_Smat_u_hat_u_asterisk_is[i]->cwSet(0.);
927 *(m_j->m_Smat_u_hat_u_asterisk_is[i]) = (1./m_s->m_tmp_2lambdaWVec[i]) * *(m_j->m_Rmat_u_hat_u_asterisk_is[i]);
929 m_j->m_Rmat_w_hat_u_asterisk_is[i]->cwSet(0.);
930 this->fillR_formula1_for_Sigma_w_hat_u_asterisk(m_s->m_paper_xs_asterisks_standard,
931 m_s->m_paper_ts_asterisks_standard,
934 m_s->m_tmp_rho_w_vec,
935 *(m_j->m_Rmat_w_hat_u_asterisk_is[i]),
936 m_j->m_predVU_counter);
937 m_j->m_Smat_w_hat_u_asterisk_is[i]->cwSet(0.);
938 *(m_j->m_Smat_w_hat_u_asterisk_is[i]) = (1./m_s->m_tmp_2lambdaWVec[i]) * *(m_j->m_Rmat_w_hat_u_asterisk_is[i]);
941 m_j->m_Smat_u_hat_u_asterisk.cwSet(0.);
942 m_j->m_Smat_u_hat_u_asterisk.fillWithBlocksDiagonally(0,0,m_j->m_Smat_u_hat_u_asterisk_is,
true,
true);
943 m_j->m_Smat_u_hat_u_asterisk_t.fillWithTranspose(0,0,m_j->m_Smat_u_hat_u_asterisk,
true,
true);
945 m_j->m_Smat_w_hat_u_asterisk.cwSet(0.);
946 m_j->m_Smat_w_hat_u_asterisk.fillWithBlocksDiagonally(0,0,m_j->m_Smat_w_hat_u_asterisk_is,
true,
true);
947 m_j->m_Smat_w_hat_u_asterisk_t.fillWithTranspose(0,0,m_j->m_Smat_w_hat_u_asterisk,
true,
true);
949 twoMats_uw[0] = &m_j->m_Smat_u_hat_u_asterisk;
950 twoMats_uw[1] = &m_j->m_Smat_w_hat_u_asterisk;
951 here_Smat_z_hat_u_asterisk.cwSet(0.);
952 here_Smat_z_hat_u_asterisk.fillWithBlocksVertically(m_e->m_v_size,0,twoMats_uw,
true,
true);
953 here_Smat_z_hat_u_asterisk_t.fillWithTranspose(0,0,here_Smat_z_hat_u_asterisk,
true,
true);
955 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
956 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
957 <<
", m_predVU_counter = " << m_j->m_predVU_counter
958 <<
": finished instantiating '>m_Smat_z_hat_u_asterisk'"
965 queso_require_equal_to_msg(m_e->m_Smat_v_asterisk_v_asterisk.numRowsLocal(), m_e->m_paper_p_delta,
"invalid 'm_Smat_v_asterisk_v_asterisk.numRowsLocal()'");
966 queso_require_equal_to_msg(m_e->m_tmp_6lambdaVVec.sizeLocal(), m_e->m_paper_p_delta,
"invalid 'm_tmp_6lambdaVVec.sizeLocal()'");
968 m_e->m_Smat_v_asterisk_v_asterisk.cwSet(0.);
969 for (
unsigned int i = 0; i < m_e->m_paper_p_delta; ++i) {
970 m_e->m_Smat_v_asterisk_v_asterisk(i,i) = 1./m_e->m_tmp_6lambdaVVec[i];
976 queso_require_equal_to_msg(m_j->m_Smat_u_asterisk_u_asterisk.numRowsLocal(), m_s->m_paper_p_eta,
"invalid 'm_Smat_u_asterisk_u_asterisk.numRowsLocal()'");
977 queso_require_equal_to_msg(m_s->m_tmp_2lambdaWVec.sizeLocal(), m_s->m_paper_p_eta,
"invalid 'm_tmp_2lambdaWVec.sizeLocal()'");
979 m_j->m_Smat_u_asterisk_u_asterisk.cwSet(0.);
980 for (
unsigned int i = 0; i < m_s->m_paper_p_eta; ++i) {
981 m_j->m_Smat_u_asterisk_u_asterisk(i,i) = 1./m_s->m_tmp_2lambdaWVec[i] + 1/m_s->m_tmp_4lambdaSVec[i];
989 P_V unique_vu_vec(m_j->m_unique_vu_space.zeroVector());
990 P_M unique_vu_mat(m_j->m_unique_vu_space.zeroVector());
992 twoMats_12[0] = &here_Smat_z_hat_v_asterisk_t;
993 twoMats_12[1] = &here_Smat_z_hat_u_asterisk_t;
994 twoMats_21[0] = &here_Smat_z_hat_v_asterisk;
995 twoMats_21[1] = &here_Smat_z_hat_u_asterisk;
996 twoMats_22[0] = &m_e->m_Smat_v_asterisk_v_asterisk;
997 twoMats_22[1] = &m_j->m_Smat_u_asterisk_u_asterisk;
999 sigmaMat11 = m_z->m_tmp_Smat_z_hat;
1000 sigmaMat12.fillWithBlocksHorizontally(0,0,twoMats_12,
true,
true);
1001 sigmaMat21.fillWithBlocksVertically (0,0,twoMats_21,
true,
true);
1002 sigmaMat22.fillWithBlocksDiagonally (0,0,twoMats_22,
true,
true);
1006 m_j->m_predVU_summingRVs_mean_of_unique_vu_covMatrices += unique_vu_mat;
1012 m_j->m_predVU_summingRVs_mean_of_unique_vu_covMatrices *= (1./(double) numSamples);
1014 m_j->m_predVU_summingRVs_unique_vu_meanVec = unique_vu_means.
unifiedMeanPlain();
1016 m_j->m_predVU_summingRVs_covMatrix_of_unique_vu_means.cwSet(0.);
1017 m_j->m_predVU_summingRVs_corrMatrix_of_unique_vu_means.cwSet(0.);
1021 m_j->m_predVU_summingRVs_covMatrix_of_unique_vu_means,
1022 m_j->m_predVU_summingRVs_corrMatrix_of_unique_vu_means);
1024 vuMeanVec = m_j->m_predVU_summingRVs_unique_vu_meanVec;
1025 vuMeanVec.cwExtract(0,vMeanVec);
1026 vuMeanVec.cwExtract(m_e->m_paper_p_delta,uMeanVec);
1028 P_M vuCovMatrix(m_j->m_unique_vu_space.zeroVector());
1029 vuCovMatrix = m_j->m_predVU_summingRVs_mean_of_unique_vu_covMatrices + m_j->m_predVU_summingRVs_covMatrix_of_unique_vu_means;
1030 vuCovMatrix.cwExtract(0,0,vCovMatrix);
1031 vuCovMatrix.cwExtract(m_e->m_paper_p_delta,m_e->m_paper_p_delta,uCovMatrix);
1033 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1034 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
1035 <<
", m_predVU_counter = " << m_j->m_predVU_counter
1036 <<
": finished computing all means and covariances"
1037 <<
"\n vuMeanVec = " << vuMeanVec
1038 <<
"\n m_predW_summingRVs_covMatrix_of_unique_vu_means = " << m_j->m_predVU_summingRVs_covMatrix_of_unique_vu_means
1039 <<
"\n m_predW_summingRVs_mean_of_unique_vu_covMatrices = " << m_j->m_predVU_summingRVs_mean_of_unique_vu_covMatrices
1040 <<
"\n vuCovMatrix = " << vuCovMatrix
1045 mean_of_unique_vu_covMatrices *= (1./(double) numSamples);
1048 if (m_optionsObj->m_predVUsAtKeyPoints) {
1052 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1053 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictVUsAtGridPoint(1)"
1054 <<
", m_predVU_counter = " << m_j->m_predVU_counter
1055 <<
", newScenarioVec = " << newScenarioVec
1056 <<
", after " << totalTime
1064 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1067 const S_V& newScenarioVec,
1068 const P_V& newParameterVec,
1069 const P_V* forcingSampleVecForDebug,
1073 struct timeval timevalBegin;
1074 gettimeofday(&timevalBegin, NULL);
1076 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1077 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1078 <<
", m_predW_counter = " << m_s->m_predW_counter
1079 <<
", newScenarioVec = " << newScenarioVec
1080 <<
", newParameterVec = " << newParameterVec
1094 if (m_optionsObj->m_predWsBySamplingRVs) {
1097 if (m_optionsObj->m_predWsBySummingRVs) {
1098 unsigned int numSamples = (
unsigned int) ((
double) m_t->m_totalPostRv.realizer().subPeriod())/((
double) m_optionsObj->m_predLag);
1099 if (forcingSampleVecForDebug) {
1102 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1103 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1104 <<
": m_t->m_totalPostRv.realizer().subPeriod() = " << m_t->m_totalPostRv.realizer().subPeriod()
1105 <<
", m_optionsObj->m_predLag = " << m_optionsObj->m_predLag
1106 <<
", numSamples = " << numSamples
1112 P_V totalSample(m_t->m_totalSpace.zeroVector());
1113 P_V muVec1 (m_s->m_unique_w_space.zeroVector());
1114 P_V muVec2 (m_s->m_w_space.zeroVector());
1115 P_M sigmaMat11 (m_s->m_unique_w_space.zeroVector());
1116 P_M sigmaMat12 (m_env,muVec1.map(),muVec2.sizeGlobal());
1117 P_M sigmaMat21 (m_env,muVec2.map(),muVec1.sizeGlobal());
1118 P_M sigmaMat22 (m_s->m_w_space.zeroVector());
1119 for (
unsigned int sampleId = 0; sampleId < numSamples; ++sampleId) {
1120 m_s->m_predW_counter++;
1123 for (
unsigned int i = 1; i < m_optionsObj->m_predLag; ++i) {
1124 m_t->m_totalPostRv.realizer().realization(totalSample);
1127 m_t->m_totalPostRv.realizer().realization(totalSample);
1128 if (forcingSampleVecForDebug) {
1129 totalSample = *forcingSampleVecForDebug;
1132 unsigned int currPosition = 0;
1133 totalSample.cwExtract(currPosition,m_s->m_tmp_1lambdaEtaVec);
1134 currPosition += m_s->m_tmp_1lambdaEtaVec.sizeLocal();
1135 totalSample.cwExtract(currPosition,m_s->m_tmp_2lambdaWVec);
1136 currPosition += m_s->m_tmp_2lambdaWVec.sizeLocal();
1137 totalSample.cwExtract(currPosition,m_s->m_tmp_3rhoWVec);
1138 currPosition += m_s->m_tmp_3rhoWVec.sizeLocal();
1139 totalSample.cwExtract(currPosition,m_s->m_tmp_4lambdaSVec);
1140 currPosition += m_s->m_tmp_4lambdaSVec.sizeLocal();
1141 totalSample.cwExtract(currPosition,m_e->m_tmp_5lambdaYVec);
1142 currPosition += m_e->m_tmp_5lambdaYVec.sizeLocal();
1143 totalSample.cwExtract(currPosition,m_e->m_tmp_6lambdaVVec);
1144 currPosition += m_e->m_tmp_6lambdaVVec.sizeLocal();
1145 totalSample.cwExtract(currPosition,m_e->m_tmp_7rhoVVec);
1146 currPosition += m_e->m_tmp_7rhoVVec.sizeLocal();
1147 totalSample.cwExtract(currPosition,m_e->m_tmp_8thetaVec);
1148 currPosition += m_e->m_tmp_8thetaVec.sizeLocal();
1149 queso_require_equal_to_msg(currPosition, totalSample.sizeLocal(),
"'currPosition' and 'totalSample.sizeLocal()' should be equal");
1156 this->formSigma_w_hat(m_s->m_tmp_1lambdaEtaVec,
1157 m_s->m_tmp_2lambdaWVec,
1158 m_s->m_tmp_3rhoWVec,
1159 m_s->m_tmp_4lambdaSVec,
1161 m_s->m_predW_counter);
1163 if (forcingSampleVecForDebug) {
1164 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1165 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1166 <<
": m_s->m_Smat_w_hat = " << m_s->m_Smat_w_hat
1175 unsigned int initialPos = 0;
1176 for (
unsigned int i = 0; i < m_s->m_Smat_w_hat_w_asterisk_is.size(); ++i) {
1177 m_s->m_tmp_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
1178 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
1179 m_s->m_Rmat_w_hat_w_asterisk_is[i]->cwSet(0.);
1180 this->fillR_formula1_for_Sigma_w_hat_w_asterisk(m_s->m_paper_xs_asterisks_standard,
1181 m_s->m_paper_ts_asterisks_standard,
1184 m_s->m_tmp_rho_w_vec,
1185 *(m_s->m_Rmat_w_hat_w_asterisk_is[i]),
1186 m_s->m_predW_counter);
1187 m_s->m_Smat_w_hat_w_asterisk_is[i]->cwSet(0.);
1188 *(m_s->m_Smat_w_hat_w_asterisk_is[i]) = (1./m_s->m_tmp_2lambdaWVec[i]) * *(m_s->m_Rmat_w_hat_w_asterisk_is[i]);
1190 m_s->m_Smat_w_hat_w_asterisk.cwSet(0.);
1191 m_s->m_Smat_w_hat_w_asterisk.fillWithBlocksDiagonally(0,0,m_s->m_Smat_w_hat_w_asterisk_is,
true,
true);
1192 m_s->m_Smat_w_hat_w_asterisk_t.fillWithTranspose(0,0,m_s->m_Smat_w_hat_w_asterisk,
true,
true);
1193 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1194 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1195 <<
", m_predW_counter = " << m_s->m_predW_counter
1196 <<
": finished instantiating 'm_Smat_w_hat_w_asterisk'"
1200 if (forcingSampleVecForDebug) {
1201 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1202 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1203 <<
": m_s->m_Smat_w_hat_w_asterisk = " << m_s->m_Smat_w_hat_w_asterisk
1211 queso_require_equal_to_msg(m_s->m_Smat_w_asterisk_w_asterisk.numRowsLocal(), m_s->m_paper_p_eta,
"invalid 'm_Smat_w_asterisk_w_asterisk.numRowsLocal()'");
1212 queso_require_equal_to_msg(m_s->m_tmp_2lambdaWVec.sizeLocal(), m_s->m_paper_p_eta,
"invalid 'm_tmp_2lambdaWVec.sizeLocal()'");
1214 m_s->m_Smat_w_asterisk_w_asterisk.cwSet(0.);
1215 for (
unsigned int i = 0; i < m_s->m_paper_p_eta; ++i) {
1216 m_s->m_Smat_w_asterisk_w_asterisk(i,i) = 1./m_s->m_tmp_2lambdaWVec[i] + 1/m_s->m_tmp_4lambdaSVec[i];
1219 if (forcingSampleVecForDebug) {
1220 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1221 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1222 <<
": m_s->m_Smat_w_asterisk_w_asterisk = " << m_s->m_Smat_w_asterisk_w_asterisk
1232 if (forcingSampleVecForDebug) {
1233 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1234 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1235 <<
": muVec1 = " << muVec1
1236 <<
", muVec2 = " << muVec2
1237 <<
", m_s->m_Zvec_hat_w = " << m_s->m_Zvec_hat_w
1242 P_V unique_w_vec(m_s->m_unique_w_space.zeroVector());
1243 P_M unique_w_mat(m_s->m_unique_w_space.zeroVector());
1245 sigmaMat11 = m_s->m_Smat_w_asterisk_w_asterisk;
1246 sigmaMat12 = m_s->m_Smat_w_hat_w_asterisk_t;
1247 sigmaMat21 = m_s->m_Smat_w_hat_w_asterisk;
1248 sigmaMat22 = m_s->m_Smat_w_hat;
1251 if (forcingSampleVecForDebug) {
1252 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1253 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1254 <<
", unique_w_vec = " << unique_w_vec
1255 <<
", unique_w_mat = " << unique_w_mat
1261 m_s->m_predW_summingRVs_mean_of_unique_w_covMatrices += unique_w_mat;
1269 m_s->m_predW_summingRVs_mean_of_unique_w_covMatrices *= (1./(double) numSamples);
1271 m_s->m_predW_summingRVs_unique_w_meanVec = unique_w_means.
unifiedMeanPlain();
1273 m_s->m_predW_summingRVs_covMatrix_of_unique_w_means.cwSet(0.);
1274 m_s->m_predW_summingRVs_corrMatrix_of_unique_w_means.cwSet(0.);
1278 m_s->m_predW_summingRVs_covMatrix_of_unique_w_means,
1279 m_s->m_predW_summingRVs_corrMatrix_of_unique_w_means);
1281 wMeanVec = m_s->m_predW_summingRVs_unique_w_meanVec;
1282 wCovMatrix = m_s->m_predW_summingRVs_mean_of_unique_w_covMatrices + m_s->m_predW_summingRVs_covMatrix_of_unique_w_means;
1284 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1285 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1286 <<
", m_predW_counter = " << m_s->m_predW_counter
1287 <<
": finished computing all means and covariances"
1288 <<
"\n wMeanVec = " << wMeanVec
1289 <<
"\n m_predW_summingRVs_covMatrix_of_unique_w_means = " << m_s->m_predW_summingRVs_covMatrix_of_unique_w_means
1290 <<
"\n m_predW_summingRVs_mean_of_unique_w_covMatrices = " << m_s->m_predW_summingRVs_mean_of_unique_w_covMatrices
1291 <<
"\n wCovMatrix = " << wCovMatrix
1297 if (m_optionsObj->m_predWsAtKeyPoints) {
1301 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1302 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictWsAtGridPoint()"
1303 <<
", m_predW_counter = " << m_s->m_predW_counter
1304 <<
", newScenarioVec = " << newScenarioVec
1305 <<
", newParameterVec = " << newParameterVec
1306 <<
", after " << totalTime
1314 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1317 const S_V& newScenarioVec,
1318 const D_M& newKmat_interp,
1320 D_V& simulationOutputMeanVec,
1321 D_V& discrepancyMeanVec)
1323 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1324 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictExperimentResults()"
1330 queso_require_msg(!((newKmat_interp.numRowsLocal() != m_s->m_paper_n_eta) || (newKmat_interp.numCols() != m_s->m_paper_p_eta)),
"invalid 'newKmat_interp'");
1332 queso_require_msg(!((newDmat.numRowsLocal() != m_s->m_paper_n_eta) || (newDmat.numCols() != m_e->m_paper_p_delta)),
"invalid 'newDmat'");
1338 P_V vMeanVec (m_e->m_unique_v_space.zeroVector());
1339 P_M vCovMatrix(m_e->m_unique_v_space.zeroVector());
1343 P_V uMeanVec (m_s->m_unique_w_space.zeroVector());
1344 P_M uCovMatrix(m_s->m_unique_w_space.zeroVector());
1346 this->predictVUsAtGridPoint(newScenarioVec,
1352 simulationOutputMeanVec = newKmat_interp * uMeanVec;
1353 discrepancyMeanVec = newDmat * vMeanVec;
1355 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1356 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictExperimentResults()"
1363 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1366 const S_V& newScenarioVec,
1367 const P_V& newParameterVec,
1368 Q_V& simulationOutputMeanVec)
1370 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1371 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictSimulationOutputs()"
1381 P_V wMeanVec (m_s->m_unique_w_space.zeroVector());
1382 P_M wCovMatrix(m_s->m_unique_w_space.zeroVector());
1383 this->predictWsAtGridPoint(newScenarioVec,
1391 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1392 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::predictSimulationOutputs()"
1399 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1404 return m_t->m_totalSpace;
1407 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1412 return m_j->m_unique_vu_space;
1415 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1420 return m_t->m_totalPriorRv;
1423 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1428 return m_t->m_totalPostRv;
1431 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1438 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1443 std::cout <<
"Entering memoryCheck(), m_like_counter = " << m_like_counter <<
", codePositionId = " << codePositionId << std::endl;
1446 for (
unsigned int i = 0; i < m_z->m_tmp_Smat_z.numRowsLocal(); ++i) {
1448 for (
unsigned int j = 0; j < m_z->m_tmp_Smat_z.numCols(); ++j) {
1450 sumZ += m_z->m_tmp_Smat_z(i,j);
1456 for (
unsigned int i = 0; i < m_e->m_Smat_v.numRowsLocal(); ++i) {
1457 for (
unsigned int j = 0; j < m_e->m_Smat_v.numCols(); ++j) {
1458 sumV += m_e->m_Smat_v(i,j);
1463 for (
unsigned int i = 0; i < m_j->m_Smat_u.numRowsLocal(); ++i) {
1464 for (
unsigned int j = 0; j < m_j->m_Smat_u.numCols(); ++j) {
1465 sumU += m_j->m_Smat_u(i,j);
1470 for (
unsigned int i = 0; i < m_s->m_Smat_w.numRowsLocal(); ++i) {
1471 for (
unsigned int j = 0; j < m_s->m_Smat_w.numCols(); ++j) {
1472 sumW += m_s->m_Smat_w(i,j);
1477 for (
unsigned int i = 0; i < m_j->m_Smat_uw.numRowsLocal(); ++i) {
1478 for (
unsigned int j = 0; j < m_j->m_Smat_uw.numCols(); ++j) {
1479 sumUW += m_j->m_Smat_uw(i,j);
1483 double sumUW_T = 0.;
1484 for (
unsigned int i = 0; i < m_j->m_Smat_uw_t.numRowsLocal(); ++i) {
1485 for (
unsigned int j = 0; j < m_j->m_Smat_uw_t.numCols(); ++j) {
1486 sumUW_T += m_j->m_Smat_uw_t(i,j);
1490 std::cout <<
"Leaving memoryCheck(), m_like_counter = " << m_like_counter <<
", codePositionId = " << codePositionId << std::endl;
1495 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1499 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1500 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::generatePriorSeq()..."
1501 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
1502 <<
", m_optionsObj->m_priorSeqNumSamples = " << m_optionsObj->m_priorSeqNumSamples
1507 P_V totalSample(m_t->m_totalSpace.zeroVector());
1508 for (
unsigned int sampleId = 0; sampleId < m_optionsObj->m_priorSeqNumSamples; ++sampleId) {
1509 m_t->m_totalPriorRv.realizer().realization(totalSample);
1513 m_optionsObj->m_priorSeqDataOutputFileType);
1515 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1516 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::generatePriorSeq()..."
1517 <<
": m_optionsObj->m_prefix.c_str() = " << m_optionsObj->m_prefix.c_str()
1524 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1527 const P_V& totalValues,
1528 const P_V* totalDirection,
1529 const void* functionDataPtr,
1542 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1545 const P_V& totalValues,
1546 const P_V* totalDirection,
1547 const void* functionDataPtr,
1552 struct timeval timevalBegin;
1553 gettimeofday(&timevalBegin, NULL);
1557 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1558 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()..."
1559 <<
": m_like_counter = " << m_like_counter
1560 <<
", totalValues = " << totalValues
1561 <<
", m_env.subComm().NumProc() = " << m_env.subComm().NumProc()
1562 <<
", my subRank = " << m_env.subRank()
1563 <<
", m_formCMatrix = " << m_formCMatrix
1564 <<
", m_cMatIsRankDefficient = " << m_cMatIsRankDefficient
1568 double lnLikelihoodValue = 0.;
1570 if (totalDirection &&
1584 m_s->m_paper_p_eta);
1587 (m_s->m_paper_p_eta*(m_s->m_paper_p_x+m_s->m_paper_p_t)));
1590 if (m_thereIsExperimentalData) {
1597 m_e->m_paper_F*m_s->m_paper_p_x);
1600 this->memoryCheck(50);
1602 unsigned int currPosition = 0;
1603 totalValues.cwExtract(currPosition,m_s->m_tmp_1lambdaEtaVec);
1604 currPosition += m_s->m_tmp_1lambdaEtaVec.sizeLocal();
1605 totalValues.cwExtract(currPosition,m_s->m_tmp_2lambdaWVec);
1606 currPosition += m_s->m_tmp_2lambdaWVec.sizeLocal();
1607 totalValues.cwExtract(currPosition,m_s->m_tmp_3rhoWVec);
1608 currPosition += m_s->m_tmp_3rhoWVec.sizeLocal();
1609 totalValues.cwExtract(currPosition,m_s->m_tmp_4lambdaSVec);
1610 currPosition += m_s->m_tmp_4lambdaSVec.sizeLocal();
1612 if (m_thereIsExperimentalData) {
1613 totalValues.cwExtract(currPosition,m_e->m_tmp_5lambdaYVec);
1614 currPosition += m_e->m_tmp_5lambdaYVec.sizeLocal();
1615 totalValues.cwExtract(currPosition,m_e->m_tmp_6lambdaVVec);
1616 currPosition += m_e->m_tmp_6lambdaVVec.sizeLocal();
1617 totalValues.cwExtract(currPosition,m_e->m_tmp_7rhoVVec);
1618 currPosition += m_e->m_tmp_7rhoVVec.sizeLocal();
1619 totalValues.cwExtract(currPosition,m_e->m_tmp_8thetaVec);
1620 currPosition += m_e->m_tmp_8thetaVec.sizeLocal();
1622 queso_require_equal_to_msg(currPosition, totalValues.sizeLocal(),
"'currPosition' and 'totalValues.sizeLocal()' should be equal");
1624 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1625 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1626 <<
", m_like_counter = " << m_like_counter
1627 <<
": finished extracting components from 'totalValues'"
1628 <<
", m_tmp_1lambdaEtaVec = " << m_s->m_tmp_1lambdaEtaVec
1629 <<
", m_tmp_2lambdaWVec = " << m_s->m_tmp_2lambdaWVec
1630 <<
", m_tmp_3rhoWVec = " << m_s->m_tmp_3rhoWVec
1631 <<
", m_tmp_4lambdaSVec = " << m_s->m_tmp_4lambdaSVec;
1632 if (m_thereIsExperimentalData) {
1633 *m_env.subDisplayFile() <<
", m_tmp_5lambdaYVec = " << m_e->m_tmp_5lambdaYVec
1634 <<
", m_tmp_6lambdaVVec = " << m_e->m_tmp_6lambdaVVec
1635 <<
", m_tmp_7rhoVVec = " << m_e->m_tmp_7rhoVVec
1636 <<
", m_tmp_8thetaVec = " << m_e->m_tmp_8thetaVec;
1638 *m_env.subDisplayFile() << std::endl;
1644 bool here_1_repeats =
false;
1645 bool here_2_repeats =
false;
1646 bool here_3_repeats =
false;
1647 bool here_4_repeats =
false;
1648 bool here_5_repeats =
false;
1649 bool here_6_repeats =
false;
1650 bool here_7_repeats =
false;
1651 bool here_8_repeats =
false;
1652 if ((m_optionsObj->m_checkAgainstPreviousSample) &&
1653 (m_like_counter == 1 )) {
1654 here_1_repeats = (m_s->m_like_previous1 == m_s->m_tmp_1lambdaEtaVec);
1655 here_2_repeats = (m_s->m_like_previous2 == m_s->m_tmp_2lambdaWVec);
1656 here_3_repeats = (m_s->m_like_previous3 == m_s->m_tmp_3rhoWVec);
1657 here_4_repeats = (m_s->m_like_previous2 == m_s->m_tmp_4lambdaSVec);
1658 if (m_thereIsExperimentalData) {
1659 here_5_repeats = (m_e->m_like_previous5 == m_e->m_tmp_5lambdaYVec);
1660 here_6_repeats = (m_e->m_like_previous6 == m_e->m_tmp_6lambdaVVec);
1661 here_7_repeats = (m_e->m_like_previous7 == m_e->m_tmp_7rhoVVec);
1662 here_8_repeats = (m_e->m_like_previous8 == m_e->m_tmp_8thetaVec);
1664 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1665 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1666 <<
", m_like_counter = " << m_like_counter
1667 <<
"\n m_like_previous1 = " << m_s->m_like_previous1
1668 <<
"\n m_like_previous2 = " << m_s->m_like_previous2
1669 <<
"\n m_like_previous3 = " << m_s->m_like_previous3;
1670 if (m_thereIsExperimentalData) {
1671 *m_env.subDisplayFile() <<
"\n m_like_previous5 = " << m_e->m_like_previous5
1672 <<
"\n m_like_previous6 = " << m_e->m_like_previous6
1673 <<
"\n m_like_previous7 = " << m_e->m_like_previous7
1674 <<
"\n m_like_previous8 = " << m_e->m_like_previous8;
1676 *m_env.subDisplayFile() << std::endl;
1678 if (here_1_repeats ||
1688 lnLikelihoodValue = 0.;
1689 if ((m_formCMatrix ) &&
1690 (m_cMatIsRankDefficient)) {
1694 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1695 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1696 <<
", m_like_counter = " << m_like_counter
1697 <<
": going through true 'm_cMatIsRankDefficient' case"
1701 this->memoryCheck(57);
1703 if (m_optionsObj->m_useTildeLogicForRankDefficientC) {
1714 this->formSigma_z_tilde_hat(m_s->m_tmp_1lambdaEtaVec,
1715 m_s->m_tmp_2lambdaWVec,
1716 m_s->m_tmp_3rhoWVec,
1717 m_s->m_tmp_4lambdaSVec,
1718 m_e->m_tmp_5lambdaYVec,
1719 m_e->m_tmp_6lambdaVVec,
1720 m_e->m_tmp_7rhoVVec,
1721 m_e->m_tmp_8thetaVec,
1724 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1725 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1726 <<
", m_like_counter = " << m_like_counter
1727 <<
": finished computing 'm_tmp_Smat_z_tilde_hat' =\n" << m_zt->m_tmp_Smat_z_tilde_hat
1731 this->memoryCheck(58);
1736 double Smat_z_tilde_hat_lnDeterminant = m_zt->m_tmp_Smat_z_tilde_hat.lnDeterminant();
1738 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1739 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1740 <<
", m_like_counter = " << m_like_counter
1741 <<
": finished computing 'm_tmp_Smat_z_tilde_hat->lnDeterminant()' = " << Smat_z_tilde_hat_lnDeterminant
1744 lnLikelihoodValue += -0.5*Smat_z_tilde_hat_lnDeterminant;
1746 this->memoryCheck(59);
1751 double tmpValue1 =
scalarProduct(m_zt->m_Zvec_tilde_hat,m_zt->m_tmp_Smat_z_tilde_hat.invertMultiply(m_zt->m_Zvec_tilde_hat));
1752 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1753 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1754 <<
", m_like_counter = " << m_like_counter
1755 <<
": finished computing 'tmpValue1 = " << tmpValue1
1758 lnLikelihoodValue += -0.5*tmpValue1;
1760 this->memoryCheck(60);
1765 double tmpValue2 = m_st->m_a_eta_modifier_tilde*std::log(m_s->m_tmp_1lambdaEtaVec[0]) - m_st->m_b_eta_modifier_tilde*m_s->m_tmp_1lambdaEtaVec[0];
1766 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1767 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1768 <<
", m_like_counter = " << m_like_counter
1769 <<
": finished computing 'tmpValue2 = " << tmpValue2
1772 lnLikelihoodValue += tmpValue2;
1774 this->memoryCheck(61);
1776 double tmpValue3 = m_jt->m_a_y_modifier_tilde*std::log(m_e->m_tmp_5lambdaYVec[0]) - m_jt->m_b_y_modifier_tilde*m_e->m_tmp_5lambdaYVec[0];
1777 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1778 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(tilde)"
1779 <<
", m_like_counter = " << m_like_counter
1780 <<
": finished computing 'tmpValue3 = " << tmpValue3
1783 lnLikelihoodValue += tmpValue3;
1785 this->memoryCheck(62);
1788 queso_error_msg(
"incomplete code for situation 'm_useTildeLogicForRankDefficientC == false'");
1795 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1796 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1797 <<
", m_like_counter = " << m_like_counter
1798 <<
": going through case where C matrix (i) does not exist or (ii) is full rank"
1799 <<
", m_thereIsExperimentalData = " << m_thereIsExperimentalData
1803 this->memoryCheck(51);
1816 if (m_thereIsExperimentalData) {
1817 this->formSigma_z_hat(m_s->m_tmp_1lambdaEtaVec,
1818 m_s->m_tmp_2lambdaWVec,
1819 m_s->m_tmp_3rhoWVec,
1820 m_s->m_tmp_4lambdaSVec,
1821 m_e->m_tmp_5lambdaYVec,
1822 m_e->m_tmp_6lambdaVVec,
1823 m_e->m_tmp_7rhoVVec,
1824 m_e->m_tmp_8thetaVec,
1828 queso_error_msg(
"incomplete code for situation 'm_thereIsExperimentalData == false'");
1830 this->formSigma_z_hat(m_s->m_tmp_1lambdaEtaVec,
1831 m_s->m_tmp_2lambdaWVec,
1832 m_s->m_tmp_3rhoWVec,
1833 m_s->m_tmp_4lambdaSVec,
1837 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1838 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1839 <<
", m_like_counter = " << m_like_counter
1840 <<
": finished computing 'm_tmp_Smat_z_hat' =\n" << m_z->m_tmp_Smat_z_hat
1844 this->memoryCheck(52);
1849 double Smat_z_hat_lnDeterminant = m_z->m_tmp_Smat_z_hat.lnDeterminant();
1851 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1852 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1853 <<
", m_like_counter = " << m_like_counter
1854 <<
": finished computing 'm_tmp_Smat_z_hat.lnDeterminant()' = " << Smat_z_hat_lnDeterminant
1857 lnLikelihoodValue += -0.5*Smat_z_hat_lnDeterminant;
1859 this->memoryCheck(53);
1864 double tmpValue1 =
scalarProduct(m_z->m_Zvec_hat,m_z->m_tmp_Smat_z_hat.invertMultiply(m_z->m_Zvec_hat));
1865 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1866 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1867 <<
", m_like_counter = " << m_like_counter
1868 <<
": finished computing 'tmpValue1 = " << tmpValue1
1871 lnLikelihoodValue += -0.5*tmpValue1;
1873 this->memoryCheck(54);
1875 if (m_allOutputsAreScalar) {
1882 double tmpValue2 = m_s->m_a_eta_modifier*std::log(m_s->m_tmp_1lambdaEtaVec[0]) - m_s->m_b_eta_modifier*m_s->m_tmp_1lambdaEtaVec[0];
1883 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1884 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1885 <<
", m_like_counter = " << m_like_counter
1886 <<
": finished computing 'tmpValue2 = " << tmpValue2
1889 lnLikelihoodValue += tmpValue2;
1891 this->memoryCheck(55);
1893 double tmpValue3 = m_j->m_a_y_modifier*std::log(m_e->m_tmp_5lambdaYVec[0]) - m_j->m_b_y_modifier*m_e->m_tmp_5lambdaYVec[0];
1894 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1895 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine(non-tilde)"
1896 <<
", m_like_counter = " << m_like_counter
1897 <<
": finished computing 'tmpValue3 = " << tmpValue3
1900 lnLikelihoodValue += tmpValue3;
1902 this->memoryCheck(56);
1910 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
1911 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1912 <<
", m_like_counter = " << m_like_counter
1913 <<
": finished computing ln(likelihood)"
1914 <<
", lnLikelihoodValue = " << lnLikelihoodValue
1918 this->memoryCheck(63);
1923 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
1924 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1925 <<
", m_like_counter = " << m_like_counter
1926 <<
": starting saving current samples as previous"
1930 m_t->m_like_previousTotal = totalValues;
1931 m_s->m_like_previous1 = m_s->m_tmp_1lambdaEtaVec;
1932 m_s->m_like_previous2 = m_s->m_tmp_2lambdaWVec;
1933 m_s->m_like_previous3 = m_s->m_tmp_3rhoWVec;
1934 m_s->m_like_previous2 = m_s->m_tmp_4lambdaSVec;
1935 m_e->m_like_previous5 = m_e->m_tmp_5lambdaYVec;
1936 m_e->m_like_previous6 = m_e->m_tmp_6lambdaVVec;
1937 m_e->m_like_previous7 = m_e->m_tmp_7rhoVVec;
1938 m_e->m_like_previous8 = m_e->m_tmp_8thetaVec;
1943 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1944 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1945 <<
": m_like_counter = " << m_like_counter
1946 <<
", totalValues = " << totalValues
1947 <<
", lnLikelihoodValue = " << lnLikelihoodValue
1948 <<
" after " << totalTime
1953 if (m_env.subRank() == 0) {
1955 std::cout <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::likelihoodRoutine()"
1956 <<
", m_like_counter = " << m_like_counter
1957 <<
": totalValues = " << totalValues
1958 <<
", lnLikelihoodValue = " << lnLikelihoodValue
1959 <<
" after " << totalTime
1972 m_env.subComm().Barrier();
1975 if (gradVector->sizeLocal() >= 4) {
1976 (*gradVector)[0] = lnLikelihoodValue;
1977 (*gradVector)[1] = 0.;
1978 (*gradVector)[2] = 0.;
1979 (*gradVector)[3] = 0.;
1983 if (m_like_counter == 0) {
1988 return lnLikelihoodValue;
1991 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
1994 const P_V& input_1lambdaEtaVec,
1995 const P_V& input_2lambdaWVec,
1996 const P_V& input_3rhoWVec,
1997 const P_V& input_4lambdaSVec,
1998 const P_V& input_5lambdaYVec,
1999 const P_V& input_6lambdaVVec,
2000 const P_V& input_7rhoVVec,
2001 const P_V& input_8thetaVec,
2002 unsigned int outerCounter)
2004 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2005 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2006 <<
", outerCounter = " << outerCounter
2007 <<
": m_formCMatrix = " << m_formCMatrix
2008 <<
", m_optionsObj->m_useTildeLogicForRankDefficientC = " << m_optionsObj->m_useTildeLogicForRankDefficientC
2009 <<
", m_Cmat = " << m_z->m_Cmat
2010 <<
", m_cMatIsRankDefficient = " << m_cMatIsRankDefficient
2015 "'m_useTildeLogicForRankDefficientC' should be 'false'");
2024 this->formSigma_z(input_2lambdaWVec,
2032 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2033 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2034 <<
", outerCounter = " << outerCounter
2035 <<
": finished forming 'm_tmp_Smat_z'"
2036 <<
"\n m_tmp_Smat_z contents = " << m_z->m_tmp_Smat_z
2040 if (m_env.displayVerbosity() >= 4) {
2041 double sigmaZLnDeterminant = m_z->m_tmp_Smat_z.lnDeterminant();
2042 unsigned int sigmaZRank = m_z->m_tmp_Smat_z.rank(0.,1.e-8 );
2043 unsigned int sigmaZRank14 = m_z->m_tmp_Smat_z.rank(0.,1.e-14);
2044 if (m_env.subDisplayFile()) {
2045 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2046 <<
", outerCounter = " << outerCounter
2047 <<
", m_tmp_Smat_z.numRowsLocal() = " << m_z->m_tmp_Smat_z.numRowsLocal()
2048 <<
", m_tmp_Smat_z.numCols() = " << m_z->m_tmp_Smat_z.numCols()
2049 <<
", m_tmp_Smat_z.lnDeterminant() = " << sigmaZLnDeterminant
2050 <<
", m_tmp_Smat_z.rank(0.,1.e-8) = " << sigmaZRank
2051 <<
", m_tmp_Smat_z.rank(0.,1.e-14) = " << sigmaZRank14
2056 std::set<unsigned int> tmpSet;
2057 tmpSet.insert(m_env.subId());
2058 if (outerCounter == 1) {
2059 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2060 m_z->m_tmp_Smat_z.subWriteContents(
"Sigma_z",
2070 if (m_allOutputsAreScalar) {
2074 m_z->m_tmp_Smat_extra.cwSet(0.);
2075 m_z->m_tmp_Smat_extra.cwSet( 0, 0,(1./input_5lambdaYVec [0]) * *m_j->m_Bop_t__Wy__Bop__inv);
2076 m_z->m_tmp_Smat_extra.cwSet(m_j->m_Bop_t__Wy__Bop__inv->numRowsLocal(),m_j->m_Bop_t__Wy__Bop__inv->numCols(),(1./input_1lambdaEtaVec[0]) * *m_s->m_Kt_K_inv );
2079 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2080 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2081 <<
", outerCounter = " << outerCounter
2082 <<
": finished forming 'm_tmp_Smat_extra'"
2083 <<
", input_5lambdaYVec[0] = " << input_5lambdaYVec[0]
2084 <<
", input_1lambdaEtaVec[0] = " << input_1lambdaEtaVec[0]
2085 <<
"\n m_Bop_t__Wy__Bop__inv = " << *m_j->m_Bop_t__Wy__Bop__inv
2086 <<
"\n m_Kt_K_inv = " << *m_s->m_Kt_K_inv
2087 <<
"\n m_tmp_Smat_extra contents = " << m_z->m_tmp_Smat_extra
2091 if (m_env.displayVerbosity() >= 4) {
2092 double extraLnDeterminant = m_z->m_tmp_Smat_extra.lnDeterminant();
2093 unsigned int extraRank = m_z->m_tmp_Smat_extra.rank(0.,1.e-8 );
2094 unsigned int extraRank14 = m_z->m_tmp_Smat_extra.rank(0.,1.e-14);
2095 if (m_env.subDisplayFile()) {
2096 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2097 <<
", outerCounter = " << outerCounter
2098 <<
", m_tmp_Smat_extra.numRowsLocal() = " << m_z->m_tmp_Smat_extra.numRowsLocal()
2099 <<
", m_tmp_Smat_extra.numCols() = " << m_z->m_tmp_Smat_extra.numCols()
2100 <<
", m_tmp_Smat_extra.lnDeterminant() = " << extraLnDeterminant
2101 <<
", m_tmp_Smat_extra.rank(0.,1.e-8) = " << extraRank
2102 <<
", m_tmp_Smat_extra.rank(0.,1.e-14) = " << extraRank14
2107 if (outerCounter == 1) {
2108 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2109 m_z->m_tmp_Smat_extra.subWriteContents(
"Sigma_extra",
2119 m_z->m_tmp_Smat_z_hat = m_z->m_tmp_Smat_z + m_z->m_tmp_Smat_extra;
2121 if (m_env.displayVerbosity() >= 4) {
2122 double zHatLnDeterminant = m_z->m_tmp_Smat_z_hat.lnDeterminant();
2123 unsigned int zHatRank = m_z->m_tmp_Smat_z_hat.rank(0.,1.e-8 );
2124 unsigned int zHatRank14 = m_z->m_tmp_Smat_z_hat.rank(0.,1.e-14);
2125 if (m_env.subDisplayFile()) {
2126 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2127 <<
", outerCounter = " << outerCounter
2128 <<
", m_tmp_Smat_z_hat.numRowsLocal() = " << m_z->m_tmp_Smat_z_hat.numRowsLocal()
2129 <<
", m_tmp_Smat_z_hat.numCols() = " << m_z->m_tmp_Smat_z_hat.numCols()
2130 <<
", m_tmp_Smat_z_hat.lnDeterminant() = " << zHatLnDeterminant
2131 <<
", m_tmp_Smat_z_hat.rank(0.,1.e-8) = " << zHatRank
2132 <<
", m_tmp_Smat_z_hat.rank(0.,1.e-14) = " << zHatRank14
2137 if (outerCounter == 1) {
2138 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2139 m_z->m_tmp_Smat_z_hat.subWriteContents(
"Sigma_z_hat",
2146 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2147 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(1)"
2148 <<
", outerCounter = " << outerCounter
2156 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
2159 const P_V& input_1lambdaEtaVec,
2160 const P_V& input_2lambdaWVec,
2161 const P_V& input_3rhoWVec,
2162 const P_V& input_4lambdaSVec,
2163 unsigned int outerCounter)
2165 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2166 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2167 <<
", outerCounter = " << outerCounter
2168 <<
": m_formCMatrix = " << m_formCMatrix
2169 <<
", m_optionsObj->m_useTildeLogicForRankDefficientC = " << m_optionsObj->m_useTildeLogicForRankDefficientC
2170 <<
", m_Cmat = " << m_z->m_Cmat
2171 <<
", m_cMatIsRankDefficient = " << m_cMatIsRankDefficient
2176 "'m_useTildeLogicForRankDefficientC' should be 'false'");
2185 this->formSigma_z(input_2lambdaWVec,
2190 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2191 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2192 <<
", outerCounter = " << outerCounter
2193 <<
": finished forming 'm_tmp_Smat_z'"
2194 <<
"\n m_tmp_Smat_z contents = " << m_z->m_tmp_Smat_z
2198 if (m_env.displayVerbosity() >= 4) {
2199 double sigmaZLnDeterminant = m_z->m_tmp_Smat_z.lnDeterminant();
2200 unsigned int sigmaZRank = m_z->m_tmp_Smat_z.rank(0.,1.e-8 );
2201 unsigned int sigmaZRank14 = m_z->m_tmp_Smat_z.rank(0.,1.e-14);
2202 if (m_env.subDisplayFile()) {
2203 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2204 <<
", outerCounter = " << outerCounter
2205 <<
", m_tmp_Smat_z.numRowsLocal() = " << m_z->m_tmp_Smat_z.numRowsLocal()
2206 <<
", m_tmp_Smat_z.numCols() = " << m_z->m_tmp_Smat_z.numCols()
2207 <<
", m_tmp_Smat_z.lnDeterminant() = " << sigmaZLnDeterminant
2208 <<
", m_tmp_Smat_z.rank(0.,1.e-8) = " << sigmaZRank
2209 <<
", m_tmp_Smat_z.rank(0.,1.e-14) = " << sigmaZRank14
2214 #if 0 // Case with no experimental data // checar
2218 if (m_allOutputsAreScalar) {
2222 m_z->m_tmp_Smat_extra.cwSet(0.);
2223 m_z->m_tmp_Smat_extra.cwSet( 0, 0,(1./input_5lambdaYVec [0]) * *m_j->m_Bop_t__Wy__Bop__inv);
2224 m_z->m_tmp_Smat_extra.cwSet(m_j->m_Bop_t__Wy__Bop__inv->numRowsLocal(),m_j->m_Bop_t__Wy__Bop__inv->numCols(),(1./input_1lambdaEtaVec[0]) * *m_s->m_Kt_K_inv );
2227 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2228 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2229 <<
", outerCounter = " << outerCounter
2230 <<
": finished forming 'm_tmp_Smat_extra'"
2231 <<
", input_5lambdaYVec[0] = " << input_5lambdaYVec[0]
2232 <<
", input_1lambdaEtaVec[0] = " << input_1lambdaEtaVec[0]
2233 <<
"\n m_Bop_t__Wy__Bop__inv = " << *m_j->m_Bop_t__Wy__Bop__inv
2234 <<
"\n m_Kt_K_inv = " << *m_s->m_Kt_K_inv
2235 <<
"\n m_tmp_Smat_extra contents = " << m_z->m_tmp_Smat_extra
2239 if (m_env.displayVerbosity() >= 4) {
2240 double extraLnDeterminant = m_z->m_tmp_Smat_extra.lnDeterminant();
2241 unsigned int extraRank = m_z->m_tmp_Smat_extra.rank(0.,1.e-8 );
2242 unsigned int extraRank14 = m_z->m_tmp_Smat_extra.rank(0.,1.e-14);
2243 if (m_env.subDisplayFile()) {
2244 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2245 <<
", outerCounter = " << outerCounter
2246 <<
", m_tmp_Smat_extra.numRowsLocal() = " << m_z->m_tmp_Smat_extra.numRowsLocal()
2247 <<
", m_tmp_Smat_extra.numCols() = " << m_z->m_tmp_Smat_extra.numCols()
2248 <<
", m_tmp_Smat_extra.lnDeterminant() = " << extraLnDeterminant
2249 <<
", m_tmp_Smat_extra.rank(0.,1.e-8) = " << extraRank
2250 <<
", m_tmp_Smat_extra.rank(0.,1.e-14) = " << extraRank14
2258 m_z->m_tmp_Smat_z_hat = m_z->m_tmp_Smat_z + m_z->m_tmp_Smat_extra;
2260 if (m_env.displayVerbosity() >= 4) {
2261 double zHatLnDeterminant = m_z->m_tmp_Smat_z_hat.lnDeterminant();
2262 unsigned int zHatRank = m_z->m_tmp_Smat_z_hat.rank(0.,1.e-8 );
2263 unsigned int zHatRank14 = m_z->m_tmp_Smat_z_hat.rank(0.,1.e-14);
2264 if (m_env.subDisplayFile()) {
2265 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2266 <<
", outerCounter = " << outerCounter
2267 <<
", m_tmp_Smat_z_hat.numRowsLocal() = " << m_z->m_tmp_Smat_z_hat.numRowsLocal()
2268 <<
", m_tmp_Smat_z_hat.numCols() = " << m_z->m_tmp_Smat_z_hat.numCols()
2269 <<
", m_tmp_Smat_z_hat.lnDeterminant() = " << zHatLnDeterminant
2270 <<
", m_tmp_Smat_z_hat.rank(0.,1.e-8) = " << zHatRank
2271 <<
", m_tmp_Smat_z_hat.rank(0.,1.e-14) = " << zHatRank14
2276 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2277 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_hat(2)"
2278 <<
", outerCounter = " << outerCounter
2285 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
2288 const P_V& input_1lambdaEtaVec,
2289 const P_V& input_2lambdaWVec,
2290 const P_V& input_3rhoWVec,
2291 const P_V& input_4lambdaSVec,
2292 const P_V& input_5lambdaYVec,
2293 const P_V& input_6lambdaVVec,
2294 const P_V& input_7rhoVVec,
2295 const P_V& input_8thetaVec,
2296 unsigned int outerCounter)
2298 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2299 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2300 <<
", outerCounter = " << outerCounter
2301 <<
": m_formCMatrix = " << m_formCMatrix
2302 <<
", m_optionsObj->m_useTildeLogicForRankDefficientC = " << m_optionsObj->m_useTildeLogicForRankDefficientC
2303 <<
", m_Cmat = " << m_z->m_Cmat
2304 <<
", m_cMatIsRankDefficient = " << m_cMatIsRankDefficient
2312 queso_require_msg(m_cMatIsRankDefficient,
"'m_Cmat' should be rank defficient");
2314 queso_require_msg(m_optionsObj->m_useTildeLogicForRankDefficientC,
"'m_useTildeLogicForRankDefficientC' should be 'true'");
2323 this->formSigma_z(input_2lambdaWVec,
2331 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2332 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2333 <<
", outerCounter = " << outerCounter
2334 <<
": finished forming 'm_tmp_Smat_z'"
2335 <<
"\n m_tmp_Smat_z contents = " << m_z->m_tmp_Smat_z
2339 if (m_env.displayVerbosity() >= 4) {
2340 double sigmaZLnDeterminant = m_z->m_tmp_Smat_z.lnDeterminant();
2341 unsigned int sigmaZRank = m_z->m_tmp_Smat_z.rank(0.,1.e-8 );
2342 unsigned int sigmaZRank14 = m_z->m_tmp_Smat_z.rank(0.,1.e-14);
2343 if (m_env.subDisplayFile()) {
2344 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2345 <<
", outerCounter = " << outerCounter
2346 <<
", m_tmp_Smat_z.numRowsLocal() = " << m_z->m_tmp_Smat_z.numRowsLocal()
2347 <<
", m_tmp_Smat_z.numCols() = " << m_z->m_tmp_Smat_z.numCols()
2348 <<
", m_tmp_Smat_z.lnDeterminant() = " << sigmaZLnDeterminant
2349 <<
", m_tmp_Smat_z.rank(0.,1.e-8) = " << sigmaZRank
2350 <<
", m_tmp_Smat_z.rank(0.,1.e-14) = " << sigmaZRank14
2358 m_zt->m_tmp_Smat_z_tilde = m_zt->m_Lmat * (m_z->m_tmp_Smat_z * m_zt->m_Lmat_t);
2360 if (m_env.displayVerbosity() >= 4) {
2361 double sigmaZTildeLnDeterminant = m_zt->m_tmp_Smat_z_tilde.lnDeterminant();
2362 unsigned int sigmaZTildeRank = m_zt->m_tmp_Smat_z_tilde.rank(0.,1.e-8 );
2363 unsigned int sigmaZTildeRank14 = m_zt->m_tmp_Smat_z_tilde.rank(0.,1.e-14);
2364 if (m_env.subDisplayFile()) {
2365 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2366 <<
", outerCounter = " << outerCounter
2367 <<
", m_tmp_Smat_z_tilde->numRowsLocal() = " << m_zt->m_tmp_Smat_z_tilde.numRowsLocal()
2368 <<
", m_tmp_Smat_z_tilde->numCols() = " << m_zt->m_tmp_Smat_z_tilde.numCols()
2369 <<
", m_tmp_Smat_z_tilde->lnDeterminant() = " << sigmaZTildeLnDeterminant
2370 <<
", m_tmp_Smat_z_tilde->rank(0.,1.e-8) = " << sigmaZTildeRank
2371 <<
", m_tmp_Smat_z_tilde->rank(0.,1.e-14) = " << sigmaZTildeRank14
2379 m_zt->m_tmp_Smat_extra_tilde.cwSet(0.);
2380 m_zt->m_tmp_Smat_extra_tilde.cwSet( 0, 0,(1./input_5lambdaYVec [0]) * (m_jt->m_Btildet_Wy_Btilde_inv));
2381 m_zt->m_tmp_Smat_extra_tilde.cwSet(m_jt->m_Btildet_Wy_Btilde_inv.numRowsLocal(),m_jt->m_Btildet_Wy_Btilde_inv.numCols(),(1./input_1lambdaEtaVec[0]) * (m_st->m_Ktildet_Ktilde_inv) );
2383 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
2384 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2385 <<
", outerCounter = " << outerCounter
2386 <<
": finished forming 'm_tmp_Smat_extra_tilde'"
2387 <<
", input_5lambdaYVec[0] = " << input_5lambdaYVec[0]
2388 <<
", input_1lambdaEtaVec[0] = " << input_1lambdaEtaVec[0]
2389 <<
"\n m_Btildet_Wy_Btilde_inv = " << m_jt->m_Btildet_Wy_Btilde_inv
2390 <<
"\n m_Ktildet_Ktilde_inv = " << m_st->m_Ktildet_Ktilde_inv
2391 <<
"\n m_tmp_Smat_extra_tilde contents = " << m_zt->m_tmp_Smat_extra_tilde
2395 if (m_env.displayVerbosity() >= 4) {
2396 double extraTildeLnDeterminant = m_zt->m_tmp_Smat_extra_tilde.lnDeterminant();
2397 unsigned int extraTildeRank = m_zt->m_tmp_Smat_extra_tilde.rank(0.,1.e-8 );
2398 unsigned int extraTildeRank14 = m_zt->m_tmp_Smat_extra_tilde.rank(0.,1.e-14);
2399 if (m_env.subDisplayFile()) {
2400 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2401 <<
", outerCounter = " << outerCounter
2402 <<
", m_tmp_Smat_extra_tilde.numRowsLocal() = " << m_zt->m_tmp_Smat_extra_tilde.numRowsLocal()
2403 <<
", m_tmp_Smat_extra_tilde.numCols() = " << m_zt->m_tmp_Smat_extra_tilde.numCols()
2404 <<
", m_tmp_Smat_extra_tilde.lnDeterminant() = " << extraTildeLnDeterminant
2405 <<
", m_tmp_Smat_extra_tilde.rank(0.,1.e-8) = " << extraTildeRank
2406 <<
", m_tmp_Smat_extra_tilde.rank(0.,1.e-14) = " << extraTildeRank14
2414 m_zt->m_tmp_Smat_z_tilde_hat = m_zt->m_tmp_Smat_z_tilde + m_zt->m_tmp_Smat_extra_tilde;
2416 if (m_env.displayVerbosity() >= 4) {
2417 double zTildeHatLnDeterminant = m_zt->m_tmp_Smat_z_tilde_hat.lnDeterminant();
2418 unsigned int zTildeHatRank = m_zt->m_tmp_Smat_z_tilde_hat.rank(0.,1.e-8 );
2419 unsigned int zTildeHatRank14 = m_zt->m_tmp_Smat_z_tilde_hat.rank(0.,1.e-14);
2420 if (m_env.subDisplayFile()) {
2421 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2422 <<
", outerCounter = " << outerCounter
2423 <<
", m_tmp_Smat_z_tilde_hat->numRowsLocal() = " << m_zt->m_tmp_Smat_z_tilde_hat.numRowsLocal()
2424 <<
", m_tmp_Smat_z_tilde_hat->numCols() = " << m_zt->m_tmp_Smat_z_tilde_hat.numCols()
2425 <<
", m_tmp_Smat_z_tilde_hat->lnDeterminant() = " << zTildeHatLnDeterminant
2426 <<
", m_tmp_Smat_z_tilde_hat->rank(0.,1.e-8) = " << zTildeHatRank
2427 <<
", m_tmp_Smat_z_tilde_hat->rank(0.,1.e-14) = " << zTildeHatRank14
2432 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2433 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z_tilde_hat()"
2434 <<
", outerCounter = " << outerCounter
2441 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
2444 const P_V& input_2lambdaWVec,
2445 const P_V& input_3rhoWVec,
2446 const P_V& input_4lambdaSVec,
2447 const P_V& input_6lambdaVVec,
2448 const P_V& input_7rhoVVec,
2449 const P_V& input_8thetaVec,
2450 unsigned int outerCounter)
2452 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2453 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2454 <<
", outerCounter = " << outerCounter
2458 std::set<unsigned int> tmpSet;
2459 tmpSet.insert(m_env.subId());
2461 this->memoryCheck(90);
2490 unsigned int initialPos = 0;
2491 for (
unsigned int i = 0; i < m_e->m_Smat_v_i_spaces.size(); ++i) {
2492 input_7rhoVVec.cwExtract(initialPos,m_e->m_tmp_rho_v_vec);
2493 initialPos += m_e->m_tmp_rho_v_vec.sizeLocal();
2494 m_e->m_Rmat_v_is[i]->cwSet(0.);
2495 this->fillR_formula2_for_Sigma_v(m_e->m_paper_xs_standard,
2496 m_e->m_tmp_rho_v_vec,
2497 *(m_e->m_Rmat_v_is[i]),
2500 m_e->m_Smat_v_is[i]->cwSet(0.);
2501 m_e->m_Smat_v_is[i]->fillWithTensorProduct(0,0,*(m_e->m_Imat_v_is[i]),*(m_e->m_Rmat_v_is[i]),
true,
true);
2502 *(m_e->m_Smat_v_is[i]) *= (1./input_6lambdaVVec[i]);
2504 m_e->m_Smat_v.cwSet(0.);
2505 m_e->m_Smat_v.fillWithBlocksDiagonally(0,0,m_e->m_Smat_v_is,
true,
true);
2506 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2507 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2508 <<
", outerCounter = " << outerCounter
2509 <<
": finished instantiating 'm_Smat_v'"
2513 if (outerCounter == 1) {
2514 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2515 m_e->m_Smat_v.subWriteContents(
"Sigma_v",
2522 this->memoryCheck(91);
2525 for (
unsigned int i = 0; i < m_j->m_Smat_u_is.size(); ++i) {
2526 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2527 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2528 m_j->m_Rmat_u_is[i]->cwSet(0.);
2529 this->fillR_formula1_for_Sigma_u(m_e->m_paper_xs_standard,
2531 m_s->m_tmp_rho_w_vec,
2532 *(m_j->m_Rmat_u_is[i]),
2535 m_j->m_Smat_u_is[i]->cwSet(0.);
2536 *(m_j->m_Smat_u_is[i]) = (1./input_2lambdaWVec[i]) * *(m_j->m_Rmat_u_is[i]);
2537 for (
unsigned int j = 0; j < m_j->m_Smat_u_is[i]->numRowsLocal(); ++j) {
2538 (*(m_j->m_Smat_u_is[i]))(j,j) += 1/m_s->m_tmp_4lambdaSVec[i];
2541 m_j->m_Smat_u.cwSet(0.);
2542 m_j->m_Smat_u.fillWithBlocksDiagonally(0,0,m_j->m_Smat_u_is,
true,
true);
2543 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2544 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2545 <<
", outerCounter = " << outerCounter
2546 <<
": finished instantiating 'm_Smat_u'"
2550 if (outerCounter == 1) {
2551 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2552 m_j->m_Smat_u.subWriteContents(
"Sigma_u",
2559 this->memoryCheck(92);
2562 for (
unsigned int i = 0; i < m_s->m_Smat_w_is.size(); ++i) {
2563 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2564 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2565 m_s->m_Rmat_w_is[i]->cwSet(0.);
2566 this->fillR_formula1_for_Sigma_w(m_s->m_paper_xs_asterisks_standard,
2567 m_s->m_paper_ts_asterisks_standard,
2568 m_s->m_tmp_rho_w_vec,
2569 *(m_s->m_Rmat_w_is[i]),
2572 m_s->m_Smat_w_is[i]->cwSet(0.);
2573 *(m_s->m_Smat_w_is[i]) = (1./input_2lambdaWVec[i]) * *(m_s->m_Rmat_w_is[i]);
2575 if ((outerCounter == 1) &&
2577 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
2578 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2579 <<
", outerCounter = " << outerCounter
2580 <<
": during the calculation of 'm_Smat_w'"
2581 <<
"\n m_s->m_paper_xs_asterisks_standard.size() = " << m_s->m_paper_xs_asterisks_standard.size();
2582 for (
unsigned int tmpId = 0; tmpId < m_s->m_paper_xs_asterisks_standard.size(); ++tmpId) {
2583 *m_env.subDisplayFile() <<
"\n m_s->m_paper_xs_asterisks_standard[" << tmpId <<
"] = "
2584 << *(m_s->m_paper_xs_asterisks_standard[tmpId])
2587 *m_env.subDisplayFile() <<
"\n m_s->m_paper_ts_asterisks_standard.size() = " << m_s->m_paper_ts_asterisks_standard.size();
2588 for (
unsigned int tmpId = 0; tmpId < m_s->m_paper_ts_asterisks_standard.size(); ++tmpId) {
2589 *m_env.subDisplayFile() <<
"\n m_s->m_paper_ts_asterisks_standard[" << tmpId <<
"] = "
2590 << *(m_s->m_paper_ts_asterisks_standard[tmpId])
2593 *m_env.subDisplayFile() <<
"\n m_s->m_tmp_rho_w_vec = " << m_s->m_tmp_rho_w_vec
2594 <<
"\n (*(m_s->m_Rmat_w_is[i=0]))(0,0) = " << (*(m_s->m_Rmat_w_is[i]))(0,0)
2595 <<
"\n input_2lambdaWVec[i=0] = " << input_2lambdaWVec[i]
2596 <<
"\n (*(m_s->m_Smat_w_is[i=0]))(0,0) = " << (*(m_s->m_Smat_w_is[i]))(0,0)
2597 <<
"\n m_s->m_tmp_4lambdaSVec[i=0] = " << m_s->m_tmp_4lambdaSVec[i]
2602 for (
unsigned int j = 0; j < m_s->m_Smat_w_is[i]->numRowsLocal(); ++j) {
2603 (*(m_s->m_Smat_w_is[i]))(j,j) += 1/m_s->m_tmp_4lambdaSVec[i];
2606 if ((outerCounter == 1) &&
2608 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
2609 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2610 <<
", outerCounter = " << outerCounter
2611 <<
": during the calculation of 'm_Smat_w'"
2612 <<
"\n (*(m_s->m_Smat_w_is[i=0]))(0,0) = " << (*(m_s->m_Smat_w_is[i]))(0,0)
2617 m_s->m_Smat_w.cwSet(0.);
2618 m_s->m_Smat_w.fillWithBlocksDiagonally(0,0,m_s->m_Smat_w_is,
true,
true);
2619 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2620 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2621 <<
", outerCounter = " << outerCounter
2622 <<
": finished instantiating 'm_Smat_w'"
2626 if (outerCounter == 1) {
2627 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2628 m_s->m_Smat_w.subWriteContents(
"Sigma_w",
2635 this->memoryCheck(93);
2638 for (
unsigned int i = 0; i < m_j->m_Smat_uw_is.size(); ++i) {
2639 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2640 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2641 m_j->m_Rmat_uw_is[i]->cwSet(0.);
2642 this->fillR_formula1_for_Sigma_uw(m_e->m_paper_xs_standard,
2644 m_s->m_paper_xs_asterisks_standard,
2645 m_s->m_paper_ts_asterisks_standard,
2646 m_s->m_tmp_rho_w_vec,*(m_j->m_Rmat_uw_is[i]),
2649 m_j->m_Smat_uw_is[i]->cwSet(0.);
2650 *(m_j->m_Smat_uw_is[i]) = (1./input_2lambdaWVec[i]) * *(m_j->m_Rmat_uw_is[i]);
2652 m_j->m_Smat_uw.cwSet(0.);
2653 m_j->m_Smat_uw.fillWithBlocksDiagonally(0,0,m_j->m_Smat_uw_is,
true,
true);
2654 m_j->m_Smat_uw_t.fillWithTranspose(0,0,m_j->m_Smat_uw,
true,
true);
2655 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2656 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2657 <<
", outerCounter = " << outerCounter
2658 <<
": finished instantiating 'm_j->m_Smat_uw'"
2662 if (outerCounter == 1) {
2663 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2664 m_j->m_Smat_uw.subWriteContents(
"Sigma_uw",
2671 this->memoryCheck(94);
2676 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2677 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2678 <<
", outerCounter = " << outerCounter
2679 <<
": m_tmp_Smat_z.numRowsLocal() = " << m_z->m_tmp_Smat_z.numRowsLocal()
2680 <<
", m_tmp_Smat_z.numCols() = " << m_z->m_tmp_Smat_z.numCols()
2681 <<
", m_Smat_v.numRowsLocal() = " << m_e->m_Smat_v.numRowsLocal()
2682 <<
", m_Smat_v.numCols() = " << m_e->m_Smat_v.numCols()
2683 <<
", m_Smat_u.numRowsLocal() = " << m_j->m_Smat_u.numRowsLocal()
2684 <<
", m_Smat_u.numCols() = " << m_j->m_Smat_u.numCols()
2685 <<
", m_Smat_w.numRowsLocal() = " << m_s->m_Smat_w.numRowsLocal()
2686 <<
", m_Smat_w.numCols() = " << m_s->m_Smat_w.numCols()
2687 <<
", m_Smat_uw.numRowsLocal() = " << m_j->m_Smat_uw.numRowsLocal()
2688 <<
", m_Smat_uw.numCols() = " << m_j->m_Smat_uw.numCols()
2689 <<
", m_Smat_v_i_spaces.size() = " << m_e->m_Smat_v_i_spaces.size()
2690 <<
", m_Smat_u_is.size() = " << m_j->m_Smat_u_is.size()
2691 <<
", m_Smat_w_is.size() = " << m_s->m_Smat_w_is.size()
2695 this->memoryCheck(95);
2697 m_z->m_tmp_Smat_z.cwSet(0.);
2698 if (m_allOutputsAreScalar) {
2702 m_z->m_tmp_Smat_z.cwSet(0,0,m_e->m_Smat_v);
2703 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal(), m_e->m_Smat_v.numCols(), m_j->m_Smat_u);
2704 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal(), m_e->m_Smat_v.numCols()+m_j->m_Smat_u.numCols(),m_j->m_Smat_uw);
2705 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal()+m_j->m_Smat_u.numRowsLocal(),m_e->m_Smat_v.numCols(), m_j->m_Smat_uw_t);
2706 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal()+m_j->m_Smat_u.numRowsLocal(),m_e->m_Smat_v.numCols()+m_j->m_Smat_u.numCols(),m_s->m_Smat_w);
2709 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2710 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(1)"
2711 <<
", outerCounter = " << outerCounter
2719 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
2722 const P_V& input_2lambdaWVec,
2723 const P_V& input_3rhoWVec,
2724 const P_V& input_4lambdaSVec,
2725 unsigned int outerCounter)
2727 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2728 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2729 <<
", outerCounter = " << outerCounter
2733 std::set<unsigned int> tmpSet;
2734 tmpSet.insert(m_env.subId());
2736 this->memoryCheck(90);
2765 #if 0 // Case with no experimental data // checar
2766 unsigned int initialPos = 0;
2767 for (
unsigned int i = 0; i < m_e->m_Smat_v_i_spaces.size(); ++i) {
2768 input_7rhoVVec.cwExtract(initialPos,m_e->m_tmp_rho_v_vec);
2769 initialPos += m_e->m_tmp_rho_v_vec.sizeLocal();
2770 m_e->m_Rmat_v_is[i]->cwSet(0.);
2771 this->fillR_formula2_for_Sigma_v(m_e->m_paper_xs_standard,
2772 m_e->m_tmp_rho_v_vec,
2773 *(m_e->m_Rmat_v_is[i]),
2776 m_e->m_Smat_v_is[i]->cwSet(0.);
2777 m_e->m_Smat_v_is[i]->fillWithTensorProduct(0,0,*(m_e->m_Imat_v_is[i]),*(m_e->m_Rmat_v_is[i]),
true,
true);
2778 *(m_e->m_Smat_v_is[i]) *= (1./input_6lambdaVVec[i]);
2780 m_e->m_Smat_v.cwSet(0.);
2781 m_e->m_Smat_v.fillWithBlocksDiagonally(0,0,m_e->m_Smat_v_is,
true,
true);
2782 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2783 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2784 <<
", outerCounter = " << outerCounter
2785 <<
": finished instantiating 'm_Smat_v'"
2789 if (outerCounter == 1) {
2790 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2791 m_e->m_Smat_v.subWriteContents(
"Sigma_v",
2797 this->memoryCheck(91);
2800 for (
unsigned int i = 0; i < m_j->m_Smat_u_is.size(); ++i) {
2801 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2802 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2803 m_j->m_Rmat_u_is[i]->cwSet(0.);
2804 this->fillR_formula1_for_Sigma_u(m_e->m_paper_xs_standard,
2806 m_s->m_tmp_rho_w_vec,
2807 *(m_j->m_Rmat_u_is[i]),
2810 m_j->m_Smat_u_is[i]->cwSet(0.);
2811 *(m_j->m_Smat_u_is[i]) = (1./input_2lambdaWVec[i]) * *(m_j->m_Rmat_u_is[i]);
2812 for (
unsigned int j = 0; j < m_j->m_Smat_u_is[i]->numRowsLocal(); ++j) {
2813 (*(m_j->m_Smat_u_is[i]))(j,j) += 1/m_s->m_tmp_4lambdaSVec[i];
2816 m_j->m_Smat_u.cwSet(0.);
2817 m_j->m_Smat_u.fillWithBlocksDiagonally(0,0,m_j->m_Smat_u_is,
true,
true);
2818 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2819 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2820 <<
", outerCounter = " << outerCounter
2821 <<
": finished instantiating 'm_Smat_u'"
2825 if (outerCounter == 1) {
2826 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2827 m_j->m_Smat_u.subWriteContents(
"Sigma_u",
2834 this->memoryCheck(92);
2837 for (
unsigned int i = 0; i < m_s->m_Smat_w_is.size(); ++i) {
2838 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2839 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2840 m_s->m_Rmat_w_is[i]->cwSet(0.);
2841 this->fillR_formula1_for_Sigma_w(m_s->m_paper_xs_asterisks_standard,
2842 m_s->m_paper_ts_asterisks_standard,
2843 m_s->m_tmp_rho_w_vec,
2844 *(m_s->m_Rmat_w_is[i]),
2847 m_s->m_Smat_w_is[i]->cwSet(0.);
2848 *(m_s->m_Smat_w_is[i]) = (1./input_2lambdaWVec[i]) * *(m_s->m_Rmat_w_is[i]);
2849 for (
unsigned int j = 0; j < m_s->m_Smat_w_is[i]->numRowsLocal(); ++j) {
2850 (*(m_s->m_Smat_w_is[i]))(j,j) += 1/m_s->m_tmp_4lambdaSVec[i];
2853 m_s->m_Smat_w.cwSet(0.);
2854 m_s->m_Smat_w.fillWithBlocksDiagonally(0,0,m_s->m_Smat_w_is,
true,
true);
2855 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2856 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2857 <<
", outerCounter = " << outerCounter
2858 <<
": finished instantiating 'm_Smat_w'"
2862 if (outerCounter == 1) {
2863 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2864 m_s->m_Smat_w.subWriteContents(
"Sigma_w",
2871 this->memoryCheck(93);
2874 for (
unsigned int i = 0; i < m_j->m_Smat_uw_is.size(); ++i) {
2875 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2876 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2877 m_j->m_Rmat_uw_is[i]->cwSet(0.);
2878 this->fillR_formula1_for_Sigma_uw(m_e->m_paper_xs_standard,
2880 m_s->m_paper_xs_asterisks_standard,
2881 m_s->m_paper_ts_asterisks_standard,
2882 m_s->m_tmp_rho_w_vec,*(m_j->m_Rmat_uw_is[i]),
2885 m_j->m_Smat_uw_is[i]->cwSet(0.);
2886 *(m_j->m_Smat_uw_is[i]) = (1./input_2lambdaWVec[i]) * *(m_j->m_Rmat_uw_is[i]);
2888 m_j->m_Smat_uw.cwSet(0.);
2889 m_j->m_Smat_uw.fillWithBlocksDiagonally(0,0,m_j->m_Smat_uw_is,
true,
true);
2890 m_j->m_Smat_uw_t.fillWithTranspose(0,0,m_j->m_Smat_uw,
true,
true);
2891 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2892 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2893 <<
", outerCounter = " << outerCounter
2894 <<
": finished instantiating 'm_j->m_Smat_uw'"
2898 if (outerCounter == 1) {
2899 if (m_optionsObj->m_dataOutputAllowedSet.find(m_env.subId()) != m_optionsObj->m_dataOutputAllowedSet.end()) {
2900 m_j->m_Smat_uw.subWriteContents(
"Sigma_uw",
2907 this->memoryCheck(94);
2912 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2913 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2914 <<
", outerCounter = " << outerCounter
2915 <<
": m_tmp_Smat_z.numRowsLocal() = " << m_z->m_tmp_Smat_z.numRowsLocal()
2916 <<
", m_tmp_Smat_z.numCols() = " << m_z->m_tmp_Smat_z.numCols()
2917 <<
", m_Smat_v.numRowsLocal() = " << m_e->m_Smat_v.numRowsLocal()
2918 <<
", m_Smat_v.numCols() = " << m_e->m_Smat_v.numCols()
2919 <<
", m_Smat_u.numRowsLocal() = " << m_j->m_Smat_u.numRowsLocal()
2920 <<
", m_Smat_u.numCols() = " << m_j->m_Smat_u.numCols()
2921 <<
", m_Smat_w.numRowsLocal() = " << m_s->m_Smat_w.numRowsLocal()
2922 <<
", m_Smat_w.numCols() = " << m_s->m_Smat_w.numCols()
2923 <<
", m_Smat_uw.numRowsLocal() = " << m_j->m_Smat_uw.numRowsLocal()
2924 <<
", m_Smat_uw.numCols() = " << m_j->m_Smat_uw.numCols()
2925 <<
", m_Smat_v_i_spaces.size() = " << m_e->m_Smat_v_i_spaces.size()
2926 <<
", m_Smat_u_is.size() = " << m_j->m_Smat_u_is.size()
2927 <<
", m_Smat_w_is.size() = " << m_s->m_Smat_w_is.size()
2931 this->memoryCheck(95);
2933 m_z->m_tmp_Smat_z.cwSet(0.);
2934 if (m_allOutputsAreScalar) {
2938 m_z->m_tmp_Smat_z.cwSet(0,0,m_e->m_Smat_v);
2939 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal(), m_e->m_Smat_v.numCols(), m_j->m_Smat_u);
2940 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal(), m_e->m_Smat_v.numCols()+m_j->m_Smat_u.numCols(),m_j->m_Smat_uw);
2941 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal()+m_j->m_Smat_u.numRowsLocal(),m_e->m_Smat_v.numCols(), m_j->m_Smat_uw_t);
2942 m_z->m_tmp_Smat_z.cwSet(m_e->m_Smat_v.numRowsLocal()+m_j->m_Smat_u.numRowsLocal(),m_e->m_Smat_v.numCols()+m_j->m_Smat_u.numCols(),m_s->m_Smat_w);
2945 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2946 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_z(2)"
2947 <<
", outerCounter = " << outerCounter
2954 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
2957 const P_V& input_1lambdaEtaVec,
2958 const P_V& input_2lambdaWVec,
2959 const P_V& input_3rhoWVec,
2960 const P_V& input_4lambdaSVec,
2961 const P_V& input_8thetaVec,
2962 unsigned int outerCounter)
2964 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2965 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_w_hat()"
2966 <<
", outerCounter = " << outerCounter
2970 unsigned int initialPos = 0;
2971 for (
unsigned int i = 0; i < m_s->m_Smat_w_is.size(); ++i) {
2972 input_3rhoWVec.cwExtract(initialPos,m_s->m_tmp_rho_w_vec);
2973 initialPos += m_s->m_tmp_rho_w_vec.sizeLocal();
2974 m_s->m_Rmat_w_is[i]->cwSet(0.);
2975 this->fillR_formula1_for_Sigma_w(m_s->m_paper_xs_asterisks_standard,
2976 m_s->m_paper_ts_asterisks_standard,
2977 m_s->m_tmp_rho_w_vec,
2978 *(m_s->m_Rmat_w_is[i]),
2981 m_s->m_Smat_w_is[i]->cwSet(0.);
2982 *(m_s->m_Smat_w_is[i]) = (1./input_2lambdaWVec[i]) * *(m_s->m_Rmat_w_is[i]);
2983 for (
unsigned int j = 0; j < m_s->m_Smat_w_is[i]->numRowsLocal(); ++j) {
2984 (*(m_s->m_Smat_w_is[i]))(j,j) += 1/m_s->m_tmp_4lambdaSVec[i];
2987 m_s->m_Smat_w.cwSet(0.);
2988 m_s->m_Smat_w.fillWithBlocksDiagonally(0,0,m_s->m_Smat_w_is,
true,
true);
2989 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
2990 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_w_hat()"
2991 <<
", outerCounter = " << outerCounter
2992 <<
": finished instantiating 'm_Smat_w'"
2996 if (m_allOutputsAreScalar) {
3000 m_s->m_Smat_w_hat = m_s->m_Smat_w + (1./input_1lambdaEtaVec[0]) * (*m_s->m_Kt_K_inv);
3003 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3004 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::formSigma_w_hat()"
3005 <<
", outerCounter = " << outerCounter
3012 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3015 const std::vector<const S_V* >& xVecs,
3016 const P_V& rho_v_vec,
3018 unsigned int outerCounter)
3020 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3021 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v()"
3022 <<
", outerCounter = " << outerCounter
3027 for (
unsigned int i = 0; i < xVecs.size(); ++i) {
3030 queso_require_msg(!((rho_v_vec.sizeLocal() == 0) || (rho_v_vec.sizeLocal() > m_s->m_paper_p_x)),
"rho_v_vec.sizeLocal() is wrong");
3034 S_V vecI(*(xVecs[0]));
3035 S_V vecJ(*(xVecs[0]));
3036 for (
unsigned int i = 0; i < m_e->m_paper_n; ++i) {
3038 for (
unsigned int j = 0; j < m_e->m_paper_n; ++j) {
3041 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3042 double diffTerm = vecI[
k] - vecJ[
k];
3043 Rmat(i,j) *= std::pow(rho_v_vec[
k],4.*diffTerm*diffTerm);
3044 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
3045 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v()"
3046 <<
", outerCounter = " << outerCounter
3050 <<
", vecI[k] = " << vecI[
k]
3051 <<
", vecJ[k] = " << vecJ[
k]
3052 <<
", diffTerm = " << diffTerm
3053 <<
", rho_v_vec[k] = " << rho_v_vec[
k]
3057 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
3058 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v()"
3059 <<
", outerCounter = " << outerCounter
3062 <<
", Rmat(i,j) = " << Rmat(i,j)
3068 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3069 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v()"
3070 <<
", outerCounter = " << outerCounter
3077 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3080 const std::vector<const S_V* >& xVecs,
3082 const P_V& rho_w_vec,
3084 unsigned int outerCounter)
3086 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3087 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_u()"
3088 <<
", outerCounter = " << outerCounter
3093 for (
unsigned int i = 0; i < xVecs.size(); ++i) {
3101 S_V vecI(*(xVecs[0]));
3102 S_V vecJ(*(xVecs[0]));
3103 for (
unsigned int i = 0; i < m_e->m_paper_n; ++i) {
3105 for (
unsigned int j = 0; j < m_e->m_paper_n; ++j) {
3108 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3109 double diffTerm = vecI[
k] - vecJ[
k];
3110 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3115 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3116 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_u()"
3117 <<
", outerCounter = " << outerCounter
3124 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3127 const std::vector<const S_V* >& xVecs,
3128 const std::vector<const P_V* >& tVecs,
3129 const P_V& rho_w_vec,
3131 unsigned int outerCounter)
3133 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3134 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w()"
3135 <<
", outerCounter = " << outerCounter
3140 for (
unsigned int i = 0; i < xVecs.size(); ++i) {
3144 for (
unsigned int i = 0; i < tVecs.size(); ++i) {
3151 S_V xVecI(*(xVecs[0]));
3152 S_V xVecJ(*(xVecs[0]));
3153 P_V tVecI(*(tVecs[0]));
3154 P_V tVecJ(*(tVecs[0]));
3155 for (
unsigned int i = 0; i < m_s->m_paper_m; ++i) {
3156 xVecI = *(xVecs[i]);
3157 tVecI = *(tVecs[i]);
3158 for (
unsigned int j = 0; j < m_s->m_paper_m; ++j) {
3159 xVecJ = *(xVecs[j]);
3160 tVecJ = *(tVecs[j]);
3162 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3163 double diffTerm = xVecI[
k] - xVecJ[
k];
3164 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3166 for (
unsigned int k = 0;
k < m_s->m_paper_p_t; ++
k) {
3167 double diffTerm = tVecI[
k] - tVecJ[
k];
3168 Rmat(i,j) *= std::pow(rho_w_vec[m_s->m_paper_p_x+
k],4.*diffTerm*diffTerm);
3173 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3174 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w()"
3175 <<
", outerCounter = " << outerCounter
3182 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3185 const std::vector<const S_V* >& xVecs1,
3187 const std::vector<const S_V* >& xVecs2,
3188 const std::vector<const P_V* >& tVecs2,
3189 const P_V& rho_w_vec,
3191 unsigned int outerCounter)
3193 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3194 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_uw()"
3195 <<
", outerCounter = " << outerCounter
3200 for (
unsigned int i = 0; i < xVecs1.size(); ++i) {
3205 for (
unsigned int i = 0; i < xVecs2.size(); ++i) {
3209 for (
unsigned int i = 0; i < tVecs2.size(); ++i) {
3216 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3217 *m_env.subDisplayFile() <<
"In GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_uw()"
3218 <<
", outerCounter = " << outerCounter
3222 S_V xVecI(*(xVecs1[0]));
3223 S_V xVecJ(*(xVecs2[0]));
3225 P_V tVecJ(*(tVecs2[0]));
3226 for (
unsigned int i = 0; i < m_e->m_paper_n; ++i) {
3227 xVecI = *(xVecs1[i]);
3229 for (
unsigned int j = 0; j < m_s->m_paper_m; ++j) {
3230 xVecJ = *(xVecs2[j]);
3231 tVecJ = *(tVecs2[j]);
3233 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3234 double diffTerm = xVecI[
k] - xVecJ[
k];
3235 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3237 for (
unsigned int k = 0;
k < m_s->m_paper_p_t; ++
k) {
3238 double diffTerm = tVecI[
k] - tVecJ[
k];
3239 Rmat(i,j) *= std::pow(rho_w_vec[m_s->m_paper_p_x+
k],4.*diffTerm*diffTerm);
3244 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3245 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_uw()"
3246 <<
", outerCounter = " << outerCounter
3253 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3256 const std::vector<const S_V* >& xVecs1,
3257 const std::vector<const P_V* >& tVecs1,
3260 const P_V& rho_v_vec,
3262 unsigned int outerCounter)
3264 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3265 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v_hat_v_asterisk()"
3266 <<
", outerCounter = " << outerCounter
3271 for (
unsigned int i = 0; i < xVecs1.size(); ++i) {
3275 for (
unsigned int i = 0; i < tVecs1.size(); ++i) {
3280 queso_require_msg(!((rho_v_vec.sizeLocal() == 0) || (rho_v_vec.sizeLocal() > m_s->m_paper_p_x)),
"rho_v_vec.sizeLocal() is wrong");
3284 S_V xVecI(*(xVecs1[0]));
3286 P_V tVecI(*(tVecs1[0]));
3288 for (
unsigned int i = 0; i < m_e->m_paper_n; ++i) {
3289 xVecI = *(xVecs1[i]);
3290 tVecI = *(tVecs1[i]);
3291 for (
unsigned int j = 0; j < 1; ++j) {
3296 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3297 double diffTerm = xVecI[
k] - xVecJ[
k];
3298 Rmat(i,j) *= std::pow(rho_v_vec[
k],4.*diffTerm*diffTerm);
3302 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3303 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula2_for_Sigma_v_hat_v_asterisk()"
3304 <<
", outerCounter = " << outerCounter
3311 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3314 const std::vector<const S_V* >& xVecs1,
3315 const std::vector<const P_V* >& tVecs1,
3318 const P_V& rho_w_vec,
3320 unsigned int outerCounter)
3322 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3323 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_u_hat_u_asterisk()"
3324 <<
", outerCounter = " << outerCounter
3328 for (
unsigned int i = 0; i < xVecs1.size(); ++i) {
3332 for (
unsigned int i = 0; i < tVecs1.size(); ++i) {
3341 S_V xVecI(*(xVecs1[0]));
3343 P_V tVecI(*(tVecs1[0]));
3345 for (
unsigned int i = 0; i < m_s->m_paper_m; ++i) {
3346 xVecI = *(xVecs1[i]);
3347 tVecI = *(tVecs1[i]);
3348 for (
unsigned int j = 0; j < 1; ++j) {
3353 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3354 double diffTerm = xVecI[
k] - xVecJ[
k];
3355 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3357 for (
unsigned int k = 0;
k < m_s->m_paper_p_t; ++
k) {
3358 double diffTerm = tVecI[
k] - tVecJ[
k];
3359 Rmat(i,j) *= std::pow(rho_w_vec[m_s->m_paper_p_x+
k],4.*diffTerm*diffTerm);
3363 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3364 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_u_hat_u_asterisk()"
3365 <<
", outerCounter = " << outerCounter
3372 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3375 const std::vector<const S_V* >& xVecs1,
3376 const std::vector<const P_V* >& tVecs1,
3379 const P_V& rho_w_vec,
3381 unsigned int outerCounter)
3383 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3384 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w_hat_u_asterisk()"
3385 <<
", outerCounter = " << outerCounter
3389 for (
unsigned int i = 0; i < xVecs1.size(); ++i) {
3393 for (
unsigned int i = 0; i < tVecs1.size(); ++i) {
3402 S_V xVecI(*(xVecs1[0]));
3404 P_V tVecI(*(tVecs1[0]));
3406 for (
unsigned int i = 0; i < m_s->m_paper_m; ++i) {
3407 xVecI = *(xVecs1[i]);
3408 tVecI = *(tVecs1[i]);
3409 for (
unsigned int j = 0; j < 1; ++j) {
3414 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3415 double diffTerm = xVecI[
k] - xVecJ[
k];
3416 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3418 for (
unsigned int k = 0;
k < m_s->m_paper_p_t; ++
k) {
3419 double diffTerm = tVecI[
k] - tVecJ[
k];
3420 Rmat(i,j) *= std::pow(rho_w_vec[m_s->m_paper_p_x+
k],4.*diffTerm*diffTerm);
3424 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3425 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w_hat_u_asterisk()"
3426 <<
", outerCounter = " << outerCounter
3433 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M,
class Q_V,
class Q_M>
3436 const std::vector<const S_V* >& xVecs1,
3437 const std::vector<const P_V* >& tVecs1,
3440 const P_V& rho_w_vec,
3442 unsigned int outerCounter)
3444 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3445 *m_env.subDisplayFile() <<
"Entering GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w_hat_w_asterisk()"
3446 <<
", outerCounter = " << outerCounter
3451 for (
unsigned int i = 0; i < xVecs1.size(); ++i) {
3455 for (
unsigned int i = 0; i < tVecs1.size(); ++i) {
3464 S_V xVecI(*(xVecs1[0]));
3466 P_V tVecI(*(tVecs1[0]));
3468 for (
unsigned int i = 0; i < m_s->m_paper_m; ++i) {
3469 xVecI = *(xVecs1[i]);
3470 tVecI = *(tVecs1[i]);
3471 for (
unsigned int j = 0; j < 1; ++j) {
3475 for (
unsigned int k = 0;
k < m_s->m_paper_p_x; ++
k) {
3476 double diffTerm = xVecI[
k] - xVecJ[
k];
3477 Rmat(i,j) *= std::pow(rho_w_vec[
k],4.*diffTerm*diffTerm);
3479 for (
unsigned int k = 0;
k < m_s->m_paper_p_t; ++
k) {
3480 double diffTerm = tVecI[
k] - tVecJ[
k];
3481 Rmat(i,j) *= std::pow(rho_w_vec[m_s->m_paper_p_x+
k],4.*diffTerm*diffTerm);
3486 if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 4)) {
3487 *m_env.subDisplayFile() <<
"Leaving GpmsaComputerModel<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::fillR_formula1_for_Sigma_w_hat_w_asterisk()"
3488 <<
", outerCounter = " << outerCounter
unsigned int displayVerbosity() const
std::string m_dataOutputFileName
VectorSet< V, M > * InstantiateIntersection(const VectorSet< V, M > &domain1, const VectorSet< V, M > &domain2)
This method calculates the intersection of domain1 and domain2.
unsigned int dimLocal() const
unsigned int numExperiments() const
unsigned int m_priorSeqNumSamples
GcmSimulationInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > * m_s
bool m_thereIsExperimentalData
const V & unifiedMeanPlain() const
Finds the mean value of the unified sequence.
GpmsaComputerModel(const char *prefix, const GcmOptionsValues *alternativeOptionsValues, const SimulationStorage< S_V, S_M, P_V, P_M, Q_V, Q_M > &simulationStorage, const SimulationModel< S_V, S_M, P_V, P_M, Q_V, Q_M > &simulationModel, const ExperimentStorage< S_V, S_M, D_V, D_M > *experimentStorage, const ExperimentModel< S_V, S_M, D_V, D_M > *experimentModel, const BaseVectorRV< P_V, P_M > *thetaPriorRv)
const BaseVectorRV< P_V, P_M > & totalPriorRv() const
void fillR_formula2_for_Sigma_v(const std::vector< const S_V * > &xVecs, const P_V &rho_v_vec, D_M &Rmat, unsigned int outerCounter)
void memoryCheck(unsigned int codePositionId)
void fillR_formula1_for_Sigma_w_hat_u_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
bool m_allOutputsAreScalar
A class for handling generic scalar functions.
void calibrateWithLanlMcmc(const MhOptionsValues *alternativeOptionsValues, const P_V &totalInitialValues, const P_M *totalInitialProposalCovMatrix)
#define queso_require_equal_to(expr1, expr2)
A templated class that represents a Metropolis-Hastings generator of samples.
void generateSequence(BaseVectorSequence< P_V, P_M > &workingChain, ScalarSequence< double > *workingLogLikelihoodValues, ScalarSequence< double > *workingLogTargetValues)
Method to generate the chain.
void formSigma_z_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_5lambdaYVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
const GcmOptionsValues * m_optionsObj
FilePtrSetStruct m_dataOutputFilePtrSet
std::ofstream * ofsVar
Provides a stream interface to write data to files.
void fillR_formula1_for_Sigma_u_hat_u_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
#define queso_error_msg(msg)
void predictSimulationOutputs(const S_V &newScenarioVec, const P_V &newParameterVec, Q_V &simulationOutputMeanVec)
const VectorSpace< P_V, P_M > & totalSpace() const
void ComputeCovCorrMatricesBetweenVectorSequences(const BaseVectorSequence< P_V, P_M > &subPSeq, const BaseVectorSequence< Q_V, Q_M > &subQSeq, unsigned int subNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
std::set< unsigned int > m_dataOutputAllowedSet
unsigned int numBasis() const
void formSigma_w_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_8thetaVec, unsigned int outerCounter)
GcmJointInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_j
void fillR_formula1_for_Sigma_u(const std::vector< const S_V * > &xVecs, const P_V &tVec, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
GcmSimulationTildeInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > * m_st
#define queso_require_equal_to_msg(expr1, expr2, msg)
void calibrateWithBayesMLSampling()
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
double scalarProduct(const GslVector &x, const GslVector &y)
void setPositionValues(unsigned int posId, const V &vec)
Set the values in vec at position posId of the sequence.
void fillR_formula1_for_Sigma_w_hat_w_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
double MiscGetEllapsedSeconds(struct timeval *timeval0)
#define queso_require_msg(asserted, msg)
GcmZTildeInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_zt
bool m_cMatIsRankDefficient
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
unsigned int MiscUintDebugMessage(unsigned int value, const char *message)
void ComputeConditionalGaussianVectorRV(const V &muVec1, const V &muVec2, const M &sigmaMat11, const M &sigmaMat12, const M &sigmaMat21, const M &sigmaMat22, const V &sampleVec2, V &muVec1_cond_on_2, M &sigmaMat11_cond_on_2)
const BaseEnvironment & m_env
bool m_useTildeLogicForRankDefficientC
GcmExperimentInfo< S_V, S_M, D_V, D_M, P_V, P_M > * m_e
GcmTotalInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_t
#define UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
This class provides options for the Metropolis-Hastings generator of samples if no input file is avai...
double likelihoodRoutine(const P_V &totalValues, const P_V *totalDirection, const void *functionDataPtr, P_V *gradVector, P_M *hessianMatrix, P_V *hessianEffect)
const VectorSpace< P_V, P_M > & unique_vu_space() const
void generateSequence(BaseVectorSequence< P_V, P_M > &workingChain, ScalarSequence< double > *workingLogLikelihoodValues, ScalarSequence< double > *workingLogTargetValues)
Method to generate the chain.
unsigned int numBasis() const
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const std::vector< unsigned int > & n_ys_transformed() const
A class for handling sequential draws (sampling) from probability density distributions.
A templated class that represents a Multilevel generator of samples.
void predictWsAtGridPoint(const S_V &newScenarioVec, const P_V &newParameterVec, const P_V *forcingSampleVecForDebug, P_V &wMeanVec, P_M &wCovMatrix)
void predictVUsAtGridPoint(const S_V &newScenarioVec, const P_V &newParameterVec, P_V &vuMeanVec, P_M &vuCovMatrix, P_V &vMeanVec, P_M &vCovMatrix, P_V &uMeanVec, P_M &uCovMatrix)
void calibrateWithBayesMetropolisHastings(const MhOptionsValues *alternativeOptionsValues, const P_V &totalInitialValues, const P_M *totalInitialProposalCovMatrix)
GcmZInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_z
GcmJointTildeInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_jt
void formSigma_z(const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
void formSigma_z_tilde_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_5lambdaYVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
bool openOutputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens an output file for each sub-environment that was chosen to send data to the file...
void fillR_formula2_for_Sigma_v_hat_v_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_v_vec, D_M &Rmat, unsigned int outerCounter)
void fillR_formula1_for_Sigma_w(const std::vector< const S_V * > &xVecs, const std::vector< const P_V * > &tVecs, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
void fillR_formula1_for_Sigma_uw(const std::vector< const S_V * > &xVecs1, const P_V &tVec1, const std::vector< const S_V * > &xVecs2, const std::vector< const P_V * > &tVecs2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
BaseScalarFunction< P_V, P_M > * m_likelihoodFunction
static double staticLikelihoodRoutine(const P_V &totalValues, const P_V *totalDirection, const void *functionDataPtr, P_V *gradVector, P_M *hessianMatrix, P_V *hessianEffect)
void predictExperimentResults(const S_V &newScenarioVec, const D_M &newKmat_interp, const D_M &newDmat, D_V &simulationOutputMeanVec, D_V &discrepancyMeanVec)
const VectorSpace< S_V, S_M > & scenarioSpace() const
const GenericVectorRV< P_V, P_M > & totalPostRv() const
void unifiedWriteContents(const std::string &fileName, const std::string &fileType) const
void print(std::ostream &os) const