umappp 0.2.3 → 0.3.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f50fd5a0af819b29f30afbf2cad8e059c679b9691b2c42a106724d7c9cb313e3
4
- data.tar.gz: d4f583765cc15aec1f4102d35699208cac47df086cea14fd485eb99c15b8a027
3
+ metadata.gz: c68c5f7c5b926e85a0b1bff33b63b0ed7b8b85ce7d6d5bc2201cfe786257186e
4
+ data.tar.gz: 6dfad841a2bce23247f695794f9406ec5aa299050093aed7d1a9b1488b43f8aa
5
5
  SHA512:
6
- metadata.gz: 9a505cbe40f4b059dc2af714759fe1cbcda70cd132fe08fe1e463a20e93c3fa3b8981152116b94e2f5e3ff1aa344959d0f815368c1838cef17cdcdfb6288dce6
7
- data.tar.gz: 7798c54f1a7bd98fb3decc32ef779e945b41d3332bd2d3b5a0c58570c084840a2da5c0af57b185d4c57b93d3b49506cb65ac86d5ccb48ba9570ba013b4de71ef
6
+ metadata.gz: 3af57550e78807e3963268059ae67b2cf47adffd940eac9e4abdd928c981740c4fefa4e7a291b94494426f5d21111f06c712b98322ec03049efeb15ca094e5d7
7
+ data.tar.gz: 47a32499f18e625e79ca964c0b6ce008717404d7ae7e2cf00050a9de9dcb28e7ccf86c4d118013c82413584e9a6a92c0240405f569a522742cdf582afbe22b20
data/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  - Ruby Umappp is a wrapper library for [C++ Umappp library](https://github.com/LTLA/umappp) created by Aaron Lun
14
14
  - Compatible with [yaumap](https://github.com/LTLA/yaumap)
15
- - Support [Numo::NArray](https://github.com/ruby-numo/numo-narray)
15
+ - Support [Numo::NArray Alternative](https://github.com/yoshoku/numo-narray-alt)
16
16
 
17
17
  ## Installation
18
18
 
@@ -24,7 +24,7 @@ gem install umappp
24
24
 
25
25
  ## Usage
26
26
 
27
- This Gem provides the module `Umappp` and its singular method `Umappp.run()`. The first argument of `Umappp.run()` is a two-dimensional Ruby array or a two-dimensional Numo array. [Numo](https://github.com/ruby-numo/numo-narray) is a library for performing N-dimensional array computing like NumPy. The argument is converted to `Numo::SFloat`. SFloat is a single precision floating point number type of Numo::NArray.
27
+ This Gem provides the module `Umappp` and its singular method `Umappp.run()`. The first argument of `Umappp.run()` is a two-dimensional Ruby array or a two-dimensional Numo array. [Numo::NArray Alternative](https://github.com/yoshoku/numo-narray-alt) is a library for performing N-dimensional array computing like NumPy. The argument is converted to `Numo::SFloat`. SFloat is a single precision floating point number type of Numo::NArray.
28
28
 
29
29
  ```ruby
30
30
  # Original high-dimensional data as two-dimensional Ruby array or Numo array
@@ -13,10 +13,13 @@ if have_library("omp") || have_library("gomp")
13
13
  $CXXFLAGS += " -fopenmp"
14
14
  end
15
15
 
16
- # numo-narray
17
- numo = File.join(Gem.loaded_specs["numo-narray"].require_path, "numo")
16
+ # numo-narray-alt
17
+ numo = File.join(Gem.loaded_specs["numo-narray-alt"].require_path, "numo")
18
18
  abort "Numo header not found" unless find_header("numo/narray.h", numo)
19
- abort "Numo library not found" if Gem.win_platform? && !find_library("narray", nil, numo)
19
+ if Gem.win_platform?
20
+ narray_lib_dirs = [numo, File.join(numo, "narray")]
21
+ abort "Numo library not found" unless find_library("narray", nil, *narray_lib_dirs)
22
+ end
20
23
  find_header("numo.hpp", File.expand_path("../../include", __dir__))
21
24
 
22
25
  dir_config "umap", vendor, vendor
data/ext/umappp/numo.hpp CHANGED
@@ -1,450 +1,362 @@
1
1
  /*!
2
- * Numo.hpp v0.2.1
2
+ * Numo.hpp v0.3.1
3
3
  * https://github.com/ankane/numo.hpp
4
4
  * BSD-2-Clause License
5
5
  */
6
6
 
7
7
  #pragma once
8
8
 
9
+ #include <cstddef>
10
+ #include <cstdint>
11
+ #include <initializer_list>
12
+
9
13
  #include <rice/rice.hpp>
14
+
10
15
  #include <numo/narray.h>
11
16
 
12
17
  namespace numo {
13
18
 
14
- class NArray {
19
+ class NArray : public Rice::Object {
15
20
  public:
16
- NArray(VALUE v) {
17
- construct_value(this->dtype(), v);
18
- }
19
-
20
- NArray(Rice::Object o) {
21
- construct_value(this->dtype(), o.value());
22
- }
21
+ NArray(VALUE v) : NArray(dtype(), v) { }
23
22
 
24
- VALUE value() const {
25
- return this->_value;
26
- }
23
+ NArray(Rice::Object o) : NArray(dtype(), o.value()) { }
27
24
 
28
25
  size_t ndim() const {
29
- return RNARRAY_NDIM(this->_value);
26
+ return RNARRAY_NDIM(value());
30
27
  }
31
28
 
32
29
  size_t* shape() const {
33
- return RNARRAY_SHAPE(this->_value);
30
+ return RNARRAY_SHAPE(value());
34
31
  }
35
32
 
36
- size_t size() const {
37
- return RNARRAY_SIZE(this->_value);
33
+ size_t shape(size_t n) const {
34
+ if (n >= ndim()) {
35
+ throw std::out_of_range{"index out of range"};
36
+ }
37
+ return shape()[n];
38
38
  }
39
39
 
40
- bool is_contiguous() const {
41
- return nary_check_contiguous(this->_value) == Qtrue;
40
+ size_t size() const {
41
+ return RNARRAY_SIZE(value());
42
42
  }
43
43
 
44
- operator Rice::Object() const {
45
- return Rice::Object(this->_value);
44
+ bool is_contiguous() const {
45
+ return Rice::detail::protect(nary_check_contiguous, value()) == Qtrue;
46
46
  }
47
47
 
48
48
  const void* read_ptr() {
49
- if (!is_contiguous()) {
50
- this->_value = nary_dup(this->_value);
51
- }
52
- return nary_get_pointer_for_read(this->_value) + nary_get_offset(this->_value);
49
+ return Rice::detail::protect([&]() {
50
+ if (!nary_check_contiguous(value())) {
51
+ set_value(nary_dup(value()));
52
+ }
53
+ return nary_get_pointer_for_read(value()) + nary_get_offset(value());
54
+ });
53
55
  }
54
56
 
55
57
  void* write_ptr() {
56
- return nary_get_pointer_for_write(this->_value);
58
+ return Rice::detail::protect(nary_get_pointer_for_write, value());
57
59
  }
58
60
 
59
61
  protected:
60
- NArray() { }
62
+ NArray(VALUE dtype, VALUE v) : Rice::Object(Rice::detail::protect(rb_funcall, dtype, rb_intern("cast"), 1, v)) { }
61
63
 
62
- void construct_value(VALUE dtype, VALUE v) {
63
- this->_value = rb_funcall(dtype, rb_intern("cast"), 1, v);
64
- }
65
-
66
- void construct_shape(VALUE dtype, std::initializer_list<size_t> shape) {
67
- // rb_narray_new doesn't modify shape, but not marked as const
68
- this->_value = rb_narray_new(dtype, shape.size(), const_cast<size_t*>(shape.begin()));
69
- }
64
+ NArray(VALUE dtype, Rice::Object o) : NArray(dtype, o.value()) { }
70
65
 
71
- VALUE _value;
66
+ // rb_narray_new doesn't modify shape, but not marked as const
67
+ NArray(VALUE dtype, std::initializer_list<size_t> shape) : Rice::Object(Rice::detail::protect(rb_narray_new, dtype, shape.size(), const_cast<size_t*>(shape.begin()))) { }
72
68
 
73
69
  private:
74
- VALUE dtype() {
70
+ static VALUE dtype() {
75
71
  return numo_cNArray;
76
72
  }
77
73
  };
78
74
 
79
75
  class SFloat: public NArray {
80
76
  public:
81
- SFloat(VALUE v) {
82
- construct_value(this->dtype(), v);
83
- }
77
+ SFloat(VALUE v) : NArray(dtype(), v) { }
84
78
 
85
- SFloat(Rice::Object o) {
86
- construct_value(this->dtype(), o.value());
87
- }
79
+ SFloat(Rice::Object o) : NArray(dtype(), o) { }
88
80
 
89
- SFloat(std::initializer_list<size_t> shape) {
90
- construct_shape(this->dtype(), shape);
91
- }
81
+ SFloat(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
92
82
 
93
83
  const float* read_ptr() {
94
- return reinterpret_cast<const float*>(NArray::read_ptr());
84
+ return static_cast<const float*>(NArray::read_ptr());
95
85
  }
96
86
 
97
87
  float* write_ptr() {
98
- return reinterpret_cast<float*>(NArray::write_ptr());
88
+ return static_cast<float*>(NArray::write_ptr());
99
89
  }
100
90
 
101
91
  private:
102
- VALUE dtype() {
92
+ static VALUE dtype() {
103
93
  return numo_cSFloat;
104
94
  }
105
95
  };
106
96
 
107
97
  class DFloat: public NArray {
108
98
  public:
109
- DFloat(VALUE v) {
110
- construct_value(this->dtype(), v);
111
- }
99
+ DFloat(VALUE v) : NArray(dtype(), v) { }
112
100
 
113
- DFloat(Rice::Object o) {
114
- construct_value(this->dtype(), o.value());
115
- }
101
+ DFloat(Rice::Object o) : NArray(dtype(), o) { }
116
102
 
117
- DFloat(std::initializer_list<size_t> shape) {
118
- construct_shape(this->dtype(), shape);
119
- }
103
+ DFloat(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
120
104
 
121
105
  const double* read_ptr() {
122
- return reinterpret_cast<const double*>(NArray::read_ptr());
106
+ return static_cast<const double*>(NArray::read_ptr());
123
107
  }
124
108
 
125
109
  double* write_ptr() {
126
- return reinterpret_cast<double*>(NArray::write_ptr());
110
+ return static_cast<double*>(NArray::write_ptr());
127
111
  }
128
112
 
129
113
  private:
130
- VALUE dtype() {
114
+ static VALUE dtype() {
131
115
  return numo_cDFloat;
132
116
  }
133
117
  };
134
118
 
135
119
  class Int8: public NArray {
136
120
  public:
137
- Int8(VALUE v) {
138
- construct_value(this->dtype(), v);
139
- }
121
+ Int8(VALUE v) : NArray(dtype(), v) { }
140
122
 
141
- Int8(Rice::Object o) {
142
- construct_value(this->dtype(), o.value());
143
- }
123
+ Int8(Rice::Object o) : NArray(dtype(), o) { }
144
124
 
145
- Int8(std::initializer_list<size_t> shape) {
146
- construct_shape(this->dtype(), shape);
147
- }
125
+ Int8(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
148
126
 
149
127
  const int8_t* read_ptr() {
150
- return reinterpret_cast<const int8_t*>(NArray::read_ptr());
128
+ return static_cast<const int8_t*>(NArray::read_ptr());
151
129
  }
152
130
 
153
131
  int8_t* write_ptr() {
154
- return reinterpret_cast<int8_t*>(NArray::write_ptr());
132
+ return static_cast<int8_t*>(NArray::write_ptr());
155
133
  }
156
134
 
157
135
  private:
158
- VALUE dtype() {
136
+ static VALUE dtype() {
159
137
  return numo_cInt8;
160
138
  }
161
139
  };
162
140
 
163
141
  class Int16: public NArray {
164
142
  public:
165
- Int16(VALUE v) {
166
- construct_value(this->dtype(), v);
167
- }
143
+ Int16(VALUE v) : NArray(dtype(), v) { }
168
144
 
169
- Int16(Rice::Object o) {
170
- construct_value(this->dtype(), o.value());
171
- }
145
+ Int16(Rice::Object o) : NArray(dtype(), o) { }
172
146
 
173
- Int16(std::initializer_list<size_t> shape) {
174
- construct_shape(this->dtype(), shape);
175
- }
147
+ Int16(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
176
148
 
177
149
  const int16_t* read_ptr() {
178
- return reinterpret_cast<const int16_t*>(NArray::read_ptr());
150
+ return static_cast<const int16_t*>(NArray::read_ptr());
179
151
  }
180
152
 
181
153
  int16_t* write_ptr() {
182
- return reinterpret_cast<int16_t*>(NArray::write_ptr());
154
+ return static_cast<int16_t*>(NArray::write_ptr());
183
155
  }
184
156
 
185
157
  private:
186
- VALUE dtype() {
158
+ static VALUE dtype() {
187
159
  return numo_cInt16;
188
160
  }
189
161
  };
190
162
 
191
163
  class Int32: public NArray {
192
164
  public:
193
- Int32(VALUE v) {
194
- construct_value(this->dtype(), v);
195
- }
165
+ Int32(VALUE v) : NArray(dtype(), v) { }
196
166
 
197
- Int32(Rice::Object o) {
198
- construct_value(this->dtype(), o.value());
199
- }
167
+ Int32(Rice::Object o) : NArray(dtype(), o) { }
200
168
 
201
- Int32(std::initializer_list<size_t> shape) {
202
- construct_shape(this->dtype(), shape);
203
- }
169
+ Int32(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
204
170
 
205
171
  const int32_t* read_ptr() {
206
- return reinterpret_cast<const int32_t*>(NArray::read_ptr());
172
+ return static_cast<const int32_t*>(NArray::read_ptr());
207
173
  }
208
174
 
209
175
  int32_t* write_ptr() {
210
- return reinterpret_cast<int32_t*>(NArray::write_ptr());
176
+ return static_cast<int32_t*>(NArray::write_ptr());
211
177
  }
212
178
 
213
179
  private:
214
- VALUE dtype() {
180
+ static VALUE dtype() {
215
181
  return numo_cInt32;
216
182
  }
217
183
  };
218
184
 
219
185
  class Int64: public NArray {
220
186
  public:
221
- Int64(VALUE v) {
222
- construct_value(this->dtype(), v);
223
- }
187
+ Int64(VALUE v) : NArray(dtype(), v) { }
224
188
 
225
- Int64(Rice::Object o) {
226
- construct_value(this->dtype(), o.value());
227
- }
189
+ Int64(Rice::Object o) : NArray(dtype(), o) { }
228
190
 
229
- Int64(std::initializer_list<size_t> shape) {
230
- construct_shape(this->dtype(), shape);
231
- }
191
+ Int64(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
232
192
 
233
193
  const int64_t* read_ptr() {
234
- return reinterpret_cast<const int64_t*>(NArray::read_ptr());
194
+ return static_cast<const int64_t*>(NArray::read_ptr());
235
195
  }
236
196
 
237
197
  int64_t* write_ptr() {
238
- return reinterpret_cast<int64_t*>(NArray::write_ptr());
198
+ return static_cast<int64_t*>(NArray::write_ptr());
239
199
  }
240
200
 
241
201
  private:
242
- VALUE dtype() {
202
+ static VALUE dtype() {
243
203
  return numo_cInt64;
244
204
  }
245
205
  };
246
206
 
247
207
  class UInt8: public NArray {
248
208
  public:
249
- UInt8(VALUE v) {
250
- construct_value(this->dtype(), v);
251
- }
209
+ UInt8(VALUE v) : NArray(dtype(), v) { }
252
210
 
253
- UInt8(Rice::Object o) {
254
- construct_value(this->dtype(), o.value());
255
- }
211
+ UInt8(Rice::Object o) : NArray(dtype(), o) { }
256
212
 
257
- UInt8(std::initializer_list<size_t> shape) {
258
- construct_shape(this->dtype(), shape);
259
- }
213
+ UInt8(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
260
214
 
261
215
  const uint8_t* read_ptr() {
262
- return reinterpret_cast<const uint8_t*>(NArray::read_ptr());
216
+ return static_cast<const uint8_t*>(NArray::read_ptr());
263
217
  }
264
218
 
265
219
  uint8_t* write_ptr() {
266
- return reinterpret_cast<uint8_t*>(NArray::write_ptr());
220
+ return static_cast<uint8_t*>(NArray::write_ptr());
267
221
  }
268
222
 
269
223
  private:
270
- VALUE dtype() {
224
+ static VALUE dtype() {
271
225
  return numo_cUInt8;
272
226
  }
273
227
  };
274
228
 
275
229
  class UInt16: public NArray {
276
230
  public:
277
- UInt16(VALUE v) {
278
- construct_value(this->dtype(), v);
279
- }
231
+ UInt16(VALUE v) : NArray(dtype(), v) { }
280
232
 
281
- UInt16(Rice::Object o) {
282
- construct_value(this->dtype(), o.value());
283
- }
233
+ UInt16(Rice::Object o) : NArray(dtype(), o) { }
284
234
 
285
- UInt16(std::initializer_list<size_t> shape) {
286
- construct_shape(this->dtype(), shape);
287
- }
235
+ UInt16(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
288
236
 
289
237
  const uint16_t* read_ptr() {
290
- return reinterpret_cast<const uint16_t*>(NArray::read_ptr());
238
+ return static_cast<const uint16_t*>(NArray::read_ptr());
291
239
  }
292
240
 
293
241
  uint16_t* write_ptr() {
294
- return reinterpret_cast<uint16_t*>(NArray::write_ptr());
242
+ return static_cast<uint16_t*>(NArray::write_ptr());
295
243
  }
296
244
 
297
245
  private:
298
- VALUE dtype() {
246
+ static VALUE dtype() {
299
247
  return numo_cUInt16;
300
248
  }
301
249
  };
302
250
 
303
251
  class UInt32: public NArray {
304
252
  public:
305
- UInt32(VALUE v) {
306
- construct_value(this->dtype(), v);
307
- }
253
+ UInt32(VALUE v) : NArray(dtype(), v) { }
308
254
 
309
- UInt32(Rice::Object o) {
310
- construct_value(this->dtype(), o.value());
311
- }
255
+ UInt32(Rice::Object o) : NArray(dtype(), o) { }
312
256
 
313
- UInt32(std::initializer_list<size_t> shape) {
314
- construct_shape(this->dtype(), shape);
315
- }
257
+ UInt32(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
316
258
 
317
259
  const uint32_t* read_ptr() {
318
- return reinterpret_cast<const uint32_t*>(NArray::read_ptr());
260
+ return static_cast<const uint32_t*>(NArray::read_ptr());
319
261
  }
320
262
 
321
263
  uint32_t* write_ptr() {
322
- return reinterpret_cast<uint32_t*>(NArray::write_ptr());
264
+ return static_cast<uint32_t*>(NArray::write_ptr());
323
265
  }
324
266
 
325
267
  private:
326
- VALUE dtype() {
268
+ static VALUE dtype() {
327
269
  return numo_cUInt32;
328
270
  }
329
271
  };
330
272
 
331
273
  class UInt64: public NArray {
332
274
  public:
333
- UInt64(VALUE v) {
334
- construct_value(this->dtype(), v);
335
- }
275
+ UInt64(VALUE v) : NArray(dtype(), v) { }
336
276
 
337
- UInt64(Rice::Object o) {
338
- construct_value(this->dtype(), o.value());
339
- }
277
+ UInt64(Rice::Object o) : NArray(dtype(), o) { }
340
278
 
341
- UInt64(std::initializer_list<size_t> shape) {
342
- construct_shape(this->dtype(), shape);
343
- }
279
+ UInt64(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
344
280
 
345
281
  const uint64_t* read_ptr() {
346
- return reinterpret_cast<const uint64_t*>(NArray::read_ptr());
282
+ return static_cast<const uint64_t*>(NArray::read_ptr());
347
283
  }
348
284
 
349
285
  uint64_t* write_ptr() {
350
- return reinterpret_cast<uint64_t*>(NArray::write_ptr());
286
+ return static_cast<uint64_t*>(NArray::write_ptr());
351
287
  }
352
288
 
353
289
  private:
354
- VALUE dtype() {
290
+ static VALUE dtype() {
355
291
  return numo_cUInt64;
356
292
  }
357
293
  };
358
294
 
359
295
  class SComplex: public NArray {
360
296
  public:
361
- SComplex(VALUE v) {
362
- construct_value(this->dtype(), v);
363
- }
297
+ SComplex(VALUE v) : NArray(dtype(), v) { }
364
298
 
365
- SComplex(Rice::Object o) {
366
- construct_value(this->dtype(), o.value());
367
- }
299
+ SComplex(Rice::Object o) : NArray(dtype(), o) { }
368
300
 
369
- SComplex(std::initializer_list<size_t> shape) {
370
- construct_shape(this->dtype(), shape);
371
- }
301
+ SComplex(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
372
302
 
373
303
  private:
374
- VALUE dtype() {
304
+ static VALUE dtype() {
375
305
  return numo_cSComplex;
376
306
  }
377
307
  };
378
308
 
379
309
  class DComplex: public NArray {
380
310
  public:
381
- DComplex(VALUE v) {
382
- construct_value(this->dtype(), v);
383
- }
311
+ DComplex(VALUE v) : NArray(dtype(), v) { }
384
312
 
385
- DComplex(Rice::Object o) {
386
- construct_value(this->dtype(), o.value());
387
- }
313
+ DComplex(Rice::Object o) : NArray(dtype(), o) { }
388
314
 
389
- DComplex(std::initializer_list<size_t> shape) {
390
- construct_shape(this->dtype(), shape);
391
- }
315
+ DComplex(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
392
316
 
393
317
  private:
394
- VALUE dtype() {
318
+ static VALUE dtype() {
395
319
  return numo_cDComplex;
396
320
  }
397
321
  };
398
322
 
399
323
  class Bit: public NArray {
400
324
  public:
401
- Bit(VALUE v) {
402
- construct_value(this->dtype(), v);
403
- }
325
+ Bit(VALUE v) : NArray(dtype(), v) { }
404
326
 
405
- Bit(Rice::Object o) {
406
- construct_value(this->dtype(), o.value());
407
- }
327
+ Bit(Rice::Object o) : NArray(dtype(), o) { }
408
328
 
409
- Bit(std::initializer_list<size_t> shape) {
410
- construct_shape(this->dtype(), shape);
411
- }
329
+ Bit(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
412
330
 
413
331
  private:
414
- VALUE dtype() {
332
+ static VALUE dtype() {
415
333
  return numo_cBit;
416
334
  }
417
335
  };
418
336
 
419
337
  class RObject: public NArray {
420
338
  public:
421
- RObject(VALUE v) {
422
- construct_value(this->dtype(), v);
423
- }
339
+ RObject(VALUE v) : NArray(dtype(), v) { }
424
340
 
425
- RObject(Rice::Object o) {
426
- construct_value(this->dtype(), o.value());
427
- }
341
+ RObject(Rice::Object o) : NArray(dtype(), o) { }
428
342
 
429
- RObject(std::initializer_list<size_t> shape) {
430
- construct_shape(this->dtype(), shape);
431
- }
343
+ RObject(std::initializer_list<size_t> shape) : NArray(dtype(), shape) { }
432
344
 
433
345
  const VALUE* read_ptr() {
434
- return reinterpret_cast<const VALUE*>(NArray::read_ptr());
346
+ return static_cast<const VALUE*>(NArray::read_ptr());
435
347
  }
436
348
 
437
349
  VALUE* write_ptr() {
438
- return reinterpret_cast<VALUE*>(NArray::write_ptr());
350
+ return static_cast<VALUE*>(NArray::write_ptr());
439
351
  }
440
352
 
441
353
  private:
442
- VALUE dtype() {
354
+ static VALUE dtype() {
443
355
  return numo_cRObject;
444
356
  }
445
357
  };
446
358
 
447
- }
359
+ } // namespace numo
448
360
 
449
361
  namespace Rice::detail {
450
362
 
@@ -460,12 +372,12 @@ public:
460
372
 
461
373
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
462
374
 
463
- Convertible is_convertible(VALUE value) {
375
+ double is_convertible(VALUE value) {
464
376
  switch (rb_type(value)) {
465
377
  case RUBY_T_DATA:
466
378
  return Data_Type<numo::NArray>::is_descendant(value) ? Convertible::Exact : Convertible::None;
467
379
  case RUBY_T_ARRAY:
468
- return Convertible::Cast;
380
+ return Convertible::Exact;
469
381
  default:
470
382
  return Convertible::None;
471
383
  }
@@ -506,12 +418,12 @@ public:
506
418
 
507
419
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
508
420
 
509
- Convertible is_convertible(VALUE value) {
421
+ double is_convertible(VALUE value) {
510
422
  switch (rb_type(value)) {
511
423
  case RUBY_T_DATA:
512
424
  return Data_Type<numo::SFloat>::is_descendant(value) ? Convertible::Exact : Convertible::None;
513
425
  case RUBY_T_ARRAY:
514
- return Convertible::Cast;
426
+ return Convertible::Exact;
515
427
  default:
516
428
  return Convertible::None;
517
429
  }
@@ -552,12 +464,12 @@ public:
552
464
 
553
465
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
554
466
 
555
- Convertible is_convertible(VALUE value) {
467
+ double is_convertible(VALUE value) {
556
468
  switch (rb_type(value)) {
557
469
  case RUBY_T_DATA:
558
470
  return Data_Type<numo::DFloat>::is_descendant(value) ? Convertible::Exact : Convertible::None;
559
471
  case RUBY_T_ARRAY:
560
- return Convertible::Cast;
472
+ return Convertible::Exact;
561
473
  default:
562
474
  return Convertible::None;
563
475
  }
@@ -598,12 +510,12 @@ public:
598
510
 
599
511
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
600
512
 
601
- Convertible is_convertible(VALUE value) {
513
+ double is_convertible(VALUE value) {
602
514
  switch (rb_type(value)) {
603
515
  case RUBY_T_DATA:
604
516
  return Data_Type<numo::Int8>::is_descendant(value) ? Convertible::Exact : Convertible::None;
605
517
  case RUBY_T_ARRAY:
606
- return Convertible::Cast;
518
+ return Convertible::Exact;
607
519
  default:
608
520
  return Convertible::None;
609
521
  }
@@ -644,12 +556,12 @@ public:
644
556
 
645
557
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
646
558
 
647
- Convertible is_convertible(VALUE value) {
559
+ double is_convertible(VALUE value) {
648
560
  switch (rb_type(value)) {
649
561
  case RUBY_T_DATA:
650
562
  return Data_Type<numo::Int16>::is_descendant(value) ? Convertible::Exact : Convertible::None;
651
563
  case RUBY_T_ARRAY:
652
- return Convertible::Cast;
564
+ return Convertible::Exact;
653
565
  default:
654
566
  return Convertible::None;
655
567
  }
@@ -690,12 +602,12 @@ public:
690
602
 
691
603
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
692
604
 
693
- Convertible is_convertible(VALUE value) {
605
+ double is_convertible(VALUE value) {
694
606
  switch (rb_type(value)) {
695
607
  case RUBY_T_DATA:
696
608
  return Data_Type<numo::Int32>::is_descendant(value) ? Convertible::Exact : Convertible::None;
697
609
  case RUBY_T_ARRAY:
698
- return Convertible::Cast;
610
+ return Convertible::Exact;
699
611
  default:
700
612
  return Convertible::None;
701
613
  }
@@ -736,12 +648,12 @@ public:
736
648
 
737
649
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
738
650
 
739
- Convertible is_convertible(VALUE value) {
651
+ double is_convertible(VALUE value) {
740
652
  switch (rb_type(value)) {
741
653
  case RUBY_T_DATA:
742
654
  return Data_Type<numo::Int64>::is_descendant(value) ? Convertible::Exact : Convertible::None;
743
655
  case RUBY_T_ARRAY:
744
- return Convertible::Cast;
656
+ return Convertible::Exact;
745
657
  default:
746
658
  return Convertible::None;
747
659
  }
@@ -782,12 +694,12 @@ public:
782
694
 
783
695
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
784
696
 
785
- Convertible is_convertible(VALUE value) {
697
+ double is_convertible(VALUE value) {
786
698
  switch (rb_type(value)) {
787
699
  case RUBY_T_DATA:
788
700
  return Data_Type<numo::UInt8>::is_descendant(value) ? Convertible::Exact : Convertible::None;
789
701
  case RUBY_T_ARRAY:
790
- return Convertible::Cast;
702
+ return Convertible::Exact;
791
703
  default:
792
704
  return Convertible::None;
793
705
  }
@@ -828,12 +740,12 @@ public:
828
740
 
829
741
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
830
742
 
831
- Convertible is_convertible(VALUE value) {
743
+ double is_convertible(VALUE value) {
832
744
  switch (rb_type(value)) {
833
745
  case RUBY_T_DATA:
834
746
  return Data_Type<numo::UInt16>::is_descendant(value) ? Convertible::Exact : Convertible::None;
835
747
  case RUBY_T_ARRAY:
836
- return Convertible::Cast;
748
+ return Convertible::Exact;
837
749
  default:
838
750
  return Convertible::None;
839
751
  }
@@ -874,12 +786,12 @@ public:
874
786
 
875
787
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
876
788
 
877
- Convertible is_convertible(VALUE value) {
789
+ double is_convertible(VALUE value) {
878
790
  switch (rb_type(value)) {
879
791
  case RUBY_T_DATA:
880
792
  return Data_Type<numo::UInt32>::is_descendant(value) ? Convertible::Exact : Convertible::None;
881
793
  case RUBY_T_ARRAY:
882
- return Convertible::Cast;
794
+ return Convertible::Exact;
883
795
  default:
884
796
  return Convertible::None;
885
797
  }
@@ -920,12 +832,12 @@ public:
920
832
 
921
833
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
922
834
 
923
- Convertible is_convertible(VALUE value) {
835
+ double is_convertible(VALUE value) {
924
836
  switch (rb_type(value)) {
925
837
  case RUBY_T_DATA:
926
838
  return Data_Type<numo::UInt64>::is_descendant(value) ? Convertible::Exact : Convertible::None;
927
839
  case RUBY_T_ARRAY:
928
- return Convertible::Cast;
840
+ return Convertible::Exact;
929
841
  default:
930
842
  return Convertible::None;
931
843
  }
@@ -966,12 +878,12 @@ public:
966
878
 
967
879
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
968
880
 
969
- Convertible is_convertible(VALUE value) {
881
+ double is_convertible(VALUE value) {
970
882
  switch (rb_type(value)) {
971
883
  case RUBY_T_DATA:
972
884
  return Data_Type<numo::SComplex>::is_descendant(value) ? Convertible::Exact : Convertible::None;
973
885
  case RUBY_T_ARRAY:
974
- return Convertible::Cast;
886
+ return Convertible::Exact;
975
887
  default:
976
888
  return Convertible::None;
977
889
  }
@@ -1012,12 +924,12 @@ public:
1012
924
 
1013
925
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
1014
926
 
1015
- Convertible is_convertible(VALUE value) {
927
+ double is_convertible(VALUE value) {
1016
928
  switch (rb_type(value)) {
1017
929
  case RUBY_T_DATA:
1018
930
  return Data_Type<numo::DComplex>::is_descendant(value) ? Convertible::Exact : Convertible::None;
1019
931
  case RUBY_T_ARRAY:
1020
- return Convertible::Cast;
932
+ return Convertible::Exact;
1021
933
  default:
1022
934
  return Convertible::None;
1023
935
  }
@@ -1058,12 +970,12 @@ public:
1058
970
 
1059
971
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
1060
972
 
1061
- Convertible is_convertible(VALUE value) {
973
+ double is_convertible(VALUE value) {
1062
974
  switch (rb_type(value)) {
1063
975
  case RUBY_T_DATA:
1064
976
  return Data_Type<numo::Bit>::is_descendant(value) ? Convertible::Exact : Convertible::None;
1065
977
  case RUBY_T_ARRAY:
1066
- return Convertible::Cast;
978
+ return Convertible::Exact;
1067
979
  default:
1068
980
  return Convertible::None;
1069
981
  }
@@ -1104,12 +1016,12 @@ public:
1104
1016
 
1105
1017
  explicit From_Ruby(Arg* arg) : arg_(arg) { }
1106
1018
 
1107
- Convertible is_convertible(VALUE value) {
1019
+ double is_convertible(VALUE value) {
1108
1020
  switch (rb_type(value)) {
1109
1021
  case RUBY_T_DATA:
1110
1022
  return Data_Type<numo::RObject>::is_descendant(value) ? Convertible::Exact : Convertible::None;
1111
1023
  case RUBY_T_ARRAY:
1112
- return Convertible::Cast;
1024
+ return Convertible::Exact;
1113
1025
  default:
1114
1026
  return Convertible::None;
1115
1027
  }
@@ -1138,4 +1050,4 @@ private:
1138
1050
  Arg* arg_ = nullptr;
1139
1051
  };
1140
1052
 
1141
- }
1053
+ } // namespace Rice::detail
@@ -5,6 +5,7 @@
5
5
 
6
6
  #include <rice/rice.hpp>
7
7
  #include <rice/stl.hpp>
8
+ #include <ruby/thread.h>
8
9
  #include <exception>
9
10
  #include <string>
10
11
  #include "numo.hpp"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Umappp
4
- VERSION = "0.2.3"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umappp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
@@ -10,7 +10,7 @@ cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
- name: numo-narray
13
+ name: numo-narray-alt
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - ">="
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 4.5.0
32
+ version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: 4.5.0
39
+ version: '0'
40
40
  description: Umappp wrapper for Ruby
41
41
  email:
42
42
  - 2xijok@gmail.com
@@ -449,14 +449,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
449
449
  requirements:
450
450
  - - ">="
451
451
  - !ruby/object:Gem::Version
452
- version: '2.7'
452
+ version: '3.0'
453
453
  required_rubygems_version: !ruby/object:Gem::Requirement
454
454
  requirements:
455
455
  - - ">="
456
456
  - !ruby/object:Gem::Version
457
457
  version: '0'
458
458
  requirements: []
459
- rubygems_version: 3.7.2
459
+ rubygems_version: 4.0.10
460
460
  specification_version: 4
461
461
  summary: Umap for Ruby
462
462
  test_files: []