ruby-gsl-ng 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/Manifest +9 -0
- data/Rakefile +9 -5
- data/ext/extconf.rb +2 -2
- data/ext/gslng_extensions.cpp +141 -36
- data/lib/gslng.rb +9 -8
- data/lib/gslng/backend.rb +5 -3
- data/lib/gslng/backend_components/error_handling.rb +11 -11
- data/lib/gslng/backend_components/matrix.rb +66 -75
- data/lib/gslng/backend_components/rng.rb +22 -0
- data/lib/gslng/backend_components/special.rb +7 -0
- data/lib/gslng/backend_components/vector.rb +63 -75
- data/lib/gslng/finalizer.rb +6 -2
- data/lib/gslng/matrix.rb +199 -134
- data/lib/gslng/matrix_view.rb +3 -2
- data/lib/gslng/rng/gaussian.rb +34 -0
- data/lib/gslng/rng/rng.rb +27 -0
- data/lib/gslng/rng/uniform.rb +23 -0
- data/lib/gslng/special.rb +22 -0
- data/lib/gslng/vector.rb +196 -125
- data/lib/gslng/vector_view.rb +5 -3
- data/ruby-gsl-ng.gemspec +6 -6
- data/test/benchmark.rb +61 -14
- data/test/benchmark_results +80 -0
- data/test/matrix_test.rb +11 -8
- data/test/rng_test.rb +27 -0
- data/test/test_special.rb +21 -0
- data/test/vector_test.rb +18 -4
- metadata +21 -4
data/History.txt
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
=== 0.2.3
|
2
|
+
* FIXES:
|
3
|
+
* HUGE memory leak, no GSL object was ever freed.
|
4
|
+
* Remove -march flag for MAC
|
5
|
+
* LOTS of improvements:
|
6
|
+
* Added map_array: a map() version that actually returns an Array instead of a Vector/Matrix
|
7
|
+
* Now you use the & idiom for map methods and such (like map_array(&:to_s))
|
8
|
+
* Added Matrix#each_row / Matrix#each_column (which pass row and column matrices to the block)
|
9
|
+
* Added Matrix#row_vecview / Matrix#column_vecview (construct a row and column Matrix::View)
|
10
|
+
* Added Matrix#each_vec_row / Matrix#each_vec_column (same as the previous ones, but the block will receive a Vector::View instead)
|
11
|
+
* Added x, y, z and w accessors for Vector (this will probably go into Vector2, Vector3 and Vector4 in the future)
|
12
|
+
* "negate" operator
|
13
|
+
* Documentation is now YARD based. This will significantly improve the documentation readability.
|
14
|
+
* Added Vector#map_index! and Vector#wrap!
|
15
|
+
* Initial support for Random Number Generators (only Uniform and Gaussian distributions for the moment)
|
16
|
+
* Added Vector#<, #>, #<= and #>=
|
17
|
+
* Added Matrix#map_with_index!
|
18
|
+
* No more #fast_each and stuff. Now #each IS fast. This is accomplished by writing actual Ruby-C code instead of using FFI for
|
19
|
+
these functions.
|
20
|
+
* Initial support for GSL's special functions
|
21
|
+
|
1
22
|
=== 0.2.1
|
2
23
|
* Fixed for FFI 0.6.0
|
3
24
|
|
data/Manifest
CHANGED
@@ -8,15 +8,24 @@ lib/gslng.rb
|
|
8
8
|
lib/gslng/backend.rb
|
9
9
|
lib/gslng/backend_components/error_handling.rb
|
10
10
|
lib/gslng/backend_components/matrix.rb
|
11
|
+
lib/gslng/backend_components/rng.rb
|
12
|
+
lib/gslng/backend_components/special.rb
|
11
13
|
lib/gslng/backend_components/vector.rb
|
12
14
|
lib/gslng/finalizer.rb
|
13
15
|
lib/gslng/matrix.rb
|
14
16
|
lib/gslng/matrix_view.rb
|
17
|
+
lib/gslng/rng/gaussian.rb
|
18
|
+
lib/gslng/rng/rng.rb
|
19
|
+
lib/gslng/rng/uniform.rb
|
20
|
+
lib/gslng/special.rb
|
15
21
|
lib/gslng/vector.rb
|
16
22
|
lib/gslng/vector_view.rb
|
17
23
|
ruby-gsl-ng.gemspec
|
18
24
|
test/benchmark.rb
|
25
|
+
test/benchmark_results
|
19
26
|
test/matrix_test.rb
|
27
|
+
test/rng_test.rb
|
20
28
|
test/test_gsl.rb
|
29
|
+
test/test_special.rb
|
21
30
|
test/vector_test.rb
|
22
31
|
Manifest
|
data/Rakefile
CHANGED
@@ -7,14 +7,18 @@ require 'yard'
|
|
7
7
|
Echoe.new('ruby-gsl-ng') do |p|
|
8
8
|
p.author = 'v01d'
|
9
9
|
p.summary = "Ruby Object Oriented Graph LIbrary"
|
10
|
-
p.url = "http://github.com/v01d/
|
11
|
-
p.version = "0.2.
|
10
|
+
p.url = "http://github.com/v01d/ruby-gsl-ng"
|
11
|
+
p.version = "0.2.3"
|
12
12
|
p.dependencies = ['yard', 'ffi']
|
13
13
|
# p.eval = proc { s.has_rdoc = 'yard' }
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
Rake::TaskManager.class_eval do
|
17
|
+
def remove_task(task)
|
18
|
+
@tasks.delete(task.to_s)
|
19
|
+
end
|
19
20
|
end
|
20
21
|
|
22
|
+
Rake.application.remove_task(:docs)
|
23
|
+
YARD::Rake::YardocTask.new(:docs) {|t| t.options = ['--verbose','--no-private','--hide-void']}
|
24
|
+
|
data/ext/extconf.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/ruby
|
2
2
|
require 'mkmf'
|
3
3
|
gsl_vars = pkg_config('gsl') or raise 'GSL not found!'
|
4
|
-
extra_flags='-
|
5
|
-
with_cppflags("#{
|
4
|
+
extra_flags='-O4 -DHAVE_INLINE'
|
5
|
+
with_cppflags("#{extra_flags}") { true }
|
6
6
|
create_makefile('gslng_extensions')
|
data/ext/gslng_extensions.cpp
CHANGED
@@ -4,43 +4,66 @@
|
|
4
4
|
* This could actually a standard C library (not a Ruby extension), but it's easier this way.
|
5
5
|
*/
|
6
6
|
|
7
|
+
#include <ruby.h>
|
7
8
|
#include <gsl/gsl_vector.h>
|
8
9
|
#include <gsl/gsl_matrix.h>
|
9
10
|
|
10
|
-
|
11
|
+
/************************* Vector functions *****************************/
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
// For Vector::map!
|
15
|
-
typedef double (*gsl_vector_callback_t)(double);
|
16
|
-
|
17
|
-
extern "C" void gsl_vector_map(gsl_vector* v, gsl_vector_callback_t callback) {
|
13
|
+
static VALUE gsl_vector_map(VALUE self, VALUE ptr) {
|
14
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
18
15
|
for (size_t i = 0; i < v->size; i++)
|
19
|
-
|
16
|
+
gsl_vector_set(v, i, NUM2DBL(rb_yield(rb_float_new(gsl_vector_get(v, i)))));
|
17
|
+
|
18
|
+
return self;
|
20
19
|
}
|
21
20
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
static VALUE gsl_vector_map_index(VALUE self, VALUE ptr) {
|
22
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
23
|
+
for (size_t i = 0; i < v->size; i++) {
|
24
|
+
VALUE vi = ULONG2NUM(i);
|
25
|
+
gsl_vector_set(v, i, NUM2DBL(rb_yield(vi)));
|
26
|
+
}
|
27
|
+
|
28
|
+
return self;
|
28
29
|
}
|
29
30
|
|
30
|
-
|
31
|
-
|
31
|
+
static VALUE gsl_vector_each_with_index(VALUE self, VALUE ptr) {
|
32
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
33
|
+
for (size_t i = 0; i < v->size; i++) {
|
34
|
+
VALUE vi = ULONG2NUM(i);
|
35
|
+
rb_yield_values(2, rb_float_new(gsl_vector_get(v, i)), vi);
|
36
|
+
}
|
37
|
+
|
38
|
+
return self;
|
39
|
+
}
|
32
40
|
|
33
|
-
|
41
|
+
static VALUE gsl_vector_each(VALUE self, VALUE ptr) {
|
42
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
34
43
|
for (size_t i = 0; i < v->size; i++)
|
35
|
-
(
|
44
|
+
rb_yield(rb_float_new(gsl_vector_get(v, i)));
|
45
|
+
|
46
|
+
return self;
|
36
47
|
}
|
37
48
|
|
38
|
-
|
39
|
-
|
49
|
+
static VALUE gsl_vector_to_a(VALUE self, VALUE ptr) {
|
50
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
51
|
+
|
52
|
+
VALUE array = rb_ary_new2(v->size);
|
53
|
+
for (size_t i = 0; i < v->size; i++)
|
54
|
+
rb_ary_store(array, i, rb_float_new(gsl_vector_get(v, i)));
|
55
|
+
|
56
|
+
return array;
|
57
|
+
}
|
40
58
|
|
41
|
-
|
59
|
+
static VALUE gsl_vector_from_array(VALUE self, VALUE ptr, VALUE array) {
|
60
|
+
gsl_vector* v = (gsl_vector*)FIX2ULONG(ptr);
|
61
|
+
if (v->size != RARRAY_LEN(array)) rb_raise(rb_eRuntimeError, "Sizes differ!");
|
62
|
+
|
42
63
|
for (size_t i = 0; i < v->size; i++)
|
43
|
-
(
|
64
|
+
gsl_vector_set(v, i, NUM2DBL(rb_ary_entry(array, i)));
|
65
|
+
|
66
|
+
return self;
|
44
67
|
}
|
45
68
|
|
46
69
|
// Hide the view in a new vector (gsl_vector_subvector)
|
@@ -59,41 +82,98 @@ extern "C" gsl_vector* gsl_vector_subvector2(gsl_vector* v, size_t offset, size_
|
|
59
82
|
return vector_view;
|
60
83
|
}
|
61
84
|
|
62
|
-
|
63
|
-
// For Matrix::map!
|
64
|
-
typedef double (*gsl_matrix_callback_t)(double);
|
85
|
+
/************************* Matrix functions *****************************/
|
65
86
|
|
66
|
-
|
87
|
+
static VALUE gsl_matrix_map(VALUE self, VALUE ptr) {
|
88
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
67
89
|
size_t size1 = m->size1;
|
68
90
|
size_t size2 = m->size2;
|
69
91
|
|
70
92
|
for (size_t i = 0; i < size1; i++)
|
71
93
|
for (size_t j = 0; j < size2; j++)
|
72
|
-
|
73
|
-
}
|
94
|
+
gsl_matrix_set(m, i, j, NUM2DBL(rb_yield(rb_float_new(gsl_matrix_get(m, i, j)))));
|
74
95
|
|
75
|
-
|
76
|
-
|
96
|
+
return self;
|
97
|
+
}
|
77
98
|
|
78
|
-
|
99
|
+
static VALUE gsl_matrix_map_index(VALUE self, VALUE ptr) {
|
100
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
79
101
|
size_t size1 = m->size1;
|
80
102
|
size_t size2 = m->size2;
|
81
103
|
|
82
104
|
for (size_t i = 0; i < size1; i++)
|
83
105
|
for (size_t j = 0; j < size2; j++)
|
84
|
-
|
106
|
+
gsl_matrix_set(m, i, j, NUM2DBL(rb_yield_values(2, ULONG2NUM(i), ULONG2NUM(j))));
|
107
|
+
|
108
|
+
return self;
|
85
109
|
}
|
86
110
|
|
87
|
-
|
88
|
-
|
111
|
+
static VALUE gsl_matrix_map_with_index(VALUE self, VALUE ptr) {
|
112
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
113
|
+
size_t size1 = m->size1;
|
114
|
+
size_t size2 = m->size2;
|
89
115
|
|
90
|
-
|
116
|
+
for (size_t i = 0; i < size1; i++)
|
117
|
+
for (size_t j = 0; j < size2; j++)
|
118
|
+
gsl_matrix_set(m, i, j, NUM2DBL(rb_yield_values(3, rb_float_new(gsl_matrix_get(m, i, j)), ULONG2NUM(i), ULONG2NUM(j))));
|
119
|
+
|
120
|
+
return self;
|
121
|
+
}
|
122
|
+
|
123
|
+
static VALUE gsl_matrix_each(VALUE self, VALUE ptr) {
|
124
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
91
125
|
size_t size1 = m->size1;
|
92
126
|
size_t size2 = m->size2;
|
93
127
|
|
94
128
|
for (size_t i = 0; i < size1; i++)
|
95
129
|
for (size_t j = 0; j < size2; j++)
|
96
|
-
|
130
|
+
rb_yield(rb_float_new(gsl_matrix_get(m, i, j)));
|
131
|
+
|
132
|
+
return self;
|
133
|
+
}
|
134
|
+
|
135
|
+
static VALUE gsl_matrix_each_with_index(VALUE self, VALUE ptr) {
|
136
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
137
|
+
size_t size1 = m->size1;
|
138
|
+
size_t size2 = m->size2;
|
139
|
+
|
140
|
+
for (size_t i = 0; i < size1; i++) {
|
141
|
+
VALUE vi = ULONG2NUM(i);
|
142
|
+
for (size_t j = 0; j < size2; j++)
|
143
|
+
rb_yield_values(3, rb_float_new(gsl_matrix_get(m, i, j)), vi, ULONG2NUM(j));
|
144
|
+
}
|
145
|
+
|
146
|
+
return self;
|
147
|
+
}
|
148
|
+
|
149
|
+
static VALUE gsl_matrix_to_a(VALUE self, VALUE ptr) {
|
150
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
151
|
+
|
152
|
+
VALUE array = rb_ary_new2(m->size1);
|
153
|
+
for (size_t i = 0; i < m->size1; i++) {
|
154
|
+
VALUE row = rb_ary_new2(m->size2);
|
155
|
+
for (size_t j = 0; j < m->size2; j++) {
|
156
|
+
rb_ary_store(row, j, rb_float_new(gsl_matrix_get(m, i, j)));
|
157
|
+
}
|
158
|
+
rb_ary_store(array, i, row);
|
159
|
+
}
|
160
|
+
|
161
|
+
return array;
|
162
|
+
}
|
163
|
+
|
164
|
+
static VALUE gsl_matrix_from_array(VALUE self, VALUE ptr, VALUE array) {
|
165
|
+
gsl_matrix* m = (gsl_matrix*)FIX2ULONG(ptr);
|
166
|
+
if (m->size1 != RARRAY_LEN(array)) rb_raise(rb_eRuntimeError, "Sizes differ!");
|
167
|
+
|
168
|
+
for (size_t i = 0; i < m->size1; i++) {
|
169
|
+
VALUE row = rb_ary_entry(array, i);
|
170
|
+
if (m->size2 != RARRAY_LEN(row)) rb_raise(rb_eRuntimeError, "Sizes differ!");
|
171
|
+
|
172
|
+
for (size_t j = 0; j < m->size2; j++)
|
173
|
+
gsl_matrix_set(m, i, j, NUM2DBL(rb_ary_entry(row, j)));
|
174
|
+
}
|
175
|
+
|
176
|
+
return self;
|
97
177
|
}
|
98
178
|
|
99
179
|
// Hide the view in a new matrix (gsl_matrix_submatrix)
|
@@ -116,4 +196,29 @@ extern "C" gsl_vector* gsl_matrix_column_view(gsl_matrix* m_ptr, size_t column,
|
|
116
196
|
gsl_vector* vector_view = gsl_vector_alloc(view.vector.size);
|
117
197
|
*vector_view = view.vector;
|
118
198
|
return vector_view;
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
/************************* Module initialization *****************************/
|
203
|
+
|
204
|
+
extern "C" void Init_gslng_extensions(void) {
|
205
|
+
VALUE GSLng_module = rb_define_module("GSLng");
|
206
|
+
VALUE Backend_module = rb_funcall(GSLng_module, rb_intern("backend"), 0);
|
207
|
+
|
208
|
+
// vector
|
209
|
+
rb_define_module_function(Backend_module, "gsl_vector_map!", (VALUE(*)(ANYARGS))gsl_vector_map, 1);
|
210
|
+
rb_define_module_function(Backend_module, "gsl_vector_map_index!", (VALUE(*)(ANYARGS))gsl_vector_map_index, 1);
|
211
|
+
rb_define_module_function(Backend_module, "gsl_vector_each_with_index", (VALUE(*)(ANYARGS))gsl_vector_each_with_index, 1);
|
212
|
+
rb_define_module_function(Backend_module, "gsl_vector_each", (VALUE(*)(ANYARGS))gsl_vector_each, 1);
|
213
|
+
rb_define_module_function(Backend_module, "gsl_vector_to_a", (VALUE(*)(ANYARGS))gsl_vector_to_a, 1);
|
214
|
+
rb_define_module_function(Backend_module, "gsl_vector_from_array", (VALUE(*)(ANYARGS))gsl_vector_from_array, 2);
|
215
|
+
|
216
|
+
// matrix
|
217
|
+
rb_define_module_function(Backend_module, "gsl_matrix_map!", (VALUE(*)(ANYARGS))gsl_matrix_map, 1);
|
218
|
+
rb_define_module_function(Backend_module, "gsl_matrix_map_index!", (VALUE(*)(ANYARGS))gsl_matrix_map_index, 1);
|
219
|
+
rb_define_module_function(Backend_module, "gsl_matrix_map_with_index!", (VALUE(*)(ANYARGS))gsl_matrix_map_with_index, 1);
|
220
|
+
rb_define_module_function(Backend_module, "gsl_matrix_each_with_index", (VALUE(*)(ANYARGS))gsl_matrix_each_with_index, 1);
|
221
|
+
rb_define_module_function(Backend_module, "gsl_matrix_each", (VALUE(*)(ANYARGS))gsl_matrix_each, 1);
|
222
|
+
rb_define_module_function(Backend_module, "gsl_matrix_to_a", (VALUE(*)(ANYARGS))gsl_matrix_to_a, 1);
|
223
|
+
rb_define_module_function(Backend_module, "gsl_matrix_from_array", (VALUE(*)(ANYARGS))gsl_matrix_from_array, 2);
|
119
224
|
}
|
data/lib/gslng.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require 'gslng/backend'
|
2
|
-
require 'gslng/finalizer'
|
3
|
-
|
4
|
-
require 'gslng/vector'
|
5
|
-
require 'gslng/vector_view'
|
6
|
-
require 'gslng/matrix'
|
7
|
-
require 'gslng/matrix_view'
|
8
|
-
|
1
|
+
require 'gslng/backend'
|
2
|
+
require 'gslng/finalizer'
|
3
|
+
|
4
|
+
require 'gslng/vector'
|
5
|
+
require 'gslng/vector_view'
|
6
|
+
require 'gslng/matrix'
|
7
|
+
require 'gslng/matrix_view'
|
8
|
+
require 'gslng/rng/rng'
|
9
|
+
require 'gslng/special'
|
data/lib/gslng/backend.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'ffi'
|
2
2
|
|
3
3
|
module GSLng
|
4
|
-
|
5
|
-
|
4
|
+
# Anonymous module: avoids exposing this internal module when doing "include GSLng" at the top-level.
|
5
|
+
# If ruby had "private" modules I wouldn't have to do this.
|
6
6
|
@backend = Module.new do
|
7
7
|
extend FFI::Library
|
8
8
|
ffi_lib(FFI::CURRENT_PROCESS)
|
9
9
|
end
|
10
10
|
|
11
11
|
# Returns the internal backend module
|
12
|
-
|
12
|
+
def GSLng.backend # @private
|
13
13
|
@backend
|
14
14
|
end
|
15
15
|
end
|
@@ -18,3 +18,5 @@ require 'gslng_extensions'
|
|
18
18
|
require 'gslng/backend_components/vector'
|
19
19
|
require 'gslng/backend_components/matrix'
|
20
20
|
require 'gslng/backend_components/error_handling'
|
21
|
+
require 'gslng/backend_components/rng'
|
22
|
+
require 'gslng/backend_components/special'
|
@@ -1,12 +1,12 @@
|
|
1
|
-
module GSLng
|
2
|
-
|
3
|
-
# All of this raises an exception when GSL registers an error
|
4
|
-
|
5
|
-
attach_function :gsl_set_error_handler, [ :error_handler_callback ], :error_handler_callback
|
6
|
-
|
7
|
-
ErrorHandlerCallback = Proc.new {|reason, file, line, errno|
|
8
|
-
raise RuntimeError, "#{reason} (errno: #{errno})", caller[2..-1]
|
9
|
-
}
|
10
|
-
gsl_set_error_handler(ErrorHandlerCallback)
|
11
|
-
|
1
|
+
module GSLng
|
2
|
+
backend.instance_eval do
|
3
|
+
# All of this raises an exception when GSL registers an error
|
4
|
+
callback :error_handler_callback, [ :string, :string, :int, :int ], :void
|
5
|
+
attach_function :gsl_set_error_handler, [ :error_handler_callback ], :error_handler_callback
|
6
|
+
|
7
|
+
ErrorHandlerCallback = Proc.new {|reason, file, line, errno|
|
8
|
+
raise RuntimeError, "#{reason} (errno: #{errno})", caller[2..-1]
|
9
|
+
}
|
10
|
+
gsl_set_error_handler(ErrorHandlerCallback)
|
11
|
+
end
|
12
12
|
end
|
@@ -1,75 +1,66 @@
|
|
1
|
-
module GSLng
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
# initializing
|
9
|
-
attach_function :gsl_matrix_set_all, [ :pointer, :double ], :void
|
10
|
-
attach_function :gsl_matrix_set_zero, [ :pointer ], :void
|
11
|
-
attach_function :gsl_matrix_set_identity, [ :pointer ], :void
|
12
|
-
|
13
|
-
# copying
|
14
|
-
attach_function :gsl_matrix_memcpy, [ :pointer, :pointer ], :int
|
15
|
-
|
16
|
-
# operations
|
17
|
-
attach_function :gsl_matrix_add, [ :pointer, :pointer ], :int
|
18
|
-
attach_function :gsl_matrix_sub, [ :pointer, :pointer ], :int
|
19
|
-
attach_function :gsl_matrix_mul_elements, [ :pointer, :pointer ], :int
|
20
|
-
attach_function :gsl_matrix_div_elements, [ :pointer, :pointer ], :int
|
21
|
-
attach_function :gsl_matrix_scale, [ :pointer, :double ], :int
|
22
|
-
attach_function :gsl_matrix_add_constant, [ :pointer, :double ], :int
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
attach_function :gsl_matrix_get, [ :pointer, :size_t, :size_t ], :double
|
32
|
-
attach_function :gsl_matrix_set, [ :pointer, :size_t, :size_t, :double ], :void
|
33
|
-
|
34
|
-
# properties
|
35
|
-
attach_function :gsl_matrix_isnull, [ :pointer ], :int
|
36
|
-
attach_function :gsl_matrix_ispos, [ :pointer ], :int
|
37
|
-
attach_function :gsl_matrix_isneg, [ :pointer ], :int
|
38
|
-
attach_function :gsl_matrix_isnonneg, [ :pointer ], :int
|
39
|
-
|
40
|
-
# max and min
|
41
|
-
attach_function :gsl_matrix_max, [ :pointer ], :double
|
42
|
-
attach_function :gsl_matrix_min, [ :pointer ], :double
|
43
|
-
attach_function :gsl_matrix_minmax, [ :pointer, :buffer_out, :buffer_out ], :void
|
44
|
-
attach_function :gsl_matrix_max_index, [ :pointer, :buffer_out, :buffer_out ], :void
|
45
|
-
attach_function :gsl_matrix_min_index, [ :pointer, :buffer_out, :buffer_out ], :void
|
46
|
-
attach_function :gsl_matrix_minmax_index, [ :pointer, :buffer_out, :buffer_out, :buffer_out, :buffer_out ], :void
|
47
|
-
|
48
|
-
# exchange elements
|
49
|
-
attach_function :gsl_matrix_swap_rows, [ :pointer, :size_t, :size_t ], :int
|
50
|
-
attach_function :gsl_matrix_swap_columns, [ :pointer, :size_t, :size_t ], :int
|
51
|
-
attach_function :gsl_matrix_swap_rowcol, [ :pointer, :size_t, :size_t ], :int
|
52
|
-
attach_function :gsl_matrix_transpose_memcpy, [ :pointer, :pointer ], :int
|
53
|
-
attach_function :gsl_matrix_transpose, [ :pointer ], :int
|
54
|
-
|
55
|
-
# From local extension
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
attach_function :gsl_matrix_row_view, [ :pointer, :size_t, :size_t, :size_t ], :pointer
|
68
|
-
attach_function :gsl_matrix_column_view, [ :pointer, :size_t, :size_t, :size_t ], :pointer
|
69
|
-
|
70
|
-
# BLAS interface
|
71
|
-
enum :cblas_transpose_t, [ :no_transpose, 111, :transpose, :conjugate_transpose ]
|
72
|
-
attach_function :gsl_blas_dgemv, [ :cblas_transpose_t, :double, :pointer, :pointer, :double, :pointer ], :int
|
73
|
-
attach_function :gsl_blas_dgemm, [ :cblas_transpose_t, :cblas_transpose_t, :double, :pointer, :pointer, :double, :pointer ], :int
|
74
|
-
end
|
75
|
-
end
|
1
|
+
module GSLng
|
2
|
+
backend.instance_eval do
|
3
|
+
# memory handling
|
4
|
+
attach_function :gsl_matrix_alloc, [ :size_t, :size_t ], :pointer
|
5
|
+
attach_function :gsl_matrix_calloc, [ :size_t, :size_t ], :pointer
|
6
|
+
attach_function :gsl_matrix_free, [ :pointer ], :void
|
7
|
+
|
8
|
+
# initializing
|
9
|
+
attach_function :gsl_matrix_set_all, [ :pointer, :double ], :void
|
10
|
+
attach_function :gsl_matrix_set_zero, [ :pointer ], :void
|
11
|
+
attach_function :gsl_matrix_set_identity, [ :pointer ], :void
|
12
|
+
|
13
|
+
# copying
|
14
|
+
attach_function :gsl_matrix_memcpy, [ :pointer, :pointer ], :int
|
15
|
+
|
16
|
+
# operations
|
17
|
+
attach_function :gsl_matrix_add, [ :pointer, :pointer ], :int
|
18
|
+
attach_function :gsl_matrix_sub, [ :pointer, :pointer ], :int
|
19
|
+
attach_function :gsl_matrix_mul_elements, [ :pointer, :pointer ], :int
|
20
|
+
attach_function :gsl_matrix_div_elements, [ :pointer, :pointer ], :int
|
21
|
+
attach_function :gsl_matrix_scale, [ :pointer, :double ], :int
|
22
|
+
attach_function :gsl_matrix_add_constant, [ :pointer, :double ], :int
|
23
|
+
|
24
|
+
# copy rows/columns into
|
25
|
+
attach_function :gsl_matrix_get_row, [ :pointer, :pointer, :size_t ], :int
|
26
|
+
attach_function :gsl_matrix_get_col, [ :pointer, :pointer, :size_t ], :int
|
27
|
+
attach_function :gsl_matrix_set_row, [ :pointer, :size_t, :pointer ], :int
|
28
|
+
attach_function :gsl_matrix_set_col, [ :pointer, :size_t, :pointer ], :int
|
29
|
+
|
30
|
+
# element access
|
31
|
+
attach_function :gsl_matrix_get, [ :pointer, :size_t, :size_t ], :double
|
32
|
+
attach_function :gsl_matrix_set, [ :pointer, :size_t, :size_t, :double ], :void
|
33
|
+
|
34
|
+
# properties
|
35
|
+
attach_function :gsl_matrix_isnull, [ :pointer ], :int
|
36
|
+
attach_function :gsl_matrix_ispos, [ :pointer ], :int
|
37
|
+
attach_function :gsl_matrix_isneg, [ :pointer ], :int
|
38
|
+
attach_function :gsl_matrix_isnonneg, [ :pointer ], :int
|
39
|
+
|
40
|
+
# max and min
|
41
|
+
attach_function :gsl_matrix_max, [ :pointer ], :double
|
42
|
+
attach_function :gsl_matrix_min, [ :pointer ], :double
|
43
|
+
attach_function :gsl_matrix_minmax, [ :pointer, :buffer_out, :buffer_out ], :void
|
44
|
+
attach_function :gsl_matrix_max_index, [ :pointer, :buffer_out, :buffer_out ], :void
|
45
|
+
attach_function :gsl_matrix_min_index, [ :pointer, :buffer_out, :buffer_out ], :void
|
46
|
+
attach_function :gsl_matrix_minmax_index, [ :pointer, :buffer_out, :buffer_out, :buffer_out, :buffer_out ], :void
|
47
|
+
|
48
|
+
# exchange elements
|
49
|
+
attach_function :gsl_matrix_swap_rows, [ :pointer, :size_t, :size_t ], :int
|
50
|
+
attach_function :gsl_matrix_swap_columns, [ :pointer, :size_t, :size_t ], :int
|
51
|
+
attach_function :gsl_matrix_swap_rowcol, [ :pointer, :size_t, :size_t ], :int
|
52
|
+
attach_function :gsl_matrix_transpose_memcpy, [ :pointer, :pointer ], :int
|
53
|
+
attach_function :gsl_matrix_transpose, [ :pointer ], :int
|
54
|
+
|
55
|
+
# From local extension
|
56
|
+
# views
|
57
|
+
attach_function :gsl_matrix_submatrix2, [ :pointer, :size_t, :size_t, :size_t, :size_t ], :pointer
|
58
|
+
attach_function :gsl_matrix_row_view, [ :pointer, :size_t, :size_t, :size_t ], :pointer
|
59
|
+
attach_function :gsl_matrix_column_view, [ :pointer, :size_t, :size_t, :size_t ], :pointer
|
60
|
+
|
61
|
+
# BLAS interface
|
62
|
+
enum :cblas_transpose_t, [ :no_transpose, 111, :transpose, :conjugate_transpose ]
|
63
|
+
attach_function :gsl_blas_dgemv, [ :cblas_transpose_t, :double, :pointer, :pointer, :double, :pointer ], :int
|
64
|
+
attach_function :gsl_blas_dgemm, [ :cblas_transpose_t, :cblas_transpose_t, :double, :pointer, :pointer, :double, :pointer ], :int
|
65
|
+
end
|
66
|
+
end
|