IMP logo
IMP Reference Guide  2.22.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-2023 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 #include <cereal/access.hpp>
13 #include <cereal/types/base_class.hpp>
14 
15 IMPCORE_BEGIN_NAMESPACE
16 
17 //! Upper bound harmonic function (non-zero when feature > mean)
18 /** \see Harmonic
19  \see HarmonicLowerBound
20  \see TruncatedHarmonicUpperBound
21  */
22 class HarmonicUpperBound : public Harmonic {
23  friend class cereal::access;
24  template<class Archive> void serialize(Archive &ar) {
25  ar(cereal::base_class<Harmonic>(this));
26  }
28  public:
29  /** Create with the given mean and the spring constant k */
30  HarmonicUpperBound(Float mean, Float k) : Harmonic(mean, k) {}
32  virtual double evaluate(double feature) const override {
33  return feature <= Harmonic::get_mean() ? 0.0 : Harmonic::evaluate(feature);
34  }
35  virtual DerivativePair evaluate_with_derivative(double feature) const
36  override {
37  return feature <= Harmonic::get_mean()
38  ? DerivativePair(0.0, 0.0)
39  : Harmonic::evaluate_with_derivative(feature);
40  }
42 };
43 
44 IMPCORE_END_NAMESPACE
45 
46 #endif /* IMPCORE_HARMONIC_UPPER_BOUND_H */
virtual double evaluate(double feature) const override
Calculate score with respect to the given feature.
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
#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
double Float
Basic floating-point value (could be float, double...)
Definition: types.h:19
virtual DerivativePair evaluate_with_derivative(double feature) const override
Calculate score and derivative with respect to the given feature.
Harmonic function (symmetric about the mean)
Definition: core/Harmonic.h:27