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  return tgamma(x + 1.);
12 }
13 
14 
15 extern "C" double degrees(const double radians) {
16  return radians * (180. / M_PI);
17 }
18 
19 extern "C" void radians(const double degrees, double* radians) {
20  *radians = degrees * (M_PI / 180.);
21 }
22 
23 
24 extern "C" double log1p(const double x) {
25  return log(x + 1.);
26 }
27 
28 extern "C" double vtrap(const double x, const double y) {
29  if (fabs(x / y) < 1e-6) {
30  return y * (1.0 - x / y / 2.0);
31  } else {
32  return x / (exp(x / y) - 1.0);
33  }
34 }
exp
Definition: extdef.h:5
log
Definition: extdef.h:4
fabs
Definition: extdef.h:3
#define e
Definition: passive0.cpp:22
double factorial(const double x)
Definition: rxdmath.cpp:10
double log1p(const double x)
Definition: rxdmath.cpp:24
double degrees(const double radians)
Definition: rxdmath.cpp:15
double vtrap(const double x, const double y)
Definition: rxdmath.cpp:28
void radians(const double degrees, double *radians)
Definition: rxdmath.cpp:19
#define M_PI
Definition: rxdmath.cpp:3