IMP  2.0.0
The Integrative Modeling Platform
Linear.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/Linear.h \brief A linear function.
3  *
4  * Copyright 2007-2013 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPCORE_LINEAR_H
8 #define IMPCORE_LINEAR_H
9 
10 #include <IMP/core/core_config.h>
11 #include <IMP/UnaryFunction.h>
13 
14 IMPCORE_BEGIN_NAMESPACE
15 
16 //! %Linear function
17 /** \note The offset is not meaningful for optimization, but does
18  make the displayed energies nicer.
19  */
20 class Linear : public UnaryFunction
21 {
22 public:
23  //! Create with the given offset and slope.
24  Linear(double offset, double slope) : slope_(slope), offset_(offset) {}
25 
27  (feature-offset_)*slope_,
28  slope_,
29  "Linear: " << slope_ << ", " << offset_
30  << std::endl);
31  void set_slope(double f) {
32  slope_=f;
33  }
34 
35  void set_offset(double f) {
36  offset_=f;
37  }
38 
39 private:
40  double slope_, offset_;
41 };
42 
43 IMPCORE_END_NAMESPACE
44 
45 #endif /* IMPCORE_LINEAR_H */