IMP
2.0.0
The Integrative Modeling Platform
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
kernel/UnaryFunction.h
Go to the documentation of this file.
1
/**
2
* \file IMP/kernel/UnaryFunction.h \brief Single variable function.
3
*
4
* Copyright 2007-2013 IMP Inventors. All rights reserved.
5
*/
6
7
#ifndef IMPKERNEL_UNARY_FUNCTION_H
8
#define IMPKERNEL_UNARY_FUNCTION_H
9
10
#include <IMP/kernel/kernel_config.h>
11
#include "
base_types.h
"
12
#include "
Object.h
"
13
#include "
Pointer.h
"
14
15
IMPKERNEL_BEGIN_NAMESPACE
16
17
//! Abstract single variable functor class for score functions.
18
/** These functors take a single feature value, and return a corresponding
19
score (and optionally also the first derivative).
20
21
Implementers should implement two functions:
22
- virtual double evaluate(double feature) const
23
- virtual DerivativePair evaluate_with_derivative(double feature) const
24
also add IMP_OBJECT_METHODS(Name) macro for Object methods
25
*/
26
class
IMPKERNELEXPORT
UnaryFunction
:
public
IMP::base::Object
27
{
28
public
:
29
UnaryFunction
(std::string name=
"UnaryFunction%1%"
);
30
31
//! Calculate score with respect to the given feature.
32
/** \param[in] feature Value of feature being tested.
33
\return Score
34
*/
35
virtual
double
evaluate(
double
feature)
const
36
#ifdef SWIG
37
=0;
38
#else
39
{
40
// to support easy generic classes
41
return
evaluate(feature);
42
}
43
#endif
44
45
//! Calculate score and derivative with respect to the given feature.
46
/** \param[in] feature Value of feature being tested.
47
\return a FloatPair containing the score and its partial derivative
48
with respect to the given feaure.
49
*/
50
virtual
DerivativePair
evaluate_with_derivative
(
double
feature)
const
{
51
// to support easy generic classes
52
return
evaluate_with_derivative(feature);
53
}
54
55
IMP_REF_COUNTED_DESTRUCTOR
(
UnaryFunction
);
56
};
57
58
IMP_OBJECTS
(
UnaryFunction
,
UnaryFunctions
);
59
60
IMPKERNEL_END_NAMESPACE
61
62
#endif
/* IMPKERNEL_UNARY_FUNCTION_H */