carray 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{LICENSES → LICENSE} +0 -0
- data/NEWS.md +42 -0
- data/README.md +5 -5
- data/TODO.md +16 -0
- data/carray.gemspec +9 -5
- data/ext/ca_iter_block.c +3 -5
- data/ext/ca_iter_dimension.c +4 -5
- data/ext/ca_iter_window.c +2 -4
- data/ext/ca_obj_array.c +394 -124
- data/ext/ca_obj_bitarray.c +3 -5
- data/ext/ca_obj_bitfield.c +3 -5
- data/ext/ca_obj_block.c +6 -8
- data/ext/ca_obj_fake.c +3 -5
- data/ext/ca_obj_farray.c +3 -5
- data/ext/ca_obj_field.c +15 -17
- data/ext/ca_obj_grid.c +5 -6
- data/ext/ca_obj_mapping.c +2 -4
- data/ext/ca_obj_object.c +3 -5
- data/ext/ca_obj_reduce.c +2 -4
- data/ext/ca_obj_refer.c +5 -7
- data/ext/ca_obj_repeat.c +2 -4
- data/ext/ca_obj_select.c +2 -4
- data/ext/ca_obj_shift.c +3 -5
- data/ext/ca_obj_transpose.c +3 -5
- data/ext/ca_obj_unbound_repeat.c +58 -81
- data/ext/ca_obj_window.c +7 -9
- data/ext/carray.h +13 -8
- data/ext/carray_access.c +111 -18
- data/ext/carray_attribute.c +136 -197
- data/ext/carray_call_cfunc.c +1 -3
- data/ext/carray_cast.c +344 -143
- data/ext/carray_cast_func.rb +1 -2
- data/ext/carray_class.c +28 -36
- data/ext/carray_conversion.c +49 -59
- data/ext/carray_copy.c +16 -32
- data/ext/carray_core.c +51 -44
- data/ext/carray_element.c +25 -44
- data/ext/carray_generate.c +71 -50
- data/ext/carray_iterator.c +13 -15
- data/ext/carray_loop.c +53 -82
- data/ext/carray_mask.c +87 -117
- data/ext/carray_math.rb +8 -10
- data/ext/carray_mathfunc.c +1 -3
- data/ext/carray_numeric.c +19 -3
- data/ext/carray_operator.c +45 -32
- data/ext/carray_order.c +72 -65
- data/ext/carray_sort_addr.c +14 -21
- data/ext/carray_stat.c +1 -3
- data/ext/carray_stat_proc.rb +2 -4
- data/ext/carray_test.c +28 -30
- data/ext/carray_undef.c +1 -3
- data/ext/carray_utils.c +12 -4
- data/ext/extconf.rb +1 -1
- data/ext/mkmath.rb +1 -1
- data/ext/ruby_carray.c +11 -6
- data/ext/ruby_ccomplex.c +1 -3
- data/ext/ruby_float_func.c +1 -3
- data/ext/version.h +5 -7
- data/lib/carray.rb +2 -0
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +6 -6
- data/lib/carray/broadcast.rb +45 -0
- data/lib/carray/construct.rb +21 -4
- data/lib/carray/iterator.rb +1 -0
- data/lib/carray/ordering.rb +28 -2
- data/spec/Classes/CABitfield_spec.rb +58 -0
- data/spec/Classes/CABlockIterator_spec.rb +114 -0
- data/spec/Classes/CABlock_spec.rb +205 -0
- data/spec/Classes/CAField_spec.rb +39 -0
- data/spec/Classes/CAGrid_spec.rb +75 -0
- data/spec/Classes/CAMap_spec.rb +0 -0
- data/{test/test_CAMapping.rb → spec/Classes/CAMapping_spec.rb} +35 -36
- data/spec/Classes/CAObject_attribute_spec.rb +33 -0
- data/spec/Classes/CAObject_spec.rb +33 -0
- data/spec/Classes/CARefer_spec.rb +93 -0
- data/spec/Classes/CARepeat_spec.rb +65 -0
- data/spec/Classes/CASelect_spec.rb +22 -0
- data/spec/Classes/CAShift_spec.rb +16 -0
- data/spec/Classes/CAStruct_spec.rb +71 -0
- data/{test/test_CATranspose.rb → spec/Classes/CATranspose_spec.rb} +20 -21
- data/spec/Classes/CAUnboudRepeat_spec.rb +78 -0
- data/spec/Classes/CAWindow_spec.rb +54 -0
- data/spec/Classes/CAWrap_spec.rb +8 -0
- data/{test/test_CArray.rb → spec/Classes/CArray_spec.rb} +48 -92
- data/spec/Classes/CScalar_spec.rb +55 -0
- data/spec/Features/feature_130_spec.rb +19 -0
- data/spec/Features/feature_attributes_spec.rb +280 -0
- data/spec/Features/feature_boolean_spec.rb +97 -0
- data/spec/Features/feature_broadcast.rb +100 -0
- data/spec/Features/feature_cast_function.rb +19 -0
- data/spec/Features/feature_cast_spec.rb +33 -0
- data/spec/Features/feature_class_spec.rb +84 -0
- data/spec/Features/feature_complex_spec.rb +42 -0
- data/{test/test_composite.rb → spec/Features/feature_composite_spec.rb} +17 -18
- data/spec/Features/feature_convert_spec.rb +46 -0
- data/spec/Features/feature_copy_spec.rb +123 -0
- data/spec/Features/feature_creation_spec.rb +84 -0
- data/spec/Features/feature_element_spec.rb +144 -0
- data/spec/Features/feature_extream_spec.rb +54 -0
- data/spec/Features/feature_generate_spec.rb +74 -0
- data/spec/Features/feature_index_spec.rb +69 -0
- data/spec/Features/feature_mask_spec.rb +574 -0
- data/spec/Features/feature_math_spec.rb +97 -0
- data/spec/Features/feature_order_spec.rb +146 -0
- data/spec/Features/feature_ref_store_spec.rb +209 -0
- data/spec/Features/feature_serialization_spec.rb +125 -0
- data/spec/Features/feature_stat_spec.rb +397 -0
- data/spec/Features/feature_virtual_spec.rb +48 -0
- data/spec/Features/method_eq_spec.rb +81 -0
- data/spec/Features/method_is_nan_spec.rb +12 -0
- data/spec/Features/method_map_spec.rb +54 -0
- data/spec/Features/method_max_with.rb +20 -0
- data/spec/Features/method_min_with.rb +19 -0
- data/spec/Features/method_ne_spec.rb +18 -0
- data/spec/Features/method_project_spec.rb +188 -0
- data/spec/Features/method_ref_spec.rb +27 -0
- data/spec/Features/method_round_spec.rb +11 -0
- data/spec/Features/method_s_linspace_spec.rb +48 -0
- data/spec/Features/method_s_span_spec.rb +14 -0
- data/spec/Features/method_seq_spec.rb +47 -0
- data/spec/Features/method_sort_with.rb +43 -0
- data/spec/Features/method_sorted_with.rb +29 -0
- data/spec/Features/method_span_spec.rb +42 -0
- data/spec/Features/method_wrap_readonly_spec.rb +43 -0
- data/{test → spec/UnitTest}/test_CAVirtual.rb +0 -0
- data/spec/spec_all.rb +0 -1
- data/utils/convert_test.rb +73 -0
- data/utils/{extract_rdoc.rb → extract_yard.rb} +7 -12
- metadata +77 -60
- data/spec/CABlockIterator/CABlockIterator_spec.rb +0 -113
- data/spec/CArray/bug/store_spec.rb +0 -27
- data/spec/CArray/index/repeat_spec.rb +0 -10
- data/spec/CArray/method/eq_spec.rb +0 -80
- data/spec/CArray/method/is_nan_spec.rb +0 -12
- data/spec/CArray/method/ne_spec.rb +0 -18
- data/spec/CArray/method/round_spec.rb +0 -11
- data/spec/CArray/object/_attribute_spec.rb +0 -32
- data/spec/CArray/object/s_new_spec.rb +0 -31
- data/spec/CArray/serialize/Serialization_spec.rb +0 -89
- data/test/test_130.rb +0 -23
- data/test/test_ALL.rb +0 -49
- data/test/test_CABitfield.rb +0 -59
- data/test/test_CABlock.rb +0 -208
- data/test/test_CAField.rb +0 -40
- data/test/test_CAGrid.rb +0 -76
- data/test/test_CAMmap.rb +0 -11
- data/test/test_CARefer.rb +0 -94
- data/test/test_CARepeat.rb +0 -66
- data/test/test_CASelect.rb +0 -23
- data/test/test_CAShift.rb +0 -17
- data/test/test_CAWindow.rb +0 -55
- data/test/test_CAWrap.rb +0 -9
- data/test/test_CComplex.rb +0 -83
- data/test/test_CScalar.rb +0 -91
- data/test/test_attribute.rb +0 -281
- data/test/test_block_iterator.rb +0 -17
- data/test/test_boolean.rb +0 -99
- data/test/test_cast.rb +0 -33
- data/test/test_class.rb +0 -85
- data/test/test_complex.rb +0 -43
- data/test/test_convert.rb +0 -79
- data/test/test_copy.rb +0 -141
- data/test/test_creation.rb +0 -85
- data/test/test_element.rb +0 -146
- data/test/test_extream.rb +0 -55
- data/test/test_generate.rb +0 -75
- data/test/test_index.rb +0 -71
- data/test/test_mask.rb +0 -578
- data/test/test_math.rb +0 -98
- data/test/test_order.rb +0 -147
- data/test/test_ref_store.rb +0 -211
- data/test/test_stat.rb +0 -406
- data/test/test_struct.rb +0 -72
- data/test/test_virtual.rb +0 -49
data/ext/carray_operator.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_operator.c
|
4
4
|
|
5
5
|
This file is part of Ruby/CArray extension library.
|
6
|
-
You can redistribute it and/or modify it under the terms of
|
7
|
-
the Ruby Licence.
|
8
6
|
|
9
|
-
Copyright (C) 2005 Hiroki Motoyoshi
|
7
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
10
8
|
|
11
9
|
---------------------------------------------------------------------------- */
|
12
10
|
|
@@ -28,7 +26,6 @@ ca_zerodiv ()
|
|
28
26
|
rb_raise(rb_eZeroDivError, "divided by 0");
|
29
27
|
}
|
30
28
|
|
31
|
-
|
32
29
|
VALUE
|
33
30
|
rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
|
34
31
|
{
|
@@ -50,7 +47,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
|
|
50
47
|
ca_attach(ca1);
|
51
48
|
ca_copy_mask_overlay(ca2, ca2->elements, 1, ca1);
|
52
49
|
func[ca1->data_type](ca1->elements,
|
53
|
-
( ca2->mask ) ? ca2->mask->ptr : NULL,
|
50
|
+
( ca2->mask ) ? (boolean8_t *)ca2->mask->ptr : NULL,
|
54
51
|
ca1->ptr, 1,
|
55
52
|
ca2->ptr, 1);
|
56
53
|
ca_detach(ca1);
|
@@ -58,7 +55,7 @@ rb_ca_call_monop (VALUE self, ca_monop_func_t func[])
|
|
58
55
|
/* unresolved unbound repeat array generates unbound repeat array again */
|
59
56
|
if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
60
57
|
CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
|
61
|
-
out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
|
58
|
+
out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
|
62
59
|
}
|
63
60
|
|
64
61
|
return out;
|
@@ -75,7 +72,7 @@ rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[])
|
|
75
72
|
|
76
73
|
ca_attach(ca1);
|
77
74
|
func[ca1->data_type](ca1->elements,
|
78
|
-
( ca1->mask ) ? ca1->mask->ptr : NULL,
|
75
|
+
( ca1->mask ) ? (boolean8_t *)ca1->mask->ptr : NULL,
|
79
76
|
ca1->ptr, 1,
|
80
77
|
ca1->ptr, 1);
|
81
78
|
ca_sync(ca1);
|
@@ -134,7 +131,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
134
131
|
out = ca_wrap_struct(ca3);
|
135
132
|
|
136
133
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
137
|
-
func[ca1->data_type](ca1->elements,
|
134
|
+
func[ca1->data_type](ca1->elements,
|
135
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
138
136
|
ca1->ptr, 0,
|
139
137
|
ca2->ptr, 0,
|
140
138
|
ca3->ptr, 0);
|
@@ -149,7 +147,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
149
147
|
out = ca_wrap_struct(ca3);
|
150
148
|
|
151
149
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
152
|
-
func[ca1->data_type](ca2->elements,
|
150
|
+
func[ca1->data_type](ca2->elements,
|
151
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
153
152
|
ca1->ptr, 0,
|
154
153
|
ca2->ptr, 1,
|
155
154
|
ca3->ptr, 1);
|
@@ -166,7 +165,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
166
165
|
out = ca_wrap_struct(ca3);
|
167
166
|
|
168
167
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
169
|
-
func[ca1->data_type](ca1->elements,
|
168
|
+
func[ca1->data_type](ca1->elements,
|
169
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
170
170
|
ca1->ptr, 1,
|
171
171
|
ca2->ptr, 0,
|
172
172
|
ca3->ptr, 1);
|
@@ -185,7 +185,8 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
185
185
|
out = ca_wrap_struct(ca3);
|
186
186
|
|
187
187
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
188
|
-
func[ca1->data_type](ca1->elements,
|
188
|
+
func[ca1->data_type](ca1->elements,
|
189
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
189
190
|
ca1->ptr, 1,
|
190
191
|
ca2->ptr, 1,
|
191
192
|
ca3->ptr, 1);
|
@@ -197,13 +198,13 @@ rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
|
197
198
|
/* unresolved unbound repeat array generates unbound repeat array again */
|
198
199
|
if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
199
200
|
CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
|
200
|
-
out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
|
201
|
+
out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
|
201
202
|
}
|
202
203
|
|
203
204
|
/* unresolved unbound repeat array generates unbound repeat array again */
|
204
205
|
if ( ca2->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
205
206
|
CAUnboundRepeat *cx = (CAUnboundRepeat *) ca2;
|
206
|
-
out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
|
207
|
+
out = rb_ca_ubrep_new(rb_ca_ubrep_shave(other, out), cx->rep_ndim, cx->rep_dim);
|
207
208
|
}
|
208
209
|
|
209
210
|
return out;
|
@@ -228,7 +229,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
|
|
228
229
|
if ( rb_obj_is_cscalar(self) ) {
|
229
230
|
if ( rb_obj_is_cscalar(other) ) { /* scalar vs scalar */
|
230
231
|
ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
|
231
|
-
func[ca1->data_type](ca1->elements,
|
232
|
+
func[ca1->data_type](ca1->elements,
|
233
|
+
( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
|
232
234
|
ca1->ptr, 0,
|
233
235
|
ca2->ptr, 0,
|
234
236
|
ca1->ptr, 0);
|
@@ -240,7 +242,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
|
|
240
242
|
}
|
241
243
|
|
242
244
|
ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
|
243
|
-
func[ca1->data_type](ca1->elements,
|
245
|
+
func[ca1->data_type](ca1->elements,
|
246
|
+
( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
|
244
247
|
ca1->ptr, 0,
|
245
248
|
ca2->ptr, 0,
|
246
249
|
ca1->ptr, 0);
|
@@ -249,7 +252,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
|
|
249
252
|
else {
|
250
253
|
if ( rb_obj_is_cscalar(other) ) { /* array vs scalar */
|
251
254
|
ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
|
252
|
-
func[ca1->data_type](ca1->elements,
|
255
|
+
func[ca1->data_type](ca1->elements,
|
256
|
+
( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
|
253
257
|
ca1->ptr, 1,
|
254
258
|
ca2->ptr, 0,
|
255
259
|
ca1->ptr, 1);
|
@@ -261,7 +265,8 @@ rb_ca_call_binop_bang (VALUE self, VALUE other, ca_binop_func_t func[])
|
|
261
265
|
}
|
262
266
|
|
263
267
|
ca_copy_mask_overlay(ca1, ca1->elements, 2, ca1, ca2);
|
264
|
-
func[ca1->data_type](ca1->elements,
|
268
|
+
func[ca1->data_type](ca1->elements,
|
269
|
+
( ca1->mask ) ? (boolean8_t *) ca1->mask->ptr : NULL,
|
265
270
|
ca1->ptr, 1,
|
266
271
|
ca2->ptr, 1,
|
267
272
|
ca1->ptr, 1);
|
@@ -294,15 +299,16 @@ rb_ca_call_moncmp (VALUE self, ca_moncmp_func_t func[])
|
|
294
299
|
|
295
300
|
ca_attach(ca1);
|
296
301
|
ca_copy_mask_overlay(ca2, ca2->elements, 1, ca1);
|
297
|
-
func[ca1->data_type](ca1->elements,
|
302
|
+
func[ca1->data_type](ca1->elements,
|
303
|
+
( ca2->mask ) ? (boolean8_t *) ca2->mask->ptr : NULL,
|
298
304
|
ca1->ptr, 1,
|
299
|
-
ca2->ptr, 1);
|
305
|
+
(boolean8_t *) ca2->ptr, 1);
|
300
306
|
ca_detach(ca1);
|
301
307
|
|
302
308
|
/* unresolved unbound repeat array generates unbound repeat array again */
|
303
309
|
if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
304
310
|
CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
|
305
|
-
out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
|
311
|
+
out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
|
306
312
|
}
|
307
313
|
|
308
314
|
return out;
|
@@ -321,10 +327,10 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
321
327
|
|
322
328
|
/* check for comparison with CA_UNDEF */
|
323
329
|
if ( other == CA_UNDEF ) {
|
324
|
-
if ( func == ca_bincmp_eq ) {
|
330
|
+
if ( (ca_bincmp_func_t) func == (ca_bincmp_func_t) ca_bincmp_eq ) { /* a.eq(UNDEF) -> a.is_masked */
|
325
331
|
return rb_ca_is_masked(self);
|
326
332
|
}
|
327
|
-
else if ( func == ca_bincmp_ne ) { /* a.ne(UNDEF) -> a.is_not_masked */
|
333
|
+
else if ( (ca_bincmp_func_t) func == (ca_bincmp_func_t) ca_bincmp_ne ) { /* a.ne(UNDEF) -> a.is_not_masked */
|
328
334
|
return rb_ca_is_not_masked(self);
|
329
335
|
}
|
330
336
|
else {
|
@@ -347,7 +353,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
347
353
|
Data_Get_Struct(out, CArray, ca3);
|
348
354
|
|
349
355
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
350
|
-
func[ca1->data_type](ca1->elements,
|
356
|
+
func[ca1->data_type](ca1->elements,
|
357
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
351
358
|
ca1->ptr, ca1->bytes, 0,
|
352
359
|
ca2->ptr, ca2->bytes, 0,
|
353
360
|
ca3->ptr, ca3->bytes, 0);
|
@@ -357,7 +364,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
357
364
|
Data_Get_Struct(out, CArray, ca3);
|
358
365
|
|
359
366
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
360
|
-
func[ca1->data_type](ca2->elements,
|
367
|
+
func[ca1->data_type](ca2->elements,
|
368
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
361
369
|
ca1->ptr, ca1->bytes, 0,
|
362
370
|
ca2->ptr, ca2->bytes, 1,
|
363
371
|
ca3->ptr, ca3->bytes, 1);
|
@@ -369,7 +377,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
369
377
|
Data_Get_Struct(out, CArray, ca3);
|
370
378
|
|
371
379
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
372
|
-
func[ca1->data_type](ca1->elements,
|
380
|
+
func[ca1->data_type](ca1->elements,
|
381
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
373
382
|
ca1->ptr, ca1->bytes, 1,
|
374
383
|
ca2->ptr, ca2->bytes, 0,
|
375
384
|
ca3->ptr, ca3->bytes, 1);
|
@@ -383,7 +392,8 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
383
392
|
Data_Get_Struct(out, CArray, ca3);
|
384
393
|
|
385
394
|
ca_copy_mask_overlay(ca3, ca3->elements, 2, ca1, ca2);
|
386
|
-
func[ca1->data_type](ca1->elements,
|
395
|
+
func[ca1->data_type](ca1->elements,
|
396
|
+
( ca3->mask ) ? (boolean8_t *) ca3->mask->ptr : NULL,
|
387
397
|
ca1->ptr, ca1->bytes, 1,
|
388
398
|
ca2->ptr, ca2->bytes, 1,
|
389
399
|
ca3->ptr, ca3->bytes, 1);
|
@@ -395,7 +405,7 @@ rb_ca_call_bincmp (volatile VALUE self, volatile VALUE other,
|
|
395
405
|
/* unresolved unbound repeat array generates unbound repeat array again */
|
396
406
|
if ( ca1->obj_type == CA_OBJ_UNBOUND_REPEAT ) {
|
397
407
|
CAUnboundRepeat *cx = (CAUnboundRepeat *) ca1;
|
398
|
-
out = rb_ca_ubrep_new(out, cx->rep_ndim, cx->rep_dim);
|
408
|
+
out = rb_ca_ubrep_new(rb_ca_ubrep_shave(self, out), cx->rep_ndim, cx->rep_dim);
|
399
409
|
}
|
400
410
|
|
401
411
|
return out;
|
@@ -458,11 +468,9 @@ ca_math_call (VALUE mod, VALUE arg, ID id)
|
|
458
468
|
}
|
459
469
|
}
|
460
470
|
|
461
|
-
/*
|
462
|
-
|
463
|
-
|
464
|
-
end
|
465
|
-
end
|
471
|
+
/* @overload coerece (other)
|
472
|
+
|
473
|
+
[TBD]
|
466
474
|
*/
|
467
475
|
|
468
476
|
static VALUE
|
@@ -524,6 +532,11 @@ rb_ca_coerce (VALUE self, VALUE other)
|
|
524
532
|
} \
|
525
533
|
}
|
526
534
|
|
535
|
+
/* @overload mul_add (weight, min_count=nil, fill_value=nil)
|
536
|
+
|
537
|
+
[TBD]
|
538
|
+
*/
|
539
|
+
|
527
540
|
static VALUE
|
528
541
|
rb_ca_mul_add (int argc, VALUE *argv, volatile VALUE self)
|
529
542
|
{
|
data/ext/carray_order.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_order.c
|
4
4
|
|
5
5
|
This file is part of Ruby/CArray extension library.
|
6
|
-
You can redistribute it and/or modify it under the terms of
|
7
|
-
the Ruby Licence.
|
8
6
|
|
9
|
-
Copyright (C) 2005 Hiroki Motoyoshi
|
7
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
10
8
|
|
11
9
|
---------------------------------------------------------------------------- */
|
12
10
|
|
@@ -140,26 +138,24 @@ ca_project (CArray *ca, CArray *ci, char *lfill, char *ufill)
|
|
140
138
|
return co;
|
141
139
|
}
|
142
140
|
|
143
|
-
/*
|
144
|
-
|
145
|
-
|
146
|
-
end
|
147
|
-
end
|
141
|
+
/* @overload project (idx, lval=nil, uval=nil)
|
142
|
+
|
143
|
+
[TBD]. Creates new array the element of the object as address.
|
148
144
|
*/
|
149
145
|
|
150
146
|
VALUE
|
151
147
|
rb_ca_project (int argc, VALUE *argv, VALUE self)
|
152
148
|
{
|
153
|
-
volatile VALUE obj,
|
149
|
+
volatile VALUE obj, ridx, vlfval, vufval;
|
154
150
|
CArray *ca, *ci, *co;
|
155
151
|
char *lfval, *ufval;
|
156
152
|
|
157
|
-
rb_scan_args(argc, argv, "12", (VALUE *)
|
153
|
+
rb_scan_args(argc, argv, "12", (VALUE *)&ridx, (VALUE *) &vlfval, (VALUE *) &vufval);
|
158
154
|
|
159
155
|
Data_Get_Struct(self, CArray, ca);
|
160
156
|
|
161
|
-
rb_check_carray_object(
|
162
|
-
ci = ca_wrap_readonly(
|
157
|
+
rb_check_carray_object(ridx);
|
158
|
+
ci = ca_wrap_readonly(ridx, CA_SIZE);
|
163
159
|
|
164
160
|
lfval = malloc_with_check(ca->bytes);
|
165
161
|
ufval = malloc_with_check(ca->bytes);
|
@@ -227,12 +223,9 @@ rb_ca_project (int argc, VALUE *argv, VALUE self)
|
|
227
223
|
free(v); \
|
228
224
|
}
|
229
225
|
|
230
|
-
/*
|
231
|
-
|
232
|
-
|
233
|
-
def reverse!
|
234
|
-
end
|
235
|
-
end
|
226
|
+
/* @overload reverse!
|
227
|
+
|
228
|
+
Reverses the elements of +ca+ in place.
|
236
229
|
*/
|
237
230
|
|
238
231
|
static VALUE
|
@@ -279,13 +272,10 @@ rb_ca_reverse_bang (VALUE self)
|
|
279
272
|
return self;
|
280
273
|
}
|
281
274
|
|
282
|
-
/*
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
def reverse
|
287
|
-
end
|
288
|
-
end
|
275
|
+
/* @overload reverse
|
276
|
+
|
277
|
+
Returns a new CArray object containing <i>ca</i>'s elements in
|
278
|
+
reverse order.
|
289
279
|
*/
|
290
280
|
|
291
281
|
static VALUE
|
@@ -384,12 +374,9 @@ ca_qsort_cmp[CA_NTYPE] = {
|
|
384
374
|
qcmp_VALUE,
|
385
375
|
};
|
386
376
|
|
387
|
-
/*
|
388
|
-
|
389
|
-
|
390
|
-
def sort!
|
391
|
-
end
|
392
|
-
end
|
377
|
+
/* @overload sort!
|
378
|
+
|
379
|
+
Sorts <i>ca</i>'s elements in place.
|
393
380
|
*/
|
394
381
|
|
395
382
|
static VALUE
|
@@ -433,12 +420,9 @@ rb_ca_sort_bang (VALUE self)
|
|
433
420
|
return self;
|
434
421
|
}
|
435
422
|
|
436
|
-
/*
|
437
|
-
|
438
|
-
|
439
|
-
def sort
|
440
|
-
end
|
441
|
-
end
|
423
|
+
/* @overload sort
|
424
|
+
|
425
|
+
Returns a new CArray object containing <i>ca</i>'s elements sorted.
|
442
426
|
*/
|
443
427
|
|
444
428
|
static VALUE
|
@@ -452,11 +436,9 @@ rb_ca_sorted_copy (VALUE self)
|
|
452
436
|
|
453
437
|
/* --------------------------------------------------------------- */
|
454
438
|
|
455
|
-
/*
|
456
|
-
|
457
|
-
|
458
|
-
end
|
459
|
-
end
|
439
|
+
/* @overload bsearch
|
440
|
+
|
441
|
+
Returns a new CArray object containing <i>ca</i>'s elements sorted.
|
460
442
|
*/
|
461
443
|
|
462
444
|
static VALUE
|
@@ -561,11 +543,9 @@ rb_ca_binary_search (VALUE self, volatile VALUE rval)
|
|
561
543
|
return out;
|
562
544
|
}
|
563
545
|
|
564
|
-
/*
|
565
|
-
|
566
|
-
|
567
|
-
end
|
568
|
-
end
|
546
|
+
/* @overload bsearch_index
|
547
|
+
|
548
|
+
[TBD].
|
569
549
|
*/
|
570
550
|
|
571
551
|
static VALUE
|
@@ -630,6 +610,33 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
|
|
630
610
|
} \
|
631
611
|
}
|
632
612
|
|
613
|
+
#define proc_find_value_float128(type, defeps) \
|
614
|
+
{ \
|
615
|
+
type *ptr = (type *) ca->ptr; \
|
616
|
+
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
617
|
+
type val = (type) NUM2DBL(value); \
|
618
|
+
float128_t eps = (NIL_P(veps)) ? defeps*fabsl(val) : NUM2DBL(veps); \
|
619
|
+
ca_size_t i; \
|
620
|
+
if ( m ) { \
|
621
|
+
for (i=0; i<ca->elements; i++, ptr++) { \
|
622
|
+
if ( ! *m++ ) { \
|
623
|
+
if ( fabsl(*ptr - val) <= eps ) { \
|
624
|
+
addr = i; \
|
625
|
+
break; \
|
626
|
+
} \
|
627
|
+
} \
|
628
|
+
} \
|
629
|
+
} \
|
630
|
+
else { \
|
631
|
+
for (i=0; i<ca->elements; i++, ptr++) { \
|
632
|
+
if ( fabsl(*ptr - val) <= eps ) { \
|
633
|
+
addr = i; \
|
634
|
+
break; \
|
635
|
+
} \
|
636
|
+
} \
|
637
|
+
} \
|
638
|
+
}
|
639
|
+
|
633
640
|
#define proc_find_value_cmplx(type, defeps) \
|
634
641
|
{ \
|
635
642
|
type *ptr = (type *) ca->ptr; \
|
@@ -683,11 +690,9 @@ rb_ca_binary_search_index (VALUE self, volatile VALUE rval)
|
|
683
690
|
}
|
684
691
|
|
685
692
|
|
686
|
-
/*
|
687
|
-
|
688
|
-
|
689
|
-
end
|
690
|
-
end
|
693
|
+
/* @overload search
|
694
|
+
|
695
|
+
[TBD].
|
691
696
|
*/
|
692
697
|
|
693
698
|
static VALUE
|
@@ -717,7 +722,7 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
|
|
717
722
|
case CA_UINT64: proc_find_value(uint64_t); break;
|
718
723
|
case CA_FLOAT32: proc_find_value_float(float32_t, FLT_EPSILON); break;
|
719
724
|
case CA_FLOAT64: proc_find_value_float(float64_t, DBL_EPSILON); break;
|
720
|
-
case CA_FLOAT128:
|
725
|
+
case CA_FLOAT128: proc_find_value_float128(float128_t, DBL_EPSILON); break;
|
721
726
|
#ifdef HAVE_COMPLEX_H
|
722
727
|
case CA_CMPLX64: proc_find_value_cmplx(cmplx64_t, FLT_EPSILON); break;
|
723
728
|
case CA_CMPLX128: proc_find_value_cmplx(cmplx128_t, DBL_EPSILON); break;
|
@@ -733,11 +738,9 @@ rb_ca_linear_search (int argc, VALUE *argv, VALUE self)
|
|
733
738
|
return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
|
734
739
|
}
|
735
740
|
|
736
|
-
/*
|
737
|
-
|
738
|
-
|
739
|
-
end
|
740
|
-
end
|
741
|
+
/* @overload search_index
|
742
|
+
|
743
|
+
[TBD].
|
741
744
|
*/
|
742
745
|
|
743
746
|
static VALUE
|
@@ -811,11 +814,9 @@ rb_ca_linear_search_index (int argc, VALUE *argv, VALUE self)
|
|
811
814
|
} \
|
812
815
|
}
|
813
816
|
|
814
|
-
/*
|
815
|
-
|
816
|
-
|
817
|
-
end
|
818
|
-
end
|
817
|
+
/* @overload search_nearest
|
818
|
+
|
819
|
+
[TBD].
|
819
820
|
*/
|
820
821
|
|
821
822
|
static VALUE
|
@@ -856,6 +857,11 @@ rb_ca_linear_search_nearest (VALUE self, VALUE value)
|
|
856
857
|
return ( addr == -1 ) ? Qnil : SIZE2NUM(addr);
|
857
858
|
}
|
858
859
|
|
860
|
+
/* @overload search_nearest_index
|
861
|
+
|
862
|
+
[TBD].
|
863
|
+
*/
|
864
|
+
|
859
865
|
static VALUE
|
860
866
|
rb_ca_linear_search_nearest_index (VALUE self, VALUE value)
|
861
867
|
{
|
@@ -876,6 +882,9 @@ Init_carray_order ()
|
|
876
882
|
rb_define_method(rb_cCArray, "sort!", rb_ca_sort_bang, 0);
|
877
883
|
rb_define_method(rb_cCArray, "sort", rb_ca_sorted_copy, 0);
|
878
884
|
|
885
|
+
rb_define_method(rb_cCArray, "bsearch", rb_ca_binary_search, 1);
|
886
|
+
rb_define_method(rb_cCArray, "bsearch_index", rb_ca_binary_search_index, 1);
|
887
|
+
|
879
888
|
rb_define_method(rb_cCArray, "search", rb_ca_linear_search, -1);
|
880
889
|
rb_define_method(rb_cCArray, "search_index", rb_ca_linear_search_index, -1);
|
881
890
|
|
@@ -884,6 +893,4 @@ Init_carray_order ()
|
|
884
893
|
rb_define_method(rb_cCArray, "search_nearest_index",
|
885
894
|
rb_ca_linear_search_nearest_index, 1);
|
886
895
|
|
887
|
-
rb_define_method(rb_cCArray, "bsearch", rb_ca_binary_search, 1);
|
888
|
-
rb_define_method(rb_cCArray, "bsearch_index", rb_ca_binary_search_index, 1);
|
889
896
|
}
|