-
Notifications
You must be signed in to change notification settings - Fork 23
/
fgsl_utils.c
1556 lines (1446 loc) · 36.3 KB
/
fgsl_utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <gsl/gsl_interp.h>
#include <gsl/gsl_spline.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_odeiv.h>
#include <gsl/gsl_odeiv2.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_qrng.h>
#include <gsl/gsl_integration.h>
#include <gsl/gsl_wavelet.h>
#include <gsl/gsl_roots.h>
#include <gsl/gsl_min.h>
#include <gsl/gsl_multiroots.h>
#include <gsl/gsl_multimin.h>
#include <gsl/gsl_multifit_nlin.h>
#include <gsl/gsl_ntuple.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_monte.h>
#include <gsl/gsl_monte_miser.h>
#include <gsl/gsl_monte_vegas.h>
#include <gsl/gsl_permutation.h>
#include <gsl/gsl_combination.h>
#include <gsl/gsl_multiset.h>
#include <gsl/gsl_wavelet.h>
#include <gsl/gsl_vector.h>
#include <gsl/gsl_matrix.h>
// FIXME: remove after IBM compiler fixed
#include <gsl/gsl_sf.h>
#include <gsl/gsl_multifit.h>
#include <gsl/gsl_multifit_nlinear.h>
#include <gsl/gsl_multilarge.h>
#include <gsl/gsl_multilarge_nlinear.h>
#include <gsl/gsl_interp2d.h>
#include <gsl/gsl_spmatrix.h>
#include <gsl/gsl_splinalg.h>
gsl_function *fgsl_function_cinit(double (*func)(double x, void *params), void *params) {
gsl_function *result;
result = (gsl_function *) malloc(sizeof(gsl_function));
result->function = func;
result->params = params;
return result;
}
gsl_function_fdf *fgsl_function_fdf_cinit(double (*f)(double x, void *params),
double (*df)(double x, void *params),
void (*fdf)(double x, void *params, double *f, double *df),
void *params) {
gsl_function_fdf *result;
result = (gsl_function_fdf *) malloc(sizeof(gsl_function_fdf));
result->f = f;
result->df = df;
result->fdf = fdf;
result->params = params;
return result;
}
double fgsl_fn_eval_aux(gsl_function *f, double x) {
return GSL_FN_EVAL(f,x);
}
double fgsl_fn_fdf_eval_f_aux(gsl_function_fdf *f, double x) {
return GSL_FN_FDF_EVAL_F(f,x);
}
double fgsl_fn_fdf_eval_df_aux(gsl_function_fdf *f, double x) {
return GSL_FN_FDF_EVAL_DF(f,x);
}
void fgsl_fn_fdf_eval_f_df_aux(gsl_function_fdf *f, double x, double *y,
double *dy) {
GSL_FN_FDF_EVAL_F_DF(f,x,y,dy);
}
void fgsl_function_cfree(gsl_function *fun) {
free(fun);
}
void fgsl_function_fdf_cfree(gsl_function_fdf *fun) {
free(fun);
}
FILE *fgsl_cstdin() {
return stdin;
}
FILE *fgsl_cstdout() {
return stdout;
}
FILE *fgsl_cstderr() {
return stderr;
}
gsl_vector *fgsl_aux_vector_double_init() {
gsl_vector *result;
result = (gsl_vector *) malloc(sizeof(gsl_vector));
result->block = (gsl_block *) malloc(sizeof(gsl_block));
result->owner = 0;
result->stride = 0;
result->size = 0;
return result;
}
gsl_vector_int *fgsl_aux_vector_int_init() {
gsl_vector_int *result;
result = (gsl_vector_int *) malloc(sizeof(gsl_vector_int));
result->block = (gsl_block_int *) malloc(sizeof(gsl_block_int));
result->owner = 0;
result->stride = 0;
result->size = 0;
return result;
}
void fgsl_aux_vector_double_free(gsl_vector *vec) {
free(vec->block);
free(vec);
}
void fgsl_aux_vector_int_free(gsl_vector_int *vec) {
free(vec->block);
free(vec);
}
int fgsl_aux_vector_double_align(double *a, size_t len, gsl_vector *fvec, size_t size,
size_t offset, size_t stride) {
if (fvec == NULL || fvec->block == NULL) {
return GSL_EFAULT;
}
if (offset + 1 + (size-1)*stride > len) {
return GSL_EINVAL;
}
fvec->block->size = len;
fvec->block->data = a;
fvec->size = size;
fvec->stride = stride;
fvec->data = a+offset;
fvec->owner = 0;
return GSL_SUCCESS;
}
int fgsl_aux_vector_int_align(int *a, size_t len, gsl_vector_int *fvec, size_t size,
size_t offset, size_t stride) {
if (fvec == NULL || fvec->block == NULL) {
return GSL_EFAULT;
}
if (offset + 1 + (size-1)*stride > len) {
return GSL_EINVAL;
}
fvec->block->size = len;
fvec->block->data = a;
fvec->size = size;
fvec->stride = stride;
fvec->data = a+offset;
fvec->owner = 0;
return GSL_SUCCESS;
}
size_t fgsl_aux_vector_double_size(gsl_vector *fvec) {
return fvec->size;
}
size_t fgsl_aux_vector_int_size(gsl_vector_int *fvec) {
return fvec->size;
}
size_t fgsl_aux_vector_double_stride(gsl_vector *fvec) {
return fvec->stride;
}
size_t fgsl_aux_vector_int_stride(gsl_vector_int *fvec) {
return fvec->stride;
}
gsl_vector_complex *fgsl_aux_vector_complex_init() {
gsl_vector_complex *result;
result = (gsl_vector_complex *) malloc(sizeof(gsl_vector_complex));
result->block = (gsl_block_complex *) malloc(sizeof(gsl_block_complex));
result->owner = 0;
result->stride = 0;
result->size = 0;
return result;
}
void fgsl_aux_vector_complex_free(gsl_vector_complex *vec) {
free(vec->block);
free(vec);
}
int fgsl_aux_vector_complex_align(double *a, size_t len,
gsl_vector_complex *fvec, size_t size,
size_t offset, size_t stride) {
if (fvec == NULL || fvec->block == NULL) {
return GSL_EFAULT;
}
if (offset + 1 + (size-1)*stride > len) {
return GSL_EINVAL;
}
fvec->block->size = len;
fvec->block->data = a;
fvec->size = size;
fvec->stride = stride;
fvec->data = a+2*offset;
fvec->owner = 0;
return GSL_SUCCESS;
}
size_t fgsl_aux_vector_complex_size(gsl_vector_complex *fvec) {
return fvec->size;
}
size_t fgsl_aux_vector_complex_stride(gsl_vector_complex *fvec) {
return fvec->stride;
}
gsl_matrix *fgsl_aux_matrix_double_init() {
gsl_matrix *result;
result = (gsl_matrix *) malloc(sizeof(gsl_matrix));
result->block = (gsl_block *) malloc(sizeof(gsl_block));
result->owner = 0;
return result;
}
void fgsl_aux_matrix_double_free(gsl_matrix *mat) {
free(mat->block);
free(mat);
}
int fgsl_aux_matrix_double_align(double *a, size_t lda, size_t n, size_t m, gsl_matrix *fvec) {
if (fvec == NULL || fvec->block == NULL) {
return GSL_EFAULT;
}
if (n > lda) {
return GSL_EINVAL;
}
fvec->block->size = lda*m;
fvec->block->data = a;
fvec->size1 = m;
fvec->size2 = n;
fvec->tda = lda;
fvec->data = a;
fvec->owner = 0;
return GSL_SUCCESS;
}
void fgsl_aux_matrix_double_size(gsl_matrix *fvec, size_t *lda, size_t *m, size_t *n) {
if (m != NULL)
*m = fvec->size2;
if (n != NULL)
*n = fvec->size1;
if (lda != NULL)
*lda = fvec->tda;
}
gsl_matrix_complex *fgsl_aux_matrix_complex_init() {
gsl_matrix_complex *result;
result = (gsl_matrix_complex *) malloc(sizeof(gsl_matrix_complex));
result->block = (gsl_block_complex *)
malloc(sizeof(gsl_block_complex));
result->owner = 0;
return result;
}
void fgsl_aux_matrix_complex_free(gsl_matrix_complex *mat) {
free(mat->block);
free(mat);
}
int fgsl_aux_matrix_complex_align(double *a, size_t lda, size_t n,
size_t m, gsl_matrix_complex *fvec) {
if (fvec == NULL || fvec->block == NULL) {
return GSL_EFAULT;
}
if (n > lda) {
return GSL_EINVAL;
}
fvec->block->size = lda*m;
fvec->block->data = a;
fvec->size1 = m;
fvec->size2 = n;
fvec->tda = lda;
fvec->data = a;
fvec->owner = 0;
return GSL_SUCCESS;
}
void fgsl_aux_matrix_complex_size(gsl_matrix_complex *fvec,
size_t *lda, size_t *m, size_t *n) {
if (m != NULL)
*m = fvec->size2;
if (n != NULL)
*n = fvec->size1;
if (lda != NULL)
*lda = fvec->tda;
}
const gsl_interp2d_type *fgsl_aux_interp2d_alloc(int i) {
const gsl_interp2d_type *res;
switch (i) {
case 1:
res = gsl_interp2d_bilinear;
break;
case 2:
res = gsl_interp2d_bicubic;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_interp_type *fgsl_aux_interp_alloc(int i) {
const gsl_interp_type *res;
switch(i) {
case 1:
res = gsl_interp_linear;
break;
case 2:
res = gsl_interp_polynomial;
break;
case 3:
// printf("here we are: ");
res = gsl_interp_cspline;
break;
case 4:
res = gsl_interp_cspline_periodic;
break;
case 5:
res = gsl_interp_akima;
break;
case 6:
res = gsl_interp_akima_periodic;
break;
case 7:
res = gsl_interp_steffen;
break;
default:
res = NULL;
break;
}
// printf("i had value %i\n",i);
// printf("Address of interp type is %p\n",res);
// printf("Address of cspline interp type is %p\n",gsl_interp_cspline);
return res;
}
gsl_odeiv_system *fgsl_odeiv_system_cinit(
int (*func)(double t, const double y[], double dydt[], void * params),
size_t dimension, void *params,
int (*jacobian)(double t, const double y[], double * dfdy, double dfdt[], void * params)) {
gsl_odeiv_system *result;
// debug
// printf("cinit starts: \n");
// printf(" params is %f\n",*(double *)params);
// double y[2] = {1.0, 0.0};
// double dydt[2];
// printf(" call func\n");
// func(0.0,y,dydt,params);
// printf(" func done: %f %f\n",dydt[0],dydt[1]);
// debug ends
result = (gsl_odeiv_system *) malloc(sizeof(gsl_odeiv_system));
result->function = func;
result->jacobian = jacobian;
result->params = params;
result->dimension = dimension;
// printf(" call func2\n");
// (*result->function)(0.0,y,dydt,params);
// printf(" func done: %f %f\n",dydt[0],dydt[1]);
return result;
}
gsl_odeiv2_system *fgsl_odeiv2_system_cinit(
int (*func)(double t, const double y[], double dydt[], void * params),
size_t dimension, void *params,
int (*jacobian)(double t, const double y[], double * dfdy, double dfdt[], void * params)) {
gsl_odeiv2_system *result;
result = (gsl_odeiv2_system *) malloc(sizeof(gsl_odeiv2_system));
result->function = func;
result->jacobian = jacobian;
result->params = params;
result->dimension = dimension;
return result;
}
void fgsl_odeiv_system_cfree(gsl_odeiv_system *system) {
free(system);
}
void fgsl_odeiv2_system_cfree(gsl_odeiv2_system *system) {
free(system);
}
const gsl_odeiv_step_type *fgsl_aux_odeiv_step_alloc(int i) {
const gsl_odeiv_step_type *res;
switch(i) {
case 1:
res = gsl_odeiv_step_rk2;
break;
case 2:
res = gsl_odeiv_step_rk4;
break;
case 3:
res = gsl_odeiv_step_rkf45;
break;
case 4:
res = gsl_odeiv_step_rkck;
break;
case 5:
res = gsl_odeiv_step_rk8pd;
break;
case 6:
res = gsl_odeiv_step_rk2imp;
break;
case 7:
res = gsl_odeiv_step_rk2simp;
break;
case 8:
res = gsl_odeiv_step_rk4imp;
break;
case 9:
res = gsl_odeiv_step_bsimp;
break;
case 10:
res = gsl_odeiv_step_gear1;
break;
case 11:
res = gsl_odeiv_step_gear2;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_odeiv2_step_type *fgsl_aux_odeiv2_step_alloc(int i) {
const gsl_odeiv2_step_type *res;
switch(i) {
case 1:
res = gsl_odeiv2_step_rk2;
break;
case 2:
res = gsl_odeiv2_step_rk4;
break;
case 3:
res = gsl_odeiv2_step_rkf45;
break;
case 4:
res = gsl_odeiv2_step_rkck;
break;
case 5:
res = gsl_odeiv2_step_rk8pd;
break;
case 6:
res = gsl_odeiv2_step_rk1imp;
break;
case 7:
res = gsl_odeiv2_step_rk2imp;
break;
case 8:
res = gsl_odeiv2_step_rk4imp;
break;
case 9:
res = gsl_odeiv2_step_bsimp;
break;
case 10:
res = gsl_odeiv2_step_msadams;
break;
case 11:
res = gsl_odeiv2_step_msbdf;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_integration_fixed_workspace *gsl_aux_integration_fixed_alloc(int t, const size_t n, const double a, const double b, const double alpha, const double beta) {
const gsl_integration_fixed_type *T;
switch(t) {
case 1:
T = gsl_integration_fixed_legendre;
break;
case 2:
T = gsl_integration_fixed_chebyshev;
break;
case 3:
T = gsl_integration_fixed_gegenbauer;
break;
case 4:
T = gsl_integration_fixed_jacobi;
break;
case 5:
T = gsl_integration_fixed_laguerre;
break;
case 6:
T = gsl_integration_fixed_hermite;
break;
case 7:
T = gsl_integration_fixed_exponential;
break;
case 8:
T = gsl_integration_fixed_rational;
break;
case 9:
T = gsl_integration_fixed_chebyshev2;
break;
default :
T = NULL;
break;
}
return gsl_integration_fixed_alloc(T, n, a, b, alpha, beta);
}
const gsl_rng_type *fgsl_aux_rng_assign(int i) {
const gsl_rng_type *res;
switch(i) {
case -1:
res = gsl_rng_default;
break;
case 1:
res = gsl_rng_borosh13;
break;
case 2:
res = gsl_rng_coveyou;
break;
case 3:
res = gsl_rng_cmrg;
break;
case 4:
res = gsl_rng_fishman18;
break;
case 5:
res = gsl_rng_fishman20;
break;
case 6:
res = gsl_rng_fishman2x;
break;
case 7:
res = gsl_rng_gfsr4;
break;
case 8:
res = gsl_rng_knuthran;
break;
case 9:
res = gsl_rng_knuthran2;
break;
case 10:
res = gsl_rng_lecuyer21;
break;
case 11:
res = gsl_rng_minstd;
break;
case 12:
res = gsl_rng_mrg;
break;
case 13:
res = gsl_rng_mt19937;
break;
case 14:
res = gsl_rng_mt19937_1999;
break;
case 15:
res = gsl_rng_mt19937_1998;
break;
case 16:
res = gsl_rng_r250;
break;
case 17:
res = gsl_rng_ran0;
break;
case 18:
res = gsl_rng_ran1;
break;
case 19:
res = gsl_rng_ran2;
break;
case 20:
res = gsl_rng_ran3;
break;
case 21:
res = gsl_rng_rand;
break;
case 22:
res = gsl_rng_rand48;
break;
case 23:
res = gsl_rng_random128_bsd;
break;
case 24:
res = gsl_rng_random128_glibc2;
break;
case 25:
res = gsl_rng_random128_libc5;
break;
case 26:
res = gsl_rng_random256_bsd;
break;
case 27:
res = gsl_rng_random256_glibc2;
break;
case 28:
res = gsl_rng_random256_libc5;
break;
case 29:
res = gsl_rng_random32_bsd;
break;
case 30:
res = gsl_rng_random32_glibc2;
break;
case 31:
res = gsl_rng_random32_libc5;
break;
case 32:
res = gsl_rng_random64_bsd;
break;
case 33:
res = gsl_rng_random64_glibc2;
break;
case 34:
res = gsl_rng_random64_libc5;
break;
case 35:
res = gsl_rng_random8_bsd;
break;
case 36:
res = gsl_rng_random8_glibc2;
break;
case 37:
res = gsl_rng_random8_libc5;
break;
case 38:
res = gsl_rng_random_bsd;
break;
case 39:
res = gsl_rng_random_glibc2;
break;
case 40:
res = gsl_rng_random_libc5;
break;
case 41:
res = gsl_rng_randu;
break;
case 42:
res = gsl_rng_ranf;
break;
case 43:
res = gsl_rng_ranlux;
break;
case 44:
res = gsl_rng_ranlux389;
break;
case 45:
res = gsl_rng_ranlxd1;
break;
case 46:
res = gsl_rng_ranlxd2;
break;
case 47:
res = gsl_rng_ranlxs0;
break;
case 48:
res = gsl_rng_ranlxs1;
break;
case 49:
res = gsl_rng_ranlxs2;
break;
case 50:
res = gsl_rng_ranmar;
break;
case 51:
res = gsl_rng_slatec;
break;
case 52:
res = gsl_rng_taus;
break;
case 53:
res = gsl_rng_taus2;
break;
case 54:
res = gsl_rng_taus113;
break;
case 55:
res = gsl_rng_transputer;
break;
case 56:
res = gsl_rng_tt800;
break;
case 57:
res = gsl_rng_uni;
break;
case 58:
res = gsl_rng_uni32;
break;
case 59:
res = gsl_rng_vax;
break;
case 60:
res = gsl_rng_waterman14;
break;
case 61:
res = gsl_rng_zuf;
break;
case 62:
res = gsl_rng_knuthran2002;
break;
default :
res = NULL;
break;
}
return res;
}
const gsl_qrng_type *fgsl_aux_qrng_assign(int i) {
const gsl_qrng_type *res;
switch(i) {
case 1:
res = gsl_qrng_niederreiter_2;
break;
case 2:
res = gsl_qrng_sobol;
break;
case 3:
res = gsl_qrng_halton;
break;
case 4:
res = gsl_qrng_reversehalton;
break;
default :
res = NULL;
break;
}
return res;
}
const gsl_multifit_robust_type *fgsl_aux_multifit_robust_alloc(int i) {
const gsl_multifit_robust_type *res;
switch (i) {
case 1:
res = gsl_multifit_robust_default;
break;
case 2:
res = gsl_multifit_robust_bisquare;
break;
case 3:
res = gsl_multifit_robust_cauchy;
break;
case 4:
res = gsl_multifit_robust_fair;
break;
case 5:
res = gsl_multifit_robust_huber;
break;
case 6:
res = gsl_multifit_robust_ols;
break;
case 7:
res = gsl_multifit_robust_welsch;
break;
default :
res = NULL;
break;
}
return res;
}
const gsl_wavelet_type *fgsl_aux_wavelet_alloc(int i) {
const gsl_wavelet_type *res;
switch(i) {
case 1:
res = gsl_wavelet_daubechies;
break;
case 2:
res = gsl_wavelet_daubechies_centered;
break;
case 3:
res = gsl_wavelet_haar;
break;
case 4:
res = gsl_wavelet_haar_centered;
break;
case 5:
res = gsl_wavelet_bspline;
break;
case 6:
res = gsl_wavelet_bspline_centered;
break;
default:
res = NULL;
break;
}
return res;
}
gsl_monte_function *fgsl_monte_function_cinit(double (*func)(double *x, size_t dim, void *params), size_t dim, void *params) {
gsl_monte_function *result;
result = (gsl_monte_function *) malloc(sizeof(gsl_monte_function));
result->f = func;
result->dim = dim;
result->params = params;
return result;
}
void fgsl_monte_function_cfree(gsl_monte_function *fun) {
free(fun);
}
void fgsl_monte_miser_csetparams(gsl_monte_miser_state *s, double estimate_frac,
size_t min_calls, size_t min_calls_per_bisection,
double alpha, double dither) {
s->estimate_frac = estimate_frac;
s->min_calls = min_calls;
s->min_calls_per_bisection = min_calls_per_bisection;
s->alpha = alpha;
s->dither = dither;
}
void fgsl_monte_miser_cgetparams(gsl_monte_miser_state *s, double *estimate_frac,
size_t *min_calls, size_t *min_calls_per_bisection,
double *alpha, double *dither) {
*estimate_frac = s->estimate_frac;
*min_calls = s->min_calls;
*min_calls_per_bisection = s->min_calls_per_bisection;
*alpha = s->alpha;
*dither = s->dither;
}
void fgsl_monte_vegas_csetparams(gsl_monte_vegas_state *s, double result,
double sigma, double chisq, double alpha,
size_t iterations, int stage, int mode,
int verbose, FILE* ostream) {
s->result = result;
s->sigma = sigma;
s->chisq = chisq;
s->alpha = alpha;
s->iterations = iterations;
s->stage = stage;
s->mode = mode;
s->verbose = verbose;
s->ostream = ostream;
}
void fgsl_monte_vegas_cgetparams(gsl_monte_vegas_state *s, double *result,
double *sigma, double *chisq, double *alpha,
size_t *iterations, int *stage, int *mode,
int *verbose, FILE* ostream) {
*result = s->result;
*sigma = s->sigma;
*chisq = s->chisq;
*alpha = s->alpha;
*iterations = s->iterations;
*stage = s->stage;
*mode = s->mode;
*verbose = s->verbose;
ostream = s->ostream;
}
const gsl_root_fsolver_type *fgsl_aux_fsolver_alloc(int i) {
const gsl_root_fsolver_type *res;
switch(i) {
case 1:
res = gsl_root_fsolver_bisection;
break;
case 2:
res = gsl_root_fsolver_brent;
break;
case 3:
res = gsl_root_fsolver_falsepos;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_root_fdfsolver_type *fgsl_aux_fdfsolver_alloc(int i) {
const gsl_root_fdfsolver_type *res;
switch(i) {
case 1:
res = gsl_root_fdfsolver_newton;
break;
case 2:
res = gsl_root_fdfsolver_secant;
break;
case 3:
res = gsl_root_fdfsolver_steffenson;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_min_fminimizer_type *fgsl_aux_fminimizer_alloc(int i) {
const gsl_min_fminimizer_type *res;
switch(i) {
case 1:
res = gsl_min_fminimizer_goldensection;
break;
case 2:
res = gsl_min_fminimizer_brent;
break;
case 3:
res = gsl_min_fminimizer_quad_golden;
break;
default:
res = NULL;
break;
}
return res;
}
gsl_multiroot_function *fgsl_multiroot_function_cinit(int (*f)(const gsl_vector *x, void *params,
gsl_vector *f), size_t n, void *params) {
gsl_multiroot_function *result;
result = (gsl_multiroot_function *) malloc(sizeof(gsl_multiroot_function));
result->f = f;
result->n = n;
result->params = params;
return result;
}
gsl_multiroot_function_fdf *fgsl_multiroot_function_fdf_cinit(
int (*f)(const gsl_vector *x, void *params, gsl_vector *f),
int (*df)(const gsl_vector *x, void *params, gsl_matrix *df),
int (*fdf)(const gsl_vector *x, void *params, gsl_vector *f, gsl_matrix *df),
size_t n, void *params) {
gsl_multiroot_function_fdf *result;
result = (gsl_multiroot_function_fdf *) malloc(sizeof(gsl_multiroot_function_fdf));
result->f = f;
result->df = df;
result->fdf = fdf;
result->n = n;
result->params = params;
return result;
}
void fgsl_multiroot_function_cfree(gsl_multiroot_function *fun) {
free(fun);
}
void fgsl_multiroot_function_fdf_cfree(gsl_multiroot_function_fdf *fun) {
free(fun);
}
gsl_multifit_nlinear_fdf *fgsl_multifit_nlinear_fdf_cinit(
size_t ndim, size_t p, void *params,
int (*f)(const gsl_vector *x, void *params, gsl_vector *f),
int (*df)(const gsl_vector *x, void *params, gsl_matrix *df),
int (*fvv)(const gsl_vector *x, const gsl_vector *v, void *params, gsl_vector *vv)
) {
gsl_multifit_nlinear_fdf *result;
result = (gsl_multifit_nlinear_fdf *) malloc(sizeof(gsl_multifit_nlinear_fdf));
result->f = f;
result->df = df;
result->fvv = fvv;
result->n = ndim;
result->p = p;
result->params = params;
return result;
}
void fgsl_multifit_nlinear_fdf_cfree(gsl_multifit_nlinear_fdf *fun) {
free(fun);
}
const gsl_multifit_nlinear_trs *gsl_multifit_nlinear_get_trs(int i) {
const gsl_multifit_nlinear_trs *res;
switch(i) {
case 1:
res = gsl_multifit_nlinear_trs_lm;
break;
case 2:
res = gsl_multifit_nlinear_trs_lmaccel;
break;
case 3:
res = gsl_multifit_nlinear_trs_dogleg;
break;
case 4:
res = gsl_multifit_nlinear_trs_ddogleg;
break;
case 5:
res = gsl_multifit_nlinear_trs_subspace2D;
break;
default:
res = NULL;
break;
}
return res;
}
const gsl_multifit_nlinear_scale *gsl_multifit_nlinear_get_scale(int i) {
const gsl_multifit_nlinear_scale *res;
switch(i) {
case 1: