ruby-dcl 1.6.3.1 → 1.7.0

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/math1_clsplib.c ADDED
@@ -0,0 +1,329 @@
1
+ /*
2
+ * $Id: p_header,v 1.2 2011-02-23 17:47:10 koshiro Exp $
3
+ */
4
+
5
+ #include <stdio.h>
6
+ #include "ruby.h"
7
+ #include "libtinyf2c.h"
8
+ #include "narray.h"
9
+
10
+ /* for compatibility with ruby 1.6 */
11
+ #ifndef StringValuePtr
12
+ #define StringValuePtr(s) STR2CSTR(s)
13
+ #endif
14
+
15
+ #define DFLT_SIZE 32
16
+
17
+ extern char *dcl_obj2ccharary(VALUE, int, int);
18
+ extern integer *dcl_obj2cintegerary(VALUE);
19
+ extern real *dcl_obj2crealary(VALUE);
20
+ extern complex *dcl_obj2ccomplexary(VALUE);
21
+ extern logical *dcl_obj2clogicalary(VALUE);
22
+
23
+ extern VALUE dcl_ccharary2obj(char *, int, int);
24
+ extern VALUE dcl_cintegerary2obj(integer *, int, int, int *);
25
+ extern VALUE dcl_crealary2obj(real *, int, int, int *);
26
+ extern VALUE dcl_ccomplexary2obj(complex *, int, char *);
27
+ extern VALUE dcl_clogicalary2obj(logical *, int, int, int *);
28
+
29
+ extern void dcl_freeccharary(char *);
30
+ extern void dcl_freecintegerary(integer *);
31
+ extern void dcl_freecrealary(real *);
32
+ extern void dcl_freeccomplexary(complex *);
33
+ extern void dcl_freeclogicalary(logical *);
34
+
35
+ /* for functions which return real */
36
+ /* fnclib */
37
+ extern real rd2r_(real *);
38
+ extern real rr2d_(real *);
39
+ extern real rexp_(real *, integer *, integer *);
40
+ extern real rfpi_(void);
41
+ extern real rmod_(real *, real *);
42
+ /* gnmlib */
43
+ extern real rgnlt_(real *);
44
+ extern real rgnle_(real *);
45
+ extern real rgngt_(real *);
46
+ extern real rgnge_(real *);
47
+ /* rfalib */
48
+ extern real rmax_(real *, integer *, integer *);
49
+ extern real rmin_(real *, integer *, integer *);
50
+ extern real rsum_(real *, integer *, integer *);
51
+ extern real rave_(real *, integer *, integer *);
52
+ extern real rvar_(real *, integer *, integer *);
53
+ extern real rstd_(real *, integer *, integer *);
54
+ extern real rrms_(real *, integer *, integer *);
55
+ extern real ramp_(real *, integer *, integer *);
56
+ /* rfblib */
57
+ extern real rprd_(real *, real *, integer *, integer *, integer *);
58
+ extern real rcov_(real *, real *, integer *, integer *, integer *);
59
+ extern real rcor_(real *, real *, integer *, integer *, integer *);
60
+
61
+
62
+ extern VALUE mDCL;
63
+
64
+ #if DCLVER >= 544
65
+
66
+ static VALUE
67
+ dcl_clrgsv(obj, r, g, b, n, m)
68
+ VALUE obj, r, g, b, n, m;
69
+ {
70
+ integer *i_r;
71
+ integer *i_g;
72
+ integer *i_b;
73
+ real *o_h;
74
+ real *o_s;
75
+ real *o_v;
76
+ integer i_n;
77
+ integer i_m;
78
+ VALUE h;
79
+ VALUE s;
80
+ VALUE v;
81
+
82
+ if ((TYPE(r) == T_BIGNUM) || (TYPE(r) == T_FIXNUM)) {
83
+ r = rb_Array(r);
84
+ }
85
+ /* if ((TYPE(r) != T_ARRAY) &&
86
+ (rb_obj_is_kind_of(r, cNArray) != Qtrue)) {
87
+ rb_raise(rb_eTypeError, "invalid type");
88
+ } -- no check since obj2c*ary will do that */
89
+ if ((TYPE(g) == T_BIGNUM) || (TYPE(g) == T_FIXNUM)) {
90
+ g = rb_Array(g);
91
+ }
92
+ /* if ((TYPE(g) != T_ARRAY) &&
93
+ (rb_obj_is_kind_of(g, cNArray) != Qtrue)) {
94
+ rb_raise(rb_eTypeError, "invalid type");
95
+ } -- no check since obj2c*ary will do that */
96
+ if ((TYPE(b) == T_BIGNUM) || (TYPE(b) == T_FIXNUM)) {
97
+ b = rb_Array(b);
98
+ }
99
+ /* if ((TYPE(b) != T_ARRAY) &&
100
+ (rb_obj_is_kind_of(b, cNArray) != Qtrue)) {
101
+ rb_raise(rb_eTypeError, "invalid type");
102
+ } -- no check since obj2c*ary will do that */
103
+ if ((TYPE(n) != T_BIGNUM) || (TYPE(n) != T_FIXNUM)) {
104
+ n = rb_funcall(n, rb_intern("to_i"), 0);
105
+ }
106
+ if ((TYPE(m) != T_BIGNUM) || (TYPE(m) != T_FIXNUM)) {
107
+ m = rb_funcall(m, rb_intern("to_i"), 0);
108
+ }
109
+
110
+ i_n = NUM2INT(n);
111
+ i_m = NUM2INT(m);
112
+ i_r = dcl_obj2cintegerary(r);
113
+ i_g = dcl_obj2cintegerary(g);
114
+ i_b = dcl_obj2cintegerary(b);
115
+
116
+ o_h= ALLOCA_N(real, (i_n*i_m));
117
+ o_s= ALLOCA_N(real, (i_n*i_m));
118
+ o_v= ALLOCA_N(real, (i_n*i_m));
119
+
120
+ clrgsv_(i_r, i_g, i_b, o_h, o_s, o_v, &i_n, &i_m);
121
+
122
+ {int array_shape[2] = {i_n, i_m};
123
+ h = dcl_crealary2obj(o_h, (i_n*i_m), 2, array_shape);
124
+ }
125
+ {int array_shape[2] = {i_n, i_m};
126
+ s = dcl_crealary2obj(o_s, (i_n*i_m), 2, array_shape);
127
+ }
128
+ {int array_shape[2] = {i_n, i_m};
129
+ v = dcl_crealary2obj(o_v, (i_n*i_m), 2, array_shape);
130
+ }
131
+
132
+ dcl_freecintegerary(i_r);
133
+ dcl_freecintegerary(i_g);
134
+ dcl_freecintegerary(i_b);
135
+
136
+ return rb_ary_new3(3, h, s, v);
137
+
138
+ }
139
+
140
+ static VALUE
141
+ dcl_clsvrg(obj, h, s, v, n, m)
142
+ VALUE obj, h, s, v, n, m;
143
+ {
144
+ real *i_h;
145
+ real *i_s;
146
+ real *i_v;
147
+ integer *o_r;
148
+ integer *o_g;
149
+ integer *o_b;
150
+ integer i_n;
151
+ integer i_m;
152
+ VALUE r;
153
+ VALUE g;
154
+ VALUE b;
155
+
156
+ if (TYPE(h) == T_FLOAT) {
157
+ h = rb_Array(h);
158
+ }
159
+ /* if ((TYPE(h) != T_ARRAY) &&
160
+ (rb_obj_is_kind_of(h, cNArray) != Qtrue)) {
161
+ rb_raise(rb_eTypeError, "invalid type");
162
+ } -- no check since obj2c*ary will do that */
163
+ if (TYPE(s) == T_FLOAT) {
164
+ s = rb_Array(s);
165
+ }
166
+ /* if ((TYPE(s) != T_ARRAY) &&
167
+ (rb_obj_is_kind_of(s, cNArray) != Qtrue)) {
168
+ rb_raise(rb_eTypeError, "invalid type");
169
+ } -- no check since obj2c*ary will do that */
170
+ if (TYPE(v) == T_FLOAT) {
171
+ v = rb_Array(v);
172
+ }
173
+ /* if ((TYPE(v) != T_ARRAY) &&
174
+ (rb_obj_is_kind_of(v, cNArray) != Qtrue)) {
175
+ rb_raise(rb_eTypeError, "invalid type");
176
+ } -- no check since obj2c*ary will do that */
177
+ if ((TYPE(n) != T_BIGNUM) || (TYPE(n) != T_FIXNUM)) {
178
+ n = rb_funcall(n, rb_intern("to_i"), 0);
179
+ }
180
+ if ((TYPE(m) != T_BIGNUM) || (TYPE(m) != T_FIXNUM)) {
181
+ m = rb_funcall(m, rb_intern("to_i"), 0);
182
+ }
183
+
184
+ i_n = NUM2INT(n);
185
+ i_m = NUM2INT(m);
186
+ i_h = dcl_obj2crealary(h);
187
+ i_s = dcl_obj2crealary(s);
188
+ i_v = dcl_obj2crealary(v);
189
+
190
+ o_r= ALLOCA_N(integer, (i_n*i_m));
191
+ o_g= ALLOCA_N(integer, (i_n*i_m));
192
+ o_b= ALLOCA_N(integer, (i_n*i_m));
193
+
194
+ clsvrg_(i_h, i_s, i_v, o_r, o_g, o_b, &i_n, &i_m);
195
+
196
+ {int array_shape[2] = {i_n, i_m};
197
+ r = dcl_cintegerary2obj(o_r, (i_n*i_m), 2, array_shape);
198
+ }
199
+ {int array_shape[2] = {i_n, i_m};
200
+ g = dcl_cintegerary2obj(o_g, (i_n*i_m), 2, array_shape);
201
+ }
202
+ {int array_shape[2] = {i_n, i_m};
203
+ b = dcl_cintegerary2obj(o_b, (i_n*i_m), 2, array_shape);
204
+ }
205
+
206
+ dcl_freecrealary(i_h);
207
+ dcl_freecrealary(i_s);
208
+ dcl_freecrealary(i_v);
209
+
210
+ return rb_ary_new3(3, r, g, b);
211
+
212
+ }
213
+
214
+ static VALUE
215
+ dcl_inorml(obj, v, n, m, x, y)
216
+ VALUE obj, v, n, m, x, y;
217
+ {
218
+ integer *i_v;
219
+ real *o_w;
220
+ integer i_n;
221
+ integer i_m;
222
+ real i_x;
223
+ real i_y;
224
+ VALUE w;
225
+
226
+ if ((TYPE(v) == T_BIGNUM) || (TYPE(v) == T_FIXNUM)) {
227
+ v = rb_Array(v);
228
+ }
229
+ /* if ((TYPE(v) != T_ARRAY) &&
230
+ (rb_obj_is_kind_of(v, cNArray) != Qtrue)) {
231
+ rb_raise(rb_eTypeError, "invalid type");
232
+ } -- no check since obj2c*ary will do that */
233
+ if ((TYPE(n) != T_BIGNUM) || (TYPE(n) != T_FIXNUM)) {
234
+ n = rb_funcall(n, rb_intern("to_i"), 0);
235
+ }
236
+ if ((TYPE(m) != T_BIGNUM) || (TYPE(m) != T_FIXNUM)) {
237
+ m = rb_funcall(m, rb_intern("to_i"), 0);
238
+ }
239
+ if (TYPE(x) != T_FLOAT) {
240
+ x = rb_funcall(x, rb_intern("to_f"), 0);
241
+ }
242
+ if (TYPE(y) != T_FLOAT) {
243
+ y = rb_funcall(y, rb_intern("to_f"), 0);
244
+ }
245
+
246
+ i_n = NUM2INT(n);
247
+ i_m = NUM2INT(m);
248
+ i_x = (real)NUM2DBL(x);
249
+ i_y = (real)NUM2DBL(y);
250
+ i_v = dcl_obj2cintegerary(v);
251
+
252
+ o_w= ALLOCA_N(real, (i_n*i_m));
253
+
254
+ inorml_(i_v, o_w, &i_n, &i_m, &i_x, &i_y);
255
+
256
+ {int array_shape[2] = {i_n, i_m};
257
+ w = dcl_crealary2obj(o_w, (i_n*i_m), 2, array_shape);
258
+ }
259
+
260
+ dcl_freecintegerary(i_v);
261
+
262
+ return w;
263
+
264
+ }
265
+
266
+ static VALUE
267
+ dcl_rnorml(obj, v, n, m, x, y)
268
+ VALUE obj, v, n, m, x, y;
269
+ {
270
+ real *i_v;
271
+ real *o_w;
272
+ integer i_n;
273
+ integer i_m;
274
+ real i_x;
275
+ real i_y;
276
+ VALUE w;
277
+
278
+ if (TYPE(v) == T_FLOAT) {
279
+ v = rb_Array(v);
280
+ }
281
+ /* if ((TYPE(v) != T_ARRAY) &&
282
+ (rb_obj_is_kind_of(v, cNArray) != Qtrue)) {
283
+ rb_raise(rb_eTypeError, "invalid type");
284
+ } -- no check since obj2c*ary will do that */
285
+ if ((TYPE(n) != T_BIGNUM) || (TYPE(n) != T_FIXNUM)) {
286
+ n = rb_funcall(n, rb_intern("to_i"), 0);
287
+ }
288
+ if ((TYPE(m) != T_BIGNUM) || (TYPE(m) != T_FIXNUM)) {
289
+ m = rb_funcall(m, rb_intern("to_i"), 0);
290
+ }
291
+ if (TYPE(x) != T_FLOAT) {
292
+ x = rb_funcall(x, rb_intern("to_f"), 0);
293
+ }
294
+ if (TYPE(y) != T_FLOAT) {
295
+ y = rb_funcall(y, rb_intern("to_f"), 0);
296
+ }
297
+
298
+ i_n = NUM2INT(n);
299
+ i_m = NUM2INT(m);
300
+ i_x = (real)NUM2DBL(x);
301
+ i_y = (real)NUM2DBL(y);
302
+ i_v = dcl_obj2crealary(v);
303
+
304
+ o_w= ALLOCA_N(real, (i_n*i_m));
305
+
306
+ rnorml_(i_v, o_w, &i_n, &i_m, &i_x, &i_y);
307
+
308
+ {int array_shape[2] = {i_n, i_m};
309
+ w = dcl_crealary2obj(o_w, (i_n*i_m), 2, array_shape);
310
+ }
311
+
312
+ dcl_freecrealary(i_v);
313
+
314
+ return w;
315
+
316
+ }
317
+
318
+ #endif
319
+ void
320
+ init_math1_clsplib(mDCL)
321
+ VALUE mDCL;
322
+ {
323
+ #if DCLVER >= 544
324
+ rb_define_module_function(mDCL, "clrgsv", dcl_clrgsv, 5);
325
+ rb_define_module_function(mDCL, "clsvrg", dcl_clsvrg, 5);
326
+ rb_define_module_function(mDCL, "inorml", dcl_inorml, 5);
327
+ rb_define_module_function(mDCL, "rnorml", dcl_rnorml, 5);
328
+ #endif
329
+ }
data/misc1_randlib.c CHANGED
@@ -61,6 +61,34 @@ extern real rcor_(real *, real *, integer *, integer *, integer *);
61
61
 
