NEST  2.6.0,not_revisioned_source_dir@0
specialfunctionsmodule.h
Go to the documentation of this file.
1 /*
2  * specialfunctionsmodule.h
3  *
4  * This file is part of NEST.
5  *
6  * Copyright (C) 2004 The NEST Initiative
7  *
8  * NEST is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * NEST is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with NEST. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 
23 #ifndef SPECIALFUNCTIONSMODULE_H
24 #define SPECIALFUNCTIONSMODULE_H
25 /*
26  SLI Module implementing functions from the GNU Science Library.
27  The GSL is available from sources.redhat.com/gsl.
28 */
29 
30 /*
31  NOTE: Special functions are available only if the GSL is installed.
32  If no GSL is available, calling special functions will result
33  in a SLI error message. HEP 2002-09-19.
34 */
35 
36 #include "slimodule.h"
37 #include "slifunction.h"
38 #include "config.h"
39 
40 #ifdef HAVE_GSL
41 #include <gsl/gsl_integration.h>
42 #endif
43 
44 // NOTE: all gsl headers are included in specialfunctionsmodule.cc
45 
47 {
48 
49  // Part 1: Methods pertaining to the module ----------------------
50 
51 public:
52 
54  // ~SpecialFunctionsModule(void);
55 
56  // The Module is registered by a call to this Function:
57  void init(SLIInterpreter *);
58 
59  // This function will return the name of our module:
60  const std::string name(void) const;
61 
62 
63  // Part 2: Classes for the implemented functions -----------------
64 
65 
66 public:
73  {
74  public:
76  void execute(SLIInterpreter *) const;
77  };
79  {
80  public:
82  void execute(SLIInterpreter *) const;
83  };
85  {
86  public:
88  void execute(SLIInterpreter *) const;
89  };
90 
91  class ErfFunction: public SLIFunction
92  {
93  public:
95  void execute(SLIInterpreter *) const;
96  };
97 
98  class ErfcFunction: public SLIFunction
99  {
100  public:
102  void execute(SLIInterpreter *) const;
103  };
104 
106  {
107  public:
108  void execute(SLIInterpreter *) const;
109 
110  // need constructor and destructor to set up integration workspace
111  GaussDiskConvFunction(void);
113 
114  private:
115  // quadrature parameters, see GSL Reference
116  static const int MAX_QUAD_SIZE;
117  static const double QUAD_ERR_LIM;
118  static const double QUAD_ERR_SCALE;
119 
120  // integration workspace
121 #ifdef HAVE_GSL
122  gsl_integration_workspace *w_;
123 
130  static double f_(double, void *);
131  static gsl_function F_; // GSL wrapper struct for it
132 #endif
133  };
134 
135  // Part 3: One instatiation of each new function class -----------
136 
137  public:
138 
145 
146  // Part 3b: Internal variables
147  private:
148 };
149 
150 
151 
152 // Part 4: Documentation for all functions -------------------------
153 
154 /* BeginDocumentation
155 
156 Name: Gammainc - incomplete gamma function
157 
158 Synopsis: x a Gammainc -> result
159 
160 Description: Computes the incomplete Gamma function
161  int(t^(a-1)*exp(-t), t=0..x) / Gamma(a)
162 
163 Parameters: x (double): upper limit of integration
164  a (double): order of Gamma function
165 
166 Examples: 2.2 1.5 Gammainc -> 0.778615
167 
168 Author: H E Plesser
169 
170 FirstVersion: 2001-07-26
171 
172 Remarks: This is the incomplete Gamma function P(a,x) defined as no. 6.5.1
173  in Abramowitz&Stegun. Requires the GSL.
174 
175 References: http://sources.redhat.com/gsl/ref
176 */
177 
178 /* BeginDocumentation
179 
180 Name: Erf - error function
181 
182 Synopsis: x Erf -> result
183 
184 Description: Computes the error function
185  erf(x) = 2/sqrt(pi) int_0^x dt exp(-t^2)
186 
187 Parameters: x (double): error function argument
188 
189 Examples: 0.5 erf -> 0.5205
190 
191 Author: H E Plesser
192 
193 FirstVersion: 2001-07-30
194 
195 Remarks: Requires the GSL.
196 
197 References: http://sources.redhat.com/gsl/ref
198 
199 SeeAlso: Erfc
200 */
201 
202 /* BeginDocumentation
203 
204 Name: Erfc - complementary error function
205 
206 Synopsis: x Erfc -> result
207 
208 Description: Computes the error function
209  erfc(x) = 1 - erf(x) = 2/sqrt(pi) int_x^inf dt exp(-t^2)
210 
211 Parameters: x (double): error function argument
212 
213 Examples: 0.5 erfc -> 0.4795
214 
215 Author: H E Plesser
216 
217 FirstVersion: 2001-07-30
218 
219 Remarks: Requires the GSL.
220 
221 References: http://sources.redhat.com/gsl/ref
222 
223 SeeAlso: Erf
224 */
225 
226 /* BeginDocumentation
227 
228 Name:GaussDiskConv - Convolution of a Gaussian with an excentric disk
229 
230 Synopsis:R r0 GaussDiskConv -> result
231 
232 Description:Computes the convolution of an excentric normalized Gaussian
233 with a disk
234 
235  C[R, r0] = IInt[ disk(rvec; R) * Gauss(rvec - r_0vec) d^2rvec ]
236  = 2 Int[ r Exp[-r0^2-r^2] I_0[2 r r_0] dr, r=0..R]
237 
238 Parameters:R radius of the disk, centered at origin
239 r0 distance of Gaussian center from origin
240 
241 Examples:SLI ] 3.2 2.3 GaussDiskConv =
242 0.873191
243 
244 Author:H E Plesser
245 
246 FirstVersion: 2002-07-12
247 
248 Remarks:This integral is needed to compute the response of a DOG model to
249  excentric light spots, see [1]. For technicalities, see [2]. Requires GSL.
250 
251 References: [1] G. T. Einevoll and P. Heggelund, Vis Neurosci 17:871-885 (2000).
252  [2] Hans E. Plesser, Convolution of an Excentric Gaussian with a Disk,
253  Technical Report, arken.nlh.no/~itfhep, 2002
254 
255 */
256 
257 #endif
Definition: specialfunctionsmodule.h:98
static double f_(double, void *)
Integrand function.
Definition: specialfunctionsmodule.cc:342
Definition: specialfunctionsmodule.h:84
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:89
static gsl_function F_
Definition: specialfunctionsmodule.h:131
Definition: specialfunctionsmodule.h:91
static const int MAX_QUAD_SIZE
Definition: specialfunctionsmodule.h:116
Definition: slifunction.h:35
GammaIncFunction()
Definition: specialfunctionsmodule.h:75
const GaussDiskConvFunction gaussdiskconvfunction
Definition: specialfunctionsmodule.h:144
const ErfcFunction erfcfunction
Definition: specialfunctionsmodule.h:143
GaussDiskConvFunction(void)
Definition: specialfunctionsmodule.cc:253
LambertWm1Function()
Definition: specialfunctionsmodule.h:87
Classes which implement the GSL Funktions.
Definition: specialfunctionsmodule.h:72
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:269
const GammaIncFunction gammaincfunction
Definition: specialfunctionsmodule.h:139
static const double QUAD_ERR_LIM
Definition: specialfunctionsmodule.h:117
const std::string name(void) const
Return name of the module.
Definition: specialfunctionsmodule.cc:59
gsl_integration_workspace * w_
Definition: specialfunctionsmodule.h:122
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:130
Definition: interpret.h:69
Definition: specialfunctionsmodule.h:105
const ErfFunction erffunction
Definition: specialfunctionsmodule.h:142
const LambertWm1Function lambertwm1function
Definition: specialfunctionsmodule.h:141
LambertW0Function()
Definition: specialfunctionsmodule.h:81
static const double QUAD_ERR_SCALE
Definition: specialfunctionsmodule.h:118
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:188
ErfFunction()
Definition: specialfunctionsmodule.h:94
ErfcFunction()
Definition: specialfunctionsmodule.h:101
const LambertW0Function lambertw0function
Definition: specialfunctionsmodule.h:140
Base class for all SLI Interpreter modules.
Definition: slimodule.h:34
SpecialFunctionsModule(void)
Definition: specialfunctionsmodule.h:53
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:159
Definition: specialfunctionsmodule.h:46
void init(SLIInterpreter *)
Initialise the module.
Definition: specialfunctionsmodule.cc:64
void execute(SLIInterpreter *) const
Definition: specialfunctionsmodule.cc:218
~GaussDiskConvFunction(void)
Definition: specialfunctionsmodule.cc:262
Definition: specialfunctionsmodule.h:78