CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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#include <iostream>
7#include <vector>
8
9#define MAXRANGE 1000
10
11namespace Genfun {
12FUNCTION_OBJECT_IMP(LogisticFunction)
13
15 _x0("X0", 0.0,0.0,1.0),
16 _a("A",2.0,1.0, 4.0)
17{}
18
20}
21
23AbsFunction(right),
24_x0(right._x0),
25_a(right._a)
26{
27}
28
29double LogisticFunction::operator() (double x) const {
30 int i = (int) (x+0.5), &back = i, end=back+1;
31
32 if (i<0 || i>MAXRANGE) {
33 return 0;
34 }
35 else {
36 // Is the vector of values stale?
37 if (__a!=_a.getValue() || __x0!=_x0.getValue()) {
38
39 // Empty the vector
40 fx.erase(fx.begin(),fx.end());
41
42 // And update the cache.
43 __a = _a.getValue();
44 __x0 = _x0.getValue();
45
46 }
47
48
49 if (fx.empty()) fx.push_back(__x0);
50
51 while (fx.size()<size_t(end)) {
52 double v = fx.back();
53 fx.push_back(__a*v*(1.0-v));
54 }
55
56 return fx[i];
57 }
58
59
60}
61
63 return _x0;
64}
65
67 return _a;
68}
69
71 return _x0;
72}
73
75 return _a;
76}
77
78
79} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
#define MAXRANGE
virtual double operator()(double argument) const override
virtual double getValue() const
Definition: Parameter.cc:29
Definition: Abs.hh:14