00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IMPEXAMPLE_EXAMPLE_UNARY_FUNCTION_H
00011 #define IMPEXAMPLE_EXAMPLE_UNARY_FUNCTION_H
00012
00013 #include "example_config.h"
00014 #include <IMP/UnaryFunction.h>
00015 #include <IMP/utility.h>
00016
00017 IMPEXAMPLE_BEGIN_NAMESPACE
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class ExampleUnaryFunction : public UnaryFunction
00028 {
00029 Float center_;
00030 Float k_;
00031 public:
00032
00033
00034
00035 ExampleUnaryFunction(Float center, Float k) : center_(center), k_(k) {
00036 IMP_USAGE_CHECK(k > 0, "The spring constant must be positive.");
00037 }
00038
00039 IMP_UNARY_FUNCTION_INLINE(ExampleUnaryFunction,
00040 .5*k_*square(feature-center_),
00041 k_*(feature - center_),
00042 "Harmonic: " << center_ << " and " << k_
00043 << std::endl);
00044 };
00045
00046 IMPEXAMPLE_END_NAMESPACE
00047
00048 #endif