Skip to content

Commit

Permalink
cerr -> cout
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakoff committed Aug 20, 2018
1 parent a399253 commit be9c701
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions pade/pade_arbitrary_degree/pade.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#pragma once
#include<complex>
#include <iostream>
#include<vector>
#include<gmpxx.h>
#include<Eigen/Core>
Expand Down
8 changes: 4 additions & 4 deletions pade/pade_arbitrary_degree/pade_interpolator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ void pade_interpolator::pade_interpolate(const imaginary_domain_data &data, real
matsubara_values [i]=pade_complex_type(data.val()[i].real(), data.val()[i].imag());
}

std::cerr<<"filling."<<std::endl;
std::cout<<"filling."<<std::endl;
pade_complex_matrix_type Vinv(pade_mu_+pade_nu_+1,pade_mu_+pade_nu_+1);
fill_Vinv_matrix(Vinv, matsubara_frequencies, pade_mu_, pade_nu_);

std::cerr<<"assembling."<<std::endl;
std::cout<<"assembling."<<std::endl;
pade_complex_matrix_type Lambda(pade_mu_+pade_nu_,pade_mu_+pade_nu_);
pade_complex_vector_type rhs(pade_mu_+pade_nu_);
assemble_matrix_system(Lambda, rhs, Vinv, matsubara_values, pade_mu_, pade_nu_);

std::cerr<<"solving."<<std::endl;
std::cout<<"solving."<<std::endl;
pade_complex_vector_type res(rhs.size(), pade_complex_type(0., 0.));
pade_complex_vector_type q(pade_mu_+pade_nu_+1);
pade_solver s;
Expand All @@ -70,7 +70,7 @@ void pade_interpolator::pade_interpolate(const imaginary_domain_data &data, real
q[i+1]=res[i];
}

std::cerr<<"evaluating."<<std::endl;
std::cout<<"evaluating."<<std::endl;
#pragma omp parallel for default(none) shared(real) firstprivate(q,matsubara_values,matsubara_frequencies,Vinv,real_frequencies,N_real)
for(int k=0;k<N_real;++k){
//real.val()[k]=to_simple_precision(evaluate_bary_poly(q, matsubara_values, matsubara_frequencies, Vinv, pade_mu_, pade_nu_, imag_frequencies[k]));
Expand Down
6 changes: 3 additions & 3 deletions pade/pade_arbitrary_degree/pade_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void pade_solver::backsub_upper(const pade_complex_matrix_type &Uinv, const pade

//run an LU decomposition with pivoting, then back-substitute
void pade_solver::solve(const pade_complex_matrix_type &A, const pade_complex_vector_type &rhs, pade_complex_vector_type &res){
std::cerr<<"multiprecision solver."<<std::endl;
std::cout<<"multiprecision solver."<<std::endl;
int N=A.rows();
pade_complex_matrix_type P=pade_complex_matrix_type::Identity(N,N);
//pade_complex_matrix_type P(pade_complex_matrix_type::identity_matrix(N));
Expand Down Expand Up @@ -87,9 +87,9 @@ void pade_solver::solve(const pade_complex_matrix_type &A, const pade_complex_ve
std::swap(rhs_pivot[i], rhs_pivot[pivot[i]]);
}
}
std::cerr<<"backsubstitution."<<std::endl;
std::cout<<"backsubstitution."<<std::endl;

backsub_lower(L, rhs_pivot, tmp);
backsub_upper(U, tmp, res);
std::cerr<<"matrix equation solved."<<std::endl;
std::cout<<"matrix equation solved."<<std::endl;
}
4 changes: 2 additions & 2 deletions src/maxent_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ double MaxEntHelper::chi_scale_factor(vector_type A, const double chi_sq, const
if (lambda[i]>=0)
Ng += lambda[i]/(lambda[i]+alpha);
}
std::cerr << "Ng: " << Ng << std::endl;
std::cout << "Ng: " << Ng << std::endl;
//std::cerr << "chi2 max: " << chi_sq << std::endl;
return sqrt(chi_sq/(ndat()-Ng));
}
Expand Down Expand Up @@ -276,7 +276,7 @@ void MaxEntHelper::backcontinue(ofstream_ &os, const vector_type &A_in,const dou

double chi_sq = chi2(A_chi);
const std::string sp = " ";
std::cerr << name << sp+sp << max_err << sp+sp+" " << chi_sq << std::endl;
std::cout << name << sp+sp << max_err << sp+sp+" " << chi_sq << std::endl;
}

