IMP logo
IMP Reference Guide  2.20.0
The Integrative Modeling Platform
Cosine.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/Cosine.h \brief Cosine function.
3  *
4  * Copyright 2007-2022 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPCORE_COSINE_H
8 #define IMPCORE_COSINE_H
9 
10 #include <IMP/core/core_config.h>
11 #include <IMP/UnaryFunction.h>
12 #include <cereal/access.hpp>
13 #include <cereal/types/base_class.hpp>
14 #include <cereal/types/polymorphic.hpp>
15 
16 IMPCORE_BEGIN_NAMESPACE
17 
18 //! %Cosine function.
19 /** This evaluates the function
20  |k| - k cos(nf + a)
21  where k is a force constant, n the periodicity, a the phase, and f the
22  input value. This is most commonly used for dihedral angle restraints,
23  e.g. in the CHARMM force field.
24  */
25 class IMPCOREEXPORT Cosine : public UnaryFunction {
26  public:
27  //! Constructor.
28  /** \param[in] force_constant Force constant (score units)
29  \param[in] periodicity Periodicity (generally 1-6)
30  \param[in] phase Phase (radians)
31  */
32  Cosine(Float force_constant, int periodicity, Float phase)
33  : force_constant_(force_constant),
34  periodicity_(periodicity),
35  phase_(phase) {}
36 
37  Cosine() {}
38 
40  double feature) const override;
41 
42  virtual double evaluate(double feature) const override;
43 
45 
46  void do_show(std::ostream &out) const;
47 
48  private:
49  Float force_constant_;
50  int periodicity_;
51  Float phase_;
52 
53  friend class cereal::access;
54 
55  template<class Archive> void serialize(Archive &ar) {
56  ar(cereal::base_class<UnaryFunction>(this),
57  force_constant_, periodicity_, phase_);
58  }
60 };
61 
62 IMPCORE_END_NAMESPACE
63 
64 #endif /* IMPCORE_COSINE_H */
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Definition: UnaryFunction.h:35
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
Single variable function.
Cosine function.
Definition: Cosine.h:25
#define IMP_OBJECT_SERIALIZE_DECL(Name)
Declare methods needed for serialization of Object pointers.
Definition: object_macros.h:95
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:22
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Definition: UnaryFunction.h:50
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
Cosine(Float force_constant, int periodicity, Float phase)
Constructor.
Definition: Cosine.h:32
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:27