IMP logo
IMP Reference Guide  2.13.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-2020 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 
13 IMPCORE_BEGIN_NAMESPACE
14 
15 //! %Cosine function.
16 /** This evaluates the function
17  |k| - k cos(nf + a)
18  where k is a force constant, n the periodicity, a the phase, and f the
19  input value. This is most commonly used for dihedral angle restraints,
20  e.g. in the CHARMM force field.
21  */
22 class IMPCOREEXPORT Cosine : public UnaryFunction {
23  public:
24  //! Constructor.
25  /** \param[in] force_constant Force constant (score units)
26  \param[in] periodicity Periodicity (generally 1-6)
27  \param[in] phase Phase (radians)
28  */
29  Cosine(Float force_constant, int periodicity, Float phase)
30  : force_constant_(force_constant),
31  periodicity_(periodicity),
32  phase_(phase) {}
33 
34  virtual DerivativePair evaluate_with_derivative(double feature) const;
35 
36  virtual double evaluate(double feature) const;
37 
39 
40  void do_show(std::ostream &out) const;
41 
42  private:
43  Float force_constant_;
44  int periodicity_;
45  Float phase_;
46 };
47 
48 IMPCORE_END_NAMESPACE
49 
50 #endif /* IMPCORE_COSINE_H */
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
Definition: UnaryFunction.h:33
#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:22
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Definition: UnaryFunction.h:48
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
Cosine(Float force_constant, int periodicity, Float phase)
Constructor.
Definition: Cosine.h:29
Abstract single variable functor class for score functions.
Definition: UnaryFunction.h:25