NEURON
rxdmath.cpp
Go to the documentation of this file.
1 #include <math.h>
2 #ifndef M_PI
3 #define M_PI (3.14159265358979323846)
4 #endif
5 
6 /*Some functions supported by numpy that aren't included in math.h
7  * names and arguments match the wrappers used in rxdmath.py
8  */
9 
10 extern "C" double factorial(const double x)
11 {
12  return tgamma(x+1.);
13 }
14 
15 
16 extern "C" double degrees(const double radians)
17 {
18  return radians * (180. / M_PI);
19 }
20 
21 extern "C" void radians(const double degrees, double *radians)
22 {
23  *radians = degrees * (M_PI / 180.);
24 }
25 
26 
27 extern "C" double log1p(const double x)
28 {
29  return log(x+1.);
30 }
31 
32 extern "C" double vtrap(const double x, const double y)
33 {
34  if(fabs(x/y) < 1e-6)
35  {
36  return y*(1.0 - x/y/2.0);
37  }
38  else
39  {
40  return x/(exp(x/y) - 1.0);
41  }
42 }
#define M_PI
Definition: rxdmath.cpp:3
log
Definition: extdef.h:3
double vtrap(const double x, const double y)
Definition: rxdmath.cpp:32
#define e
Definition: passive0.cpp:24
double log1p(const double x)
Definition: rxdmath.cpp:27
double factorial(const double x)
Definition: rxdmath.cpp:10
exp
Definition: extdef.h:3
void radians(const double degrees, double *radians)
Definition: rxdmath.cpp:21
double degrees(const double radians)
Definition: rxdmath.cpp:16
fabs
Definition: extdef.h:3