/[cl-gsl]/cl-gsl/c/cwrapperstub.c
ViewVC logotype

Contents of /cl-gsl/c/cwrapperstub.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations)
Tue May 17 00:54:03 2005 UTC (8 years, 11 months ago) by edenny
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +16 -16 lines
File MIME type: text/plain
Fixes for random-number-generator.
1 /*
2 Copyright (C) 2005 Edgar Denny <edgardenny@comcast.net>
3 This file is part of CL-GSL.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20 #include <stdio.h>
21 #include <string.h>
22
23 #include <gsl/gsl_blas.h>
24 #include <gsl/gsl_block.h>
25 #include <gsl/gsl_block_complex.h>
26 #include <gsl/gsl_cblas.h>
27 #include <gsl/gsl_cdf.h>
28 #include <gsl/gsl_chebyshev.h>
29 #include <gsl/gsl_check_range.h>
30 #include <gsl/gsl_combination.h>
31 #include <gsl/gsl_complex.h>
32 #include <gsl/gsl_complex_math.h>
33 #include <gsl/gsl_const.h>
34 #include <gsl/gsl_deriv.h>
35 #include <gsl/gsl_dft_complex.h>
36 #include <gsl/gsl_dft_complex_float.h>
37 #include <gsl/gsl_dht.h>
38 #include <gsl/gsl_diff.h>
39 #include <gsl/gsl_eigen.h>
40 #include <gsl/gsl_errno.h>
41 #include <gsl/gsl_fft.h>
42 #include <gsl/gsl_fft_complex.h>
43 #include <gsl/gsl_fft_complex_float.h>
44 #include <gsl/gsl_fft_halfcomplex.h>
45 #include <gsl/gsl_fft_halfcomplex_float.h>
46 #include <gsl/gsl_fft_real.h>
47 #include <gsl/gsl_fft_real_float.h>
48 #include <gsl/gsl_fit.h>
49 #include <gsl/gsl_heapsort.h>
50 #include <gsl/gsl_histogram.h>
51 #include <gsl/gsl_histogram2d.h>
52 #include <gsl/gsl_ieee_utils.h>
53 #include <gsl/gsl_integration.h>
54 #include <gsl/gsl_interp.h>
55 #include <gsl/gsl_linalg.h>
56 #include <gsl/gsl_machine.h>
57 #include <gsl/gsl_math.h>
58 #include <gsl/gsl_matrix.h>
59 #include <gsl/gsl_message.h>
60 #include <gsl/gsl_min.h>
61 #include <gsl/gsl_mode.h>
62 #include <gsl/gsl_monte.h>
63 #include <gsl/gsl_monte_miser.h>
64 #include <gsl/gsl_monte_plain.h>
65 #include <gsl/gsl_monte_vegas.h>
66 #include <gsl/gsl_multifit.h>
67 #include <gsl/gsl_multifit_nlin.h>
68 #include <gsl/gsl_multimin.h>
69 #include <gsl/gsl_multiroots.h>
70 #include <gsl/gsl_nan.h>
71 #include <gsl/gsl_ntuple.h>
72 #include <gsl/gsl_odeiv.h>
73 #include <gsl/gsl_permutation.h>
74 #include <gsl/gsl_permute.h>
75 #include <gsl/gsl_permute_vector.h>
76 #include <gsl/gsl_poly.h>
77 #include <gsl/gsl_pow_int.h>
78 #include <gsl/gsl_precision.h>
79 #include <gsl/gsl_qrng.h>
80 #include <gsl/gsl_randist.h>
81 #include <gsl/gsl_rng.h>
82 #include <gsl/gsl_roots.h>
83 #include <gsl/gsl_sf.h>
84 #include <gsl/gsl_sf_result.h>
85 #include <gsl/gsl_siman.h>
86 #include <gsl/gsl_sort.h>
87 #include <gsl/gsl_sort_vector.h>
88 #include <gsl/gsl_specfunc.h>
89 #include <gsl/gsl_spline.h>
90 #include <gsl/gsl_statistics.h>
91 #include <gsl/gsl_sum.h>
92 #include <gsl/gsl_sys.h>
93 #include <gsl/gsl_test.h>
94 #include <gsl/gsl_types.h>
95 #include <gsl/gsl_vector.h>
96 #include <gsl/gsl_vector_complex.h>
97 #include <gsl/gsl_version.h>
98 /* #include <gsl/gsl_wavelet.h>
99 #include <gsl/gsl_wavelet2d.h> */
100
101 double min_light_travel_from_earth (void)
102 {
103 double c = GSL_CONST_MKSA_SPEED_OF_LIGHT;
104 double au = GSL_CONST_MKSA_ASTRONOMICAL_UNIT;
105 double minutes = GSL_CONST_MKSA_MINUTE;
106
107 /* distance stored in meters */
108 double r_earth = 1.00 * au;
109 double r_mars = 1.52 * au;
110
111 double t_min, t_max;
112
113 t_min = (r_mars - r_earth) / c;
114 t_max = (r_mars + r_earth) / c;
115
116 return (t_min / minutes);
117 }
118
119 void wrap_test_function(double (*func)(double, void *), void *ps)
120 {
121 gsl_function F;
122
123 F.function = func;
124 F.params = ps;
125
126 GSL_FN_EVAL(&F, 2.0);
127 }
128
129 const gsl_root_fsolver_type* wrap_gsl_root_fsolver_brent ()
130 {
131 const gsl_root_fsolver_type *T;
132 T = gsl_root_fsolver_brent;
133 return T;
134 }
135
136 /* ----------------------------------------------------------------- */
137
138 int wrap_gsl_vector_fwrite(char *fn, const gsl_vector *v)
139 {
140 FILE* stream;
141 int ret;
142
143 stream = fopen(fn, "wb");
144 ret = gsl_vector_fwrite(stream, v);
145 fclose(stream);
146
147 return ret;
148 }
149
150 int wrap_gsl_vector_fread(char *fn, gsl_vector *v)
151 {
152 FILE* stream;
153 int ret;
154
155 stream = fopen(fn, "rb");
156 ret = gsl_vector_fread(stream, v);
157 fclose(stream);
158
159 return ret;
160 }
161
162 int wrap_gsl_vector_fprintf(char *fn, const gsl_vector *v)
163 {
164 FILE* stream;
165 int ret;
166
167 stream = fopen(fn, "w");
168 ret = gsl_vector_fprintf(stream, v, "%lf");
169 fclose(stream);
170
171 return ret;
172 }
173
174 int wrap_gsl_vector_fscanf(char *fn, gsl_vector *v)
175 {
176 FILE* stream;
177 int ret;
178
179 stream = fopen(fn, "r");
180 ret = gsl_vector_fscanf(stream, v);
181 fclose(stream);
182
183 return ret;
184 }
185
186 /* ----------------------------------------------------------------- */
187
188 int wrap_gsl_vector_float_fwrite(char *fn, const gsl_vector_float *v)
189 {
190 FILE* stream;
191 int ret;
192
193 stream = fopen(fn, "wb");
194 ret = gsl_vector_float_fwrite(stream, v);
195 fclose(stream);
196
197 return ret;
198 }
199
200 int wrap_gsl_vector_float_fread(char *fn, gsl_vector_float *v)
201 {
202 FILE* stream;
203 int ret;
204
205 stream = fopen(fn, "rb");
206 ret = gsl_vector_float_fread(stream, v);
207 fclose(stream);
208
209 return ret;
210 }
211
212 int wrap_gsl_vector_float_fprintf(char *fn, const gsl_vector_float *v)
213 {
214 FILE* stream;
215 int ret;
216
217 stream = fopen(fn, "w");
218 ret = gsl_vector_float_fprintf(stream, v, "%f");
219 fclose(stream);
220
221 return ret;
222 }
223
224 int wrap_gsl_vector_float_fscanf(char *fn, gsl_vector_float *v)
225 {
226 FILE* stream;
227 int ret;
228
229 stream = fopen(fn, "r");
230 ret = gsl_vector_float_fscanf(stream, v);
231 fclose(stream);
232
233 return ret;
234 }
235
236 /* ----------------------------------------------------------------- */
237
238 int wrap_gsl_vector_int_fwrite(char *fn, const gsl_vector_int *v)
239 {
240 FILE* stream;
241 int ret;
242
243 stream = fopen(fn, "wb");
244 ret = gsl_vector_int_fwrite(stream, v);
245 fclose(stream);
246
247 return ret;
248 }
249
250 int wrap_gsl_vector_int_fread(char *fn, gsl_vector_int *v)
251 {
252 FILE* stream;
253 int ret;
254
255 stream = fopen(fn, "rb");
256 ret = gsl_vector_int_fread(stream, v);
257 fclose(stream);
258
259 return ret;
260 }
261
262 int wrap_gsl_vector_int_fprintf(char *fn, const gsl_vector_int *v)
263 {
264 FILE* stream;
265 int ret;
266
267 stream = fopen(fn, "w");
268 ret = gsl_vector_int_fprintf(stream, v, "%d");
269 fclose(stream);
270
271 return ret;
272 }
273
274 int wrap_gsl_vector_int_fscanf(char *fn, gsl_vector_int *v)
275 {
276 FILE* stream;
277 int ret;
278
279 stream = fopen(fn, "r");
280 ret = gsl_vector_int_fscanf(stream, v);
281 fclose(stream);
282
283 return ret;
284 }
285
286 /* ----------------------------------------------------------------- */
287
288 int wrap_gsl_vector_complex_fwrite(char *fn, const gsl_vector_complex *v)
289 {
290 FILE* stream;
291 int ret;
292
293 stream = fopen(fn, "wb");
294 ret = gsl_vector_complex_fwrite(stream, v);
295 fclose(stream);
296
297 return ret;
298 }
299
300 int wrap_gsl_vector_complex_fread(char *fn, gsl_vector_complex *v)
301 {
302 FILE* stream;
303 int ret;
304
305 stream = fopen(fn, "rb");
306 ret = gsl_vector_complex_fread(stream, v);
307 fclose(stream);
308
309 return ret;
310 }
311
312 int wrap_gsl_vector_complex_fprintf(char *fn, const gsl_vector_complex *v)
313 {
314 FILE* stream;
315 int ret;
316
317 stream = fopen(fn, "w");
318 ret = gsl_vector_complex_fprintf(stream, v, "%lf");
319 fclose(stream);
320
321 return ret;
322 }
323
324 int wrap_gsl_vector_complex_fscanf(char *fn, gsl_vector_complex *v)
325 {
326 FILE* stream;
327 int ret;
328
329 stream = fopen(fn, "r");
330 ret = gsl_vector_complex_fscanf(stream, v);
331 fclose(stream);
332
333 return ret;
334 }
335
336 /* ----------------------------------------------------------------- */
337
338 int wrap_gsl_vector_complex_float_fwrite(char *fn,
339 const gsl_vector_complex_float *v)
340 {
341 FILE* stream;
342 int ret;
343
344 stream = fopen(fn, "wb");
345 ret = gsl_vector_complex_float_fwrite(stream, v);
346 fclose(stream);
347
348 return ret;
349 }
350
351 int wrap_gsl_vector_complex_float_fread(char *fn, gsl_vector_complex_float *v)
352 {
353 FILE* stream;
354 int ret;
355
356 stream = fopen(fn, "rb");
357 ret = gsl_vector_complex_float_fread(stream, v);
358 fclose(stream);
359
360 return ret;
361 }
362
363 int wrap_gsl_vector_complex_float_fprintf(char *fn,
364 const gsl_vector_complex_float *v)
365 {
366 FILE* stream;
367 int ret;
368
369 stream = fopen(fn, "w");
370 ret = gsl_vector_complex_float_fprintf(stream, v, "%lf");
371 fclose(stream);
372
373 return ret;
374 }
375
376 int wrap_gsl_vector_complex_float_fscanf(char *fn, gsl_vector_complex_float *v)
377 {
378 FILE* stream;
379 int ret;
380
381 stream = fopen(fn, "r");
382 ret = gsl_vector_complex_float_fscanf(stream, v);
383 fclose(stream);
384
385 return ret;
386 }
387
388 /* ----------------------------------------------------------------- */
389
390 gsl_vector *wrap_gsl_vector_subvector(gsl_vector *v, size_t offset, size_t n)
391 {
392 gsl_vector *ret;
393 gsl_vector_view v_view = gsl_vector_subvector(v, offset, n);
394 ret = &v_view.vector;
395 return ret;
396 }
397
398 gsl_vector_float *wrap_gsl_vector_float_subvector(gsl_vector_float *v,
399 size_t offset,
400 size_t n)
401 {
402 gsl_vector_float *ret;
403 gsl_vector_float_view v_view = gsl_vector_float_subvector(v, offset, n);
404 ret = &v_view.vector;
405 return ret;
406 }
407
408 gsl_vector_int *wrap_gsl_vector_int_subvector(gsl_vector_int *v,
409 size_t offset,
410 size_t n)
411 {
412 gsl_vector_int *ret;
413 gsl_vector_int_view v_view = gsl_vector_int_subvector(v, offset, n);
414 ret = &v_view.vector;
415 return ret;
416 }
417
418 gsl_vector_complex *wrap_gsl_vector_complex_subvector(gsl_vector_complex *v,
419 size_t offset,
420 size_t n)
421 {
422 gsl_vector_complex *ret;
423 gsl_vector_complex_view v_view = gsl_vector_complex_subvector(v, offset, n);
424 ret = &v_view.vector;
425 return ret;
426 }
427
428 gsl_vector_complex_float *wrap_gsl_vector_complex_float_subvector(
429 gsl_vector_complex_float *v,
430 size_t offset,
431 size_t n)
432 {
433 gsl_vector_complex_float *ret;
434 gsl_vector_complex_float_view v_view =
435 gsl_vector_complex_float_subvector(v, offset, n);
436 ret = &v_view.vector;
437 return ret;
438 }
439
440 /* ----------------------------------------------------------------- */
441
442 gsl_vector *wrap_gsl_vector_subvector_with_stride(
443 gsl_vector *v,
444 size_t offset,
445 size_t stride,
446 size_t n)
447 {
448 gsl_vector *ret;
449 gsl_vector_view v_view =
450 gsl_vector_subvector_with_stride(v, offset, stride, n);
451 ret = &v_view.vector;
452 return ret;
453 }
454
455 gsl_vector_float *wrap_gsl_vector_float_subvector_with_stride(
456 gsl_vector_float *v,
457 size_t offset,
458 size_t stride,
459 size_t n)
460 {
461 gsl_vector_float *ret;
462 gsl_vector_float_view v_view =
463 gsl_vector_float_subvector_with_stride(v, offset, stride, n);
464 ret = &v_view.vector;
465 return ret;
466 }
467
468 gsl_vector_int *wrap_gsl_vector_int_subvector_with_stride(
469 gsl_vector_int *v,
470 size_t offset,
471 size_t stride,
472 size_t n)
473 {
474 gsl_vector_int *ret;
475 gsl_vector_int_view v_view =
476 gsl_vector_int_subvector_with_stride(v, offset, stride, n);
477 ret = &v_view.vector;
478 return ret;
479 }
480
481 gsl_vector_complex *wrap_gsl_vector_complex_subvector_with_stride(
482 gsl_vector_complex *v,
483 size_t offset,
484 size_t stride,
485 size_t n)
486 {
487 gsl_vector_complex *ret;
488 gsl_vector_complex_view v_view =
489 gsl_vector_complex_subvector_with_stride(v, offset, stride, n);
490 ret = &v_view.vector;
491 return ret;
492 }
493
494 gsl_vector_complex_float *wrap_gsl_vector_complex_float_subvector_with_stride(
495 gsl_vector_complex_float *v,
496 size_t offset,
497 size_t stride,
498 size_t n)
499 {
500 gsl_vector_complex_float *ret;
501 gsl_vector_complex_float_view v_view =
502 gsl_vector_complex_float_subvector_with_stride(v, offset, stride, n);
503 ret = &v_view.vector;
504 return ret;
505 }
506
507 /* ----------------------------------------------------------------- */
508
509 void wrap_gsl_vector_complex_float_set(gsl_vector_complex_float *v,
510 const size_t i,
511 gsl_complex_float *z)
512 {
513 v->data[2 * i * v->stride] = z->dat[0];
514 v->data[(2 * i * v->stride) + 1] = z->dat[1];
515 }
516
517 void wrap_gsl_vector_complex_set(gsl_vector_complex *v,
518 const size_t i,
519 gsl_complex *z)
520 {
521 v->data[2 * i * v->stride] = z->dat[0];
522 v->data[(2 * i * v->stride) + 1] = z->dat[1];
523 }
524
525 void wrap_gsl_vector_complex_set_all(gsl_vector_complex *v,
526 gsl_complex *z)
527 {
528 gsl_vector_complex_set_all(v , *z);
529 }
530
531 void wrap_gsl_vector_complex_float_set_all(gsl_vector_complex_float *v,
532 gsl_complex_float *z)
533 {
534 gsl_vector_complex_float_set_all(v , *z);
535 }
536
537
538 /* ----------------------------------------------------------------- */
539
540 void wrap_gsl_matrix_complex_float_set(gsl_matrix_complex_float *m,
541 const size_t i,
542 const size_t j,
543 gsl_complex_float *z)
544 {
545 m->data[2 * (i * m->tda + j)] = z->dat[0];
546 m->data[(2 * (i * m->tda + j)) + 1] = z->dat[1];
547 }
548
549 void wrap_gsl_matrix_complex_set(gsl_matrix_complex *m,
550 const size_t i,
551 const size_t j,
552 gsl_complex *z)
553 {
554 m->data[2 * (i * m->tda + j)] = z->dat[0];
555 m->data[(2 * (i * m->tda + j)) + 1] = z->dat[1];
556 }
557
558 void wrap_gsl_matrix_complex_set_all(gsl_matrix_complex *m,
559 gsl_complex *z)
560 {
561 gsl_matrix_complex_set_all(m , *z);
562 }
563
564 void wrap_gsl_matrix_complex_float_set_all(gsl_matrix_complex_float *m,
565 gsl_complex_float *z)
566 {
567 gsl_matrix_complex_float_set_all(m , *z);
568 }
569
570 /* ----------------------------------------------------------------- */
571
572 int wrap_gsl_matrix_fwrite(char *fn, const gsl_matrix *m)
573 {
574 FILE* stream;
575 int ret;
576
577 stream = fopen(fn, "wb");
578 ret = gsl_matrix_fwrite(stream, m);
579 fclose(stream);
580
581 return ret;
582 }
583
584 int wrap_gsl_matrix_fread(char *fn, gsl_matrix *m)
585 {
586 FILE* stream;
587 int ret;
588
589 stream = fopen(fn, "rb");
590 ret = gsl_matrix_fread(stream, m);
591 fclose(stream);
592
593 return ret;
594 }
595
596 int wrap_gsl_matrix_fprintf(char *fn, const gsl_matrix *m)
597 {
598 FILE* stream;
599 int ret;
600
601 stream = fopen(fn, "w");
602 ret = gsl_matrix_fprintf(stream, m, "%lf");
603 fclose(stream);
604
605 return ret;
606 }
607
608 int wrap_gsl_matrix_fscanf(char *fn, gsl_matrix *m)
609 {
610 FILE* stream;
611 int ret;
612
613 stream = fopen(fn, "r");
614 ret = gsl_matrix_fscanf(stream, m);
615 fclose(stream);
616
617 return ret;
618 }
619
620 /* ----------------------------------------------------------------- */
621
622 int wrap_gsl_matrix_float_fwrite(char *fn, const gsl_matrix_float *m)
623 {
624 FILE* stream;
625 int ret;
626
627 stream = fopen(fn, "wb");
628 ret = gsl_matrix_float_fwrite(stream, m);
629 fclose(stream);
630
631 return ret;
632 }
633
634 int wrap_gsl_matrix_float_fread(char *fn, gsl_matrix_float *m)
635 {
636 FILE* stream;
637 int ret;
638
639 stream = fopen(fn, "rb");
640 ret = gsl_matrix_float_fread(stream, m);
641 fclose(stream);
642
643 return ret;
644 }
645
646 int wrap_gsl_matrix_float_fprintf(char *fn, const gsl_matrix_float *m)
647 {
648 FILE* stream;
649 int ret;
650
651 stream = fopen(fn, "w");
652 ret = gsl_matrix_float_fprintf(stream, m, "%f");
653 fclose(stream);
654
655 return ret;
656 }
657
658 int wrap_gsl_matrix_float_fscanf(char *fn, gsl_matrix_float *m)
659 {
660 FILE* stream;
661 int ret;
662
663 stream = fopen(fn, "r");
664 ret = gsl_matrix_float_fscanf(stream, m);
665 fclose(stream);
666
667 return ret;
668 }
669
670 /* ----------------------------------------------------------------- */
671
672 int wrap_gsl_matrix_int_fwrite(char *fn, const gsl_matrix_int *m)
673 {
674 FILE* stream;
675 int ret;
676
677 stream = fopen(fn, "wb");
678 ret = gsl_matrix_int_fwrite(stream, m);
679 fclose(stream);
680
681 return ret;
682 }
683
684 int wrap_gsl_matrix_int_fread(char *fn, gsl_matrix_int *m)
685 {
686 FILE* stream;
687 int ret;
688
689 stream = fopen(fn, "rb");
690 ret = gsl_matrix_int_fread(stream, m);
691 fclose(stream);
692
693 return ret;
694 }
695
696 int wrap_gsl_matrix_int_fprintf(char *fn, const gsl_matrix_int *m)
697 {
698 FILE* stream;
699 int ret;
700
701 stream = fopen(fn, "w");
702 ret = gsl_matrix_int_fprintf(stream, m, "%d");
703 fclose(stream);
704
705 return ret;
706 }
707
708 int wrap_gsl_matrix_int_fscanf(char *fn, gsl_matrix_int *m)
709 {
710 FILE* stream;
711 int ret;
712
713 stream = fopen(fn, "r");
714 ret = gsl_matrix_int_fscanf(stream, m);
715 fclose(stream);
716
717 return ret;
718 }
719
720 /* ----------------------------------------------------------------- */
721
722 int wrap_gsl_matrix_complex_fwrite(char *fn, const gsl_matrix_complex *m)
723 {
724 FILE* stream;
725 int ret;
726
727 stream = fopen(fn, "wb");
728 ret = gsl_matrix_complex_fwrite(stream, m);
729 fclose(stream);
730
731 return ret;
732 }
733
734 int wrap_gsl_matrix_complex_fread(char *fn, gsl_matrix_complex *m)
735 {
736 FILE* stream;
737 int ret;
738
739 stream = fopen(fn, "rb");
740 ret = gsl_matrix_complex_fread(stream, m);
741 fclose(stream);
742
743 return ret;
744 }
745
746 int wrap_gsl_matrix_complex_fprintf(char *fn, const gsl_matrix_complex *m)
747 {
748 FILE* stream;
749 int ret;
750
751 stream = fopen(fn, "w");
752 ret = gsl_matrix_complex_fprintf(stream, m, "%lf");
753 fclose(stream);
754
755 return ret;
756 }
757
758 int wrap_gsl_matrix_complex_fscanf(char *fn, gsl_matrix_complex *m)
759 {
760 FILE* stream;
761 int ret;
762
763 stream = fopen(fn, "r");
764 ret = gsl_matrix_complex_fscanf(stream, m);
765 fclose(stream);
766
767 return ret;
768 }
769
770 /* ----------------------------------------------------------------- */
771
772 int wrap_gsl_matrix_complex_float_fwrite(char *fn,
773 const gsl_matrix_complex_float *m)
774 {
775 FILE* stream;
776 int ret;
777
778 stream = fopen(fn, "wb");
779 ret = gsl_matrix_complex_float_fwrite(stream, m);
780 fclose(stream);
781
782 return ret;
783 }
784
785 int wrap_gsl_matrix_complex_float_fread(char *fn, gsl_matrix_complex_float *m)
786 {
787 FILE* stream;
788 int ret;
789
790 stream = fopen(fn, "rb");
791 ret = gsl_matrix_complex_float_fread(stream, m);
792 fclose(stream);
793
794 return ret;
795 }
796
797 int wrap_gsl_matrix_complex_float_fprintf(char *fn,
798 const gsl_matrix_complex_float *m)
799 {
800 FILE* stream;
801 int ret;
802
803 stream = fopen(fn, "w");
804 ret = gsl_matrix_complex_float_fprintf(stream, m, "%lf");
805 fclose(stream);
806
807 return ret;
808 }
809
810 int wrap_gsl_matrix_complex_float_fscanf(char *fn, gsl_matrix_complex_float *m)
811 {
812 FILE* stream;
813 int ret;
814
815 stream = fopen(fn, "r");
816 ret = gsl_matrix_complex_float_fscanf(stream, m);
817 fclose(stream);
818
819 return ret;
820 }
821
822 /* ----------------------------------------------------------------- */
823
824 int wrap_gsl_permutation_fwrite(char *fn, const gsl_permutation *p)
825 {
826 FILE* stream;
827 int ret;
828
829 stream = fopen(fn, "wb");
830 ret = gsl_permutation_fwrite(stream, p);
831 fclose(stream);
832
833 return ret;
834 }
835
836 int wrap_gsl_permutation_fread(char *fn, gsl_permutation *p)
837 {
838 FILE* stream;
839 int ret;
840
841 stream = fopen(fn, "rb");
842 ret = gsl_permutation_fread(stream, p);
843 fclose(stream);
844
845 return ret;
846 }
847
848 int wrap_gsl_permutation_fprintf(char *fn, const gsl_permutation *p)
849 {
850 FILE* stream;
851 int ret;
852
853 stream = fopen(fn, "w");
854 ret = gsl_permutation_fprintf(stream, p, "%u\n");
855 fclose(stream);
856
857 return ret;
858 }
859
860 int wrap_gsl_permutation_fscanf(char *fn, gsl_permutation *p)
861 {
862 FILE* stream;
863 int ret;
864
865 stream = fopen(fn, "r");
866 ret = gsl_permutation_fscanf(stream, p);
867 fclose(stream);
868
869 return ret;
870 }
871
872 gsl_rng *wrap_gsl_rng_set_type(char *tp)
873 {
874 gsl_rng *r;
875
876 if (strncmp( "borosh13", tp, 8) == 0)
877 r = gsl_rng_alloc (gsl_rng_borosh13);
878 else if (strncmp( "coveyou", tp, 7) == 0)
879 r = gsl_rng_alloc(gsl_rng_coveyou);
880 else if (strncmp( "cmrg", tp, 4) == 0)
881 r = gsl_rng_alloc(gsl_rng_cmrg);
882 else if (strncmp( "fishman18", tp, 9) == 0)
883 r = gsl_rng_alloc(gsl_rng_fishman18);
884 else if (strncmp( "fishman20", tp, 9) == 0)
885 r = gsl_rng_alloc(gsl_rng_fishman20);
886 else if (strncmp( "fishman2x", tp, 9) == 0)
887 r = gsl_rng_alloc(gsl_rng_fishman2x);
888 else if (strncmp( "gfsr4", tp, 5) == 0)
889 r = gsl_rng_alloc(gsl_rng_gfsr4);
890 else if (strncmp( "knuthran2", tp, 9) == 0)
891 r = gsl_rng_alloc(gsl_rng_knuthran2);
892 else if (strncmp( "knuthran", tp, 8) == 0)
893 r = gsl_rng_alloc(gsl_rng_knuthran);
894 else if (strncmp( "lecuyer21", tp, 9) == 0)
895 r = gsl_rng_alloc(gsl_rng_lecuyer21);
896 else if (strncmp( "minstd", tp, 6) == 0)
897 r = gsl_rng_alloc(gsl_rng_minstd);
898 else if (strncmp( "mrg", tp, 3) == 0)
899 r = gsl_rng_alloc(gsl_rng_mrg);
900 else if (strncmp( "mt19937-1999", tp, 12) == 0)
901 r = gsl_rng_alloc(gsl_rng_mt19937_1999);
902 else if (strncmp( "mt19937-1998", tp, 12) == 0)
903 r = gsl_rng_alloc(gsl_rng_mt19937_1998);
904 else if (strncmp( "mt19937", tp, 7) == 0)
905 r = gsl_rng_alloc(gsl_rng_mt19937);
906 else if (strncmp( "r250", tp, 4) == 0)
907 r = gsl_rng_alloc(gsl_rng_r250);
908 else if (strncmp( "ran0", tp, 4) == 0)
909 r = gsl_rng_alloc(gsl_rng_ran0);
910 else if (strncmp( "ran1", tp, 4) == 0)
911 r = gsl_rng_alloc(gsl_rng_ran1);
912 else if (strncmp( "ran2", tp, 4) == 0)
913 r = gsl_rng_alloc(gsl_rng_ran2);
914 else if (strncmp( "ran3", tp, 4) == 0)
915 r = gsl_rng_alloc(gsl_rng_ran3);
916 else if (strncmp( "randu", tp, 5) == 0)
917 r = gsl_rng_alloc(gsl_rng_randu);
918 else if (strncmp( "rand48", tp, 6) == 0)
919 r = gsl_rng_alloc(gsl_rng_rand48);
920 else if (strncmp( "random128-bsd", tp, 13) == 0)
921 r = gsl_rng_alloc(gsl_rng_random128_bsd);
922 else if (strncmp( "random128-glibc2", tp, 16) == 0)
923 r = gsl_rng_alloc(gsl_rng_random128_glibc2);
924 else if (strncmp( "random128-libc5", tp, 15) == 0)
925 r = gsl_rng_alloc(gsl_rng_random128_libc5);
926 else if (strncmp( "random256-bsd", tp, 13) == 0)
927 r = gsl_rng_alloc(gsl_rng_random256_bsd);
928 else if (strncmp( "random256-glibc2", tp, 16) == 0)
929 r = gsl_rng_alloc(gsl_rng_random256_glibc2);
930 else if (strncmp( "random256-libc5", tp, 15) == 0)
931 r = gsl_rng_alloc(gsl_rng_random256_libc5);
932 else if (strncmp( "random32-bsd", tp, 12) == 0)
933 r = gsl_rng_alloc(gsl_rng_random32_bsd);
934 else if (strncmp( "random32-glibc2", tp, 15) == 0)
935 r = gsl_rng_alloc(gsl_rng_random32_glibc2);
936 else if (strncmp( "random32-libc5", tp, 14) == 0)
937 r = gsl_rng_alloc(gsl_rng_random32_libc5);
938 else if (strncmp( "random64-bsd", tp, 12) == 0)
939 r = gsl_rng_alloc(gsl_rng_random64_bsd);
940 else if (strncmp( "random64-glibc2", tp, 15) == 0)
941 r = gsl_rng_alloc(gsl_rng_random64_glibc2);
942 else if (strncmp( "random64-libc5", tp, 14) == 0)
943 r = gsl_rng_alloc(gsl_rng_random64_libc5);
944 else if (strncmp( "random8-bsd", tp, 11) == 0)
945 r = gsl_rng_alloc(gsl_rng_random8_bsd);
946 else if (strncmp( "random8-glibc2", tp, 14) == 0)
947 r = gsl_rng_alloc(gsl_rng_random8_glibc2);
948 else if (strncmp( "random8-libc5", tp, 13) == 0)
949 r = gsl_rng_alloc(gsl_rng_random8_libc5);
950 else if (strncmp( "random-bsd", tp, 10) == 0)
951 r = gsl_rng_alloc(gsl_rng_random_bsd);
952 else if (strncmp( "random-glibc2", tp, 13) == 0)
953 r = gsl_rng_alloc(gsl_rng_random_glibc2);
954 else if (strncmp( "random-libc5", tp, 12) == 0)
955 r = gsl_rng_alloc(gsl_rng_random_libc5);
956 else if (strncmp( "rand", tp, 4) == 0)
957 r = gsl_rng_alloc(gsl_rng_rand);
958 else if (strncmp( "ranf", tp, 4) == 0)
959 r = gsl_rng_alloc(gsl_rng_ranf);
960 else if (strncmp( "ranlux389", tp, 9) == 0)
961 r = gsl_rng_alloc(gsl_rng_ranlux389);
962 else if (strncmp( "ranlux", tp, 6) == 0)
963 r = gsl_rng_alloc(gsl_rng_ranlux);
964 else if (strncmp( "ranlxd1", tp, 7) == 0)
965 r = gsl_rng_alloc(gsl_rng_ranlxd1);
966 else if (strncmp( "ranlxd2", tp, 7) == 0)
967 r = gsl_rng_alloc(gsl_rng_ranlxd2);
968 else if (strncmp( "ranlxs0", tp, 7) == 0)
969 r = gsl_rng_alloc(gsl_rng_ranlxs0);
970 else if (strncmp( "ranlxs1", tp, 7) == 0)
971 r = gsl_rng_alloc(gsl_rng_ranlxs1);
972 else if (strncmp( "ranlxs2", tp, 7) == 0)
973 r = gsl_rng_alloc(gsl_rng_ranlxs2);
974 else if (strncmp( "ranmar", tp, 6) == 0)
975 r = gsl_rng_alloc(gsl_rng_ranmar);
976 else if (strncmp( "slatec", tp, 6) == 0)
977 r = gsl_rng_alloc(gsl_rng_slatec);
978 else if (strncmp( "taus113", tp, 7) == 0)
979 r = gsl_rng_alloc(gsl_rng_taus113);
980 else if (strncmp( "taus2", tp, 5) == 0)
981 r = gsl_rng_alloc(gsl_rng_taus2);
982 else if (strncmp( "taus", tp, 4) == 0)
983 r = gsl_rng_alloc(gsl_rng_taus);
984 else if (strncmp( "transputer", tp, 10) == 0)
985 r = gsl_rng_alloc(gsl_rng_transputer);
986 else if (strncmp( "tt800", tp, 5) == 0)
987 r = gsl_rng_alloc(gsl_rng_tt800);
988 else if (strncmp( "uni32", tp, 5) == 0)
989 r = gsl_rng_alloc(gsl_rng_uni32);
990 else if (strncmp( "uni", tp, 3) == 0)
991 r = gsl_rng_alloc(gsl_rng_uni);
992 else if (strncmp( "vax", tp, 3) == 0)
993 r = gsl_rng_alloc(gsl_rng_vax);
994 else if (strncmp( "waterman14", tp, 10) == 0)
995 r = gsl_rng_alloc(gsl_rng_waterman14);
996 else if (strncmp( "zuf", tp, 3) == 0)
997 r = gsl_rng_alloc(gsl_rng_zuf);
998 else
999 r = gsl_rng_alloc(gsl_rng_default);
1000
1001 return r;
1002 }
1003
1004 /* ----------------------------------------------------------------- */
1005
1006 int wrap_gsl_rng_fwrite(char *fn, const gsl_rng *r)
1007 {
1008 FILE* stream;
1009 int ret;
1010
1011 stream = fopen(fn, "wb");
1012 ret = gsl_rng_fwrite(stream, r);
1013 fclose(stream);
1014
1015 return ret;
1016 }
1017
1018 int wrap_gsl_rng_fread(char *fn, gsl_rng *r)
1019 {
1020 FILE* stream;
1021 int ret;
1022
1023 stream = fopen(fn, "rb");
1024 ret = gsl_rng_fread(stream, r);
1025 fclose(stream);
1026
1027 return ret;
1028 }

  ViewVC Help
Powered by ViewVC 1.1.5