CLHEP VERSION Reference Documentation
CLHEP Home Page
CLHEP Documentation
CLHEP Bug Reports
Main Page
Namespaces
Classes
Files
File List
File Members
GenericFunctions
src
LogisticFunction.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
// $Id:
3
#include "
CLHEP/GenericFunctions/LogisticFunction.hh
"
4
#include "
CLHEP/GenericFunctions/Variable.hh
"
5
#include <assert.h>
6
#define MAXRANGE 1000
7
8
namespace
Genfun {
9
FUNCTION_OBJECT_IMP
(LogisticFunction)
10
11
LogisticFunction
::
LogisticFunction
():
12
_x0("X0", 0.0,0.0,1.0),
13
_a("A",2.0,1.0, 4.0)
14
{}
15
16
LogisticFunction::~LogisticFunction
() {
17
}
18
19
LogisticFunction::LogisticFunction
(
const
LogisticFunction
& right):
20
_x0(right._x0),
21
_a(right._a)
22
{
23
}
24
25
double
LogisticFunction::operator()
(
double
x)
const
{
26
int
i = (int) (x+0.5), &back = i, end=back+1;
27
28
if
(i<0 || i>
MAXRANGE
) {
29
return
0;
30
}
31
else
{
32
// Is the vector of values stale?
33
if
(__a!=_a.
getValue
() || __x0!=_x0.
getValue
()) {
34
35
// Empty the vector
36
fx.erase(fx.begin(),fx.end());
37
38
// And update the cache.
39
__a = _a.
getValue
();
40
__x0 = _x0.
getValue
();
41
42
}
43
44
45
if
(fx.empty()) fx.push_back(__x0);
46
47
while
(fx.size()<size_t(end)) {
48
double
v = fx.back();
49
fx.push_back(__a*v*(1.0-v));
50
}
51
52
return
fx[i];
53
}
54
55
56
}
57
58
Parameter
&
LogisticFunction::x0
() {
59
return
_x0;
60
}
61
62
Parameter
&
LogisticFunction::a
() {
63
return
_a;
64
}
65
66
const
Parameter
&
LogisticFunction::x0
()
const
{
67
return
_x0;
68
}
69
70
const
Parameter
&
LogisticFunction::a
()
const
{
71
return
_a;
72
}
73
74
75
}
// namespace Genfun
Generated on Sun Jun 17 2012 08:08:26 for CLHEP by
1.8.1.1