00001
00002
00003
00004
00005
00006
00007 #ifndef IMPCORE_TRUNCATED_HARMONIC_H
00008 #define IMPCORE_TRUNCATED_HARMONIC_H
00009
00010 #include "core_config.h"
00011 #include "internal/truncated_harmonic.h"
00012 #include <IMP/UnaryFunction.h>
00013 #include <IMP/utility.h>
00014
00015 IMPCORE_BEGIN_NAMESPACE
00016
00017 enum BoundDirection {LOWER, BOTH, UPPER};
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 template <int DIRECTION>
00038 class TruncatedHarmonic : public UnaryFunction {
00039 public:
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 TruncatedHarmonic(Float center,
00051 Float k, Float threshold,
00052 Float limit):
00053 d_(center, k, threshold, limit){
00054 }
00055
00056 TruncatedHarmonic(Float center,
00057 Float k, Float threshold):
00058 d_(center, k, threshold, k*square(threshold-center)){
00059 }
00060
00061 IMP_UNARY_FUNCTION_INLINE(TruncatedHarmonic,
00062 ((DIRECTION == LOWER && (feature > d_.c_))
00063 || (DIRECTION == UPPER && (feature < d_.c_)))?
00064 0: d_.evaluate(feature),
00065 ((DIRECTION == LOWER && (feature > d_.c_))
00066 || (DIRECTION == UPPER && (feature < d_.c_)))?
00067 0: d_.evaluate_with_derivative(feature).second,
00068 "TruncatedHarmonic: " << d_ << std::endl);
00069
00070 private:
00071 internal::TruncatedHarmonicData d_;
00072 };
00073
00074
00075 typedef TruncatedHarmonic<UPPER> TruncatedHarmonicUpperBound;
00076
00077 typedef TruncatedHarmonic<LOWER> TruncatedHarmonicLowerBound;
00078
00079 typedef TruncatedHarmonic<BOTH> TruncatedHarmonicBound;
00080
00081 IMPCORE_END_NAMESPACE
00082
00083 #endif