IMP logo
IMP Reference Guide  2.13.0
The Integrative Modeling Platform
core/HarmonicUpperBound.h
Go to the documentation of this file.
1 /**
2  * \file IMP/core/HarmonicUpperBound.h \brief Harmonic upper bound function.
3  *
4  * Copyright 2007-2020 IMP Inventors. All rights reserved.
5  */
6 
7 #ifndef IMPCORE_HARMONIC_UPPER_BOUND_H
8 #define IMPCORE_HARMONIC_UPPER_BOUND_H
9 
10 #include <IMP/core/core_config.h>
11 #include "Harmonic.h"
12 
13 IMPCORE_BEGIN_NAMESPACE
14 
15 //! Upper bound harmonic function (non-zero when feature > mean)
16 /** \see Harmonic
17  \see HarmonicLowerBound
18  \see TruncatedHarmonicUpperBound
19  */
20 class HarmonicUpperBound : public Harmonic {
21  public:
22  /** Create with the given mean and the spring constant k */
23  HarmonicUpperBound(Float mean, Float k) : Harmonic(mean, k) {}
24  virtual double evaluate(double feature) const IMP_OVERRIDE {
25  return feature <= Harmonic::get_mean() ? 0.0 : Harmonic::evaluate(feature);
26  }
27  virtual DerivativePair evaluate_with_derivative(double feature) const
28  IMP_OVERRIDE {
29  return feature <= Harmonic::get_mean()
30  ? DerivativePair(0.0, 0.0)
31  : Harmonic::evaluate_with_derivative(feature);
32  }
34 };
35 
36 IMPCORE_END_NAMESPACE
37 
38 #endif /* IMPCORE_HARMONIC_UPPER_BOUND_H */
double get_mean(const cv::Mat &mat, const cvIntMat &mask)
Harmonic function.
Upper bound harmonic function (non-zero when feature > mean)
#define IMP_OBJECT_METHODS(Name)
Define the basic things needed by any Object.
Definition: object_macros.h:25
virtual double evaluate(double feature) const
Calculate score with respect to the given feature.
virtual DerivativePair evaluate_with_derivative(double feature) const
Calculate score and derivative with respect to the given feature.
std::pair< double, double > DerivativePair
A pair representing a function value with its first derivative.
Definition: types.h:23
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:20
#define IMP_OVERRIDE
Cause a compile error if this method does not override a parent method.
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:24