IMP  2.2.1
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-2014 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)
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.
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: base/types.h:23
double Float
Basic floating-point value (could be float, double...)
Definition: base/types.h:20
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:24