1 %include typemaps.i 2 3 %{ 4 typedef struct { 5 double n; 6 double d; 7 } fract; 8 9 typedef struct { 10 double r; 11 double i; 12 } cmplx; 13 14 typedef double * arr1d; 15 typedef int * arr1i; 16 %} 17 18 19 %typemap(in) arr1d { 20 $1 = (double *) pack1D($input,'d'); 21 } 22 23 %typemap(in) arr1i { 24 $1 = (int *) pack1D($input,'i'); 25 } 26 27 %typemap(argout) arr1d { 28 unpack1D((SV*)$input, (void *)$1, 'd', 0); 29 } 30 31 %typemap(argout) arr1i { 32 unpack1D((SV*)$input, (void *)$1, 'i', 0); 33 } 34 35 typedef struct { 36 double r; 37 double i; 38 %extend { 39 cmplx(double r=0, double i=0) { 40 cmplx *c; 41 c = (cmplx *) malloc(sizeof(cmplx)); 42 c->r = r; 43 c->i = i; 44 return c; 45 } ~cmplx__anonb487e6f8030846 ~cmplx() { 47 free(self); 48 } 49 } 50 } cmplx; 51 52 typedef struct { 53 double n; 54 double d; 55 %extend { 56 fract(double n=0, double d=1) { 57 fract *f; 58 f = (fract *) malloc(sizeof(fract)); 59 f->n = n; 60 f->d = d; 61 return f; 62 } ~fract__anonb487e6f8040863 ~fract() { 64 free(self); 65 } 66 } 67 } fract; 68 69 70 extern double MACHEP; 71 extern double MAXLOG; 72 extern double MINLOG; 73 extern double MAXNUM; 74 extern double PI; 75 extern double PIO2; 76 extern double PIO4; 77 extern double SQRT2; 78 extern double SQRTH; 79 extern double LOG2E; 80 extern double SQ2OPI; 81 extern double LOGE2; 82 extern double LOGSQ2; 83 extern double THPIO4; 84 extern double TWOOPI; 85 86 extern double md_acosh ( double x ); 87 extern int airy ( double x, double *OUTPUT, double *OUTPUT, double *OUTPUT, double *OUTPUT ); 88 extern double md_asin ( double x ); 89 extern double md_acos ( double x ); 90 extern double md_asinh ( double x ); 91 extern double md_atan ( double x ); 92 extern double md_atan2 ( double y, double x ); 93 extern double md_atanh ( double x ); 94 extern double bdtrc ( int k, int n, double p ); 95 extern double bdtr ( int k, int n, double p ); 96 extern double bdtri ( int k, int n, double y ); 97 extern double beta ( double a, double b ); 98 extern double lbeta ( double a, double b ); 99 extern double btdtr ( double a, double b, double x ); 100 extern double md_cbrt ( double x ); 101 extern double chbevl ( double x, void *P, int n ); 102 extern double chdtrc ( double df, double x ); 103 extern double chdtr ( double df, double x ); 104 extern double chdtri ( double df, double y ); 105 extern void md_clog ( cmplx *z, cmplx *w ); 106 extern void md_cexp ( cmplx *z, cmplx *w ); 107 extern void md_csin ( cmplx *z, cmplx *w ); 108 extern void md_ccos ( cmplx *z, cmplx *w ); 109 extern void md_ctan ( cmplx *z, cmplx *w ); 110 extern void ccot ( cmplx *z, cmplx *w ); 111 extern void md_casin ( cmplx *z, cmplx *w ); 112 extern void md_cacos ( cmplx *z, cmplx *w ); 113 extern void md_catan ( cmplx *z, cmplx *w ); 114 extern void md_csinh ( cmplx *z, cmplx *w ); 115 extern void md_casinh ( cmplx *z, cmplx *w ); 116 extern void md_ccosh ( cmplx *z, cmplx *w ); 117 extern void md_cacosh ( cmplx *z, cmplx *w ); 118 extern void md_ctanh ( cmplx *z, cmplx *w ); 119 extern void md_catanh ( cmplx *z, cmplx *w ); 120 extern void md_cpow ( cmplx *a, cmplx *z, cmplx *w ); 121 extern void radd ( fract *a, fract *b, fract *c ); 122 extern void rsub ( fract *a, fract *b, fract *c ); 123 extern void rmul ( fract *a, fract *b, fract *c ); 124 extern void rdiv ( fract *a, fract *b, fract *c ); 125 extern double euclid ( double *INOUT, double *INOUT); 126 extern void cadd ( cmplx *a, cmplx *b, cmplx *c ); 127 extern void csub ( cmplx *a, cmplx *b, cmplx *c ); 128 extern void cmul ( cmplx *a, cmplx *b, cmplx *c ); 129 extern void cdiv ( cmplx *a, cmplx *b, cmplx *c ); 130 extern void cmov ( void *a, void *b ); 131 extern void cneg ( cmplx *a ); 132 extern double md_cabs ( cmplx *z ); 133 extern void md_csqrt ( cmplx *z, cmplx *w ); 134 extern double md_hypot ( double x, double y ); 135 extern double md_cosh ( double x ); 136 extern double dawsn ( double xx ); 137 extern double ellie ( double phi, double m ); 138 extern double ellik ( double phi, double m ); 139 extern double ellpe ( double x ); 140 extern int ellpj ( double u, double m, double *OUTPUT, double *OUTPUT, double *OUTPUT, double *OUTPUT ); 141 extern double ellpk ( double x ); 142 extern double md_exp ( double x ); 143 extern double md_exp10 ( double x ); 144 /* extern double exp1m ( double x ); */ 145 extern double md_exp2 ( double x ); 146 extern double md_expn ( int n, double x ); 147 extern double ei ( double x ); 148 extern double md_fabs ( double x ); 149 extern double fac ( int i ); 150 extern double fdtrc ( int ia, int ib, double x ); 151 extern double fdtr ( int ia, int ib, double x ); 152 extern double fdtri ( int ia, int ib, double y ); 153 extern double md_ceil ( double x ); 154 extern double md_floor ( double x ); 155 extern double md_frexp ( double x, int *OUTPUT); 156 /* extern double md_frexp ( double x, int *pw2 ); */ 157 extern double md_ldexp ( double x, int pw2 ); 158 /* extern int signbit ( double x ); */ 159 /* extern int isnan ( double x ); */ 160 /* extern int isfinite ( double x ); */ 161 extern int fresnl ( double xxa, double *OUTPUT, double *OUTPUT); 162 extern double md_gamma ( double x ); 163 extern double lgam ( double x ); 164 extern double gdtr ( double a, double b, double x ); 165 extern double gdtrc ( double a, double b, double x ); 166 extern double hyp2f1 ( double a, double b, double c, double x ); 167 extern double hyperg ( double a, double b, double x ); 168 extern double hyp2f0 ( double a, double b, double x, int type, double *OUTPUT ); 169 extern double i0 ( double x ); 170 extern double i0e ( double x ); 171 extern double i1 ( double x ); 172 extern double i1e ( double x ); 173 extern double igamc ( double a, double x ); 174 extern double igam ( double a, double x ); 175 extern double igami ( double a, double md_y0 ); 176 extern double incbet ( double aa, double bb, double xx ); 177 extern double incbi ( double aa, double bb, double yy0 ); 178 extern double iv ( double v, double x ); 179 extern double md_j0 ( double x ); 180 extern double md_y0 ( double x ); 181 extern double md_j1 ( double x ); 182 extern double md_y1 ( double x ); 183 extern double md_jn ( int n, double x ); 184 extern double jv ( double n, double x ); 185 extern double k0 ( double x ); 186 extern double k0e ( double x ); 187 extern double k1 ( double x ); 188 extern double k1e ( double x ); 189 extern double kn ( int nn, double x ); 190 extern double md_log ( double x ); 191 extern double md_log10 ( double x ); 192 extern double md_log2 ( double x ); 193 extern long lrand ( void ); 194 extern long lsqrt ( long x ); 195 extern int mtherr ( char *name, int code ); 196 extern double polevl ( double x, void *P, int N ); 197 extern double p1evl ( double x, void *P, int N ); 198 extern double nbdtrc ( int k, int n, double p ); 199 extern double nbdtr ( int k, int n, double p ); 200 extern double nbdtri ( int k, int n, double p ); 201 extern double ndtr ( double a ); 202 extern double md_erfc ( double a ); 203 extern double md_erf ( double x ); 204 extern double ndtri ( double md_y0 ); 205 extern double pdtrc ( int k, double m ); 206 extern double pdtr ( int k, double m ); 207 extern double pdtri ( int k, double y ); 208 extern double md_pow ( double x, double y ); 209 extern double md_powi ( double x, int nn ); 210 extern double psi ( double x ); 211 extern double rgamma ( double x ); 212 extern double md_round ( double x ); 213 extern int shichi ( double x, double *OUTPUT, double *OUTPUT ); 214 extern int sici ( double x, double *OUTPUT, double *OUTPUT ); 215 extern double md_sin ( double x ); 216 extern double md_cos ( double x ); 217 extern double radian ( double d, double m, double s ); 218 /* 219 extern int sincos ( double x, double *OUTPUT, double *OUTPUT, int flg ); 220 */ 221 extern double md_sindg ( double x ); 222 extern double cosdg ( double x ); 223 extern double md_sinh ( double x ); 224 extern double spence ( double x ); 225 extern double sqrt ( double x ); 226 extern double stdtr ( int k, double t ); 227 extern double stdtri ( int k, double p ); 228 extern double onef2 ( double a, double b, double c, double x, double *OUTPUT ); 229 extern double threef0 ( double a, double b, double c, double x, double *OUTPUT ); 230 extern double struve ( double v, double x ); 231 extern double md_tan ( double x ); 232 extern double cot ( double x ); 233 extern double tandg ( double x ); 234 extern double cotdg ( double x ); 235 extern double md_tanh ( double x ); 236 extern double md_log1p ( double x ); 237 extern double expm1 ( double x ); 238 extern double cosm1 ( double x ); 239 extern double md_yn ( int n, double x ); 240 extern double yv ( double n, double x ); 241 extern double zeta ( double x, double q ); 242 extern double zetac ( double x ); 243 extern int drand ( double *OUTPUT ); 244 extern double plancki(double w, double T); 245 246 extern void polini( int maxdeg ); 247 extern void polmul ( arr1d A, int na, arr1d B, int nb, arr1d C ); 248 extern int poldiv ( arr1d A, int na, arr1d B, int nb, arr1d C); 249 extern void poladd ( arr1d A, int na, arr1d B, int nb, arr1d C ); 250 extern void polsub ( arr1d A, int na, arr1d B, int nb, arr1d C ); 251 extern void polsbt ( arr1d A, int na, arr1d B, int nb, arr1d C ); 252 extern double poleva (arr1d A, int na, double x); 253 extern void polatn(arr1d A, arr1d B, arr1d C, int n); 254 extern void polsqt(arr1d A, arr1d B, int n); 255 extern void polsin(arr1d A, arr1d B, int n); 256 extern void polcos(arr1d A, arr1d B, int n); 257 extern int polrt_wrap(arr1d xcof, arr1d cof, int m, arr1d r, arr1d i); 258 extern int cpmul_wrap(arr1d ar, arr1d ai, int da, arr1d br, arr1d bi, int db, arr1d cr, arr1d ci, int *INOUT); 259 260 extern void fpolini( int maxdeg ); 261 extern void fpolmul_wrap ( arr1d A, arr1d Ad, int na, arr1d Bn, arr1d Bd, int nb, arr1d Cn, arr1d Cd, int nc ); 262 extern int fpoldiv_wrap ( arr1d A, arr1d Ad, int na, arr1d Bn, arr1d Bd, int nb, arr1d Cn, arr1d Cd, int nc); 263 extern void fpoladd_wrap ( arr1d A, arr1d Ad, int na, arr1d Bn, arr1d Bd, int nb, arr1d Cn, arr1d Cd, int nc ); 264 extern void fpolsub_wrap ( arr1d A, arr1d Ad, int na, arr1d Bn, arr1d Bd, int nb, arr1d Cn, arr1d Cd, int nc ); 265 extern void fpolsbt_wrap ( arr1d A, arr1d Ad, int na, arr1d Bn, arr1d Bd, int nb, arr1d Cn, arr1d Cd, int nc ); 266 extern void fpoleva_wrap( arr1d An, arr1d Ad, int na, fract *x, fract *s); 267 268 extern void bernum_wrap(arr1d num, arr1d den); 269 extern double simpsn_wrap(arr1d f, int n, double h); 270 extern int minv(arr1d A, arr1d X, int n, arr1d B, arr1i IPS); 271 extern void mtransp(int n, arr1d A, arr1d X); 272 extern void eigens(arr1d A, arr1d EV, arr1d E, int n); 273 extern int simq(arr1d A, arr1d B, arr1d X, int n, int flag, arr1i IPS); 274 extern double polylog(int n, double x); 275 extern double arcdot(arr1d p, arr1d q); 276 extern double expx2(double x, int sign); 277