62
62
  extern VALUE mDCL;
63
63
 
64
+ #if DCLVER >= 544
65
+
66
+ static VALUE
67
+ dcl_rngu0(obj, iseed)
68
+ VALUE obj, iseed;
69
+ {
70
+ integer io_iseed;
71
+ real o_rtn_val;
72
+ VALUE rtn_val;
73
+
74
+ if ((TYPE(iseed) != T_BIGNUM) || (TYPE(iseed) != T_FIXNUM)) {
75
+ iseed = rb_funcall(iseed, rb_intern("to_i"), 0);
76
+ }
77
+
78
+ io_iseed = NUM2INT(iseed);
79
+
80
+
81
+ o_rtn_val = rngu0_(&io_iseed);
82
+
83
+ rtn_val = rb_float_new((double)o_rtn_val);
84
+
85
+
86
+ return rtn_val;
87
+
88
+ }
89
+
90
+ #endif
91
+
64
92
  static VALUE
65
93
  dcl_rngu1(obj, iseed)
66
94
  VALUE obj, iseed;
@@ -109,6 +137,8 @@ dcl_rngu2(obj, iseed)
109
137
 
110
138
  }
111
139
 
140
+ #if DCLVER < 544
141
+
112
142
  static VALUE
113
143
  dcl_rngu3(obj, iseed)
114
144
  VALUE obj, iseed;
@@ -132,11 +162,18 @@ dcl_rngu3(obj, iseed)
132
162
  return rtn_val;
133
163
 
134
164
  }
165
+
166
+ #endif
135
167
  void
136
168
  init_misc1_randlib(mDCL)
137
169
  VALUE mDCL;
138
170
  {
171
+ #if DCLVER >= 544
172
+ rb_define_module_function(mDCL, "rngu0", dcl_rngu0, 1);
173
+ #endif
139
174
  rb_define_module_function(mDCL, "rngu1", dcl_rngu1, 1);
140
175
  rb_define_module_function(mDCL, "rngu2", dcl_rngu2, 1);
176
+ #if DCLVER < 544
141
177
  rb_define_module_function(mDCL, "rngu3", dcl_rngu3, 1);
178
+ #endif
142
179
  }
data/ruby-dcl.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path("../lib", __FILE__)
3
+ require "dcl/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ruby-dcl"
7
+ s.version = DCL::VERSION
8
+ s.authors = ["T. Horinouchi", "K. Kuroi", "K. Goto"\
9
+ ,"S. Nishizawa", "T. Koshiro",'GFD Dennou Club']
10
+ s.email = ["eriko@gfd-dennou.org"]
11
+ s.homepage = 'http://www.gfd-dennou.org/arch/ruby/products/ruby-dcl/'
12
+ s.summary = %q{one-to-one interface to the DCL graphic library}
13
+ s.description = %q{RubyDCL is a ruby interface to the scientific graphic library DCL. It supports all the subroutines and functions in DCL on a one-to-one basis. }
14
+
15
+ s.rubyforge_project = "ruby-dcl"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.extensions << "extconf.rb"
22
+
23
+ # specify any dependencies here; for example:
24
+ #s.add_development_dependency "rspec"
25
+ #s.add_runtime_dependency "narray"
26
+ s.required_ruby_version = Gem::Requirement.new(">= 1.6")
27
+ s.add_runtime_dependency(%q<narray>, [">= 0.5.5"])
28
+ s.add_runtime_dependency(%q<narray_miss>, [">= 0"])
29
+ s.add_runtime_dependency(%q<gtk2>, [">= 0"])
30
+ end