IMP logo
IMP Reference Guide  develop.7482b7c7af, 2026/12/05
The Integrative Modeling Platform
ParabolicFit.h
Go to the documentation of this file.
1/**
2 * \file IMP/algebra/ParabolicFit.h
3 * \brief Fit data with parabola
4 *
5 * Copyright 2007-2026 IMP Inventors. All rights reserved.
6 *
7 */
8
9#ifndef IMPALGEBRA_PARABOLIC_FIT_H
10#define IMPALGEBRA_PARABOLIC_FIT_H
11
12#include "Vector2D.h"
14#include <cereal/access.hpp>
15#include <vector>
16
17IMPALGEBRA_BEGIN_NAMESPACE
18
19//! Calculate parabola that fits best the input data points
20class IMPALGEBRAEXPORT ParabolicFit2D : public GeometricPrimitiveD<2> {
21 public:
22 ParabolicFit2D() {}
23
24 //! Constructor
25 /**
26 \param[in] data vector of pairs (VectorD<2>) with x and their
27 corresponding y values
28 */
30
31 //! fit error
32 double get_fit_error() const { return error_; }
33
34 //! get a value (a*x^2)
35 double get_a() const { return a_; }
36
37 //! get b value (b*x)
38 double get_b() const { return b_; }
39
40 //! get c value (constant)
41 double get_c() const { return c_; }
42
44 out << "y = " << a_ << "x^2 + " << b_ << "x + " << c_ << std::endl;
45 out << "Error = " << error_ << std::endl;
46 });
47
48 private:
49 void find_regression(const Vector2Ds& data);
50 void evaluate_error(const Vector2Ds& data);
51
52 private:
53 double a_, b_, c_;
54 double error_;
55
56 friend class cereal::access;
57
58 template<class Archive> void serialize(Archive &ar) {
59 ar(a_, b_, c_, error_);
60 }
61};
62
64#ifndef IMP_DOXYGEN
65typedef ParabolicFit2D ParabolicFit;
66#endif
67
68IMPALGEBRA_END_NAMESPACE
69
70#endif /* IMPALGEBRA_PARABOLIC_FIT_H */
Base class for geometric types.
Simple 2D vector class.
Calculate parabola that fits best the input data points.
ParabolicFit2D(const Vector2Ds &data)
Constructor.
double get_a() const
get a value (a*x^2)
double get_b() const
get b value (b*x)
double get_fit_error() const
fit error
double get_c() const
get c value (constant)
IMP::Vector< ParabolicFit2D > ParabolicFit2Ds
Vector< VectorD< 2 > > Vector2Ds
Definition VectorD.h:405
#define IMP_SHOWABLE_INLINE(Name, how_to_show)
Declare the methods needed by an object that can be printed.
#define IMP_VALUES(Name, PluralName)
Define the type for storing sets of values.