My Project  0.0.16
QUCS Mapping
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
pad3bit.analogfunction.cpp
Go to the documentation of this file.
1 /*
2  * pad3bit.analogfunction.cpp - analog function implementations
3  *
4  * This is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  */
10 
11 #include <stdio.h>
12 #include "pad3bit.analogfunction.h"
13 #include <math.h>
14 
15 /* math functions and appropriate derivatives */
16 inline double _cos(double arg) { return cos(arg); }
17 inline double _d0_cos(double arg) { return (-sin(arg)); }
18 inline double _sin(double arg) { return sin(arg); }
19 inline double _d0_sin(double arg) { return (cos(arg)); }
20 inline double _tan(double arg) { return tan(arg); }
21 inline double _d0_tan(double arg) { return (1.0/cos(arg)/cos(arg)); }
22 inline double _cosh(double arg) { return cosh(arg); }
23 inline double _d0_cosh(double arg) { return (sinh(arg)); }
24 inline double _sinh(double arg) { return sinh(arg); }
25 inline double _d0_sinh(double arg) { return (cosh(arg)); }
26 inline double _tanh(double arg) { return tanh(arg); }
27 inline double _d0_tanh(double arg) { return (1.0/cosh(arg)/cosh(arg)); }
28 inline double _acos(double arg) { return acos(arg); }
29 inline double _d0_acos(double arg) { return (-1.0/sqrt(1-arg*arg)); }
30 inline double _asin(double arg) { return asin(arg); }
31 inline double _d0_asin(double arg) { return (+1.0/sqrt(1-arg*arg)); }
32 inline double _atan(double arg) { return atan(arg); }
33 inline double _d0_atan(double arg) { return (+1.0/(1+arg*arg)); }
34 inline double _atanh(double arg) { return atanh(arg); }
35 inline double _d0_atanh(double arg) { return (+1.0/(1-arg*arg)); }
36 inline double _logE(double arg) { return log(arg); }
37 inline double _d0_logE(double arg) { return (1.0/arg); }
38 inline double _log10(double arg) { return log10(arg); }
39 inline double _d0_log10(double arg) { return (1.0/arg/log(10.0)); }
40 inline double _exp(double arg) { return exp(arg); }
41 inline double _d0_exp(double arg) { return exp(arg); }
42 inline double _sqrt(double arg) { return sqrt(arg); }
43 inline double _d0_sqrt(double arg) { return (1.0/sqrt(arg)/2.0); }
44 inline double _abs(double arg) { return fabs(arg); }
45 inline double _d0_abs(double arg) { return (((arg)>=0)?(+1.0):(-1.0)); }
46 inline int _floor(double arg) { return floor(arg); }
47 inline int _d0_floor(double) { return (1.0); }
48 
49 inline double _hypot(double x,double y) { return sqrt((x)*(x)+(y)*(y)); }
50 inline double _d0_hypot(double x,double y) { return (x)/sqrt((x)*(x)+(y)*(y)); }
51 inline double _d1_hypot(double x,double y) { return (y)/sqrt((x)*(x)+(y)*(y)); }
52 
53 inline double _max(double x,double y) { return ((x)>(y))?(x):(y); }
54 inline double _d0_max(double x,double y) { return ((x)>(y))?1.0:0.0; }
55 inline double _d1_max(double x,double y) { return ((x)>(y))?0.0:1.0; }
56 
57 inline double _min(double x,double y) { return ((x)<(y))?(x):(y); }
58 inline double _d0_min(double x,double y) { return ((x)<(y))?1.0:0.0; }
59 inline double _d1_min(double x,double y) { return ((x)<(y))?0.0:1.0; }
60 
61 inline double _pow(double x,double y) { return pow(x,y); }
62 inline double _d0_pow(double x,double y) { return (x==0.0)?0.0:((y/x)*pow(x,y)); }
63 inline double _d1_pow(double x,double y) { return (x==0.0)?0.0:((log(x)/exp(0.0))*pow(x,y)); }
64 
65 inline double _limexp(double arg) { return ((arg)<(80))?(exp(arg)):(exp(80.0)*(1.0+(arg-80))); }
66 inline double _d0_limexp(double arg) { return ((arg)<(80))?(exp(arg)):(exp(80.0)); }
67 
68 inline double _vt(double arg) { return 1.3806503e-23*arg/1.602176462e-19; }
69 inline double _d0_vt(double) { return 1.3806503e-23/1.602176462e-19; }
70