///calculates the varience of a std::vector of eigen3 vectors
Expand Down
6 changes: 3 additions & 3 deletions src/maxent_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void ContiParameters::read_data_from_param_file(const alps::params& p) {
if (!p.defined("NORM")) {
throw std::runtime_error("parameter NORM missing!");
} else
std::cerr << "Data normalized to: " << static_cast<double>(p["NORM"])
std::cout << "Data normalized to: " << static_cast<double>(p["NORM"])
<< std::endl;

for (int i = 0; i < ndat(); ++i) {
Expand Down Expand Up @@ -206,7 +206,7 @@ void ContiParameters::scale_data_with_error(const int ntab) {
void ContiParameters::read_covariance_matrix_from_text_file(
const std::string& fname) {
cov_.resize(ndat(), ndat());
std::cerr << "Reading covariance matrix\n";
std::cout << "Reading covariance matrix\n";
std::ifstream covstream(fname.c_str());
if (!covstream)
boost::throw_exception(
Expand Down Expand Up @@ -398,7 +398,7 @@ MaxEntParameters::MaxEntParameters(alps::params& p) :
//The then define y := \bar{G}/sigma_ and K := (1/sigma_)\tilde{K}
scale_data_with_error(nfreq());

std::cerr << "Kernel is set up\n";
std::cout << "Kernel is set up\n";

vector_type S(ndat());
bool verbose=p["VERBOSE"];
Expand Down
20 changes: 10 additions & 10 deletions src/maxent_simulation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ void MaxEntSimulation::run()
//this loop is the 'core' of the maxent program: iterate over all alphas, compute the spectra, normalization, and probabilities
//loop over all alpha values
for (std::size_t a=0; a<alpha.size(); ++a) {
std::cerr << "alpha it: " << a << "\t";
std::cout << "alpha it: " << a << "\t";
//fitting procedure for 'u'
u = levenberg_marquardt(u, alpha[a]);
//computation of spectral function out of 'u'
vector_type A = get_spectrum(u);
//computation of normalization
std::cerr << "norm: " << transform_into_real_space(u).sum() << "\t";
std::cout << "norm: " << transform_into_real_space(u).sum() << "\t";
if (text_output) {
spectral_function_file<<"# alpha: "<<alpha[a]<<std::endl;
for (std::size_t i=0; i<A.size(); ++i)
Expand All @@ -138,8 +138,8 @@ void MaxEntSimulation::run()
//computation of chi2
double chi_squared = chi2(transform_into_real_space(u));
chi_sq[a] = chi_squared;
if (verbose) std::cerr << "0.5*chi2 : " << 0.5*chi_squared;
std::cerr << std::endl;
if (verbose) std::cout << "0.5*chi2 : " << 0.5*chi_squared;
std::cout << std::endl;
if (text_output) print_chi2(transform_into_real_space(u), fits_file);
qvec(a)=Q(u,alpha[a]);
}
Expand Down Expand Up @@ -180,7 +180,7 @@ void MaxEntSimulation::evaluate(){
int max_a,nothing; double max_lprob;
max_lprob=lprob.maxCoeff(&max_a,&nothing);
const double factor = chi_scale_factor(spectra[max_a], chi_sq[max_a], alpha[max_a]);
if (verbose) std::cerr << "chi scale factor: " << factor << std::endl;
if (verbose) std::cout << "chi scale factor: " << factor << std::endl;

alps::hdf5::archive ar(name+"out.h5", "w");
ar << alps::make_pvp("/alpha/values",alpha);
Expand Down Expand Up @@ -341,8 +341,8 @@ void MaxEntSimulation::evaluate(){
norm_fix *=-M_PI;
}

std::cerr << "spectra"<<sp<< " max backcont diff" <<sp<< "chi^2 value " <<std::endl;
std::cerr << "======="<< sp<<" ================="<< sp<< "=========== " <<std::endl;
std::cout << "spectra"<<sp<< " max backcont diff" <<sp<< "chi^2 value " <<std::endl;
std::cout << "======="<< sp<<" ================="<< sp<< "=========== " <<std::endl;
backcontinue(chispec_back_file,specchi,norm_fix,"chispec",chispec_back);
backcontinue(avspec_back_file,avspec,norm_fix,"avspec ",avspec_back);
backcontinue(maxspec_back_file,maxspec,norm_fix,"maxspec",maxspec_back);
Expand Down Expand Up @@ -389,9 +389,9 @@ vector_type MaxEntSimulation::levenberg_marquardt(vector_type u, const double al
break;
}
if (it == max_it) std::cerr<<"WARNING: iteration reached max_it without converging, your minimizer is having problems. Please be careful!"<<std::endl;
if (verbose) std::cerr <<"Iterations: " << it+1 << "\t";
std::cerr << "Q = 0.5chi^2-\\alpha*entropy: " << Q1 << "\t";
if (verbose) std::cerr << "entropy: "<<entropy(transform_into_real_space(u))<<"\talpha*entropy: "<<alpha*entropy(transform_into_real_space(u))<<"\t ";
if (verbose) std::cout <<"Iterations: " << it+1 << "\t";
std::cout << "Q = 0.5chi^2-\\alpha*entropy: " << Q1 << "\t";
if (verbose) std::cout << "entropy: "<<entropy(transform_into_real_space(u))<<"\talpha*entropy: "<<alpha*entropy(transform_into_real_space(u))<<"\t ";
return u;
}

Expand Down

0 comments on commit be9c701

Please sign in to comment.