gsl 1.12.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +29 -0
- data/Rakefile +54 -0
- data/VERSION +2 -0
- data/ext/MANIFEST +119 -0
- data/ext/alf.c +206 -0
- data/ext/array.c +666 -0
- data/ext/array_complex.c +247 -0
- data/ext/blas.c +29 -0
- data/ext/blas1.c +731 -0
- data/ext/blas2.c +1093 -0
- data/ext/blas3.c +881 -0
- data/ext/block.c +44 -0
- data/ext/block_source.c +886 -0
- data/ext/bspline.c +130 -0
- data/ext/bundle.c +3 -0
- data/ext/cdf.c +754 -0
- data/ext/cheb.c +542 -0
- data/ext/combination.c +283 -0
- data/ext/common.c +325 -0
- data/ext/complex.c +1004 -0
- data/ext/const.c +673 -0
- data/ext/const_additional.c +120 -0
- data/ext/cqp.c +283 -0
- data/ext/deriv.c +195 -0
- data/ext/dht.c +361 -0
- data/ext/diff.c +166 -0
- data/ext/dirac.c +395 -0
- data/ext/eigen.c +2373 -0
- data/ext/error.c +194 -0
- data/ext/extconf.rb +281 -0
- data/ext/fcmp.c +66 -0
- data/ext/fft.c +1092 -0
- data/ext/fit.c +205 -0
- data/ext/fresnel.c +312 -0
- data/ext/function.c +524 -0
- data/ext/geometry.c +139 -0
- data/ext/graph.c +1638 -0
- data/ext/gsl.c +271 -0
- data/ext/gsl_narray.c +653 -0
- data/ext/histogram.c +1995 -0
- data/ext/histogram2d.c +1068 -0
- data/ext/histogram3d.c +884 -0
- data/ext/histogram3d_source.c +750 -0
- data/ext/histogram_find.c +101 -0
- data/ext/histogram_oper.c +159 -0
- data/ext/ieee.c +98 -0
- data/ext/integration.c +1138 -0
- data/ext/interp.c +512 -0
- data/ext/jacobi.c +739 -0
- data/ext/linalg.c +4047 -0
- data/ext/linalg_complex.c +741 -0
- data/ext/math.c +725 -0
- data/ext/matrix.c +39 -0
- data/ext/matrix_complex.c +1732 -0
- data/ext/matrix_double.c +560 -0
- data/ext/matrix_int.c +256 -0
- data/ext/matrix_source.c +2733 -0
- data/ext/min.c +250 -0
- data/ext/monte.c +992 -0
- data/ext/multifit.c +1879 -0
- data/ext/multimin.c +808 -0
- data/ext/multimin_fsdf.c +156 -0
- data/ext/multiroots.c +955 -0
- data/ext/ndlinear.c +321 -0
- data/ext/nmf.c +167 -0
- data/ext/nmf_wrap.c +72 -0
- data/ext/ntuple.c +469 -0
- data/ext/odeiv.c +959 -0
- data/ext/ool.c +879 -0
- data/ext/oper_complex_source.c +253 -0
- data/ext/permutation.c +596 -0
- data/ext/poly.c +42 -0
- data/ext/poly2.c +265 -0
- data/ext/poly_source.c +1885 -0
- data/ext/qrng.c +171 -0
- data/ext/randist.c +1873 -0
- data/ext/rational.c +480 -0
- data/ext/rng.c +612 -0
- data/ext/root.c +408 -0
- data/ext/sf.c +1494 -0
- data/ext/sf_airy.c +200 -0
- data/ext/sf_bessel.c +867 -0
- data/ext/sf_clausen.c +28 -0
- data/ext/sf_coulomb.c +206 -0
- data/ext/sf_coupling.c +118 -0
- data/ext/sf_dawson.c +29 -0
- data/ext/sf_debye.c +157 -0
- data/ext/sf_dilog.c +42 -0
- data/ext/sf_elementary.c +44 -0
- data/ext/sf_ellint.c +206 -0
- data/ext/sf_elljac.c +29 -0
- data/ext/sf_erfc.c +93 -0
- data/ext/sf_exp.c +164 -0
- data/ext/sf_expint.c +211 -0
- data/ext/sf_fermi_dirac.c +148 -0
- data/ext/sf_gamma.c +344 -0
- data/ext/sf_gegenbauer.c +96 -0
- data/ext/sf_hyperg.c +197 -0
- data/ext/sf_laguerre.c +112 -0
- data/ext/sf_lambert.c +47 -0
- data/ext/sf_legendre.c +367 -0
- data/ext/sf_log.c +104 -0
- data/ext/sf_mathieu.c +238 -0
- data/ext/sf_power.c +46 -0
- data/ext/sf_psi.c +98 -0
- data/ext/sf_synchrotron.c +48 -0
- data/ext/sf_transport.c +76 -0
- data/ext/sf_trigonometric.c +207 -0
- data/ext/sf_zeta.c +119 -0
- data/ext/signal.c +310 -0
- data/ext/siman.c +718 -0
- data/ext/sort.c +208 -0
- data/ext/spline.c +395 -0
- data/ext/stats.c +799 -0
- data/ext/sum.c +168 -0
- data/ext/tamu_anova.c +56 -0
- data/ext/tensor.c +38 -0
- data/ext/tensor_source.c +1123 -0
- data/ext/vector.c +38 -0
- data/ext/vector_complex.c +2236 -0
- data/ext/vector_double.c +1433 -0
- data/ext/vector_int.c +204 -0
- data/ext/vector_source.c +3329 -0
- data/ext/wavelet.c +937 -0
- data/include/rb_gsl.h +151 -0
- data/include/rb_gsl_array.h +238 -0
- data/include/rb_gsl_cheb.h +21 -0
- data/include/rb_gsl_common.h +343 -0
- data/include/rb_gsl_complex.h +25 -0
- data/include/rb_gsl_const.h +29 -0
- data/include/rb_gsl_dirac.h +13 -0
- data/include/rb_gsl_eigen.h +17 -0
- data/include/rb_gsl_fft.h +62 -0
- data/include/rb_gsl_fit.h +25 -0
- data/include/rb_gsl_function.h +27 -0
- data/include/rb_gsl_graph.h +70 -0
- data/include/rb_gsl_histogram.h +63 -0
- data/include/rb_gsl_histogram3d.h +97 -0
- data/include/rb_gsl_integration.h +17 -0
- data/include/rb_gsl_interp.h +46 -0
- data/include/rb_gsl_linalg.h +25 -0
- data/include/rb_gsl_math.h +26 -0
- data/include/rb_gsl_odeiv.h +21 -0
- data/include/rb_gsl_poly.h +71 -0
- data/include/rb_gsl_rational.h +37 -0
- data/include/rb_gsl_rng.h +21 -0
- data/include/rb_gsl_root.h +22 -0
- data/include/rb_gsl_sf.h +119 -0
- data/include/rb_gsl_statistics.h +17 -0
- data/include/rb_gsl_tensor.h +45 -0
- data/include/rb_gsl_with_narray.h +22 -0
- data/include/templates_off.h +87 -0
- data/include/templates_on.h +241 -0
- data/lib/gsl/gnuplot.rb +41 -0
- data/lib/gsl/oper.rb +68 -0
- data/lib/ool.rb +22 -0
- data/lib/ool/conmin.rb +30 -0
- metadata +224 -0
data/ext/error.c
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
error.c
|
|
3
|
+
Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
|
|
4
|
+
(C) Copyright 2001-2006 by Yoshiki Tsunesada
|
|
5
|
+
|
|
6
|
+
Ruby/GSL is free software: you can redistribute it and/or modify it
|
|
7
|
+
under the terms of the GNU General Public License.
|
|
8
|
+
This library is distributed in the hope that it will be useful, but
|
|
9
|
+
WITHOUT ANY WARRANTY.
|
|
10
|
+
*/
|
|
11
|
+
#include "rb_gsl.h"
|
|
12
|
+
#include <gsl/gsl_errno.h>
|
|
13
|
+
#include "rb_gsl_array.h"
|
|
14
|
+
#include "rb_gsl_common.h"
|
|
15
|
+
#include "rb_gsl_function.h"
|
|
16
|
+
|
|
17
|
+
static VALUE eHandler;
|
|
18
|
+
static VALUE cgsl_error[35];
|
|
19
|
+
static VALUE *pgsl_error;
|
|
20
|
+
|
|
21
|
+
static void Init_rb_gsl_define_GSL_CONST(VALUE module);
|
|
22
|
+
void rb_gsl_error_handler(const char *reason, const char *file,
|
|
23
|
+
int line, int gsl_errno);
|
|
24
|
+
static void rb_gsl_my_error_handler(const char *reason, const char *file,
|
|
25
|
+
int line, int gsl_errno);
|
|
26
|
+
|
|
27
|
+
void rb_gsl_error_handler(const char *reason, const char *file,
|
|
28
|
+
int line, int gsl_errno)
|
|
29
|
+
{
|
|
30
|
+
const char *emessage = gsl_strerror(gsl_errno);
|
|
31
|
+
rb_raise(pgsl_error[gsl_errno],
|
|
32
|
+
"Ruby/GSL error code %d, %s (file %s, line %d), %s",
|
|
33
|
+
gsl_errno, reason, file, line, emessage);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static void rb_gsl_my_error_handler(const char *reason, const char *file,
|
|
37
|
+
int line, int gsl_errno)
|
|
38
|
+
{
|
|
39
|
+
VALUE vreason, vfile;
|
|
40
|
+
VALUE vline, verrno;
|
|
41
|
+
VALUE result;
|
|
42
|
+
vreason = rb_str_new2(reason);
|
|
43
|
+
vfile = rb_str_new2(file);
|
|
44
|
+
vline = INT2FIX(line);
|
|
45
|
+
verrno = INT2FIX(gsl_errno);
|
|
46
|
+
result = rb_funcall(eHandler, RBGSL_ID_call, 4, vreason, vfile, vline, verrno);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static VALUE rb_gsl_set_error_handler(int argc, VALUE *argv, VALUE module)
|
|
50
|
+
{
|
|
51
|
+
if (rb_block_given_p()) {
|
|
52
|
+
eHandler = RB_GSL_MAKE_PROC;
|
|
53
|
+
gsl_set_error_handler(&rb_gsl_my_error_handler);
|
|
54
|
+
return Qtrue;
|
|
55
|
+
}
|
|
56
|
+
switch (argc) {
|
|
57
|
+
case 0:
|
|
58
|
+
gsl_set_error_handler(&rb_gsl_error_handler);
|
|
59
|
+
return Qtrue;
|
|
60
|
+
break;
|
|
61
|
+
case 1:
|
|
62
|
+
CHECK_PROC(argv[0]);
|
|
63
|
+
eHandler = argv[0];
|
|
64
|
+
gsl_set_error_handler(&rb_gsl_my_error_handler);
|
|
65
|
+
return Qtrue;
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
rb_raise(rb_eArgError, "too many arguments (%d for 0 or 1 Proc)", argc);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static VALUE rb_gsl_set_default_error_handler(VALUE module)
|
|
74
|
+
{
|
|
75
|
+
gsl_set_error_handler(&rb_gsl_error_handler);
|
|
76
|
+
return Qtrue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
static void rb_gsl_define_exceptions(VALUE module)
|
|
80
|
+
{
|
|
81
|
+
VALUE mgsl_error;
|
|
82
|
+
mgsl_error = rb_define_module_under(module, "ERROR");
|
|
83
|
+
pgsl_error = &cgsl_error[2];
|
|
84
|
+
pgsl_error[-2] = rb_define_class_under(mgsl_error, "CONTINUE", rb_cFixnum);
|
|
85
|
+
pgsl_error[-1] = rb_define_class_under(mgsl_error, "FAILURE", rb_eRuntimeError);
|
|
86
|
+
pgsl_error[0] = rb_define_class_under(mgsl_error, "SUCCESS", rb_cFixnum);
|
|
87
|
+
pgsl_error[1] = rb_define_class_under(mgsl_error, "EDOM", rb_eRangeError);
|
|
88
|
+
pgsl_error[2] = rb_define_class_under(mgsl_error, "ERANGE", rb_eRangeError);
|
|
89
|
+
pgsl_error[3] = rb_define_class_under(mgsl_error, "EFAULT", rb_eRuntimeError);
|
|
90
|
+
pgsl_error[4] = rb_define_class_under(mgsl_error, "EINVAL", rb_eIndexError);
|
|
91
|
+
pgsl_error[5] = rb_define_class_under(mgsl_error, "EFAILED", rb_eRuntimeError);
|
|
92
|
+
pgsl_error[6] = rb_define_class_under(mgsl_error, "EFACTOR", rb_eRuntimeError);
|
|
93
|
+
pgsl_error[7] = rb_define_class_under(mgsl_error, "ESANITY", rb_eRuntimeError);
|
|
94
|
+
pgsl_error[8] = rb_define_class_under(mgsl_error, "ENOMEM", rb_eNoMemError);
|
|
95
|
+
pgsl_error[9] = rb_define_class_under(mgsl_error, "EBADFUNC", rb_eRuntimeError);
|
|
96
|
+
pgsl_error[10] = rb_define_class_under(mgsl_error, "ERUNAWAY", rb_eRuntimeError);
|
|
97
|
+
pgsl_error[11] = rb_define_class_under(mgsl_error, "EMAXITER", rb_eRuntimeError);
|
|
98
|
+
pgsl_error[12] = rb_define_class_under(mgsl_error, "EZERODIV", rb_eZeroDivError);
|
|
99
|
+
pgsl_error[13] = rb_define_class_under(mgsl_error, "EBADTOL", rb_eRuntimeError);
|
|
100
|
+
pgsl_error[14] = rb_define_class_under(mgsl_error, "ETOL", rb_eRuntimeError);
|
|
101
|
+
pgsl_error[15] = rb_define_class_under(mgsl_error, "EUNDRFLW", rb_eRangeError);
|
|
102
|
+
pgsl_error[16] = rb_define_class_under(mgsl_error, "EOVRFLW", rb_eRangeError);
|
|
103
|
+
pgsl_error[17] = rb_define_class_under(mgsl_error, "ELOSS", rb_eRuntimeError);
|
|
104
|
+
pgsl_error[18] = rb_define_class_under(mgsl_error, "EROUND", rb_eRuntimeError);
|
|
105
|
+
pgsl_error[19] = rb_define_class_under(mgsl_error, "EBADLEN", rb_eIndexError);
|
|
106
|
+
pgsl_error[20] = rb_define_class_under(mgsl_error, "ENOTSQR", rb_eRuntimeError);
|
|
107
|
+
pgsl_error[21] = rb_define_class_under(mgsl_error, "ESING", rb_eRuntimeError);
|
|
108
|
+
pgsl_error[22] = rb_define_class_under(mgsl_error, "EDIVERGE", rb_eRuntimeError);
|
|
109
|
+
pgsl_error[23] = rb_define_class_under(mgsl_error, "EUNSUP", rb_eRuntimeError);
|
|
110
|
+
pgsl_error[24] = rb_define_class_under(mgsl_error, "EUNIMPL", rb_eNotImpError);
|
|
111
|
+
pgsl_error[25] = rb_define_class_under(mgsl_error, "ECACHE", rb_eRuntimeError);
|
|
112
|
+
pgsl_error[26] = rb_define_class_under(mgsl_error, "ETABLE", rb_eRuntimeError);
|
|
113
|
+
pgsl_error[27] = rb_define_class_under(mgsl_error, "ENOPROG", rb_eRuntimeError);
|
|
114
|
+
pgsl_error[28] = rb_define_class_under(mgsl_error, "ENOPROGJ", rb_eRuntimeError);
|
|
115
|
+
pgsl_error[29] = rb_define_class_under(mgsl_error, "ETOLF", rb_eRuntimeError);
|
|
116
|
+
pgsl_error[30] = rb_define_class_under(mgsl_error, "ETOLX", rb_eRuntimeError);
|
|
117
|
+
pgsl_error[31] = rb_define_class_under(mgsl_error, "ETOLG", rb_eRuntimeError);
|
|
118
|
+
pgsl_error[32] = rb_define_class_under(mgsl_error, "EOF", rb_eEOFError);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static void Init_rb_gsl_define_GSL_CONST(VALUE module)
|
|
122
|
+
{
|
|
123
|
+
rb_define_const(module, "SUCCESS", INT2FIX(GSL_SUCCESS));
|
|
124
|
+
rb_define_const(module, "FAILURE", INT2FIX(GSL_FAILURE));
|
|
125
|
+
rb_define_const(module, "CONTINUE", INT2FIX(GSL_CONTINUE));
|
|
126
|
+
rb_define_const(module, "EDOM", INT2FIX(GSL_EDOM));
|
|
127
|
+
rb_define_const(module, "ERANGE", INT2FIX(GSL_ERANGE));
|
|
128
|
+
rb_define_const(module, "EFAULT", INT2FIX(GSL_EFAULT));
|
|
129
|
+
rb_define_const(module, "EINVAL", INT2FIX(GSL_EINVAL));
|
|
130
|
+
rb_define_const(module, "EFAILED", INT2FIX(GSL_EFAILED));
|
|
131
|
+
rb_define_const(module, "EFACTOR", INT2FIX(GSL_EFACTOR));
|
|
132
|
+
rb_define_const(module, "ESANITY", INT2FIX(GSL_ESANITY));
|
|
133
|
+
rb_define_const(module, "ENOMEM", INT2FIX(GSL_ENOMEM));
|
|
134
|
+
rb_define_const(module, "EBADFUNC", INT2FIX(GSL_EBADFUNC));
|
|
135
|
+
rb_define_const(module, "ERUNAWAY", INT2FIX(GSL_ERUNAWAY));
|
|
136
|
+
rb_define_const(module, "EMAXITER", INT2FIX(GSL_EMAXITER));
|
|
137
|
+
rb_define_const(module, "EZERODIV", INT2FIX(GSL_EZERODIV));
|
|
138
|
+
rb_define_const(module, "EBADTOL", INT2FIX(GSL_EBADTOL));
|
|
139
|
+
rb_define_const(module, "ETOL", INT2FIX(GSL_ETOL));
|
|
140
|
+
rb_define_const(module, "EUNDRFLW", INT2FIX(GSL_EUNDRFLW));
|
|
141
|
+
rb_define_const(module, "EOVRFLW", INT2FIX(GSL_EOVRFLW));
|
|
142
|
+
rb_define_const(module, "ELOSS", INT2FIX(GSL_ELOSS));
|
|
143
|
+
rb_define_const(module, "EROUND", INT2FIX(GSL_EROUND));
|
|
144
|
+
rb_define_const(module, "EBADLEN", INT2FIX(GSL_EBADLEN));
|
|
145
|
+
rb_define_const(module, "ENOTSQR", INT2FIX(GSL_ENOTSQR));
|
|
146
|
+
rb_define_const(module, "ESING", INT2FIX(GSL_ESING));
|
|
147
|
+
rb_define_const(module, "EDIVERGE", INT2FIX(GSL_EDIVERGE));
|
|
148
|
+
rb_define_const(module, "EUNSUP", INT2FIX(GSL_EUNSUP));
|
|
149
|
+
rb_define_const(module, "EUNIMPL", INT2FIX(GSL_EUNIMPL));
|
|
150
|
+
rb_define_const(module, "ECACHE", INT2FIX(GSL_ECACHE));
|
|
151
|
+
rb_define_const(module, "ETABLE", INT2FIX(GSL_ETABLE));
|
|
152
|
+
rb_define_const(module, "ENOPROG", INT2FIX(GSL_ENOPROG));
|
|
153
|
+
rb_define_const(module, "ENOPROGJ", INT2FIX(GSL_ENOPROGJ));
|
|
154
|
+
rb_define_const(module, "ETOLF", INT2FIX(GSL_ETOLF));
|
|
155
|
+
rb_define_const(module, "ETOLX", INT2FIX(GSL_ETOLX));
|
|
156
|
+
rb_define_const(module, "ETOLG", INT2FIX(GSL_ETOLG));
|
|
157
|
+
rb_define_const(module, "EOF", INT2FIX(GSL_EOF));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
static VALUE rb_gsl_set_error_handler_off(VALUE module)
|
|
161
|
+
{
|
|
162
|
+
gsl_set_error_handler_off();
|
|
163
|
+
return Qtrue;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
static void define_module_functions(VALUE module);
|
|
167
|
+
static VALUE rb_gsl_strerror(VALUE obj, VALUE errn);
|
|
168
|
+
static void define_module_functions(VALUE module)
|
|
169
|
+
{
|
|
170
|
+
rb_define_module_function(module, "set_error_handler_off",
|
|
171
|
+
rb_gsl_set_error_handler_off, 0);
|
|
172
|
+
rb_define_module_function(module, "strerror",
|
|
173
|
+
rb_gsl_strerror, 1);
|
|
174
|
+
rb_define_module_function(module, "set_error_handler",
|
|
175
|
+
rb_gsl_set_error_handler, -1);
|
|
176
|
+
rb_define_module_function(module, "set_default_error_handler",
|
|
177
|
+
rb_gsl_set_default_error_handler, 0);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
static VALUE rb_gsl_strerror(VALUE obj, VALUE errn)
|
|
181
|
+
{
|
|
182
|
+
int gsl_errno = FIX2INT(errn);
|
|
183
|
+
return rb_str_new2(gsl_strerror(gsl_errno));
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void Init_gsl_error(VALUE module)
|
|
187
|
+
{
|
|
188
|
+
Init_rb_gsl_define_GSL_CONST(module);
|
|
189
|
+
|
|
190
|
+
gsl_set_error_handler(&rb_gsl_error_handler);
|
|
191
|
+
|
|
192
|
+
define_module_functions(module);
|
|
193
|
+
rb_gsl_define_exceptions(module);
|
|
194
|
+
}
|
data/ext/extconf.rb
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
require 'mkmf'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module GSL
|
|
5
|
+
class Version
|
|
6
|
+
def initialize(str)
|
|
7
|
+
@str = str
|
|
8
|
+
@ary = str.split(".").collect { |elm| elm.to_i }
|
|
9
|
+
end
|
|
10
|
+
def to_s; @str; end
|
|
11
|
+
def inspect; @str; end
|
|
12
|
+
def >=(ver)
|
|
13
|
+
ary2 = ver.split(".").collect { |elm| elm.to_i }
|
|
14
|
+
if @ary[0] > ary2[0]; return true; end
|
|
15
|
+
if @ary[0] < ary2[0]; return false; end
|
|
16
|
+
if @ary[1] > ary2[1]; return true; end
|
|
17
|
+
if @ary[1] < ary2[1]; return false; end
|
|
18
|
+
if @ary.size < ary2.size; return false; end
|
|
19
|
+
if @ary.size == 3 and ary2.size == 3
|
|
20
|
+
if @ary[2] < ary2[2]; return false; end
|
|
21
|
+
end
|
|
22
|
+
return true
|
|
23
|
+
end
|
|
24
|
+
def <(ver)
|
|
25
|
+
ary2 = ver.split(".").collect { |elm| elm.to_i }
|
|
26
|
+
if @ary[0] >= ary2[0]; return false; end
|
|
27
|
+
if @ary[0] >= ary2[0]; return false; end
|
|
28
|
+
return true
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
if /mingw/ =~ RUBY_PLATFORM
|
|
34
|
+
GSL_CONFIG = "sh gsl-config"
|
|
35
|
+
else
|
|
36
|
+
GSL_CONFIG = "gsl-config"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def gsl_config()
|
|
40
|
+
print("checking gsl cflags... ")
|
|
41
|
+
IO.popen("#{GSL_CONFIG} --cflags") do |f|
|
|
42
|
+
cflags = f.gets.chomp
|
|
43
|
+
puts(cflags)
|
|
44
|
+
$CFLAGS += " " + cflags
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
IO.popen("#{GSL_CONFIG} --libs") do |f|
|
|
48
|
+
libs = f.gets.chomp
|
|
49
|
+
dir_config("cblas")
|
|
50
|
+
dir_config("atlas")
|
|
51
|
+
if have_library("cblas") and have_library("atlas")
|
|
52
|
+
libs.gsub!("-lgslcblas", "-lcblas -latlas")
|
|
53
|
+
$LOCAL_LIBS += " " + libs.gsub(" -lgslcblas", "")
|
|
54
|
+
print("checking gsl libs... ")
|
|
55
|
+
puts(libs)
|
|
56
|
+
else
|
|
57
|
+
print("checking gsl libs... ")
|
|
58
|
+
puts(libs)
|
|
59
|
+
$LOCAL_LIBS += " " + libs
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def check_version(configfile)
|
|
66
|
+
|
|
67
|
+
print("checking gsl version... ")
|
|
68
|
+
IO.popen("#{GSL_CONFIG} --version") do |f|
|
|
69
|
+
ver = GSL::Version.new(f.gets.chomp)
|
|
70
|
+
puts(ver)
|
|
71
|
+
configfile.printf("#ifndef GSL_VERSION\n#define GSL_VERSION \"#{ver}\"\n#endif\n")
|
|
72
|
+
|
|
73
|
+
if ver >= "0.9.4"
|
|
74
|
+
configfile.printf("#ifndef GSL_0_9_4_LATER\n#define GSL_0_9_4_LATER\n#endif\n")
|
|
75
|
+
else
|
|
76
|
+
configfile.close
|
|
77
|
+
raise("Ruby/GSL requires gsl-0.9.4 or later.")
|
|
78
|
+
end
|
|
79
|
+
if ver >= "1.0"
|
|
80
|
+
configfile.printf("#ifndef GSL_1_0_LATER\n#define GSL_1_0_LATER\n#endif\n")
|
|
81
|
+
end
|
|
82
|
+
if ver >= "1.1"
|
|
83
|
+
configfile.printf("#ifndef GSL_1_1_LATER\n#define GSL_1_1_LATER\n#endif\n")
|
|
84
|
+
end
|
|
85
|
+
if ver >= "1.1.1"
|
|
86
|
+
configfile.printf("#ifndef GSL_1_1_1_LATER\n#define GSL_1_1_1_LATER\n#endif\n")
|
|
87
|
+
end
|
|
88
|
+
if ver >= "1.2"
|
|
89
|
+
configfile.printf("#ifndef GSL_1_2_LATER\n#define GSL_1_2_LATER\n#endif\n")
|
|
90
|
+
end
|
|
91
|
+
if ver >= "1.3"
|
|
92
|
+
configfile.printf("#ifndef GSL_1_3_LATER\n#define GSL_1_3_LATER\n#endif\n")
|
|
93
|
+
end
|
|
94
|
+
if ver >= "1.4"
|
|
95
|
+
configfile.printf("#ifndef GSL_1_4_LATER\n#define GSL_1_4_LATER\n#endif\n")
|
|
96
|
+
end
|
|
97
|
+
if ver >= "1.4.90"
|
|
98
|
+
configfile.printf("#ifndef GSL_1_4_9_LATER\n#define GSL_1_4_9_LATER\n#endif\n")
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if ver >= "1.5.90"
|
|
102
|
+
configfile.printf("#ifndef GSL_1_6_LATER\n#define GSL_1_6_LATER\n#endif\n")
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
if ver >= "1.7.90"
|
|
106
|
+
configfile.printf("#ifndef GSL_1_8_LATER\n#define GSL_1_8_LATER\n#endif\n")
|
|
107
|
+
end
|
|
108
|
+
if ver >= "1.8.90"
|
|
109
|
+
configfile.printf("#ifndef GSL_1_9_LATER\n#define GSL_1_9_LATER\n#endif\n")
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
if ver >= "1.9.90"
|
|
113
|
+
configfile.printf("#ifndef GSL_1_10_LATER\n#define GSL_1_10_LATER\n#endif\n")
|
|
114
|
+
end
|
|
115
|
+
if ver < "1.4"
|
|
116
|
+
configfile.printf("#ifndef GSL_CONST_OLD\n#define GSL_CONST_OLD\n#endif\n")
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
if ver >= "1.11"
|
|
120
|
+
configfile.printf("#ifndef GSL_1_11_LATER\n#define GSL_1_11_LATER\n#endif\n")
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
if ver >= "1.12.90"
|
|
124
|
+
configfile.printf("#ifndef GSL_1_13_LATER\n#define GSL_1_13_LATER\n#endif\n")
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
#####
|
|
130
|
+
|
|
131
|
+
$CFLAGS = " -Wall -I../include "
|
|
132
|
+
|
|
133
|
+
begin
|
|
134
|
+
RB_GSL_CONFIG = File.open("../include/rb_gsl_config.h", "w")
|
|
135
|
+
RB_GSL_CONFIG.printf("#ifndef ___RB_GSL_CONFIG_H___\n")
|
|
136
|
+
RB_GSL_CONFIG.printf("#define ___RB_GSL_CONFIG_H___\n\n")
|
|
137
|
+
|
|
138
|
+
check_version(RB_GSL_CONFIG)
|
|
139
|
+
|
|
140
|
+
gsl_config()
|
|
141
|
+
|
|
142
|
+
have_func("round")
|
|
143
|
+
|
|
144
|
+
# Check GSL extensions
|
|
145
|
+
|
|
146
|
+
if have_header("rngextra/rngextra.h")
|
|
147
|
+
have_library("rngextra")
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
if have_header("qrngextra/qrngextra.h")
|
|
151
|
+
have_library("qrngextra")
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
if have_header("ool/ool_version.h")
|
|
155
|
+
have_library("ool")
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
if have_header("tensor/tensor.h")
|
|
159
|
+
have_library("tensor")
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
if have_header("jacobi.h")
|
|
163
|
+
have_library("jacobi")
|
|
164
|
+
end
|
|
165
|
+
if have_header("gsl/gsl_cqp.h")
|
|
166
|
+
have_library("cqp")
|
|
167
|
+
end
|
|
168
|
+
if have_header("gsl/gsl_multimin_fsdf.h")
|
|
169
|
+
have_library("bundle_method")
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
if have_library("gsl", "gsl_poly_solve_quartic")
|
|
173
|
+
RB_GSL_CONFIG.printf("#ifndef HAVE_POLY_SOLVE_QUARTIC\n#define HAVE_POLY_SOLVE_QUARTIC\n#endif\n")
|
|
174
|
+
end
|
|
175
|
+
if have_library("gsl", "gsl_eigen_francis")
|
|
176
|
+
RB_GSL_CONFIG.printf("#ifndef HAVE_EIGEN_FRANCIS\n#define HAVE_EIGEN_FRANCIS\n#endif\n")
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
if have_header("ndlinear/gsl_multifit_ndlinear.h")
|
|
180
|
+
have_library("ndlinear")
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
# Added 2009/Apr/20
|
|
184
|
+
if have_header("alf/alf.h")
|
|
185
|
+
have_library("alf")
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
begin
|
|
189
|
+
print("checking rb-gsl version...")
|
|
190
|
+
IO.popen("cat ../VERSION") do |f|
|
|
191
|
+
ver = GSL::Version.new(f.gets.chomp)
|
|
192
|
+
puts(ver)
|
|
193
|
+
RB_GSL_CONFIG.printf("#ifndef RUBY_GSL_VERSION\n#define RUBY_GSL_VERSION \"#{ver}\"\n#endif\n")
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
RUBY_VERSION2 = GSL::Version.new(RUBY_VERSION)
|
|
198
|
+
|
|
199
|
+
puts("checking ruby version... #{RUBY_VERSION2}")
|
|
200
|
+
if RUBY_VERSION2 >= "1.8"
|
|
201
|
+
RB_GSL_CONFIG.printf("#ifndef RUBY_1_8_LATER\n#define RUBY_1_8_LATER\n#endif\n")
|
|
202
|
+
|
|
203
|
+
if find_executable("graph")
|
|
204
|
+
RB_GSL_CONFIG.printf("#ifndef HAVE_GNU_GRAPH\n#define HAVE_GNU_GRAPH\n#endif\n")
|
|
205
|
+
end
|
|
206
|
+
else
|
|
207
|
+
path = (path || ENV['PATH']).split(File::PATH_SEPARATOR)
|
|
208
|
+
flag = 0
|
|
209
|
+
print("checking for GNU graph... ")
|
|
210
|
+
path.each do |dir|
|
|
211
|
+
if File.executable?(file = File.join(dir, "graph"))
|
|
212
|
+
puts("yes")
|
|
213
|
+
RB_GSL_CONFIG.printf("#ifndef HAVE_GNU_GRAPH\n#define HAVE_GNU_GRAPH\n#endif\n")
|
|
214
|
+
flag = 1
|
|
215
|
+
break
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
puts("no") if flag == 0
|
|
219
|
+
end
|
|
220
|
+
if RUBY_VERSION2 >= "1.9"
|
|
221
|
+
RB_GSL_CONFIG.printf("#ifndef RUBY_1_9_LATER\n#define RUBY_1_9_LATER\n#endif\n")
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
RB_GSL_CONFIG.printf("\n#endif\n")
|
|
225
|
+
RB_GSL_CONFIG.close
|
|
226
|
+
|
|
227
|
+
rescue
|
|
228
|
+
raise("Check GSL>=0.9.4 is installed, and the command \"gsl-config\" is in search path.")
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
#narray_config = dir_config("narray")
|
|
232
|
+
narray_config = dir_config('narray',$sitearchdir,$sitearchdir)
|
|
233
|
+
# Try to find narray with RubyGems
|
|
234
|
+
begin
|
|
235
|
+
require 'rubygems'
|
|
236
|
+
na_gemspec=Gem.searcher.find('narray.h')
|
|
237
|
+
if na_gemspec
|
|
238
|
+
narray_config = File.join(na_gemspec.full_gem_path, na_gemspec.require_path)
|
|
239
|
+
$CPPFLAGS = " -I#{narray_config} "+$CPPFLAGS
|
|
240
|
+
end
|
|
241
|
+
rescue LoadError
|
|
242
|
+
end
|
|
243
|
+
have_narray_h = have_header("narray.h")
|
|
244
|
+
if narray_config
|
|
245
|
+
if RUBY_PLATFORM =~ /cygwin|mingw/
|
|
246
|
+
# have_library("narray") || raise("ERROR: narray import library is not found")
|
|
247
|
+
have_library("narray")
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
tamu_anova_config = dir_config('tamu_anova',$sitearchdir,$sitearchdir)
|
|
252
|
+
have_tamu_anova_h = have_header("tamu_anova/tamu_anova.h")
|
|
253
|
+
if tamu_anova_config
|
|
254
|
+
have_library("tamuanova")
|
|
255
|
+
# if RUBY_PLATFORM =~ /cygwin|mingw/
|
|
256
|
+
# have_library("tamuanova") || raise("ERROR: tamu_anova import library is not found")
|
|
257
|
+
# end
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
File.open("../lib/gsl.rb", "w") do |file|
|
|
261
|
+
if have_narray_h
|
|
262
|
+
file.print("require('narray')\n")
|
|
263
|
+
end
|
|
264
|
+
# file.print("require('rb_gsl')\ninclude GSL\n")
|
|
265
|
+
file.print("require('rb_gsl')\n")
|
|
266
|
+
file.print("require('gsl/oper.rb')\n")
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
File.open("../lib/rbgsl.rb", "w") do |file|
|
|
270
|
+
if have_narray_h
|
|
271
|
+
file.print("require('narray')\n")
|
|
272
|
+
end
|
|
273
|
+
file.print("require('rb_gsl')\n")
|
|
274
|
+
file.print("require('gsl/oper.rb')\n")
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
srcs = Dir.glob("*.c") - ["vector_source.c", "matrix_source.c", "tensor_source.c", "poly_source.c", "block_source.c"]
|
|
278
|
+
|
|
279
|
+
$objs = srcs.collect { |f| f.sub(".c", ".o") }
|
|
280
|
+
|
|
281
|
+
create_makefile("rb_gsl")
|