gsl4r 0.0.2 → 0.0.3
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/INSTALL +3 -8
- data/README +20 -3
- data/Rakefile +6 -0
- data/changelog +2 -0
- data/lib/b_t.rb +16 -0
- data/lib/gsl4r.rb +1 -1
- data/lib/gsl4r/block.rb +64 -21
- data/lib/gsl4r/complex.rb +20 -0
- data/lib/gsl4r/harness.rb +2 -2
- data/lib/gsl4r/util.rb +56 -21
- data/lib/gsl4r/vector.rb +328 -12
- data/lib/t.rb +19 -10
- data/test/README +6 -2
- data/test/block_class_test.rb +104 -0
- data/test/complex_test.rb +210 -210
- data/test/gsl_complex_tests_gen +0 -0
- data/test/gsl_complex_tests_gen.c +613 -613
- data/test/gsl_vector_tests_gen +0 -0
- data/test/gsl_vector_tests_gen.c +203 -0
- data/test/vector_class_test.rb +128 -0
- data/test/vector_test.rb +104 -0
- metadata +18 -5
Binary file
|
@@ -0,0 +1,203 @@
|
|
1
|
+
/* Auto generated by GSL4r::Vector::Harness */
|
2
|
+
#include <stdio.h>
|
3
|
+
#include "gsl/gsl_vector.h"
|
4
|
+
int main( int argc, char **argv )
|
5
|
+
{
|
6
|
+
puts("$: << File.join('..','lib')\nrequire 'test/unit'\nrequire 'test/unit/autorunner'\nrequire 'gsl4r/vector'\ninclude GSL4r::Vector\nclass VectorTests < Test::Unit::TestCase\n EPSILON = 5.0e-15");
|
7
|
+
/* c_test_gsl_vector_sub */
|
8
|
+
gsl_vector * v76;
|
9
|
+
v76 = gsl_vector_alloc(3);
|
10
|
+
gsl_vector_set(v76, 0, 1.0 ); gsl_vector_set(v76, 1, 2.0 ); gsl_vector_set(v76, 2, 3.0 );
|
11
|
+
gsl_vector * v77;
|
12
|
+
v77 = gsl_vector_alloc(3);
|
13
|
+
gsl_vector_set(v77, 0, 1.0 ); gsl_vector_set(v77, 1, 2.0 ); gsl_vector_set(v77, 2, 3.0 );
|
14
|
+
gsl_vector_sub(v76,v77);
|
15
|
+
puts("def test_gsl_vector_sub()");
|
16
|
+
puts(" v76 = GSL_Vector.create(3)");
|
17
|
+
puts(" v76.set( [1.0,2.0,3.0] )");
|
18
|
+
puts(" v77 = GSL_Vector.create(3)");
|
19
|
+
puts(" v77.set( [1.0,2.0,3.0] )");
|
20
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_sub(v76,v77)");
|
21
|
+
printf(" assert v76.values == ");
|
22
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v76,0),gsl_vector_get(v76,1),gsl_vector_get(v76,2));
|
23
|
+
puts("end");
|
24
|
+
/* c_test_gsl_vector_scale */
|
25
|
+
gsl_vector * v82;
|
26
|
+
v82 = gsl_vector_alloc(3);
|
27
|
+
gsl_vector_set(v82, 0, 1.0 ); gsl_vector_set(v82, 1, 2.0 ); gsl_vector_set(v82, 2, 3.0 );
|
28
|
+
double v83 = (double)2.0;
|
29
|
+
gsl_vector_scale(v82,v83);
|
30
|
+
puts("def test_gsl_vector_scale()");
|
31
|
+
puts(" v82 = GSL_Vector.create(3)");
|
32
|
+
puts(" v82.set( [1.0,2.0,3.0] )");
|
33
|
+
puts("");
|
34
|
+
puts(" v83 = 2.0");
|
35
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_scale(v82,v83)");
|
36
|
+
printf(" assert v82.values == ");
|
37
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v82,0),gsl_vector_get(v82,1),gsl_vector_get(v82,2));
|
38
|
+
puts("end");
|
39
|
+
/* c_test_gsl_vector_max_index */
|
40
|
+
gsl_vector * v87;
|
41
|
+
v87 = gsl_vector_alloc(3);
|
42
|
+
gsl_vector_set(v87, 0, 1.0 ); gsl_vector_set(v87, 1, 2.0 ); gsl_vector_set(v87, 2, 3.0 );
|
43
|
+
size_t c_r86;
|
44
|
+
c_r86 = gsl_vector_max_index(v87);
|
45
|
+
puts("def test_gsl_vector_max_index()");
|
46
|
+
puts(" v87 = GSL_Vector.create(3)");
|
47
|
+
puts(" v87.set( [1.0,2.0,3.0] )");
|
48
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_max_index(v87)");
|
49
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r86);
|
50
|
+
puts("end");
|
51
|
+
/* c_test_gsl_vector_isneg */
|
52
|
+
gsl_vector * v92;
|
53
|
+
v92 = gsl_vector_alloc(3);
|
54
|
+
gsl_vector_set(v92, 0, 1.0 ); gsl_vector_set(v92, 1, 2.0 ); gsl_vector_set(v92, 2, 3.0 );
|
55
|
+
int c_r91;
|
56
|
+
c_r91 = gsl_vector_isneg(v92);
|
57
|
+
puts("def test_gsl_vector_isneg()");
|
58
|
+
puts(" v92 = GSL_Vector.create(3)");
|
59
|
+
puts(" v92.set( [1.0,2.0,3.0] )");
|
60
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isneg(v92)");
|
61
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r91);
|
62
|
+
puts("end");
|
63
|
+
/* c_test_gsl_vector_mul */
|
64
|
+
gsl_vector * v78;
|
65
|
+
v78 = gsl_vector_alloc(3);
|
66
|
+
gsl_vector_set(v78, 0, 1.0 ); gsl_vector_set(v78, 1, 2.0 ); gsl_vector_set(v78, 2, 3.0 );
|
67
|
+
gsl_vector * v79;
|
68
|
+
v79 = gsl_vector_alloc(3);
|
69
|
+
gsl_vector_set(v79, 0, 1.0 ); gsl_vector_set(v79, 1, 2.0 ); gsl_vector_set(v79, 2, 3.0 );
|
70
|
+
gsl_vector_mul(v78,v79);
|
71
|
+
puts("def test_gsl_vector_mul()");
|
72
|
+
puts(" v78 = GSL_Vector.create(3)");
|
73
|
+
puts(" v78.set( [1.0,2.0,3.0] )");
|
74
|
+
puts(" v79 = GSL_Vector.create(3)");
|
75
|
+
puts(" v79.set( [1.0,2.0,3.0] )");
|
76
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_mul(v78,v79)");
|
77
|
+
printf(" assert v78.values == ");
|
78
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v78,0),gsl_vector_get(v78,1),gsl_vector_get(v78,2));
|
79
|
+
puts("end");
|
80
|
+
/* c_test_gsl_vector_add_constant */
|
81
|
+
gsl_vector * v84;
|
82
|
+
v84 = gsl_vector_alloc(3);
|
83
|
+
gsl_vector_set(v84, 0, 1.0 ); gsl_vector_set(v84, 1, 2.0 ); gsl_vector_set(v84, 2, 3.0 );
|
84
|
+
double v85 = (double)2.0;
|
85
|
+
gsl_vector_add_constant(v84,v85);
|
86
|
+
puts("def test_gsl_vector_add_constant()");
|
87
|
+
puts(" v84 = GSL_Vector.create(3)");
|
88
|
+
puts(" v84.set( [1.0,2.0,3.0] )");
|
89
|
+
puts("");
|
90
|
+
puts(" v85 = 2.0");
|
91
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_add_constant(v84,v85)");
|
92
|
+
printf(" assert v84.values == ");
|
93
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v84,0),gsl_vector_get(v84,1),gsl_vector_get(v84,2));
|
94
|
+
puts("end");
|
95
|
+
/* c_test_gsl_vector_isnull */
|
96
|
+
gsl_vector * v90;
|
97
|
+
v90 = gsl_vector_alloc(3);
|
98
|
+
gsl_vector_set(v90, 0, 1.0 ); gsl_vector_set(v90, 1, 2.0 ); gsl_vector_set(v90, 2, 3.0 );
|
99
|
+
int c_r89;
|
100
|
+
c_r89 = gsl_vector_isnull(v90);
|
101
|
+
puts("def test_gsl_vector_isnull()");
|
102
|
+
puts(" v90 = GSL_Vector.create(3)");
|
103
|
+
puts(" v90.set( [1.0,2.0,3.0] )");
|
104
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isnull(v90)");
|
105
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r89);
|
106
|
+
puts("end");
|
107
|
+
/* c_test_gsl_vector_min */
|
108
|
+
gsl_vector * v88;
|
109
|
+
v88 = gsl_vector_alloc(3);
|
110
|
+
gsl_vector_set(v88, 0, 1.0 ); gsl_vector_set(v88, 1, 2.0 ); gsl_vector_set(v88, 2, 3.0 );
|
111
|
+
double c_r87;
|
112
|
+
c_r87 = gsl_vector_min(v88);
|
113
|
+
puts("def test_gsl_vector_min()");
|
114
|
+
puts(" v88 = GSL_Vector.create(3)");
|
115
|
+
puts(" v88.set( [1.0,2.0,3.0] )");
|
116
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_min(v88)");
|
117
|
+
printf(" assert_in_delta r_r1, %.15g, EPSILON\n", c_r87);
|
118
|
+
puts("end");
|
119
|
+
/* c_test_gsl_vector_isnonneg */
|
120
|
+
gsl_vector * v93;
|
121
|
+
v93 = gsl_vector_alloc(3);
|
122
|
+
gsl_vector_set(v93, 0, 1.0 ); gsl_vector_set(v93, 1, 2.0 ); gsl_vector_set(v93, 2, 3.0 );
|
123
|
+
int c_r92;
|
124
|
+
c_r92 = gsl_vector_isnonneg(v93);
|
125
|
+
puts("def test_gsl_vector_isnonneg()");
|
126
|
+
puts(" v93 = GSL_Vector.create(3)");
|
127
|
+
puts(" v93.set( [1.0,2.0,3.0] )");
|
128
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isnonneg(v93)");
|
129
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r92);
|
130
|
+
puts("end");
|
131
|
+
/* c_test_gsl_vector_add */
|
132
|
+
gsl_vector * v74;
|
133
|
+
v74 = gsl_vector_alloc(3);
|
134
|
+
gsl_vector_set(v74, 0, 1.0 ); gsl_vector_set(v74, 1, 2.0 ); gsl_vector_set(v74, 2, 3.0 );
|
135
|
+
gsl_vector * v75;
|
136
|
+
v75 = gsl_vector_alloc(3);
|
137
|
+
gsl_vector_set(v75, 0, 1.0 ); gsl_vector_set(v75, 1, 2.0 ); gsl_vector_set(v75, 2, 3.0 );
|
138
|
+
gsl_vector_add(v74,v75);
|
139
|
+
puts("def test_gsl_vector_add()");
|
140
|
+
puts(" v74 = GSL_Vector.create(3)");
|
141
|
+
puts(" v74.set( [1.0,2.0,3.0] )");
|
142
|
+
puts(" v75 = GSL_Vector.create(3)");
|
143
|
+
puts(" v75.set( [1.0,2.0,3.0] )");
|
144
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_add(v74,v75)");
|
145
|
+
printf(" assert v74.values == ");
|
146
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v74,0),gsl_vector_get(v74,1),gsl_vector_get(v74,2));
|
147
|
+
puts("end");
|
148
|
+
/* c_test_gsl_vector_div */
|
149
|
+
gsl_vector * v80;
|
150
|
+
v80 = gsl_vector_alloc(3);
|
151
|
+
gsl_vector_set(v80, 0, 1.0 ); gsl_vector_set(v80, 1, 2.0 ); gsl_vector_set(v80, 2, 3.0 );
|
152
|
+
gsl_vector * v81;
|
153
|
+
v81 = gsl_vector_alloc(3);
|
154
|
+
gsl_vector_set(v81, 0, 1.0 ); gsl_vector_set(v81, 1, 2.0 ); gsl_vector_set(v81, 2, 3.0 );
|
155
|
+
gsl_vector_div(v80,v81);
|
156
|
+
puts("def test_gsl_vector_div()");
|
157
|
+
puts(" v80 = GSL_Vector.create(3)");
|
158
|
+
puts(" v80.set( [1.0,2.0,3.0] )");
|
159
|
+
puts(" v81 = GSL_Vector.create(3)");
|
160
|
+
puts(" v81.set( [1.0,2.0,3.0] )");
|
161
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_div(v80,v81)");
|
162
|
+
printf(" assert v80.values == ");
|
163
|
+
printf("[%.15g,%.15g,%.15g]\n",gsl_vector_get(v80,0),gsl_vector_get(v80,1),gsl_vector_get(v80,2));
|
164
|
+
puts("end");
|
165
|
+
/* c_test_gsl_vector_max */
|
166
|
+
gsl_vector * v86;
|
167
|
+
v86 = gsl_vector_alloc(3);
|
168
|
+
gsl_vector_set(v86, 0, 1.0 ); gsl_vector_set(v86, 1, 2.0 ); gsl_vector_set(v86, 2, 3.0 );
|
169
|
+
double c_r85;
|
170
|
+
c_r85 = gsl_vector_max(v86);
|
171
|
+
puts("def test_gsl_vector_max()");
|
172
|
+
puts(" v86 = GSL_Vector.create(3)");
|
173
|
+
puts(" v86.set( [1.0,2.0,3.0] )");
|
174
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_max(v86)");
|
175
|
+
printf(" assert_in_delta r_r1, %.15g, EPSILON\n", c_r85);
|
176
|
+
puts("end");
|
177
|
+
/* c_test_gsl_vector_ispos */
|
178
|
+
gsl_vector * v91;
|
179
|
+
v91 = gsl_vector_alloc(3);
|
180
|
+
gsl_vector_set(v91, 0, 1.0 ); gsl_vector_set(v91, 1, 2.0 ); gsl_vector_set(v91, 2, 3.0 );
|
181
|
+
int c_r90;
|
182
|
+
c_r90 = gsl_vector_ispos(v91);
|
183
|
+
puts("def test_gsl_vector_ispos()");
|
184
|
+
puts(" v91 = GSL_Vector.create(3)");
|
185
|
+
puts(" v91.set( [1.0,2.0,3.0] )");
|
186
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_ispos(v91)");
|
187
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r90);
|
188
|
+
puts("end");
|
189
|
+
/* c_test_gsl_vector_min_index */
|
190
|
+
gsl_vector * v89;
|
191
|
+
v89 = gsl_vector_alloc(3);
|
192
|
+
gsl_vector_set(v89, 0, 1.0 ); gsl_vector_set(v89, 1, 2.0 ); gsl_vector_set(v89, 2, 3.0 );
|
193
|
+
size_t c_r88;
|
194
|
+
c_r88 = gsl_vector_min_index(v89);
|
195
|
+
puts("def test_gsl_vector_min_index()");
|
196
|
+
puts(" v89 = GSL_Vector.create(3)");
|
197
|
+
puts(" v89.set( [1.0,2.0,3.0] )");
|
198
|
+
puts(" r_r1 = ::GSL4r::Vector::Methods::gsl_vector_min_index(v89)");
|
199
|
+
printf(" assert_in_delta r_r1, %lu, EPSILON\n", c_r88);
|
200
|
+
puts("end");
|
201
|
+
puts("end");
|
202
|
+
return(0);
|
203
|
+
}
|
@@ -0,0 +1,128 @@
|
|
1
|
+
$: << File.join('..','lib')
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'ffi'
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
require 'test/unit/autorunner'
|
8
|
+
|
9
|
+
require 'gsl4r'
|
10
|
+
require 'gsl4r/vector'
|
11
|
+
|
12
|
+
include GSL4r::Vector
|
13
|
+
include FFI
|
14
|
+
|
15
|
+
class VectorTests < Test::Unit::TestCase
|
16
|
+
|
17
|
+
SIZE=50
|
18
|
+
|
19
|
+
def test_gsl_vector_alloc_and_free()
|
20
|
+
assert_nothing_raised do
|
21
|
+
vecptr = MemoryPointer.new :pointer
|
22
|
+
vecptr = GSL4r::Vector::Methods::gsl_vector_alloc( SIZE )
|
23
|
+
GSL4r::Vector::Methods::gsl_vector_free( vecptr )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# freed by leaving scope
|
28
|
+
def test_gsl_vector_calloc()
|
29
|
+
assert_nothing_raised do
|
30
|
+
vecptr = MemoryPointer.new :pointer
|
31
|
+
vecptr = GSL4r::Vector::Methods::gsl_vector_calloc( SIZE )
|
32
|
+
vec = GSL_Vector.new( vecptr )
|
33
|
+
|
34
|
+
v = vec.values
|
35
|
+
assert v.length == SIZE
|
36
|
+
v.each { |i| assert i == 0 }
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_gsl_vector_new()
|
42
|
+
assert_nothing_raised do
|
43
|
+
vec = GSL_Vector.create( SIZE )
|
44
|
+
|
45
|
+
assert vec.length == SIZE
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class ::GSL4r::Vector::GSL_Vector_Monitor < ::GSL4r::Vector::GSL_Vector
|
50
|
+
def self.release(ptr)
|
51
|
+
super
|
52
|
+
$release_count = $release_count + 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
class ::GSL4r::Vector::GSL_Vector_Cast_Monitor < ::GSL4r::Vector::GSL_Vector_Cast
|
57
|
+
def self.release(ptr)
|
58
|
+
super
|
59
|
+
$release_count = $release_count + 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# tests using a cast object to retain a reference
|
64
|
+
# to a memory pointer, without freeing it when the
|
65
|
+
# object is garbage collected.
|
66
|
+
def test_gsl_vector_cast()
|
67
|
+
$release_count = 0
|
68
|
+
|
69
|
+
assert_nothing_raised do
|
70
|
+
vecptr = MemoryPointer.new :pointer
|
71
|
+
vecptr = GSL4r::Vector::Methods::gsl_vector_alloc( SIZE )
|
72
|
+
|
73
|
+
v1=GSL4r::Vector::GSL_Vector_Monitor.new( vecptr )
|
74
|
+
v2=GSL4r::Vector::GSL_Vector_Cast_Monitor.new( vecptr )
|
75
|
+
|
76
|
+
assert v1.length == v2.length
|
77
|
+
end
|
78
|
+
|
79
|
+
v1=nil
|
80
|
+
v2=nil
|
81
|
+
GC.start
|
82
|
+
|
83
|
+
assert $release_count == 1
|
84
|
+
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_gsl_vector_set_values()
|
88
|
+
assert_nothing_raised do
|
89
|
+
vec = GSL_Vector.create( SIZE )
|
90
|
+
|
91
|
+
vec.set_with_array( (0..SIZE-1).to_a.collect { |i| i=i*i } )
|
92
|
+
v = vec.values
|
93
|
+
(0..SIZE-1).each { |i| assert v[i] == i*i }
|
94
|
+
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_gsl_vector_set_all()
|
99
|
+
assert_nothing_raised do
|
100
|
+
vec = GSL_Vector.create( SIZE )
|
101
|
+
|
102
|
+
vec.set_all( 5 )
|
103
|
+
v = vec.values
|
104
|
+
s = 0.0
|
105
|
+
(0..SIZE-1).each { |i| s = s + v[i] }
|
106
|
+
|
107
|
+
assert (SIZE*5) == s
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_gsl_vector_subvector()
|
112
|
+
assert_nothing_raised do
|
113
|
+
vec = GSL_Vector.create( SIZE )
|
114
|
+
|
115
|
+
a = Array.new( SIZE )
|
116
|
+
vec.set_with_array( (0..SIZE-1).to_a.collect { |i| i=i+1.0 } )
|
117
|
+
|
118
|
+
subvec = vec.subvector( 10, 5 )
|
119
|
+
|
120
|
+
v = subvec.values
|
121
|
+
|
122
|
+
test_a = (0..4).to_a.collect { |i| i=i+11.0 }
|
123
|
+
|
124
|
+
assert v == test_a
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
end
|
data/test/vector_test.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
$: << File.join('..','lib')
|
2
|
+
require 'test/unit'
|
3
|
+
require 'test/unit/autorunner'
|
4
|
+
require 'gsl4r/vector'
|
5
|
+
include GSL4r::Vector
|
6
|
+
class VectorTests < Test::Unit::TestCase
|
7
|
+
EPSILON = 5.0e-15
|
8
|
+
def test_gsl_vector_sub()
|
9
|
+
v76 = GSL_Vector.create(3)
|
10
|
+
v76.set( [1.0,2.0,3.0] )
|
11
|
+
v77 = GSL_Vector.create(3)
|
12
|
+
v77.set( [1.0,2.0,3.0] )
|
13
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_sub(v76,v77)
|
14
|
+
assert v76.values == [0,0,0]
|
15
|
+
end
|
16
|
+
def test_gsl_vector_scale()
|
17
|
+
v82 = GSL_Vector.create(3)
|
18
|
+
v82.set( [1.0,2.0,3.0] )
|
19
|
+
|
20
|
+
v83 = 2.0
|
21
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_scale(v82,v83)
|
22
|
+
assert v82.values == [2,4,6]
|
23
|
+
end
|
24
|
+
def test_gsl_vector_max_index()
|
25
|
+
v87 = GSL_Vector.create(3)
|
26
|
+
v87.set( [1.0,2.0,3.0] )
|
27
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_max_index(v87)
|
28
|
+
assert_in_delta r_r1, 2, EPSILON
|
29
|
+
end
|
30
|
+
def test_gsl_vector_isneg()
|
31
|
+
v92 = GSL_Vector.create(3)
|
32
|
+
v92.set( [1.0,2.0,3.0] )
|
33
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isneg(v92)
|
34
|
+
assert_in_delta r_r1, 0, EPSILON
|
35
|
+
end
|
36
|
+
def test_gsl_vector_mul()
|
37
|
+
v78 = GSL_Vector.create(3)
|
38
|
+
v78.set( [1.0,2.0,3.0] )
|
39
|
+
v79 = GSL_Vector.create(3)
|
40
|
+
v79.set( [1.0,2.0,3.0] )
|
41
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_mul(v78,v79)
|
42
|
+
assert v78.values == [1,4,9]
|
43
|
+
end
|
44
|
+
def test_gsl_vector_add_constant()
|
45
|
+
v84 = GSL_Vector.create(3)
|
46
|
+
v84.set( [1.0,2.0,3.0] )
|
47
|
+
|
48
|
+
v85 = 2.0
|
49
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_add_constant(v84,v85)
|
50
|
+
assert v84.values == [3,4,5]
|
51
|
+
end
|
52
|
+
def test_gsl_vector_isnull()
|
53
|
+
v90 = GSL_Vector.create(3)
|
54
|
+
v90.set( [1.0,2.0,3.0] )
|
55
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isnull(v90)
|
56
|
+
assert_in_delta r_r1, 0, EPSILON
|
57
|
+
end
|
58
|
+
def test_gsl_vector_min()
|
59
|
+
v88 = GSL_Vector.create(3)
|
60
|
+
v88.set( [1.0,2.0,3.0] )
|
61
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_min(v88)
|
62
|
+
assert_in_delta r_r1, 1, EPSILON
|
63
|
+
end
|
64
|
+
def test_gsl_vector_isnonneg()
|
65
|
+
v93 = GSL_Vector.create(3)
|
66
|
+
v93.set( [1.0,2.0,3.0] )
|
67
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_isnonneg(v93)
|
68
|
+
assert_in_delta r_r1, 1, EPSILON
|
69
|
+
end
|
70
|
+
def test_gsl_vector_add()
|
71
|
+
v74 = GSL_Vector.create(3)
|
72
|
+
v74.set( [1.0,2.0,3.0] )
|
73
|
+
v75 = GSL_Vector.create(3)
|
74
|
+
v75.set( [1.0,2.0,3.0] )
|
75
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_add(v74,v75)
|
76
|
+
assert v74.values == [2,4,6]
|
77
|
+
end
|
78
|
+
def test_gsl_vector_div()
|
79
|
+
v80 = GSL_Vector.create(3)
|
80
|
+
v80.set( [1.0,2.0,3.0] )
|
81
|
+
v81 = GSL_Vector.create(3)
|
82
|
+
v81.set( [1.0,2.0,3.0] )
|
83
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_div(v80,v81)
|
84
|
+
assert v80.values == [1,1,1]
|
85
|
+
end
|
86
|
+
def test_gsl_vector_max()
|
87
|
+
v86 = GSL_Vector.create(3)
|
88
|
+
v86.set( [1.0,2.0,3.0] )
|
89
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_max(v86)
|
90
|
+
assert_in_delta r_r1, 3, EPSILON
|
91
|
+
end
|
92
|
+
def test_gsl_vector_ispos()
|
93
|
+
v91 = GSL_Vector.create(3)
|
94
|
+
v91.set( [1.0,2.0,3.0] )
|
95
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_ispos(v91)
|
96
|
+
assert_in_delta r_r1, 1, EPSILON
|
97
|
+
end
|
98
|
+
def test_gsl_vector_min_index()
|
99
|
+
v89 = GSL_Vector.create(3)
|
100
|
+
v89.set( [1.0,2.0,3.0] )
|
101
|
+
r_r1 = ::GSL4r::Vector::Methods::gsl_vector_min_index(v89)
|
102
|
+
assert_in_delta r_r1, 0, EPSILON
|
103
|
+
end
|
104
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gsl4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Colby Gutierrez-Kraybill
|
@@ -9,7 +14,7 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-22 00:00:00 -07:00
|
13
18
|
default_executable:
|
14
19
|
dependencies: []
|
15
20
|
|
@@ -32,6 +37,7 @@ files:
|
|
32
37
|
- Rakefile
|
33
38
|
- TODO
|
34
39
|
- changelog
|
40
|
+
- lib/b_t.rb
|
35
41
|
- lib/gsl4r/block.rb
|
36
42
|
- lib/gsl4r/complex.rb
|
37
43
|
- lib/gsl4r/const.rb
|
@@ -46,10 +52,15 @@ files:
|
|
46
52
|
- lib/gsl4r/vector.rb
|
47
53
|
- lib/gsl4r.rb
|
48
54
|
- lib/t.rb
|
55
|
+
- test/block_class_test.rb
|
49
56
|
- test/complex_test.rb
|
50
57
|
- test/gsl_complex_tests_gen
|
51
58
|
- test/gsl_complex_tests_gen.c
|
59
|
+
- test/gsl_vector_tests_gen
|
60
|
+
- test/gsl_vector_tests_gen.c
|
52
61
|
- test/README
|
62
|
+
- test/vector_class_test.rb
|
63
|
+
- test/vector_test.rb
|
53
64
|
has_rdoc: true
|
54
65
|
homepage: http://gsl4r.rubyforge.org
|
55
66
|
licenses: []
|
@@ -63,18 +74,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
74
|
requirements:
|
64
75
|
- - ">="
|
65
76
|
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
66
79
|
version: "0"
|
67
|
-
version:
|
68
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
81
|
requirements:
|
70
82
|
- - ">="
|
71
83
|
- !ruby/object:Gem::Version
|
84
|
+
segments:
|
85
|
+
- 0
|
72
86
|
version: "0"
|
73
|
-
version:
|
74
87
|
requirements:
|
75
88
|
- GNU Scientific Library, version 1.13 or greater
|
76
89
|
rubyforge_project: gsl4r
|
77
|
-
rubygems_version: 1.3.
|
90
|
+
rubygems_version: 1.3.6
|
78
91
|
signing_key:
|
79
92
|
specification_version: 3
|
80
93
|
summary: GSL4r, ruby FFI wrappers around GNU Scientific Library
|