13 #include <boost/lexical_cast.hpp>
54 Pars.push_back(Par_i);
59 unsigned int size =
Pars.size();
61 throw std::runtime_error(
"The size of the correlated parameters in " +
name +
" does not match the size of the correlation matrix!");
63 for (
unsigned int i = 0; i < size; i++)
64 for (
unsigned int j = 0; j < size; j++)
65 (*
Cov)(i, j) =
Pars.at(i).geterrg() * Corr(i, j) *
Pars.at(j).geterrg();
82 for(std::vector<ModelParameter>::iterator it =
Pars.begin(); it !=
Pars.end(); it++)
84 ave_in(ind) = it->getave();
90 for (
unsigned int i = 0; i < size; i++)
94 std::string namei =
name + ss.str();
103 if (DiagPars_i.size() !=
DiagPars.size()) {
104 std::stringstream out;
105 out << DiagPars_i.size();
106 throw std::runtime_error(
"CorrelatedGaussianParameters::getOrigParsValue(DiagPars_i): DiagPars_i.size() = " + out.str() +
" does not match the size of DiagPars");
111 for (std::vector<double>::const_iterator it = DiagPars_i.begin(); it != DiagPars_i.end(); it++) {
118 std::vector<double> res;
120 for (
unsigned int i = 0; i < DiagPars_i.size(); i++) {
121 res.push_back(val(i));
127 std::string& filename,
128 std::ifstream& ifile,
129 boost::tokenizer<boost::char_separator<char> >::iterator & beg,
135 int size = atoi((*beg).c_str());
138 boost::char_separator<char>sep(
" \t");
139 for (
int i = 0; i < size; i++) {
140 IsEOF = getline(ifile, line).eof();
141 if (line.empty() || line.at(0) ==
'#') {
142 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);
146 boost::tokenizer<boost::char_separator<char> > tok(line, sep);
148 std::string type = *beg;
150 if (type.compare(
"ModelParameter") != 0){
151 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");
156 if (beg != tok.end())
157 if (rank == 0) std::cout <<
"WARNING: unread information in parameter " << tmpMP.
getname() << std::endl;
165 for (
int i = 0; i < size; i++) {
166 IsEOF = getline(ifile, line).eof();
167 if (line.empty() || line.at(0) ==
'#') {
168 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);
172 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
175 for (
int j = 0; j < size; j++) {
176 if ((*beg).compare(0, 1,
"0") == 0
177 || (*beg).compare(0, 1,
"1") == 0
178 || (*beg).compare(0, 1,
"-") == 0) {
179 if (std::distance(mytok.begin(), mytok.end()) < size) {
180 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");
183 myCorr(ni, nj) = atof((*beg).c_str());
187 if (rank == 0) std::cout <<
"ERROR: invalid correlation matrix for "
188 <<
name <<
". Check element (" << ni + 1 <<
"," << nj + 1 <<
") in line number " + boost::lexical_cast<std::string>(lineNo) << std::endl;
198 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;
200 for (
int i = 0; i < size; i++) {
201 IsEOF = getline(ifile, line).eof();
void setCgp_name(std::string cgp_name)
A set method to set the name of the set of correlated parameter.
A class for constructing and defining operations on real matrices.
A class for model parameters.
matrix< double > transpose()
void eigensystem(matrix< complex > &U, vector< complex > &S)
std::string getname() const
A get method to get the name of each parameter.
A class for constructing and defining operations on real vectors.
boost::tokenizer< boost::char_separator< char > >::iterator & ParseModelParameter(boost::tokenizer< boost::char_separator< char > >::iterator &beg)
Parser for model parameters.
matrix< double > inverse()
complex sqrt(const complex &z)