28 #include <boost/filesystem/operations.hpp>
33 using namespace pwiz::util;
34 using namespace pwiz::frequency;
35 using namespace pwiz::data;
56 if (
os_) *
os_ <<
"testBasic(): success!\n";
67 vector< pair<double,double> > samples;
68 for (
int i=-2; i<3; i++)
69 samples.push_back(make_pair(i/10.,ref(i/10.)));
75 *
os_ <<
"coefficients: " << setprecision(14);
79 *os_ <<
"error: " << m(0)-1 << endl;
81 for (
int i=0; i<5; i++)
82 *os_ << i <<
", " << m(i) << endl;
90 if (
os_) *
os_ <<
"testFit(): success!\n";
96 string filename =
"MagnitudeLorentizianTest.cfd.temp.txt";
97 ofstream temp(filename.c_str());
102 boost::filesystem::remove(filename);
105 if (
os_) *
os_ <<
"max: (" << max->x <<
", " << abs(max->y) <<
")\n";
109 vector< pair<double,double> > samples1;
110 transform(fd.
max()-1, fd.
max()+2, back_inserter(samples1), FrequencyData::magnitudeSample);
114 *
os_ <<
"raw data:\n";
115 for (
unsigned int i=0; i<samples1.size(); i++)
116 *
os_ <<
"sample " << i <<
": (" << samples1[i].first <<
", " << samples1[i].second <<
")\n";
128 for (
unsigned int i=0; i<samples1.size(); i++)
129 *os_ <<
"m1(" << i <<
") == " << m1(samples1[i].first) << endl;
137 vector< pair<double,double> > samples2;
138 transform(fd.
max()-1, fd.
max()+2, back_inserter(samples2), FrequencyData::magnitudeSample);
142 *
os_ <<
"normalized: \n";
143 for (
unsigned int i=0; i<samples2.size(); i++)
144 *
os_ <<
"sample " << i <<
": (" << samples2[i].first <<
", " << samples2[i].second <<
")\n";
156 for (
unsigned int i=0; i<samples2.size(); i++)
157 *os_ <<
"m2(" << i <<
") == " << m2(samples2[i].first) <<
" [" << fd.
scale()*m2(samples2[i].first) <<
"]\n";
164 int main(
int argc,
char* argv[])
170 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
171 if (
os_) *
os_ <<
"MagnitudeLorentzianTest\n";