rb-gsl 1.15.3.1 → 1.15.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHORS +2 -2
- data/ChangeLog +8 -0
- data/Rakefile +39 -96
- data/VERSION +1 -1
- data/ext/array.c +2 -2
- data/ext/block_source.c +1 -1
- data/ext/dirac.c +1 -1
- data/ext/eigen.c +13 -13
- data/ext/extconf.rb +17 -11
- data/ext/function.c +5 -5
- data/ext/gsl_narray.c +6 -6
- data/ext/histogram.c +7 -6
- data/ext/histogram2d.c +4 -4
- data/ext/interp.c +1 -1
- data/ext/linalg.c +13 -11
- data/ext/linalg_complex.c +8 -6
- data/ext/math.c +1 -1
- data/ext/matrix_complex.c +6 -6
- data/ext/matrix_source.c +10 -10
- data/ext/monte.c +2 -2
- data/ext/multimin.c +4 -4
- data/ext/multiroots.c +8 -8
- data/ext/nmf.c +6 -6
- data/ext/ntuple.c +4 -4
- data/ext/odeiv.c +2 -2
- data/ext/permutation.c +1 -1
- data/ext/poly2.c +6 -6
- data/ext/poly_source.c +9 -6
- data/ext/sf.c +31 -45
- data/ext/signal.c +2 -2
- data/ext/vector_complex.c +11 -10
- data/ext/vector_double.c +7 -4
- data/ext/vector_source.c +29 -26
- data/ext/wavelet.c +1 -1
- data/include/rb_gsl_common.h +12 -0
- data/include/rb_gsl_config.h +10 -1
- data/rdoc/blas.rdoc +4 -4
- data/rdoc/bspline.rdoc +8 -8
- data/rdoc/cheb.rdoc +9 -9
- data/rdoc/cholesky_complex.rdoc +1 -1
- data/rdoc/combi.rdoc +10 -10
- data/rdoc/complex.rdoc +12 -12
- data/rdoc/const.rdoc +21 -21
- data/rdoc/dht.rdoc +7 -7
- data/rdoc/diff.rdoc +7 -7
- data/rdoc/ehandling.rdoc +4 -4
- data/rdoc/eigen.rdoc +12 -12
- data/rdoc/fft.rdoc +27 -27
- data/rdoc/fit.rdoc +19 -19
- data/rdoc/function.rdoc +1 -1
- data/rdoc/graph.rdoc +3 -3
- data/rdoc/hist.rdoc +17 -17
- data/rdoc/hist2d.rdoc +5 -5
- data/rdoc/hist3d.rdoc +4 -4
- data/rdoc/index.rdoc +4 -4
- data/rdoc/integration.rdoc +17 -17
- data/rdoc/interp.rdoc +12 -12
- data/rdoc/intro.rdoc +4 -4
- data/rdoc/linalg.rdoc +21 -21
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +14 -14
- data/rdoc/matrix.rdoc +21 -21
- data/rdoc/min.rdoc +10 -10
- data/rdoc/monte.rdoc +4 -4
- data/rdoc/multimin.rdoc +13 -13
- data/rdoc/multiroot.rdoc +13 -13
- data/rdoc/narray.rdoc +10 -10
- data/rdoc/ndlinear.rdoc +5 -5
- data/rdoc/nonlinearfit.rdoc +18 -18
- data/rdoc/ntuple.rdoc +6 -6
- data/rdoc/odeiv.rdoc +13 -13
- data/rdoc/perm.rdoc +12 -12
- data/rdoc/poly.rdoc +18 -18
- data/rdoc/qrng.rdoc +10 -10
- data/rdoc/randist.rdoc +11 -11
- data/rdoc/ref.rdoc +50 -50
- data/rdoc/rng.rdoc +10 -10
- data/rdoc/rngextra.rdoc +5 -5
- data/rdoc/roots.rdoc +13 -13
- data/rdoc/sf.rdoc +36 -36
- data/rdoc/siman.rdoc +4 -4
- data/rdoc/sort.rdoc +7 -7
- data/rdoc/start.rdoc +1 -1
- data/rdoc/stats.rdoc +14 -14
- data/rdoc/sum.rdoc +5 -5
- data/rdoc/tensor.rdoc +4 -4
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +5 -5
- data/rdoc/vector.rdoc +29 -29
- data/rdoc/vector_complex.rdoc +6 -6
- data/rdoc/wavelet.rdoc +9 -9
- data/test/gsl/blas_test.rb +79 -0
- data/test/gsl/bspline_test.rb +63 -0
- data/test/gsl/cdf_test.rb +1512 -0
- data/test/gsl/cheb_test.rb +80 -0
- data/test/gsl/combination_test.rb +100 -0
- data/test/gsl/complex_test.rb +20 -0
- data/test/gsl/const_test.rb +29 -0
- data/test/gsl/deriv_test.rb +62 -0
- data/test/gsl/dht_test.rb +79 -0
- data/test/gsl/diff_test.rb +53 -0
- data/test/gsl/eigen_test.rb +563 -0
- data/test/gsl/err_test.rb +23 -0
- data/test/gsl/fit_test.rb +101 -0
- data/test/gsl/histo_test.rb +14 -0
- data/test/gsl/integration_test.rb +274 -0
- data/test/gsl/interp_test.rb +27 -0
- data/test/gsl/linalg_test.rb +463 -0
- data/test/gsl/matrix_nmf_test.rb +37 -0
- data/test/gsl/matrix_test.rb +77 -0
- data/test/gsl/min_test.rb +89 -0
- data/test/gsl/monte_test.rb +77 -0
- data/test/gsl/multifit_test.rb +753 -0
- data/test/gsl/multimin_test.rb +157 -0
- data/test/gsl/multiroot_test.rb +135 -0
- data/test/gsl/multiset_test.rb +52 -0
- data/test/gsl/odeiv_test.rb +275 -0
- data/test/gsl/poly_test.rb +338 -0
- data/test/gsl/qrng_test.rb +94 -0
- data/test/gsl/quartic_test.rb +28 -0
- data/test/gsl/randist_test.rb +122 -0
- data/test/gsl/rng_test.rb +303 -0
- data/test/gsl/roots_test.rb +78 -0
- data/test/gsl/sf_test.rb +2079 -0
- data/test/gsl/stats_test.rb +122 -0
- data/test/gsl/sum_test.rb +69 -0
- data/test/gsl/tensor_test.rb +396 -0
- data/test/gsl/vector_test.rb +223 -0
- data/test/gsl/wavelet_test.rb +130 -0
- data/test/gsl_test.rb +321 -0
- data/test/test_helper.rb +42 -0
- metadata +107 -150
- data/setup.rb +0 -1585
- data/tests/blas/amax.rb +0 -14
- data/tests/blas/asum.rb +0 -16
- data/tests/blas/axpy.rb +0 -25
- data/tests/blas/copy.rb +0 -23
- data/tests/blas/dot.rb +0 -23
- data/tests/bspline.rb +0 -53
- data/tests/cdf.rb +0 -1388
- data/tests/cheb.rb +0 -112
- data/tests/combination.rb +0 -123
- data/tests/complex.rb +0 -17
- data/tests/const.rb +0 -24
- data/tests/deriv.rb +0 -85
- data/tests/dht/dht1.rb +0 -17
- data/tests/dht/dht2.rb +0 -23
- data/tests/dht/dht3.rb +0 -23
- data/tests/dht/dht4.rb +0 -23
- data/tests/diff.rb +0 -78
- data/tests/eigen/eigen.rb +0 -220
- data/tests/eigen/gen.rb +0 -105
- data/tests/eigen/genherm.rb +0 -66
- data/tests/eigen/gensymm.rb +0 -68
- data/tests/eigen/nonsymm.rb +0 -53
- data/tests/eigen/nonsymmv.rb +0 -53
- data/tests/eigen/symm-herm.rb +0 -74
- data/tests/err.rb +0 -58
- data/tests/fit.rb +0 -124
- data/tests/gsl_test.rb +0 -118
- data/tests/gsl_test2.rb +0 -110
- data/tests/histo.rb +0 -12
- data/tests/integration/integration1.rb +0 -72
- data/tests/integration/integration2.rb +0 -71
- data/tests/integration/integration3.rb +0 -71
- data/tests/integration/integration4.rb +0 -71
- data/tests/interp.rb +0 -45
- data/tests/linalg/HH.rb +0 -64
- data/tests/linalg/LU.rb +0 -47
- data/tests/linalg/QR.rb +0 -77
- data/tests/linalg/SV.rb +0 -24
- data/tests/linalg/TDN.rb +0 -116
- data/tests/linalg/TDS.rb +0 -122
- data/tests/linalg/bidiag.rb +0 -73
- data/tests/linalg/cholesky.rb +0 -20
- data/tests/linalg/linalg.rb +0 -158
- data/tests/matrix/matrix_complex_test.rb +0 -36
- data/tests/matrix/matrix_nmf_test.rb +0 -39
- data/tests/matrix/matrix_test.rb +0 -48
- data/tests/min.rb +0 -99
- data/tests/monte/miser.rb +0 -31
- data/tests/monte/vegas.rb +0 -45
- data/tests/multifit/test_2dgauss.rb +0 -112
- data/tests/multifit/test_brown.rb +0 -90
- data/tests/multifit/test_enso.rb +0 -246
- data/tests/multifit/test_filip.rb +0 -155
- data/tests/multifit/test_gauss.rb +0 -97
- data/tests/multifit/test_longley.rb +0 -110
- data/tests/multifit/test_multifit.rb +0 -52
- data/tests/multimin.rb +0 -139
- data/tests/multiroot.rb +0 -131
- data/tests/multiset.rb +0 -52
- data/tests/narray/blas_dnrm2.rb +0 -20
- data/tests/odeiv.rb +0 -353
- data/tests/poly/poly.rb +0 -290
- data/tests/poly/special.rb +0 -65
- data/tests/qrng.rb +0 -131
- data/tests/quartic.rb +0 -29
- data/tests/randist.rb +0 -134
- data/tests/rng.rb +0 -305
- data/tests/roots.rb +0 -76
- data/tests/run-test.sh +0 -17
- data/tests/sf/gsl_test_sf.rb +0 -249
- data/tests/sf/test_airy.rb +0 -83
- data/tests/sf/test_bessel.rb +0 -306
- data/tests/sf/test_coulomb.rb +0 -17
- data/tests/sf/test_dilog.rb +0 -25
- data/tests/sf/test_gamma.rb +0 -209
- data/tests/sf/test_hyperg.rb +0 -356
- data/tests/sf/test_legendre.rb +0 -227
- data/tests/sf/test_mathieu.rb +0 -59
- data/tests/sf/test_mode.rb +0 -19
- data/tests/sf/test_sf.rb +0 -839
- data/tests/stats.rb +0 -174
- data/tests/stats_mt.rb +0 -16
- data/tests/sum.rb +0 -98
- data/tests/sys.rb +0 -323
- data/tests/tensor.rb +0 -419
- data/tests/vector/vector_complex_test.rb +0 -101
- data/tests/vector/vector_test.rb +0 -141
- data/tests/wavelet.rb +0 -142
@@ -0,0 +1,223 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class VectorTest < GSL::TestCase
|
4
|
+
|
5
|
+
def test_get
|
6
|
+
v = GSL::Vector::Int.indgen(5)
|
7
|
+
assert_equal GSL::Vector::Int[3, 1, 2], v.get([3, 1, 2])
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_addsub
|
11
|
+
a = GSL::Vector::Int[2, 5, 4]
|
12
|
+
b = GSL::Vector::Int[10, 30, 20]
|
13
|
+
c = GSL::Vector::Int[12, 35, 24]
|
14
|
+
d = GSL::Vector::Int[8, 25, 16]
|
15
|
+
|
16
|
+
assert_equal c, a + b
|
17
|
+
assert_equal d, b - a
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_collect
|
21
|
+
v = GSL::Vector::Int.indgen(5)
|
22
|
+
u = GSL::Vector::Int[0, 1, 4, 9, 16]
|
23
|
+
|
24
|
+
assert_equal u, v.collect { |val| val * val }
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_ispos_neg
|
28
|
+
v = GSL::Vector::Int.indgen(5)
|
29
|
+
assert_equal 0, v.ispos
|
30
|
+
assert_equal false, v.ispos?
|
31
|
+
assert_equal 0, v.isneg
|
32
|
+
assert_equal false, v.isneg?
|
33
|
+
|
34
|
+
v += 1
|
35
|
+
assert_equal 1, v.ispos
|
36
|
+
assert_equal true, v.ispos?
|
37
|
+
assert_equal 0, v.isneg
|
38
|
+
assert_equal false, v.isneg?
|
39
|
+
|
40
|
+
v -= 100
|
41
|
+
assert_equal 0, v.ispos
|
42
|
+
assert_equal false, v.ispos?
|
43
|
+
assert_equal 1, v.isneg
|
44
|
+
assert_equal true, v.isneg?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_isnonneg
|
48
|
+
v = GSL::Vector::Int.indgen(5)
|
49
|
+
assert_equal 1, v.isnonneg
|
50
|
+
assert_equal true, v.isnonneg?
|
51
|
+
assert_equal 0, v.isneg
|
52
|
+
assert_equal false, v.isneg?
|
53
|
+
|
54
|
+
v -= 100
|
55
|
+
assert_equal 0, v.isnonneg
|
56
|
+
assert_equal false, v.isnonneg?
|
57
|
+
assert_equal 1, v.isneg
|
58
|
+
assert_equal true, v.isneg?
|
59
|
+
|
60
|
+
v += 200
|
61
|
+
assert_equal 1, v.isnonneg
|
62
|
+
assert_equal true, v.isnonneg?
|
63
|
+
assert_equal 1, v.ispos
|
64
|
+
assert_equal true, v.ispos?
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_subvector
|
68
|
+
v = GSL::Vector::Int.indgen(12)
|
69
|
+
|
70
|
+
vv = v.subvector
|
71
|
+
assert_not_equal v.object_id, vv.object_id
|
72
|
+
assert_equal v.subvector, v
|
73
|
+
|
74
|
+
vv = v.subvector(3)
|
75
|
+
assert_equal [0, 1, 2], vv.to_a
|
76
|
+
assert_nothing_raised('subvector(-1)') { v.subvector(-1) }
|
77
|
+
|
78
|
+
vv = v.subvector(-1)
|
79
|
+
assert_equal [11], vv.to_a
|
80
|
+
|
81
|
+
vv = v.subvector(-2)
|
82
|
+
assert_equal [10, 11], vv.to_a
|
83
|
+
assert_raises(RangeError) { v.subvector(-13) }
|
84
|
+
|
85
|
+
vv = v.subvector(2, 3)
|
86
|
+
assert_equal [2, 3, 4], vv.to_a
|
87
|
+
|
88
|
+
vv = v.subvector(-4, 3)
|
89
|
+
assert_equal [8, 9, 10], vv.to_a
|
90
|
+
assert_nothing_raised('subvector(-4, -3)') { v.subvector(-4, -3) }
|
91
|
+
|
92
|
+
vv = v.subvector(-4, -3)
|
93
|
+
assert_equal [8, 7, 6], vv.to_a
|
94
|
+
assert_raises(GSL::ERROR::EINVAL) { v.subvector(-11, -3) }
|
95
|
+
|
96
|
+
vv = v.subvector(1, 3, 4)
|
97
|
+
assert_equal [1, 4, 7, 10], vv.to_a
|
98
|
+
|
99
|
+
{
|
100
|
+
# ( range ) => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
101
|
+
( 1.. 3) => [ 1, 2, 3 ],
|
102
|
+
( 1... 3) => [ 1, 2 ],
|
103
|
+
( 3.. 1) => [ 3, 2, 1 ],
|
104
|
+
( 3... 1) => [ 3, 2 ],
|
105
|
+
(-7.. 9) => [ 5, 6, 7, 8, 9 ],
|
106
|
+
(-7... 9) => [ 5, 6, 7, 8 ],
|
107
|
+
( 4.. -3) => [ 4, 5, 6, 7, 8, 9 ],
|
108
|
+
( 4...-3) => [ 4, 5, 6, 7, 8 ],
|
109
|
+
( 2.. -2) => [ 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
|
110
|
+
( 2...-2) => [ 2, 3, 4, 5, 6, 7, 8, 9 ],
|
111
|
+
(-2.. 2) => [ 10, 9, 8, 7, 6, 5, 4, 3, 2 ],
|
112
|
+
(-2... 2) => [ 10, 9, 8, 7, 6, 5, 4, 3 ],
|
113
|
+
(-3.. -1) => [ 9, 10, 11],
|
114
|
+
(-3...-1) => [ 9, 10 ],
|
115
|
+
(-1.. -3) => [ 11, 10, 9],
|
116
|
+
(-1...-3) => [ 11, 10 ]
|
117
|
+
}.each { |r, x|
|
118
|
+
assert_nothing_raised("subvector(#{r})") { v.subvector(r) }
|
119
|
+
assert_equal x, v.subvector(r).to_a, "subvector(#{r})"
|
120
|
+
}
|
121
|
+
|
122
|
+
{
|
123
|
+
# [( range ), s] => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
124
|
+
[( 1.. 6), 2] => [ 1, 3, 5 ],
|
125
|
+
[( 1... 6), 2] => [ 1, 3, 5 ],
|
126
|
+
[( 0.. 6), 3] => [0, 3, 6 ],
|
127
|
+
[( 0... 6), 3] => [0, 3 ]
|
128
|
+
}.each { |(r, s), x|
|
129
|
+
assert_nothing_raised("subvector(#{r},#{s})") { v.subvector(r) }
|
130
|
+
assert_equal x, v.subvector(r,s).to_a, "subvector(#{r},#{s})"
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_complex_get
|
135
|
+
v = GSL::Vector::Complex.indgen(5)
|
136
|
+
assert_equal GSL::Vector::Complex[[3, 0], [1, 0], [2, 0]], v.get([3, 1, 2])
|
137
|
+
end
|
138
|
+
|
139
|
+
def test_complex_addsub
|
140
|
+
a = GSL::Vector::Complex[[-2, 5], [ 4, -1]]
|
141
|
+
b = GSL::Vector::Complex[[10, 30], [20, 40]]
|
142
|
+
c = GSL::Vector::Complex[[ 8, 35], [24, 39]]
|
143
|
+
d = GSL::Vector::Complex[[12, 25], [16, 41]]
|
144
|
+
|
145
|
+
assert_equal c, a + b
|
146
|
+
assert_equal d, b - a
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_complex_collect
|
150
|
+
v = GSL::Vector::Complex.indgen(5)
|
151
|
+
u = GSL::Vector::Complex[[0, 0], [1, 0], [4, 0], [9, 0], [16, 0]]
|
152
|
+
|
153
|
+
assert_equal u, v.collect { |val| val * val }
|
154
|
+
end
|
155
|
+
|
156
|
+
def test_complex_subvector
|
157
|
+
v = GSL::Vector::Complex.indgen(12)
|
158
|
+
|
159
|
+
vv = v.subvector
|
160
|
+
assert_not_equal v.object_id, vv.object_id
|
161
|
+
assert_equal v.subvector, v
|
162
|
+
|
163
|
+
vv = v.subvector(3)
|
164
|
+
assert_equal [0, 0, 1, 0, 2, 0], vv.to_a
|
165
|
+
assert_nothing_raised('subvector(-1)') { v.subvector(-1) }
|
166
|
+
|
167
|
+
vv = v.subvector(-1)
|
168
|
+
assert_equal [11, 0], vv.to_a
|
169
|
+
|
170
|
+
vv = v.subvector(-2)
|
171
|
+
assert_equal [10, 0, 11, 0], vv.to_a
|
172
|
+
assert_raises(RangeError) { v.subvector(-13) }
|
173
|
+
|
174
|
+
vv = v.subvector(2, 3)
|
175
|
+
assert_equal [2, 0, 3, 0, 4, 0], vv.to_a
|
176
|
+
|
177
|
+
vv = v.subvector(-4, 3)
|
178
|
+
assert_equal [8, 0, 9, 0, 10, 0], vv.to_a
|
179
|
+
assert_nothing_raised('subvector(-4, -3)') { v.subvector(-4, -3) }
|
180
|
+
|
181
|
+
vv = v.subvector(-4, -3)
|
182
|
+
assert_equal [8, 0, 7, 0, 6, 0], vv.to_a
|
183
|
+
assert_raises(GSL::ERROR::EINVAL) { v.subvector(-11, -3) }
|
184
|
+
|
185
|
+
vv = v.subvector(1, 3, 4)
|
186
|
+
assert_equal [1, 0, 4, 0, 7, 0, 10, 0], vv.to_a
|
187
|
+
|
188
|
+
{
|
189
|
+
# ( range ) => [0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0]
|
190
|
+
( 1.. 3) => [ 1, 0, 2, 0, 3, 0 ],
|
191
|
+
( 1... 3) => [ 1, 0, 2, 0, ],
|
192
|
+
( 3.. 1) => [ 3, 0, 2, 0, 1, 0 ],
|
193
|
+
( 3... 1) => [ 3, 0, 2, 0 ],
|
194
|
+
(-7.. 9) => [ 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 ],
|
195
|
+
(-7... 9) => [ 5, 0, 6, 0, 7, 0, 8, 0 ],
|
196
|
+
( 4.. -3) => [ 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 ],
|
197
|
+
( 4...-3) => [ 4, 0, 5, 0, 6, 0, 7, 0, 8, 0 ],
|
198
|
+
( 2.. -2) => [ 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0 ],
|
199
|
+
( 2...-2) => [ 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0 ],
|
200
|
+
(-2.. 2) => [ 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0, 2, 0 ],
|
201
|
+
(-2... 2) => [ 10, 0, 9, 0, 8, 0, 7, 0, 6, 0, 5, 0, 4, 0, 3, 0 ],
|
202
|
+
(-3.. -1) => [ 9, 0, 10, 0, 11, 0],
|
203
|
+
(-3...-1) => [ 9, 0, 10, 0 ],
|
204
|
+
(-1.. -3) => [ 11, 0, 10, 0, 9, 0],
|
205
|
+
(-1...-3) => [ 11, 0, 10, 0 ]
|
206
|
+
}.each { |r, x|
|
207
|
+
assert_nothing_raised("subvector(#{r})") { v.subvector(r) }
|
208
|
+
assert_equal x, v.subvector(r).to_a, "subvector(#{r})"
|
209
|
+
}
|
210
|
+
|
211
|
+
{
|
212
|
+
# [( range ), s] => [0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0]
|
213
|
+
[( 1.. 6), 2] => [ 1, 0, 3, 0, 5, 0 ],
|
214
|
+
[( 1... 6), 2] => [ 1, 0, 3, 0, 5, 0 ],
|
215
|
+
[( 0.. 6), 3] => [0, 0, 3, 0, 6, 0 ],
|
216
|
+
[( 0... 6), 3] => [0, 0, 3, 0 ]
|
217
|
+
}.each { |(r, s), x|
|
218
|
+
assert_nothing_raised("subvector(#{r},#{s})") { v.subvector(r) }
|
219
|
+
assert_equal x, v.subvector(r,s).to_a, "subvector(#{r},#{s})"
|
220
|
+
}
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class WaveletTest < GSL::TestCase
|
4
|
+
|
5
|
+
MEMBERS = [309, 307, 305, 303, 301, 208, 206, 204, 202, 105, 103]
|
6
|
+
|
7
|
+
def _urand
|
8
|
+
x = 1
|
9
|
+
x = (1103515245 * x + 12345) & 0x7fffffff
|
10
|
+
x / 2147483648.0
|
11
|
+
end
|
12
|
+
|
13
|
+
def _test_1d(n, stride, type, member)
|
14
|
+
nn = n * stride
|
15
|
+
data = GSL::Vector.alloc(nn)
|
16
|
+
nn.times { |i| data[i] = 12345.0 + i }
|
17
|
+
|
18
|
+
v1 = data.view_with_stride(0, stride, n)
|
19
|
+
n.times { |i| v1[i] = _urand }
|
20
|
+
|
21
|
+
v2 = GSL::Vector.alloc(n)
|
22
|
+
GSL::Vector.memcpy(v2, v1)
|
23
|
+
|
24
|
+
vdelta = GSL::Vector.alloc(n)
|
25
|
+
|
26
|
+
work = GSL::Wavelet::Workspace.alloc(n)
|
27
|
+
w = GSL::Wavelet.alloc(type, member)
|
28
|
+
w.transform_forward(v2, work)
|
29
|
+
w.transform_inverse(v2, work)
|
30
|
+
|
31
|
+
n.times { |i| vdelta[i] = (v1[i] - v2[i]).abs }
|
32
|
+
|
33
|
+
i = vdelta.max_index
|
34
|
+
x1, x2 = v1[i], v2[i]
|
35
|
+
|
36
|
+
refute((x2 - x1).abs > n * 1e-15,
|
37
|
+
"#{w.name}(#{member}), n = #{n}, stride = #{stride}, maxerr = #{(x2 - x1).abs}")
|
38
|
+
|
39
|
+
assert((0...nn).all? { |j| j % stride == 0 || data[j] == 12345.0 + j },
|
40
|
+
"#{w.name}(#{member}) other data untouched, n = #{n}, stride = #{stride}") if stride > 1
|
41
|
+
end
|
42
|
+
|
43
|
+
def _test_2d(n, tda, t, member, type)
|
44
|
+
nn = n * tda
|
45
|
+
data = GSL::Vector.alloc(nn)
|
46
|
+
nn.times { |i| data[i] = 12345.0 + i }
|
47
|
+
|
48
|
+
m1 = data.matrix_view_with_tda(n, n, tda)
|
49
|
+
n.times { |i| n.times { |j| m1.set(i, j, _urand) } }
|
50
|
+
|
51
|
+
m2 = GSL::Matrix.alloc(n, n)
|
52
|
+
GSL::Matrix.memcpy(m2, m1)
|
53
|
+
|
54
|
+
mdelta = GSL::Matrix.alloc(n, n)
|
55
|
+
|
56
|
+
work = GSL::Wavelet::Workspace.alloc(n)
|
57
|
+
w = GSL::Wavelet.alloc(t, member)
|
58
|
+
|
59
|
+
typename = case type
|
60
|
+
when 1
|
61
|
+
GSL::Wavelet2d.transform_matrix_forward(w, m2, work)
|
62
|
+
GSL::Wavelet2d.transform_matrix_inverse(w, m2, work)
|
63
|
+
'standard'
|
64
|
+
when 2
|
65
|
+
GSL::Wavelet2d.nstransform_matrix_forward(w, m2, work)
|
66
|
+
GSL::Wavelet2d.nstransform_matrix_inverse(w, m2, work)
|
67
|
+
'nonstd'
|
68
|
+
end
|
69
|
+
|
70
|
+
n.times { |i| n.times { |j| mdelta.set(i, j, (m1[i, j] - m2[i, j]).abs) } }
|
71
|
+
|
72
|
+
i, j = mdelta.max_index
|
73
|
+
x1, x2 = m1[i, j], m1[i, j]
|
74
|
+
|
75
|
+
refute((x2 - x1).abs > n * 1e-15,
|
76
|
+
"#{w.name}(#{member})-2d #{typename}, n = #{n}, tda = #{tda}, maxerr = #{(x2 - x1).abs}")
|
77
|
+
|
78
|
+
assert((0...n).to_a.product((n...tda).to_a).all? { |k, l| data[k * tda + l] == 12345.0 + k * tda + l },
|
79
|
+
"#{w.name}(#{member})-2d #{typename} other data untouched, n = #{n}, tda = #{tda}") if tda > n
|
80
|
+
end
|
81
|
+
|
82
|
+
def _each_pow(n = 14)
|
83
|
+
n.times { |i| yield 2 ** i }
|
84
|
+
end
|
85
|
+
|
86
|
+
def _each_n(n = 9, m = 4)
|
87
|
+
n.times { |i| yield m + 2 * i }
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_1d_bspline
|
91
|
+
_each_pow { |n| MEMBERS.each { |m| _test_1d(n, 1, 'bspline', m) } }
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_1d_bspline_centered
|
95
|
+
_each_pow { |n| MEMBERS.each { |m| _test_1d(n, 1, 'bspline_centered', m) } }
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_1d_daubechies
|
99
|
+
_each_pow { |n| _each_n { |i| _test_1d(n, 1, 'daubechies', i) } }
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_1d_daubechies_centered
|
103
|
+
_each_pow { |n| _each_n { |i|_test_1d(n, 1, 'daubechies_centered', i) } }
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_1d_haar
|
107
|
+
_each_pow { |n| _test_1d(n, 1, 'haar', 2) }
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_1d_haar_centered
|
111
|
+
_each_pow { |n| _test_1d(n, 1, 'haar_centered', 2) }
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_2d_bspline_standard
|
115
|
+
_each_pow(6) { |n| MEMBERS.each { |m| _test_2d(n, n, 'bspline', m, 1) } }
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_2d_bspline_centered_standard
|
119
|
+
_each_pow(6) { |n| MEMBERS.each { |m| _test_2d(n, n, 'bspline_centered', m, 1) } }
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_2d_bspline_nonstd
|
123
|
+
_each_pow(6) { |n| MEMBERS.each { |m| _test_2d(n, n, 'bspline', m, 2) } }
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_2d_bspline_centered_nonstd
|
127
|
+
_each_pow(6) { |n| MEMBERS.each { |m| _test_2d(n, n, 'bspline_centered', m, 2) } }
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
data/test/gsl_test.rb
ADDED
@@ -0,0 +1,321 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class GSLTest < GSL::TestCase
|
4
|
+
|
5
|
+
def test_expm1
|
6
|
+
y = GSL.expm1(0.0)
|
7
|
+
y_expected = 0.0
|
8
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(0.0)'
|
9
|
+
|
10
|
+
y = GSL.expm1(1e-10)
|
11
|
+
y_expected = 1.000000000050000000002e-10
|
12
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(1e-10)'
|
13
|
+
|
14
|
+
y = GSL.expm1(-1e-10)
|
15
|
+
y_expected = -9.999999999500000000017e-11
|
16
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(-1e-10)'
|
17
|
+
|
18
|
+
y = GSL.expm1(0.1)
|
19
|
+
y_expected = 0.1051709180756476248117078264902
|
20
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(0.1)'
|
21
|
+
|
22
|
+
y = GSL.expm1(-0.1)
|
23
|
+
y_expected = -0.09516258196404042683575094055356
|
24
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(-0.1)'
|
25
|
+
|
26
|
+
y = GSL.expm1(10.0)
|
27
|
+
y_expected = 22025.465794806716516957900645284
|
28
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(10.0)'
|
29
|
+
|
30
|
+
y = GSL.expm1(-10.0)
|
31
|
+
y_expected = -0.99995460007023751514846440848444
|
32
|
+
assert_rel y, y_expected, 1e-15, 'GSL.expm1(-10.0)'
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_log1p
|
36
|
+
y = GSL.log1p(0.0)
|
37
|
+
y_expected = 0.0
|
38
|
+
assert_rel y, y_expected, 1e-15, 'GSL.log1p(0.0)'
|
39
|
+
|
40
|
+
y = GSL.log1p(1e-10)
|
41
|
+
y_expected = 9.9999999995000000000333333333308e-11
|
42
|
+
assert_rel y, y_expected, 1e-15, 'GSL.log1p(1e-10)'
|
43
|
+
|
44
|
+
y = GSL.log1p(0.1)
|
45
|
+
y_expected = 0.095310179804324860043952123280765
|
46
|
+
assert_rel y, y_expected, 1e-15, 'GSL.log1p(0.1)'
|
47
|
+
|
48
|
+
y = GSL.log1p(10.0)
|
49
|
+
y_expected = 2.3978952727983705440619435779651
|
50
|
+
assert_rel y, y_expected, 1e-15, 'GSL.log1p(10.0)'
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_hypot
|
54
|
+
y = GSL.hypot(0.0, 0.0)
|
55
|
+
y_expected = 0.0
|
56
|
+
assert_rel y, y_expected, 1e-15, 'GSL.hypot(0.0, 0.0)'
|
57
|
+
|
58
|
+
y = GSL.hypot(1e-10, 1e-10)
|
59
|
+
y_expected = 1.414213562373095048801688e-10
|
60
|
+
assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e-10, 1e-10)'
|
61
|
+
|
62
|
+
y = GSL.hypot(1e-38, 1e-38)
|
63
|
+
y_expected = 1.414213562373095048801688e-38
|
64
|
+
assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e-38, 1e-38)'
|
65
|
+
|
66
|
+
y = GSL.hypot(1e-10, -1.0)
|
67
|
+
y_expected = 1.000000000000000000005
|
68
|
+
assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e-10, -1)'
|
69
|
+
|
70
|
+
y = GSL.hypot(-1.0, 1e-10)
|
71
|
+
y_expected = 1.000000000000000000005
|
72
|
+
assert_rel y, y_expected, 1e-15, 'GSL.hypot(-1, 1e-10)'
|
73
|
+
|
74
|
+
#y = GSL.hypot(1e307, 1e301)
|
75
|
+
#y_expected = 1.000000000000499999999999e307
|
76
|
+
#assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e307, 1e301)'
|
77
|
+
|
78
|
+
#y = GSL.hypot(1e301, 1e307)
|
79
|
+
#y_expected = 1.000000000000499999999999e307
|
80
|
+
#assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e301, 1e307)'
|
81
|
+
|
82
|
+
#y = GSL.hypot(1e307, 1e307)
|
83
|
+
#y_expected = 1.414213562373095048801688e307
|
84
|
+
#assert_rel y, y_expected, 1e-15, 'GSL.hypot(1e307, 1e307)'
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_acosh
|
88
|
+
y = GSL.acosh(1.0)
|
89
|
+
y_expected = 0.0
|
90
|
+
assert_rel y, y_expected, 1e-15, 'GSL.acosh(1.0)'
|
91
|
+
|
92
|
+
y = GSL.acosh(1.1)
|
93
|
+
y_expected = 4.435682543851151891329110663525e-1
|
94
|
+
assert_rel y, y_expected, 1e-15, 'GSL.acosh(1.1)'
|
95
|
+
|
96
|
+
y = GSL.acosh(10.0)
|
97
|
+
y_expected = 2.9932228461263808979126677137742e0
|
98
|
+
assert_rel y, y_expected, 1e-15, 'GSL.acosh(10.0)'
|
99
|
+
|
100
|
+
y = GSL.acosh(1e10)
|
101
|
+
y_expected = 2.3718998110500402149594646668302e1
|
102
|
+
assert_rel y, y_expected, 1e-15, 'GSL.acosh(1e10)'
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_asinh
|
106
|
+
y = GSL.asinh(0.0)
|
107
|
+
y_expected = 0.0
|
108
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(0.0)'
|
109
|
+
|
110
|
+
y = GSL.asinh(1e-10)
|
111
|
+
y_expected = 9.9999999999999999999833333333346e-11
|
112
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(1e-10)'
|
113
|
+
|
114
|
+
y = GSL.asinh(-1e-10)
|
115
|
+
y_expected = -9.9999999999999999999833333333346e-11
|
116
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(1e-10)'
|
117
|
+
|
118
|
+
y = GSL.asinh(0.1)
|
119
|
+
y_expected = 9.983407889920756332730312470477e-2
|
120
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(0.1)'
|
121
|
+
|
122
|
+
y = GSL.asinh(-0.1)
|
123
|
+
y_expected = -9.983407889920756332730312470477e-2
|
124
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(-0.1)'
|
125
|
+
|
126
|
+
y = GSL.asinh(1.0)
|
127
|
+
y_expected = 8.8137358701954302523260932497979e-1
|
128
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(1.0)'
|
129
|
+
|
130
|
+
y = GSL.asinh(-1.0)
|
131
|
+
y_expected = -8.8137358701954302523260932497979e-1
|
132
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(-1.0)'
|
133
|
+
|
134
|
+
y = GSL.asinh(10.0)
|
135
|
+
y_expected = 2.9982229502979697388465955375965e0
|
136
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(10)'
|
137
|
+
|
138
|
+
y = GSL.asinh(-10.0)
|
139
|
+
y_expected = -2.9982229502979697388465955375965e0
|
140
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(-10)'
|
141
|
+
|
142
|
+
y = GSL.asinh(1e10)
|
143
|
+
y_expected = 2.3718998110500402149599646668302e1
|
144
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(1e10)'
|
145
|
+
|
146
|
+
y = GSL.asinh(-1e10)
|
147
|
+
y_expected = -2.3718998110500402149599646668302e1
|
148
|
+
assert_rel y, y_expected, 1e-15, 'GSL.asinh(-1e10)'
|
149
|
+
end
|
150
|
+
|
151
|
+
def test_atanh
|
152
|
+
y = GSL.atanh(0.0)
|
153
|
+
y_expected = 0.0
|
154
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(0.0)'
|
155
|
+
|
156
|
+
y = GSL.atanh(1e-20)
|
157
|
+
y_expected = 1e-20
|
158
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(1e-20)'
|
159
|
+
|
160
|
+
y = GSL.atanh(-1e-20)
|
161
|
+
y_expected = -1e-20
|
162
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(-1e-20)'
|
163
|
+
|
164
|
+
y = GSL.atanh(0.1)
|
165
|
+
y_expected = 1.0033534773107558063572655206004e-1
|
166
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(0.1)'
|
167
|
+
|
168
|
+
y = GSL.atanh(-0.1)
|
169
|
+
y_expected = -1.0033534773107558063572655206004e-1
|
170
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(-0.1)'
|
171
|
+
|
172
|
+
y = GSL.atanh(0.9)
|
173
|
+
y_expected = 1.4722194895832202300045137159439e0
|
174
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(0.9)'
|
175
|
+
|
176
|
+
y = GSL.atanh(-0.9)
|
177
|
+
y_expected = -1.4722194895832202300045137159439e0
|
178
|
+
assert_rel y, y_expected, 1e-15, 'GSL.atanh(0.9)'
|
179
|
+
end
|
180
|
+
|
181
|
+
def test_pow_int
|
182
|
+
y = GSL.pow_2(-3.14)
|
183
|
+
y_expected = GSL.pow(-3.14, 2.0)
|
184
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_2(-3.14)'
|
185
|
+
|
186
|
+
y = GSL.pow_3(-3.14)
|
187
|
+
y_expected = GSL.pow(-3.14, 3.0)
|
188
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_3(-3.14)'
|
189
|
+
|
190
|
+
y = GSL.pow_4(-3.14)
|
191
|
+
y_expected = GSL.pow(-3.14, 4.0)
|
192
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_4(-3.14)'
|
193
|
+
|
194
|
+
y = GSL.pow_5(-3.14)
|
195
|
+
y_expected = GSL.pow(-3.14, 5.0)
|
196
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_5(-3.14)'
|
197
|
+
|
198
|
+
y = GSL.pow_6(-3.14)
|
199
|
+
y_expected = GSL.pow(-3.14, 6.0)
|
200
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_6(-3.14)'
|
201
|
+
|
202
|
+
y = GSL.pow_7(-3.14)
|
203
|
+
y_expected = GSL.pow(-3.14, 7.0)
|
204
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_7(-3.14)'
|
205
|
+
|
206
|
+
y = GSL.pow_8(-3.14)
|
207
|
+
y_expected = GSL.pow(-3.14, 8.0)
|
208
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_8(-3.14)'
|
209
|
+
|
210
|
+
y = GSL.pow_9(-3.14)
|
211
|
+
y_expected = GSL.pow(-3.14, 9.0)
|
212
|
+
assert_rel y, y_expected, 1e-15, 'GSL.pow_9(-3.14)'
|
213
|
+
|
214
|
+
-9.upto(9) { |n|
|
215
|
+
y = GSL.pow_int(-3.14, n)
|
216
|
+
y_expected = GSL.pow(-3.14, n)
|
217
|
+
assert_rel y, y_expected, 1e-15, "GSL.pow_n(-3.14,#{n})"
|
218
|
+
}
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_ldexp
|
222
|
+
y = GSL.ldexp(GSL::M_PI, -2)
|
223
|
+
y_expected = GSL::M_PI_4
|
224
|
+
assert_rel y, y_expected, 1e-15, 'GSL.ldexp(pi,-2)'
|
225
|
+
|
226
|
+
y = GSL.ldexp(1.0, 2)
|
227
|
+
y_expected = 4.000000
|
228
|
+
assert_rel y, y_expected, 1e-15, 'GSL.ldexp(1.0,2)'
|
229
|
+
|
230
|
+
y = GSL.ldexp(0.0, 2)
|
231
|
+
y_expected = 0.0
|
232
|
+
assert_rel y, y_expected, 1e-15, 'GSL.ldexp(0.0,2)'
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_frexp
|
236
|
+
y, e = GSL.frexp(GSL::M_PI)
|
237
|
+
y_expected = GSL::M_PI_4
|
238
|
+
e_expected = 2
|
239
|
+
assert_rel y, y_expected, 1e-15, 'GSL.frexp(pi) fraction'
|
240
|
+
assert_int e, e_expected, 'GSL.frexp(pi) exponent'
|
241
|
+
|
242
|
+
y, e = GSL.frexp(2.0)
|
243
|
+
y_expected = 0.5
|
244
|
+
e_expected = 2
|
245
|
+
assert_rel y, y_expected, 1e-15, 'GSL.frexp(2.0) fraction'
|
246
|
+
assert_int e, e_expected, 'GSL.frexp(2.0) exponent'
|
247
|
+
|
248
|
+
y, e = GSL.frexp(1.0 / 4.0)
|
249
|
+
y_expected = 0.5
|
250
|
+
e_expected = -1
|
251
|
+
assert_rel y, y_expected, 1e-15, 'GSL.frexp(0.25) fraction'
|
252
|
+
assert_int e, e_expected, 'GSL.frexp(0.25) exponent'
|
253
|
+
|
254
|
+
y, e = GSL.frexp(1.0 / 4.0 - 4.0 * GSL::DBL_EPSILON)
|
255
|
+
y_expected = 0.999999999999996447
|
256
|
+
e_expected = -2
|
257
|
+
assert_rel y, y_expected, 1e-15, 'GSL.frexp(0.25-eps) fraction'
|
258
|
+
assert_int e, e_expected, 'GSL.frexp(0.25-eps) exponent'
|
259
|
+
end
|
260
|
+
|
261
|
+
def test_gsl
|
262
|
+
x = GSL::M_PI
|
263
|
+
y = 22.0 / 7.0
|
264
|
+
|
265
|
+
10.times { |i|
|
266
|
+
tol = GSL.pow(10, -i)
|
267
|
+
res = GSL.fcmp(x, y, tol)
|
268
|
+
assert_int res, i >= 4 ? -1 : 0, "GSL.fcmp(#{x},#{y},#{tol})"
|
269
|
+
|
270
|
+
res = GSL.fcmp(y, x, tol)
|
271
|
+
assert_int res, i >= 4 ? 1 : 0, "GSL.fcmp(#{y},#{x},#{tol})"
|
272
|
+
}
|
273
|
+
|
274
|
+
zero = 0.0
|
275
|
+
one = 1.0
|
276
|
+
inf = Math.exp(1.0e10)
|
277
|
+
nan = inf / inf
|
278
|
+
|
279
|
+
s = GSL.isinf(zero)
|
280
|
+
assert_int s, 0, 'GSL.isinf(0)'
|
281
|
+
|
282
|
+
s = GSL.isinf(one)
|
283
|
+
assert_int s, 0, 'GSL.isinf(1)'
|
284
|
+
|
285
|
+
s = GSL.isinf(inf)
|
286
|
+
assert_int s, 1, 'GSL.isinf(inf)'
|
287
|
+
|
288
|
+
# Commented out 2008/Oct/17 by YT
|
289
|
+
# This test fails in (Darwin 9.5.0, gcc4.0.1):
|
290
|
+
# gsl_isinf() returns 1 for -inf
|
291
|
+
#s = GSL.isinf(-inf)
|
292
|
+
#assert_int s, -1, 'GSL.isinf(-inf)'
|
293
|
+
|
294
|
+
s = GSL.isinf(nan)
|
295
|
+
assert_int s, 0, 'GSL.isinf(nan)'
|
296
|
+
|
297
|
+
s = GSL.isnan(zero)
|
298
|
+
assert_int s, 0, 'GSL.isnan(0)'
|
299
|
+
|
300
|
+
s = GSL.isnan(one)
|
301
|
+
assert_int s, 0, 'GSL.isnan(1)'
|
302
|
+
s = GSL.isnan(inf)
|
303
|
+
assert_int s, 0, 'GSL.isnan(inf)'
|
304
|
+
|
305
|
+
s = GSL.isnan(nan)
|
306
|
+
assert_int s, 1, 'GSL.isnan(nan)'
|
307
|
+
|
308
|
+
s = GSL.finite(zero)
|
309
|
+
assert_int s, 1, 'GSL.finite(0)'
|
310
|
+
|
311
|
+
s = GSL.finite(one)
|
312
|
+
assert_int s, 1, 'GSL.finite(1)'
|
313
|
+
|
314
|
+
s = GSL.finite(inf)
|
315
|
+
assert_int s, 0, 'GSL.finite(inf)'
|
316
|
+
|
317
|
+
s = GSL.finite(nan)
|
318
|
+
assert_int s, 0, 'GSL.finite(nan)'
|
319
|
+
end
|
320
|
+
|
321
|
+
end
|