IMP  2.2.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-2014 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 DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
Import IMP/kernel/UnaryFunction.h in the namespace.
Cosine function.
Definition: Cosine.h:22
Abstract single variable functor class for score functions.
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: base/types.h:23
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
Cosine(Float force_constant, int periodicity, Float phase)
Constructor.
Definition: Cosine.h:29