rb-gsl 1.16.0.4 → 1.16.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -0
- data/.travis.yml +24 -0
- data/AUTHORS +6 -0
- data/COPYING +341 -339
- data/ChangeLog +608 -587
- data/Gemfile +4 -0
- data/README.md +77 -0
- data/Rakefile +14 -33
- data/THANKS +1 -1
- data/examples/blas/blas.rb +1 -1
- data/examples/bspline.rb +3 -3
- data/examples/complex/functions.rb +4 -4
- data/examples/complex/mul.rb +1 -1
- data/examples/const/physconst.rb +4 -4
- data/examples/const/travel.rb +4 -4
- data/examples/eigen/nonsymmv.rb +1 -1
- data/examples/eigen/qhoscillator.rb +3 -3
- data/examples/fft/radix2.rb +1 -1
- data/examples/fft/real-halfcomplex.rb +3 -3
- data/examples/fft/real-halfcomplex2.rb +3 -3
- data/examples/fit/expfit.rb +1 -1
- data/examples/fit/multifit.rb +1 -1
- data/examples/fit/ndlinear.rb +44 -44
- data/examples/fit/nonlinearfit.rb +1 -1
- data/examples/fit/wlinear.rb +3 -3
- data/examples/function/function.rb +1 -1
- data/examples/function/min.rb +1 -1
- data/examples/function/synchrotron.rb +2 -2
- data/examples/gallery/koch.rb +1 -1
- data/examples/histogram/cauchy.rb +2 -2
- data/examples/histogram/exponential.rb +1 -1
- data/examples/histogram/histo3d.rb +1 -1
- data/examples/histogram/histogram-pdf.rb +2 -2
- data/examples/histogram/xexp.rb +1 -1
- data/examples/integration/ahmed.rb +2 -2
- data/examples/integration/cosmology.rb +7 -7
- data/examples/integration/friedmann.rb +4 -4
- data/examples/integration/qng.rb +1 -1
- data/examples/interp/demo.rb +2 -2
- data/examples/linalg/LQ_solve.rb +1 -1
- data/examples/linalg/LU.rb +1 -1
- data/examples/linalg/LU2.rb +1 -1
- data/examples/linalg/LU_narray.rb +1 -1
- data/examples/linalg/PTLQ.rb +1 -1
- data/examples/linalg/QRPT.rb +1 -1
- data/examples/linalg/chol.rb +1 -1
- data/examples/linalg/chol_narray.rb +1 -1
- data/examples/linalg/complex.rb +1 -1
- data/examples/math/elementary.rb +1 -1
- data/examples/math/functions.rb +1 -1
- data/examples/math/inf_nan.rb +1 -1
- data/examples/math/minmax.rb +1 -1
- data/examples/math/power.rb +1 -1
- data/examples/math/test.rb +1 -1
- data/examples/min.rb +1 -1
- data/examples/multimin/bundle.rb +1 -1
- data/examples/multimin/cqp.rb +17 -17
- data/examples/multiroot/fsolver3.rb +1 -1
- data/examples/odeiv/binarysystem.rb +12 -12
- data/examples/odeiv/demo.rb +3 -3
- data/examples/odeiv/frei1.rb +7 -7
- data/examples/odeiv/frei2.rb +4 -4
- data/examples/odeiv/oscillator.rb +1 -1
- data/examples/odeiv/sedov.rb +3 -3
- data/examples/odeiv/whitedwarf.rb +11 -11
- data/examples/permutation/ex1.rb +2 -2
- data/examples/permutation/permutation.rb +1 -1
- data/examples/poly/demo.rb +1 -1
- data/examples/random/diffusion.rb +1 -1
- data/examples/random/generator.rb +2 -2
- data/examples/random/randomwalk.rb +3 -3
- data/examples/random/rng.rb +1 -1
- data/examples/roots/bisection.rb +1 -1
- data/examples/roots/brent.rb +1 -1
- data/examples/roots/demo.rb +1 -1
- data/examples/roots/newton.rb +2 -2
- data/examples/roots/recombination.gp +0 -1
- data/examples/sf/hyperg.rb +1 -1
- data/examples/sf/sphbessel.rb +1 -1
- data/examples/sort/sort.rb +1 -1
- data/examples/tamu_anova.rb +4 -4
- data/examples/vector/add.rb +1 -1
- data/examples/vector/decimate.rb +1 -1
- data/examples/vector/gnuplot.rb +8 -8
- data/examples/vector/vector.rb +2 -2
- data/examples/wavelet/wavelet1.rb +1 -1
- data/ext/{gsl → gsl_native}/alf.c +9 -9
- data/ext/{gsl → gsl_native}/array.c +64 -151
- data/ext/{gsl → gsl_native}/array_complex.c +61 -63
- data/ext/{gsl → gsl_native}/blas.c +0 -0
- data/ext/{gsl → gsl_native}/blas1.c +32 -32
- data/ext/{gsl → gsl_native}/blas2.c +54 -58
- data/ext/{gsl → gsl_native}/blas3.c +54 -54
- data/ext/{gsl → gsl_native}/block.c +3 -6
- data/ext/{gsl/block_source.c → gsl_native/block_source.h} +109 -111
- data/ext/gsl_native/bspline.c +122 -0
- data/ext/{gsl → gsl_native}/bundle.c +0 -0
- data/ext/{gsl → gsl_native}/cdf.c +76 -88
- data/ext/{gsl → gsl_native}/cheb.c +74 -85
- data/ext/{gsl → gsl_native}/combination.c +9 -16
- data/ext/{gsl → gsl_native}/common.c +7 -37
- data/ext/{gsl → gsl_native}/complex.c +113 -115
- data/ext/gsl_native/const.c +331 -0
- data/ext/{gsl → gsl_native}/const_additional.c +12 -33
- data/ext/gsl_native/cqp.c +283 -0
- data/ext/{gsl → gsl_native}/deriv.c +22 -30
- data/ext/{gsl → gsl_native}/dht.c +20 -28
- data/ext/{gsl → gsl_native}/diff.c +23 -25
- data/ext/{gsl → gsl_native}/dirac.c +44 -45
- data/ext/{gsl → gsl_native}/eigen.c +1031 -1082
- data/ext/{gsl → gsl_native}/error.c +13 -13
- data/ext/{gsl → gsl_native}/extconf.rb +5 -13
- data/ext/{gsl → gsl_native}/fft.c +192 -198
- data/ext/{gsl → gsl_native}/fit.c +16 -16
- data/ext/gsl_native/fresnel.c +312 -0
- data/ext/{gsl → gsl_native}/function.c +29 -35
- data/ext/{gsl → gsl_native}/geometry.c +15 -15
- data/ext/{gsl → gsl_native}/graph.c +37 -87
- data/ext/{gsl → gsl_native}/gsl.c +10 -23
- data/ext/{gsl → gsl_native}/gsl_narray.c +15 -24
- data/ext/{gsl → gsl_native}/histogram.c +123 -150
- data/ext/{gsl → gsl_native}/histogram2d.c +71 -96
- data/ext/{gsl → gsl_native}/histogram3d.c +72 -72
- data/ext/{gsl → gsl_native}/histogram3d_source.c +195 -196
- data/ext/{gsl → gsl_native}/histogram_find.c +31 -33
- data/ext/{gsl → gsl_native}/histogram_oper.c +43 -52
- data/ext/{gsl → gsl_native}/ieee.c +7 -15
- data/ext/{gsl → gsl_native}/include/rb_gsl.h +0 -7
- data/ext/{gsl → gsl_native}/include/rb_gsl_array.h +15 -25
- data/ext/{gsl → gsl_native}/include/rb_gsl_cheb.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_common.h +44 -52
- data/ext/{gsl → gsl_native}/include/rb_gsl_complex.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_const.h +0 -5
- data/ext/{gsl → gsl_native}/include/rb_gsl_dirac.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_eigen.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_fft.h +0 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_fit.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_function.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_graph.h +2 -2
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram.h +8 -8
- data/ext/{gsl → gsl_native}/include/rb_gsl_histogram3d.h +50 -50
- data/ext/{gsl → gsl_native}/include/rb_gsl_integration.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_interp.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_linalg.h +0 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_math.h +0 -4
- data/ext/{gsl → gsl_native}/include/rb_gsl_odeiv.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_poly.h +3 -3
- data/ext/{gsl → gsl_native}/include/rb_gsl_rational.h +1 -1
- data/ext/{gsl → gsl_native}/include/rb_gsl_rng.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_root.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_sf.h +39 -43
- data/ext/{gsl → gsl_native}/include/rb_gsl_statistics.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_tensor.h +0 -0
- data/ext/{gsl → gsl_native}/include/rb_gsl_with_narray.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_off.h +0 -0
- data/ext/{gsl → gsl_native}/include/templates_on.h +1 -1
- data/ext/{gsl → gsl_native}/integration.c +160 -183
- data/ext/{gsl → gsl_native}/interp.c +23 -31
- data/ext/gsl_native/jacobi.c +733 -0
- data/ext/{gsl → gsl_native}/linalg.c +448 -576
- data/ext/{gsl → gsl_native}/linalg_complex.c +84 -98
- data/ext/{gsl → gsl_native}/math.c +45 -63
- data/ext/{gsl → gsl_native}/matrix.c +4 -6
- data/ext/{gsl → gsl_native}/matrix_complex.c +111 -114
- data/ext/{gsl → gsl_native}/matrix_double.c +74 -77
- data/ext/{gsl → gsl_native}/matrix_int.c +49 -50
- data/ext/{gsl/matrix_source.c → gsl_native/matrix_source.h} +280 -302
- data/ext/{gsl → gsl_native}/min.c +43 -74
- data/ext/{gsl → gsl_native}/monte.c +45 -59
- data/ext/{gsl → gsl_native}/multifit.c +138 -147
- data/ext/{gsl → gsl_native}/multimin.c +55 -83
- data/ext/{gsl → gsl_native}/multimin_fsdf.c +15 -15
- data/ext/{gsl → gsl_native}/multiroots.c +61 -64
- data/ext/{gsl → gsl_native}/multiset.c +3 -7
- data/ext/{gsl → gsl_native}/ndlinear.c +320 -321
- data/ext/{gsl → gsl_native}/nmf.c +11 -11
- data/ext/{gsl → gsl_native}/nmf_wrap.c +1 -1
- data/ext/{gsl → gsl_native}/ntuple.c +13 -13
- data/ext/{gsl → gsl_native}/odeiv.c +95 -106
- data/ext/gsl_native/ool.c +879 -0
- data/ext/{gsl → gsl_native}/permutation.c +36 -34
- data/ext/{gsl → gsl_native}/poly.c +2 -5
- data/ext/{gsl → gsl_native}/poly2.c +6 -6
- data/ext/{gsl/poly_source.c → gsl_native/poly_source.h} +232 -275
- data/ext/{gsl → gsl_native}/qrng.c +6 -17
- data/ext/{gsl → gsl_native}/randist.c +218 -243
- data/ext/{gsl → gsl_native}/rational.c +9 -9
- data/ext/{gsl → gsl_native}/rng.c +29 -45
- data/ext/{gsl → gsl_native}/root.c +43 -43
- data/ext/{gsl → gsl_native}/sf.c +163 -197
- data/ext/{gsl → gsl_native}/sf_airy.c +0 -0
- data/ext/{gsl → gsl_native}/sf_bessel.c +6 -6
- data/ext/{gsl → gsl_native}/sf_clausen.c +0 -0
- data/ext/{gsl → gsl_native}/sf_coulomb.c +39 -39
- data/ext/{gsl → gsl_native}/sf_coupling.c +29 -29
- data/ext/{gsl → gsl_native}/sf_dawson.c +0 -0
- data/ext/{gsl → gsl_native}/sf_debye.c +0 -9
- data/ext/{gsl → gsl_native}/sf_dilog.c +0 -0
- data/ext/{gsl → gsl_native}/sf_elementary.c +2 -2
- data/ext/{gsl → gsl_native}/sf_ellint.c +42 -42
- data/ext/{gsl → gsl_native}/sf_elljac.c +2 -2
- data/ext/{gsl → gsl_native}/sf_erfc.c +0 -4
- data/ext/{gsl → gsl_native}/sf_exp.c +2 -2
- data/ext/{gsl → gsl_native}/sf_expint.c +1 -11
- data/ext/{gsl → gsl_native}/sf_fermi_dirac.c +0 -0
- data/ext/{gsl → gsl_native}/sf_gamma.c +1 -5
- data/ext/{gsl → gsl_native}/sf_gegenbauer.c +0 -0
- data/ext/{gsl → gsl_native}/sf_hyperg.c +0 -0
- data/ext/{gsl → gsl_native}/sf_laguerre.c +3 -3
- data/ext/{gsl → gsl_native}/sf_lambert.c +0 -0
- data/ext/{gsl → gsl_native}/sf_legendre.c +0 -0
- data/ext/{gsl → gsl_native}/sf_log.c +3 -3
- data/ext/gsl_native/sf_mathieu.c +235 -0
- data/ext/{gsl → gsl_native}/sf_power.c +0 -0
- data/ext/{gsl → gsl_native}/sf_psi.c +2 -11
- data/ext/{gsl → gsl_native}/sf_synchrotron.c +0 -0
- data/ext/{gsl → gsl_native}/sf_transport.c +0 -0
- data/ext/{gsl → gsl_native}/sf_trigonometric.c +3 -3
- data/ext/{gsl → gsl_native}/sf_zeta.c +0 -4
- data/ext/{gsl → gsl_native}/signal.c +60 -64
- data/ext/{gsl → gsl_native}/siman.c +36 -40
- data/ext/{gsl → gsl_native}/sort.c +3 -4
- data/ext/{gsl → gsl_native}/spline.c +25 -43
- data/ext/{gsl → gsl_native}/stats.c +102 -115
- data/ext/{gsl → gsl_native}/sum.c +32 -32
- data/ext/{gsl → gsl_native}/tamu_anova.c +0 -0
- data/ext/{gsl → gsl_native}/tensor.c +2 -4
- data/ext/{gsl/tensor_source.c → gsl_native/tensor_source.h} +144 -144
- data/ext/{gsl → gsl_native}/vector.c +2 -4
- data/ext/{gsl → gsl_native}/vector_complex.c +165 -171
- data/ext/{gsl → gsl_native}/vector_double.c +167 -174
- data/ext/{gsl → gsl_native}/vector_int.c +23 -25
- data/ext/{gsl/vector_source.c → gsl_native/vector_source.h} +400 -414
- data/ext/{gsl → gsl_native}/wavelet.c +215 -236
- data/lib/gsl.rb +1 -7
- data/lib/gsl/gnuplot.rb +2 -2
- data/lib/gsl/version.rb +1 -3
- data/rb-gsl.gemspec +29 -0
- data/rdoc/blas.rdoc +3 -3
- data/rdoc/bspline.rdoc +7 -7
- data/rdoc/cheb.rdoc +8 -8
- data/rdoc/cholesky_complex.rdoc +1 -1
- data/rdoc/combi.rdoc +9 -9
- data/rdoc/complex.rdoc +11 -11
- data/rdoc/const.rdoc +20 -20
- data/rdoc/dht.rdoc +6 -6
- data/rdoc/diff.rdoc +6 -6
- data/rdoc/ehandling.rdoc +3 -3
- data/rdoc/eigen.rdoc +11 -11
- data/rdoc/fft.rdoc +26 -26
- data/rdoc/fit.rdoc +18 -18
- data/rdoc/graph.rdoc +2 -2
- data/rdoc/hist.rdoc +16 -16
- data/rdoc/hist2d.rdoc +4 -4
- data/rdoc/hist3d.rdoc +3 -3
- data/rdoc/integration.rdoc +16 -16
- data/rdoc/interp.rdoc +11 -11
- data/rdoc/intro.rdoc +3 -3
- data/rdoc/linalg.rdoc +20 -20
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +13 -13
- data/rdoc/matrix.rdoc +22 -22
- data/rdoc/min.rdoc +9 -9
- data/rdoc/monte.rdoc +3 -3
- data/rdoc/multimin.rdoc +12 -12
- data/rdoc/multiroot.rdoc +12 -12
- data/rdoc/narray.rdoc +9 -9
- data/rdoc/ndlinear.rdoc +4 -4
- data/rdoc/nonlinearfit.rdoc +17 -17
- data/rdoc/ntuple.rdoc +5 -5
- data/rdoc/odeiv.rdoc +12 -12
- data/rdoc/perm.rdoc +11 -11
- data/rdoc/poly.rdoc +17 -17
- data/rdoc/qrng.rdoc +9 -9
- data/rdoc/randist.rdoc +10 -10
- data/rdoc/ref.rdoc +49 -49
- data/rdoc/rng.rdoc +9 -9
- data/rdoc/roots.rdoc +12 -12
- data/rdoc/sf.rdoc +35 -35
- data/rdoc/siman.rdoc +3 -3
- data/rdoc/sort.rdoc +6 -6
- data/rdoc/start.rdoc +2 -2
- data/rdoc/stats.rdoc +13 -13
- data/rdoc/sum.rdoc +4 -4
- data/rdoc/tensor.rdoc +3 -3
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +3 -3
- data/rdoc/vector.rdoc +28 -28
- data/rdoc/vector_complex.rdoc +6 -6
- data/rdoc/wavelet.rdoc +8 -8
- data/test/gsl/blas_test.rb +1 -1
- data/test/gsl/index_test.rb +61 -0
- data/test/gsl/matrix_test.rb +21 -0
- data/uncrustify.cfg +1693 -0
- metadata +212 -243
- data/README +0 -28
- data/ext/gsl/bspline.c +0 -130
- data/ext/gsl/const.c +0 -672
- data/ext/gsl/cqp.c +0 -283
- data/ext/gsl/fcmp.c +0 -64
- data/ext/gsl/fresnel.c +0 -312
- data/ext/gsl/jacobi.c +0 -739
- data/ext/gsl/ool.c +0 -879
- data/ext/gsl/oper_complex_source.c +0 -251
- data/ext/gsl/sf_mathieu.c +0 -238
- data/rdoc/index.rdoc +0 -50
data/ext/gsl/cqp.c
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
#ifdef HAVE_GSL_GSL_CQP_H
|
2
|
-
|
3
|
-
#include "include/rb_gsl.h"
|
4
|
-
#include "gsl/gsl_cqp.h"
|
5
|
-
|
6
|
-
static const gsl_cqpminimizer_type* type_by_string(VALUE t);
|
7
|
-
static const gsl_cqpminimizer_type* get_type(VALUE t)
|
8
|
-
{
|
9
|
-
|
10
|
-
switch (TYPE(t)) {
|
11
|
-
case T_STRING:
|
12
|
-
return type_by_string(t);
|
13
|
-
break;
|
14
|
-
default:
|
15
|
-
rb_raise(rb_eTypeError, "Wrong argument type %s.", rb_class2name(CLASS_OF(t)));
|
16
|
-
}
|
17
|
-
}
|
18
|
-
|
19
|
-
static const gsl_cqpminimizer_type* type_by_string(VALUE t)
|
20
|
-
{
|
21
|
-
char *name;
|
22
|
-
name = STR2CSTR(t);
|
23
|
-
if (strcmp(name, "mg_pdip") == 0) {
|
24
|
-
return gsl_cqpminimizer_mg_pdip;
|
25
|
-
} else {
|
26
|
-
rb_raise(rb_eRuntimeError, "Unknown minimizer type %s.", name);
|
27
|
-
}
|
28
|
-
return NULL; /* never reach here */
|
29
|
-
}
|
30
|
-
|
31
|
-
static VALUE rb_cqpminimizer_alloc(VALUE klass, VALUE t, VALUE n, VALUE me, VALUE mi)
|
32
|
-
{
|
33
|
-
gsl_cqpminimizer *m;
|
34
|
-
m = gsl_cqpminimizer_alloc(get_type(t), (size_t) FIX2INT(n), (size_t) FIX2INT(me), (size_t) FIX2INT(mi));
|
35
|
-
return Data_Wrap_Struct(klass, 0, gsl_cqpminimizer_free, m);
|
36
|
-
}
|
37
|
-
|
38
|
-
static VALUE rb_cqpminimizer_set(VALUE obj, VALUE data)
|
39
|
-
{
|
40
|
-
gsl_cqpminimizer *m;
|
41
|
-
gsl_cqp_data *d;
|
42
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
43
|
-
Data_Get_Struct(data, gsl_cqp_data, d);
|
44
|
-
gsl_cqpminimizer_set(m, d);
|
45
|
-
return Qtrue;
|
46
|
-
}
|
47
|
-
|
48
|
-
static VALUE rb_cqpminimizer_name(VALUE obj)
|
49
|
-
{
|
50
|
-
gsl_cqpminimizer *m;
|
51
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
52
|
-
return rb_str_new2(gsl_cqpminimizer_name(m));
|
53
|
-
}
|
54
|
-
|
55
|
-
static VALUE rb_cqpminimizer_iterate(VALUE obj)
|
56
|
-
{
|
57
|
-
gsl_cqpminimizer *m;
|
58
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
59
|
-
return INT2FIX(gsl_cqpminimizer_iterate(m));
|
60
|
-
}
|
61
|
-
|
62
|
-
static VALUE rb_cqpminimizer_x(VALUE obj)
|
63
|
-
{
|
64
|
-
gsl_cqpminimizer *m;
|
65
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
66
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, gsl_cqpminimizer_x(m));
|
67
|
-
}
|
68
|
-
|
69
|
-
static VALUE rb_cqpminimizer_lm_eq(VALUE obj)
|
70
|
-
{
|
71
|
-
gsl_cqpminimizer *m;
|
72
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
73
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, gsl_cqpminimizer_lm_eq(m));
|
74
|
-
}
|
75
|
-
static VALUE rb_cqpminimizer_lm_ineq(VALUE obj)
|
76
|
-
{
|
77
|
-
gsl_cqpminimizer *m;
|
78
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
79
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, gsl_cqpminimizer_lm_ineq(m));
|
80
|
-
}
|
81
|
-
static VALUE rb_cqpminimizer_f(VALUE obj)
|
82
|
-
{
|
83
|
-
gsl_cqpminimizer *m;
|
84
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
85
|
-
return rb_float_new(gsl_cqpminimizer_f(m));
|
86
|
-
}
|
87
|
-
static VALUE rb_cqpminimizer_gap(VALUE obj)
|
88
|
-
{
|
89
|
-
gsl_cqpminimizer *m;
|
90
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
91
|
-
return rb_float_new(gsl_cqpminimizer_gap(m));
|
92
|
-
}
|
93
|
-
static VALUE rb_cqpminimizer_residuals_norm(VALUE obj)
|
94
|
-
{
|
95
|
-
gsl_cqpminimizer *m;
|
96
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
97
|
-
return rb_float_new(gsl_cqpminimizer_residuals_norm(m));
|
98
|
-
}
|
99
|
-
/*
|
100
|
-
static VALUE rb_cqpminimizer_minimum(VALUE obj)
|
101
|
-
{
|
102
|
-
gsl_cqpminimizer *m;
|
103
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
104
|
-
return rb_float_new(gsl_cqpminimizer_minimum(m));
|
105
|
-
}
|
106
|
-
*/
|
107
|
-
static VALUE rb_cqpminimizer_test_convergence(VALUE obj, VALUE g, VALUE r)
|
108
|
-
{
|
109
|
-
gsl_cqpminimizer *m;
|
110
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
111
|
-
return INT2FIX(gsl_cqpminimizer_test_convergence(m, NUM2DBL(g), NUM2DBL(r)));
|
112
|
-
}
|
113
|
-
static VALUE rb_cqpminimizer_test_infeasibility(VALUE obj, VALUE e)
|
114
|
-
{
|
115
|
-
gsl_cqpminimizer *m;
|
116
|
-
Data_Get_Struct(obj, gsl_cqpminimizer, m);
|
117
|
-
return INT2FIX(gsl_cqp_minimizer_test_infeasibility(m, NUM2DBL(e)));
|
118
|
-
}
|
119
|
-
|
120
|
-
static VALUE rb_cqp_data_alloc(VALUE klass)
|
121
|
-
{
|
122
|
-
gsl_cqp_data *d;
|
123
|
-
d = (gsl_cqp_data*) malloc(sizeof(gsl_cqp_data));
|
124
|
-
return Data_Wrap_Struct(klass, 0, free, d);
|
125
|
-
}
|
126
|
-
|
127
|
-
static VALUE rb_cqp_data_Q(VALUE obj)
|
128
|
-
{
|
129
|
-
gsl_cqp_data *d;
|
130
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
131
|
-
return Data_Wrap_Struct(cgsl_matrix_view, 0, NULL, d->Q);
|
132
|
-
}
|
133
|
-
|
134
|
-
static VALUE rb_cqp_data_q(VALUE obj)
|
135
|
-
{
|
136
|
-
gsl_cqp_data *d;
|
137
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
138
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, d->q);
|
139
|
-
}
|
140
|
-
|
141
|
-
static VALUE rb_cqp_data_A(VALUE obj)
|
142
|
-
{
|
143
|
-
gsl_cqp_data *d;
|
144
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
145
|
-
return Data_Wrap_Struct(cgsl_matrix_view, 0, NULL, d->A);
|
146
|
-
}
|
147
|
-
|
148
|
-
static VALUE rb_cqp_data_b(VALUE obj)
|
149
|
-
{
|
150
|
-
gsl_cqp_data *d;
|
151
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
152
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, d->b);
|
153
|
-
}
|
154
|
-
|
155
|
-
static VALUE rb_cqp_data_C(VALUE obj)
|
156
|
-
{
|
157
|
-
gsl_cqp_data *d;
|
158
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
159
|
-
return Data_Wrap_Struct(cgsl_matrix_view, 0, NULL, d->C);
|
160
|
-
}
|
161
|
-
|
162
|
-
static VALUE rb_cqp_data_d(VALUE obj)
|
163
|
-
{
|
164
|
-
gsl_cqp_data *d;
|
165
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
166
|
-
return Data_Wrap_Struct(cgsl_vector_view, 0, NULL, d->d);
|
167
|
-
}
|
168
|
-
|
169
|
-
static VALUE rb_cqp_data_set_Q(VALUE obj, VALUE mm)
|
170
|
-
{
|
171
|
-
gsl_cqp_data *d;
|
172
|
-
gsl_matrix *m;
|
173
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
174
|
-
CHECK_MATRIX(mm);
|
175
|
-
Data_Get_Struct(mm, gsl_matrix, m);
|
176
|
-
d->Q = m;
|
177
|
-
return Qtrue;
|
178
|
-
}
|
179
|
-
|
180
|
-
static VALUE rb_cqp_data_set_q(VALUE obj, VALUE vv)
|
181
|
-
{
|
182
|
-
gsl_cqp_data *d;
|
183
|
-
gsl_vector *v;
|
184
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
185
|
-
CHECK_VECTOR(vv);
|
186
|
-
Data_Get_Struct(vv, gsl_vector, v);
|
187
|
-
d->q = v;
|
188
|
-
return Qtrue;
|
189
|
-
}
|
190
|
-
|
191
|
-
static VALUE rb_cqp_data_set_A(VALUE obj, VALUE mm)
|
192
|
-
{
|
193
|
-
gsl_cqp_data *d;
|
194
|
-
gsl_matrix *m;
|
195
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
196
|
-
CHECK_MATRIX(mm);
|
197
|
-
Data_Get_Struct(mm, gsl_matrix, m);
|
198
|
-
d->A = m;
|
199
|
-
return Qtrue;
|
200
|
-
}
|
201
|
-
|
202
|
-
static VALUE rb_cqp_data_set_b(VALUE obj, VALUE vv)
|
203
|
-
{
|
204
|
-
gsl_cqp_data *d;
|
205
|
-
gsl_vector *v;
|
206
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
207
|
-
CHECK_VECTOR(vv);
|
208
|
-
Data_Get_Struct(vv, gsl_vector, v);
|
209
|
-
d->b = v;
|
210
|
-
return Qtrue;
|
211
|
-
}
|
212
|
-
|
213
|
-
static VALUE rb_cqp_data_set_C(VALUE obj, VALUE mm)
|
214
|
-
{
|
215
|
-
gsl_cqp_data *d;
|
216
|
-
gsl_matrix *m;
|
217
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
218
|
-
CHECK_MATRIX(mm);
|
219
|
-
Data_Get_Struct(mm, gsl_matrix, m);
|
220
|
-
d->C = m;
|
221
|
-
return Qtrue;
|
222
|
-
}
|
223
|
-
|
224
|
-
static VALUE rb_cqp_data_set_d(VALUE obj, VALUE vv)
|
225
|
-
{
|
226
|
-
gsl_cqp_data *d;
|
227
|
-
gsl_vector *v;
|
228
|
-
Data_Get_Struct(obj, gsl_cqp_data, d);
|
229
|
-
CHECK_VECTOR(vv);
|
230
|
-
Data_Get_Struct(vv, gsl_vector, v);
|
231
|
-
d->d = v;
|
232
|
-
return Qtrue;
|
233
|
-
}
|
234
|
-
|
235
|
-
void Init_cqp(VALUE module)
|
236
|
-
{
|
237
|
-
VALUE mCQP, cMinimizer, cData;
|
238
|
-
|
239
|
-
mCQP = rb_define_module_under(module, "CQP");
|
240
|
-
cMinimizer = rb_define_class_under(mCQP, "Minimizer", cGSL_Object);
|
241
|
-
cData = rb_define_class_under(mCQP, "Data", cGSL_Object);
|
242
|
-
|
243
|
-
rb_define_singleton_method(cMinimizer, "alloc", rb_cqpminimizer_alloc, 4);
|
244
|
-
|
245
|
-
rb_define_method(cMinimizer, "set", rb_cqpminimizer_set, 1);
|
246
|
-
rb_define_method(cMinimizer, "name", rb_cqpminimizer_name, 0);
|
247
|
-
rb_define_method(cMinimizer, "iterate", rb_cqpminimizer_iterate, 0);
|
248
|
-
rb_define_method(cMinimizer, "x", rb_cqpminimizer_x, 0);
|
249
|
-
rb_define_method(cMinimizer, "lm_eq", rb_cqpminimizer_lm_eq, 0);
|
250
|
-
rb_define_method(cMinimizer, "lm_ineq", rb_cqpminimizer_lm_ineq, 0);
|
251
|
-
rb_define_method(cMinimizer, "f", rb_cqpminimizer_f, 0);
|
252
|
-
rb_define_method(cMinimizer, "gap", rb_cqpminimizer_gap, 0);
|
253
|
-
rb_define_method(cMinimizer, "residuals_norm", rb_cqpminimizer_residuals_norm, 0);
|
254
|
-
/* rb_define_method(cMinimizer, "minimum", rb_cqpminimizer_minimum, 0); */
|
255
|
-
rb_define_method(cMinimizer, "test_convergence", rb_cqpminimizer_test_convergence, 2);
|
256
|
-
rb_define_method(cMinimizer, "test_infeasibility", rb_cqpminimizer_test_infeasibility, 1);
|
257
|
-
|
258
|
-
/*****/
|
259
|
-
rb_define_singleton_method(cData, "alloc", rb_cqp_data_alloc, 0);
|
260
|
-
|
261
|
-
rb_define_method(cData, "Q", rb_cqp_data_Q, 0);
|
262
|
-
rb_define_method(cData, "q", rb_cqp_data_q, 0);
|
263
|
-
rb_define_method(cData, "A", rb_cqp_data_A, 0);
|
264
|
-
rb_define_method(cData, "b", rb_cqp_data_b, 0);
|
265
|
-
rb_define_method(cData, "C", rb_cqp_data_C, 0);
|
266
|
-
rb_define_method(cData, "d", rb_cqp_data_d, 0);
|
267
|
-
|
268
|
-
rb_define_method(cData, "set_Q", rb_cqp_data_set_Q, 1);
|
269
|
-
rb_define_method(cData, "set_q", rb_cqp_data_set_q, 1);
|
270
|
-
rb_define_method(cData, "set_A", rb_cqp_data_set_A, 1);
|
271
|
-
rb_define_method(cData, "set_b", rb_cqp_data_set_b, 1);
|
272
|
-
rb_define_method(cData, "set_C", rb_cqp_data_set_C, 1);
|
273
|
-
rb_define_method(cData, "set_d", rb_cqp_data_set_d, 1);
|
274
|
-
rb_define_alias(cData, "Q=", "set_Q");
|
275
|
-
rb_define_alias(cData, "q=", "set_q");
|
276
|
-
rb_define_alias(cData, "A=", "set_A");
|
277
|
-
rb_define_alias(cData, "b=", "set_b");
|
278
|
-
rb_define_alias(cData, "C=", "set_C");
|
279
|
-
rb_define_alias(cData, "d=", "set_d");
|
280
|
-
}
|
281
|
-
|
282
|
-
#endif
|
283
|
-
|
data/ext/gsl/fcmp.c
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
/* sys/gsl_compare.c
|
2
|
-
*
|
3
|
-
* Copyright (C) 2002 Gert Van den Eynde
|
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 (at
|
8
|
-
* your option) any later version.
|
9
|
-
*
|
10
|
-
* This program is distributed in the hope that it will be useful, but
|
11
|
-
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
-
* 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
18
|
-
*
|
19
|
-
* Based on fcmp 1.2.2 Copyright (c) 1998-2000 Theodore C. Belding
|
20
|
-
* University of Michigan Center for the Study of Complex Systems
|
21
|
-
* Ted.Belding@umich.edu
|
22
|
-
*
|
23
|
-
*/
|
24
|
-
|
25
|
-
#ifndef GSL_1_3_LATER
|
26
|
-
|
27
|
-
#include <config.h>
|
28
|
-
#include <gsl/gsl_sys.h>
|
29
|
-
#include <math.h>
|
30
|
-
|
31
|
-
int gsl_fcmp(const double x1, const double x2, const double epsilon)
|
32
|
-
{
|
33
|
-
int exponent;
|
34
|
-
double delta, difference;
|
35
|
-
|
36
|
-
/* Find exponent of largest absolute value */
|
37
|
-
|
38
|
-
{
|
39
|
-
double max = (fabs (x1) > fabs (x2)) ? x1 : x2;
|
40
|
-
|
41
|
-
frexp (max, &exponent);
|
42
|
-
}
|
43
|
-
|
44
|
-
/* Form a neighborhood of size 2 * delta */
|
45
|
-
|
46
|
-
delta = ldexp (epsilon, exponent);
|
47
|
-
|
48
|
-
difference = x1 - x2;
|
49
|
-
|
50
|
-
if (difference > delta) /* x1 > x2 */
|
51
|
-
{
|
52
|
-
return 1;
|
53
|
-
}
|
54
|
-
else if (difference < -delta) /* x1 < x2 */
|
55
|
-
{
|
56
|
-
return -1;
|
57
|
-
}
|
58
|
-
else /* -delta <= difference <= delta */
|
59
|
-
{
|
60
|
-
return 0; /* x1 ~=~ x2 */
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
#endif
|
data/ext/gsl/fresnel.c
DELETED
@@ -1,312 +0,0 @@
|
|
1
|
-
/****************************************************************************
|
2
|
-
* fresnel.c -
|
3
|
-
* Calculation of Fresnel integrals by expansion to Chebyshev series
|
4
|
-
* Expansions are taken from the book
|
5
|
-
* Y.L. Luke. Mathematical functions and their approximations.
|
6
|
-
* Moscow, "Mir", 1980. PP. 145-149 (Russian edition)
|
7
|
-
****************************************************************************
|
8
|
-
*/
|
9
|
-
/*
|
10
|
-
Modified for Ruby bindings
|
11
|
-
2006/Dec/24 Y. TSUNESADA
|
12
|
-
*/
|
13
|
-
#include <math.h>
|
14
|
-
#include "include/rb_gsl.h"
|
15
|
-
#include "include/rb_gsl_sf.h"
|
16
|
-
|
17
|
-
static const double sqrt_pi_2 = 1.2533141373155002512078826424; /* sqrt(pi/2) */
|
18
|
-
static const double sqrt_2_pi = 0.7978845608028653558798921199; /* sqrt(2/pi) */
|
19
|
-
static const double _1_sqrt_2pi = 0.3989422804014326779399460599; /* 1/sqrt(2*pi) */
|
20
|
-
static const double pi_2 = 1.5707963267948966192313216916; /* pi/2 */
|
21
|
-
|
22
|
-
static double f_data_a[18] =
|
23
|
-
{
|
24
|
-
0.76435138664186000189,
|
25
|
-
-0.43135547547660179313,
|
26
|
-
0.43288199979726653054,
|
27
|
-
-0.26973310338387111029,
|
28
|
-
0.08416045320876935378,
|
29
|
-
-0.01546524484461381958,
|
30
|
-
0.00187855423439822018,
|
31
|
-
-0.00016264977618887547,
|
32
|
-
0.00001057397656383260,
|
33
|
-
-0.00000053609339889243,
|
34
|
-
0.00000002181658454933,
|
35
|
-
-0.00000000072901621186,
|
36
|
-
0.00000000002037332546,
|
37
|
-
-0.00000000000048344033,
|
38
|
-
0.00000000000000986533,
|
39
|
-
-0.00000000000000017502,
|
40
|
-
0.00000000000000000272,
|
41
|
-
-0.00000000000000000004
|
42
|
-
};
|
43
|
-
|
44
|
-
static double f_data_b[17] =
|
45
|
-
{
|
46
|
-
0.63041404314570539241,
|
47
|
-
-0.42344511405705333544,
|
48
|
-
0.37617172643343656625,
|
49
|
-
-0.16249489154509567415,
|
50
|
-
0.03822255778633008694,
|
51
|
-
-0.00564563477132190899,
|
52
|
-
0.00057454951976897367,
|
53
|
-
-0.00004287071532102004,
|
54
|
-
0.00000245120749923299,
|
55
|
-
-0.00000011098841840868,
|
56
|
-
0.00000000408249731696,
|
57
|
-
-0.00000000012449830219,
|
58
|
-
0.00000000000320048425,
|
59
|
-
-0.00000000000007032416,
|
60
|
-
0.00000000000000133638,
|
61
|
-
-0.00000000000000002219,
|
62
|
-
0.00000000000000000032
|
63
|
-
};
|
64
|
-
|
65
|
-
static double fresnel_cos_0_8(double x)
|
66
|
-
{
|
67
|
-
double x_8 = x/8.0;
|
68
|
-
double xx = 2.0*x_8*x_8 - 1.0;
|
69
|
-
|
70
|
-
double t0 = 1.0;
|
71
|
-
double t1 = xx;
|
72
|
-
double sumC = f_data_a[0] + f_data_a[1]*t1;
|
73
|
-
double t2;
|
74
|
-
int n;
|
75
|
-
for (n=2; n < 18; n++)
|
76
|
-
{
|
77
|
-
t2 = 2.0*xx*t1 - t0;
|
78
|
-
sumC += f_data_a[n]*t2;
|
79
|
-
t0 = t1; t1 = t2;
|
80
|
-
}
|
81
|
-
return _1_sqrt_2pi*sqrt(x)*sumC;
|
82
|
-
}
|
83
|
-
|
84
|
-
static double fresnel_sin_0_8(double x)
|
85
|
-
{
|
86
|
-
double x_8 = x/8.0;
|
87
|
-
double xx = 2.0*x_8*x_8 - 1.0;
|
88
|
-
double t0 = 1.;
|
89
|
-
double t1 = xx;
|
90
|
-
double ot1 = x_8;
|
91
|
-
double ot2 = 2.0*x_8*t1 - ot1;
|
92
|
-
double sumS = f_data_b[0]*ot1 + f_data_b[1]*ot2;
|
93
|
-
int n;
|
94
|
-
double t2;
|
95
|
-
for (n=2; n < 17; n++)
|
96
|
-
{
|
97
|
-
t2 = 2.0*xx*t1 - t0;
|
98
|
-
ot1 = ot2;
|
99
|
-
ot2 = 2.0*x_8*t2 - ot1;
|
100
|
-
sumS += f_data_b[n]*ot2;
|
101
|
-
t0 = t1; t1 = t2;
|
102
|
-
}
|
103
|
-
return _1_sqrt_2pi*sqrt(x)*sumS;
|
104
|
-
}
|
105
|
-
|
106
|
-
static double f_data_e[41] =
|
107
|
-
{
|
108
|
-
0.97462779093296822410,
|
109
|
-
-0.02424701873969321371,
|
110
|
-
0.00103400906842977317,
|
111
|
-
-0.00008052450246908016,
|
112
|
-
0.00000905962481966582,
|
113
|
-
-0.00000131016996757743,
|
114
|
-
0.00000022770820391497,
|
115
|
-
-0.00000004558623552026,
|
116
|
-
0.00000001021567537083,
|
117
|
-
-0.00000000251114508133,
|
118
|
-
0.00000000066704761275,
|
119
|
-
-0.00000000018931512852,
|
120
|
-
0.00000000005689898935,
|
121
|
-
-0.00000000001798219359,
|
122
|
-
0.00000000000594162963,
|
123
|
-
-0.00000000000204285065,
|
124
|
-
0.00000000000072797580,
|
125
|
-
-0.00000000000026797428,
|
126
|
-
0.00000000000010160694,
|
127
|
-
-0.00000000000003958559,
|
128
|
-
0.00000000000001581262,
|
129
|
-
-0.00000000000000646411,
|
130
|
-
0.00000000000000269981,
|
131
|
-
-0.00000000000000115038,
|
132
|
-
0.00000000000000049942,
|
133
|
-
-0.00000000000000022064,
|
134
|
-
0.00000000000000009910,
|
135
|
-
-0.00000000000000004520,
|
136
|
-
0.00000000000000002092,
|
137
|
-
-0.00000000000000000982,
|
138
|
-
0.00000000000000000467,
|
139
|
-
-0.00000000000000000225,
|
140
|
-
0.00000000000000000110,
|
141
|
-
-0.00000000000000000054,
|
142
|
-
0.00000000000000000027,
|
143
|
-
-0.00000000000000000014,
|
144
|
-
0.00000000000000000007,
|
145
|
-
-0.00000000000000000004,
|
146
|
-
0.00000000000000000002,
|
147
|
-
-0.00000000000000000001,
|
148
|
-
0.00000000000000000001
|
149
|
-
};
|
150
|
-
|
151
|
-
static double f_data_f[35] =
|
152
|
-
{
|
153
|
-
0.99461545179407928910,
|
154
|
-
-0.00524276766084297210,
|
155
|
-
0.00013325864229883909,
|
156
|
-
-0.00000770856452642713,
|
157
|
-
0.00000070848077032045,
|
158
|
-
-0.00000008812517411602,
|
159
|
-
0.00000001359784717148,
|
160
|
-
-0.00000000246858295747,
|
161
|
-
0.00000000050925789921,
|
162
|
-
-0.00000000011653400634,
|
163
|
-
0.00000000002906578309,
|
164
|
-
-0.00000000000779847361,
|
165
|
-
0.00000000000222802542,
|
166
|
-
-0.00000000000067239338,
|
167
|
-
0.00000000000021296411,
|
168
|
-
-0.00000000000007041482,
|
169
|
-
0.00000000000002419805,
|
170
|
-
-0.00000000000000861080,
|
171
|
-
0.00000000000000316287,
|
172
|
-
-0.00000000000000119596,
|
173
|
-
0.00000000000000046444,
|
174
|
-
-0.00000000000000018485,
|
175
|
-
0.00000000000000007527,
|
176
|
-
-0.00000000000000003131,
|
177
|
-
0.00000000000000001328,
|
178
|
-
-0.00000000000000000574,
|
179
|
-
0.00000000000000000252,
|
180
|
-
-0.00000000000000000113,
|
181
|
-
0.00000000000000000051,
|
182
|
-
-0.00000000000000000024,
|
183
|
-
0.00000000000000000011,
|
184
|
-
-0.00000000000000000005,
|
185
|
-
0.00000000000000000002,
|
186
|
-
-0.00000000000000000001,
|
187
|
-
0.00000000000000000001
|
188
|
-
};
|
189
|
-
|
190
|
-
static double fresnel_cos_8_inf(double x)
|
191
|
-
{
|
192
|
-
double xx = 128.0/(x*x) - 1.0; /* 2.0*(8/x)^2 - 1 */
|
193
|
-
double t0 = 1.0;
|
194
|
-
double t1 = xx;
|
195
|
-
double sumP = f_data_e[0] + f_data_e[1]*t1;
|
196
|
-
double sumQ = f_data_f[0] + f_data_f[1]*t1;
|
197
|
-
double t2;
|
198
|
-
int n;
|
199
|
-
for(n = 2; n < 35; n++)
|
200
|
-
{
|
201
|
-
t2 = 2.0*xx*t1 - t0;
|
202
|
-
sumP += f_data_e[n]*t2; /* sumP += f_data_e[n]*ChebyshevT(n,xx) */
|
203
|
-
sumQ += f_data_f[n]*t2; /* sumQ += f_data_f[n]*ChebyshevT(n,xx) */
|
204
|
-
t0 = t1; t1 = t2;
|
205
|
-
}
|
206
|
-
for(n = 35; n < 41; n++)
|
207
|
-
{
|
208
|
-
t2 = 2.0*xx*t1 - t0;
|
209
|
-
sumP += f_data_e[n]*t2; /* sumP += f_data_e[n]*ChebyshevT(n,xx) */
|
210
|
-
t0 = t1; t1 = t2;
|
211
|
-
}
|
212
|
-
return 0.5 - _1_sqrt_2pi*(0.5*sumP*cos(x)/x - sumQ*sin(x))/sqrt(x);
|
213
|
-
}
|
214
|
-
|
215
|
-
static double fresnel_sin_8_inf(double x)
|
216
|
-
{
|
217
|
-
double xx = 128.0/(x*x) - 1.0; /* 2.0*(8/x)^2 - 1 */
|
218
|
-
double t0 = 1.0;
|
219
|
-
double t1 = xx;
|
220
|
-
double sumP = f_data_e[0] + f_data_e[1]*t1;
|
221
|
-
double sumQ = f_data_f[0] + f_data_f[1]*t1;
|
222
|
-
double t2;
|
223
|
-
int n;
|
224
|
-
for(n = 2; n < 35; n++)
|
225
|
-
{
|
226
|
-
t2 = 2.0*xx*t1 - t0;
|
227
|
-
sumP += f_data_e[n]*t2; /* sumP += f_data_e[n]*ChebyshevT(n,xx) */
|
228
|
-
sumQ += f_data_f[n]*t2; /* sumQ += f_data_f[n]*ChebyshevT(n,xx) */
|
229
|
-
t0 = t1; t1 = t2;
|
230
|
-
}
|
231
|
-
for(n = 35; n < 41; n++)
|
232
|
-
{
|
233
|
-
t2 = 2.0*xx*t1 - t0;
|
234
|
-
sumP += f_data_e[n]*t2; /* sumQ += f_data_f[n]*ChebyshevT(n,xx) */
|
235
|
-
t0 = t1; t1 = t2;
|
236
|
-
}
|
237
|
-
return 0.5 - _1_sqrt_2pi*(0.5*sumP*sin(x)/x + sumQ*cos(x))/sqrt(x);
|
238
|
-
}
|
239
|
-
|
240
|
-
|
241
|
-
double fresnel_c(double x)
|
242
|
-
{
|
243
|
-
double xx = x*x*pi_2;
|
244
|
-
double ret_val;
|
245
|
-
if(xx<=8.0)
|
246
|
-
ret_val = fresnel_cos_0_8(xx);
|
247
|
-
else
|
248
|
-
ret_val = fresnel_cos_8_inf(xx);
|
249
|
-
return (x<0.0) ? -ret_val : ret_val;
|
250
|
-
}
|
251
|
-
|
252
|
-
double fresnel_s(double x)
|
253
|
-
{
|
254
|
-
double xx = x*x*pi_2;
|
255
|
-
double ret_val;
|
256
|
-
if(xx<=8.0)
|
257
|
-
ret_val = fresnel_sin_0_8(xx);
|
258
|
-
else
|
259
|
-
ret_val = fresnel_sin_8_inf(xx);
|
260
|
-
return (x<0.0) ? -ret_val : ret_val;
|
261
|
-
}
|
262
|
-
|
263
|
-
double fresnel_c1(double x)
|
264
|
-
{
|
265
|
-
return fresnel_c(x*sqrt_2_pi);
|
266
|
-
}
|
267
|
-
|
268
|
-
double fresnel_s1(double x)
|
269
|
-
{
|
270
|
-
return fresnel_s(x*sqrt_2_pi);
|
271
|
-
}
|
272
|
-
|
273
|
-
static VALUE rb_fresnel_c(VALUE obj, VALUE x)
|
274
|
-
{
|
275
|
-
return rb_gsl_sf_eval1(fresnel_c, x);
|
276
|
-
}
|
277
|
-
static VALUE rb_fresnel_s(VALUE obj, VALUE x)
|
278
|
-
{
|
279
|
-
return rb_gsl_sf_eval1(fresnel_s, x);
|
280
|
-
}
|
281
|
-
static VALUE rb_fresnel_c1(VALUE obj, VALUE x)
|
282
|
-
{
|
283
|
-
return rb_gsl_sf_eval1(fresnel_c1, x);
|
284
|
-
}
|
285
|
-
static VALUE rb_fresnel_s1(VALUE obj, VALUE x)
|
286
|
-
{
|
287
|
-
return rb_gsl_sf_eval1(fresnel_s1, x);
|
288
|
-
}
|
289
|
-
void Init_fresnel(VALUE module)
|
290
|
-
{
|
291
|
-
VALUE mfresnel;
|
292
|
-
mfresnel = rb_define_module_under(module, "Fresnel");
|
293
|
-
rb_define_module_function(module, "fresnel_c", rb_fresnel_c, 1);
|
294
|
-
rb_define_module_function(module, "fresnel_s", rb_fresnel_s, 1);
|
295
|
-
rb_define_module_function(module, "fresnel_c1", rb_fresnel_c1, 1);
|
296
|
-
rb_define_module_function(module, "fresnel_s1", rb_fresnel_s1, 1);
|
297
|
-
rb_define_module_function(mfresnel, "c", rb_fresnel_c, 1);
|
298
|
-
rb_define_module_function(mfresnel, "s", rb_fresnel_s, 1);
|
299
|
-
rb_define_module_function(mfresnel, "c1", rb_fresnel_c1, 1);
|
300
|
-
rb_define_module_function(mfresnel, "s1", rb_fresnel_s1, 1);
|
301
|
-
}
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|