1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#ifndef OPT_IO
#define OPT_IO
#include <iostream>
#include <cmath>
#include "core/fitter.hpp"
namespace opt_utilities
{
template <typename Ty,typename Tx>
std::ostream& operator<<(std::ostream& os,const data<Ty,Tx>& d)
{
os<<d.get_x()<<"("<<-std::abs(d.get_x_lower_err())<<",+"<<std::abs(d.get_x_upper_err())<<") "<<d.get_y()<<"("<<-std::abs(d.get_y_lower_err())<<",+"<<std::abs(d.get_y_upper_err())<<") ";
return os;
}
template <typename Ty,typename Tx>
std::ostream& operator<<(std::ostream& os,const data_set<Ty,Tx>& ds)
{
os<<"data set with size of "<<ds.size()<<"\n"
<<"[\n";
int s=5>ds.size()?ds.size():5;
for(int i=0;i<s;++i)
{
os<<ds.get_data(i)<<"\n";
}
os<<"...\n";
os<<"...\n";
os<<"...\n";
os<<"]";
return os;
}
template<typename Ty,typename Tx,typename Tp,typename Ts,typename Tstr>
std::ostream& operator<<(std::ostream& os,const fitter<Ty,Tx,Tp,Ts,Tstr>& f)
{
os<<"Fitting session:\n";
os<<"Model:";
try
{
os<<f.get_model().get_type_name()<<"\n";
os<<"Current model parameters:\n";
os<<"==========================\n";
for(int i=0;i<f.get_num_params();++i)
{
const param_info<Tp,Tstr>& pinfo=f.get_param_info(i);
os<<pinfo.get_name()<<"=\t"<<pinfo.get_value()<<"\n";
}
os<<"==========================\n";
}
catch(const model_not_defined& e)
{
os<<"Undefined\n";
}
os<<"Statistic:";
try
{
os<<f.get_statistic().get_type_name()<<"\n";
}
catch(const statistic_not_defined& e)
{
os<<"Undefined\n";
}
os<<"Opt method:";
try
{
os<<f.get_opt_method().get_type_name()<<"\n";
}
catch(const opt_method_not_defined& e)
{
os<<"Undefined\n";
}
os<<"Data set:";
try
{
os<<f.get_data_set().get_type_name()<<"\n";
os<<f.get_data_set()<<"\n";
}
catch(const data_not_loaded& e)
{
os<<"Undefined\n";
}
return os;
}
}
#endif
|