ProteoWizard
Functions
LeastSquaresCalibratorTest.cpp File Reference
#include "LeastSquaresCalibrator.hpp"
#include "pwiz/utility/misc/unit.hpp"
#include <iostream>
#include <iomanip>

Go to the source code of this file.

Functions

void test ()
int main ()

Function Documentation

void test ( )

Definition at line 36 of file LeastSquaresCalibratorTest.cpp.

References pwiz::data::CalibrationParameters::A, pwiz::data::CalibrationParameters::B, pwiz::calibration::LeastSquaresCalibrator::calibrate(), e(), epsilon, pwiz::calibration::LeastSquaresCalibrator::error(), pwiz::data::CalibrationParameters::frequency(), pwiz::calibration::LeastSquaresCalibrator::parameters(), and unit_assert_equal.

Referenced by main(), runTests(), test(), testConfiguration(), and testThreadSafetyWorker().

{
vector<double> trueMasses;
trueMasses.push_back(100);
trueMasses.push_back(200);
trueMasses.push_back(300);
CalibrationParameters p = CalibrationParameters::thermo_FT();
vector<double> observedFrequencies;
for (vector<double>::iterator it=trueMasses.begin(); it!=trueMasses.end(); ++it)
observedFrequencies.push_back(p.frequency(*it));
auto_ptr<LeastSquaresCalibrator> calibrator = LeastSquaresCalibrator::create(trueMasses,
observedFrequencies);
calibrator->calibrate();
/*
cout << setprecision(10) << p << endl;
cout << calibrator->parameters() << endl;
cout << "error: " << calibrator->error() << endl;
*/
const double epsilon = .2; // not too small since A,B ~ 1e8
unit_assert_equal(p.A, calibrator->parameters().A, epsilon);
unit_assert_equal(p.B, calibrator->parameters().B, epsilon);
unit_assert_equal(0, calibrator->error(), 1e-15);
}
int main ( )

Definition at line 66 of file LeastSquaresCalibratorTest.cpp.

References e(), and test().

{
try
{
test();
return 0;
}
catch (exception& e)
{
cerr << e.what() << endl;
return 1;
}
}