13 #include <boost/lexical_cast.hpp>
57 Pars.push_back(Par_i);
62 unsigned int size =
Pars.size();
64 throw std::runtime_error(
"The size of the correlated parameters in " +
name +
" does not match the size of the correlation matrix!");
66 for (
unsigned int i = 0; i < size; i++)
67 for (
unsigned int j = 0; j < size; j++)
68 (*
Cov)(i, j) =
Pars.at(i).geterrg() * Corr(i, j) *
Pars.at(j).geterrg();
85 for(std::vector<ModelParameter>::iterator it =
Pars.begin(); it !=
Pars.end(); it++)
87 ave_in(ind) = it->getave();
93 for (
unsigned int i = 0; i < size; i++)
97 std::string namei =
name + ss.str();
106 if (DiagPars_i.size() !=
DiagPars.size()) {
107 std::stringstream out;
108 out << DiagPars_i.size();
109 throw std::runtime_error(
"CorrelatedGaussianParameters::getOrigParsValue(DiagPars_i): DiagPars_i.size() = " + out.str() +
" does not match the size of DiagPars");
114 for (std::vector<double>::const_iterator it = DiagPars_i.begin(); it != DiagPars_i.end(); it++) {
121 std::vector<double> res;
123 for (
unsigned int i = 0; i < DiagPars_i.size(); i++) {
124 res.push_back(val(i));
130 std::string& filename,
131 std::ifstream& ifile,
132 boost::tokenizer<boost::char_separator<char> >::iterator & beg,
138 int size = atoi((*beg).c_str());
140 std::vector<bool> lines;
142 boost::char_separator<char>sep(
" \t");
143 for (
int i = 0; i < size; i++) {
144 IsEOF = getline(ifile, line).eof();
145 if (line.empty() || line.at(0) ==
'#') {
146 if (rank == 0)
throw std::runtime_error(
"ERROR: no comments or empty lines in CorrelatedGaussianParameters please! In line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + filename);
150 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
152 std::string type = *beg;
154 if (type.compare(
"ModelParameter") != 0){
155 if (rank == 0)
throw std::runtime_error(
"ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + filename +
", expecting a ModelParameter type here...\n");
160 lines.push_back(!tmpMP.
IsFixed());
161 if (beg != tok.end())
162 if (rank == 0) std::cout <<
"WARNING: unread information in parameter " << tmpMP.
getname() << std::endl;
168 ModPars.push_back(tmpMP);
174 for (
int i = 0; i < size; i++) {
175 IsEOF = getline(ifile, line).eof();
176 if (line.empty() || line.at(0) ==
'#') {
177 if (rank == 0)
throw std::runtime_error(
"ERROR: no comments or empty lines in CorrelatedGaussianParameters please! In line no." + boost::lexical_cast<std::string>(lineNo) +
" of file " + filename);
182 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
185 for (
int j = 0; j < size; j++) {
186 if ((*beg).compare(0, 1,
"0") == 0
187 || (*beg).compare(0, 1,
"1") == 0
188 || (*beg).compare(0, 1,
"-") == 0) {
189 if (std::distance(mytok.begin(), mytok.end()) < size) {
190 if (rank == 0)
throw std::runtime_error(
"ERROR: invalid correlation matrix for " +
name +
". Check element (" + boost::lexical_cast<std::string>(ni + 1) +
"," + boost::lexical_cast<std::string>(nj + 1) +
") in line number " + boost::lexical_cast<std::string>(lineNo) +
" in file " + filename +
".\n");
194 myCorr(ni, nj) = atof((*beg).c_str());
199 if (rank == 0) std::cout <<
"ERROR: invalid correlation matrix for "
200 <<
name <<
". Check element (" << ni + 1 <<
"," << nj + 1 <<
") in line number " + boost::lexical_cast<std::string>(lineNo) << std::endl;
211 if (rank == 0) std::cout <<
"\nWARNING: Correlated Gaussian Parameters " <<
name.c_str() <<
" defined with less than two correlated parameters. The set is being marked as normal Parameters." << std::endl;
213 for (
int i = 0; i < size; i++) {
214 IsEOF = getline(ifile, line).eof();