2 * Grace - GRaphing, Advanced Computation and Exploration of data
4 * Home page: http://plasma-gate.weizmann.ac.il/Grace/
6 * Copyright (c) 1991-1995 Paul J Turner, Portland, OR
7 * Copyright (c) 1996-2001 Grace Development Team
9 * Maintained by Evgeny Stambulchik
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 /* Wrappers for some math functions */
38 #include "mathstuff.h"
40 double ai_wrap(double x
)
42 double retval
, dummy1
, dummy2
, dummy3
;
43 (void) airy(x
, &retval
, &dummy1
, &dummy2
, &dummy3
);
47 double bi_wrap(double x
)
49 double retval
, dummy1
, dummy2
, dummy3
;
50 (void) airy(x
, &dummy1
, &dummy2
, &retval
, &dummy3
);
54 double ci_wrap(double x
)
56 double retval
, dummy1
;
57 (void) sici(x
, &dummy1
, &retval
);
61 double si_wrap(double x
)
63 double retval
, dummy1
;
64 (void) sici(x
, &retval
, &dummy1
);
68 double chi_wrap(double x
)
70 double retval
, dummy1
;
71 (void) shichi(x
, &dummy1
, &retval
);
75 double shi_wrap(double x
)
77 double retval
, dummy1
;
78 (void) shichi(x
, &retval
, &dummy1
);
82 double fresnlc_wrap(double x
)
84 double retval
, dummy1
;
85 (void) fresnl(x
, &dummy1
, &retval
);
89 double fresnls_wrap(double x
)
91 double retval
, dummy1
;
92 (void) fresnl(x
, &retval
, &dummy1
);
96 double iv_wrap(double v
, double x
)
109 double jv_wrap(double v
, double x
)
113 retval
= jn((int) v
, x
);
120 double kn_wrap(int n
, double x
)
133 double yv_wrap(double v
, double x
)
137 retval
= yn((int) v
, x
);
144 double sqr_wrap(double x
)
149 double max_wrap(double x
, double y
)
154 double min_wrap(double x
, double y
)
159 double irand_wrap(int x
)
161 return (double) (lrand48() % x
);
164 double pi_const(void)
169 double deg_uconst(void)
174 double rad_uconst(void)
179 #define C1 0.1978977093962766
180 #define C2 0.1352915131768107
182 double rnorm(double mean
, double sdev
)
184 double u
= drand48();
186 return mean
+ sdev
* (pow(u
, C2
) - pow(1.0 - u
, C2
)) / C1
;
191 return 1.0 / sqrt(2.0 * M_PI
) * exp(-x
* x
* 0.5);
195 /* Wrapper around the cephes ellpe() call which definition
196 is different to the standard definition. See cephes/ellpe.c */
197 double ellpe_wrap ( double x
) {
205 /* Wrapper around the cephes ellpk() call which definition
206 is different to the standard definition. See cephes/ellpk.c */
207 double ellpk_wrap ( double x
) {