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_sort_addr.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_sort_addr.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
|
|
@@ -151,16 +149,14 @@ qcmp_func (struct cmp_data *a, struct cmp_data *b)
|
|
151
149
|
return ( ia > ib ) ? 1 : -1; /* for stable sort */
|
152
150
|
}
|
153
151
|
|
154
|
-
/*
|
155
|
-
# returns index table for index sort
|
156
|
-
#
|
157
|
-
# idx = CA.sort_addr(a, b, c) ### priority a > b > c
|
158
|
-
# a[idx]
|
159
|
-
# b[idx]
|
160
|
-
# c[idx]
|
152
|
+
/* @overload sort_addr (*args)
|
161
153
|
|
162
|
-
|
163
|
-
|
154
|
+
(Sort) Returns index table for index sort
|
155
|
+
|
156
|
+
idx = CA.sort_addr(a, b, c) ### priority a > b > c
|
157
|
+
a[idx]
|
158
|
+
b[idx]
|
159
|
+
c[idx]
|
164
160
|
*/
|
165
161
|
|
166
162
|
static VALUE
|
@@ -234,15 +230,12 @@ rb_ca_s_sort_addr (int argc, VALUE *argv, VALUE self)
|
|
234
230
|
return out;
|
235
231
|
}
|
236
232
|
|
237
|
-
/*
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
def sort_addr (*args)
|
244
|
-
end
|
245
|
-
end
|
233
|
+
/* @overload sort_addr (*args)
|
234
|
+
|
235
|
+
(Sort) Returns index table for index sort
|
236
|
+
This method same as,
|
237
|
+
|
238
|
+
idx = CA.sort_addr(self, *args)
|
246
239
|
*/
|
247
240
|
|
248
241
|
static VALUE
|
data/ext/carray_stat.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_stat.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
|
|
data/ext/carray_stat_proc.rb
CHANGED
@@ -286,12 +286,10 @@ header = < |
|
286
286
|
carray_stat_proc.c
|
287
287
|
|
288
288
|
This file is part of Ruby/CArray extension library.
|
289
|
-
You can redistribute it and/or modify it under the terms of
|
290
|
-
the Ruby Licence.
|
291
289
|
|
292
|
-
This file is automatically generated from carray_stat_proc.rb
|
293
290
|
|
294
|
-
|
291
|
+
This file is automatically generated from carray_stat_proc.rb
|
292
|
+
Copyright (C) 2005-2020 Hiroki Motoyoshi
|
295
293
|
|
296
294
|
---------------------------------------------------------------------------- */
|
297
295
|
|
data/ext/carray_test.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_test.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
|
This file includes the modified routine (ca_mem_hash) from
|
12
10
|
|
@@ -220,11 +218,10 @@ rb_obj_is_data_class (VALUE rtype)
|
|
220
218
|
|
221
219
|
/* ------------------------------------------------------------- */
|
222
220
|
|
223
|
-
/*
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
end
|
221
|
+
/* @overload valid_index? (*idx)
|
222
|
+
|
223
|
+
(Inquiry)
|
224
|
+
Returns true if the given number list is valid as array index for the object
|
228
225
|
*/
|
229
226
|
|
230
227
|
static VALUE
|
@@ -253,11 +250,10 @@ rb_ca_is_valid_index (int argc, VALUE *argv, VALUE self)
|
|
253
250
|
return Qtrue;
|
254
251
|
}
|
255
252
|
|
256
|
-
/*
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
end
|
253
|
+
/* @overload valid_addr? (*addr)
|
254
|
+
|
255
|
+
(Inquiry)
|
256
|
+
Returns true if the given number is valid as array address for the object
|
261
257
|
*/
|
262
258
|
|
263
259
|
static VALUE
|
@@ -279,11 +275,10 @@ rb_ca_is_valid_addr (VALUE self, VALUE raddr)
|
|
279
275
|
}
|
280
276
|
}
|
281
277
|
|
282
|
-
/*
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
end
|
278
|
+
/* @overload has_same_shape?
|
279
|
+
|
280
|
+
(Inquiry)
|
281
|
+
Returns true if the object has the same shape with the given array.
|
287
282
|
*/
|
288
283
|
|
289
284
|
static VALUE
|
@@ -453,12 +448,10 @@ ca_equal (void *ap, void *bp)
|
|
453
448
|
return flag;
|
454
449
|
}
|
455
450
|
|
456
|
-
/*
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
alias eql? ==
|
461
|
-
end
|
451
|
+
/* @overload == (other)
|
452
|
+
|
453
|
+
(Inquiry)
|
454
|
+
Returns true if the object equals the given array.
|
462
455
|
*/
|
463
456
|
|
464
457
|
static VALUE
|
@@ -545,11 +538,10 @@ ca_hash (CArray *ca)
|
|
545
538
|
return hash;
|
546
539
|
}
|
547
540
|
|
548
|
-
/*
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
end
|
541
|
+
/* @overload hash
|
542
|
+
|
543
|
+
(Inquiry)
|
544
|
+
Returns the hash value of the object.
|
553
545
|
*/
|
554
546
|
|
555
547
|
VALUE
|
@@ -578,6 +570,12 @@ rb_ca_modify (VALUE self)
|
|
578
570
|
*/
|
579
571
|
}
|
580
572
|
|
573
|
+
/* @overload freeze
|
574
|
+
|
575
|
+
Freeze the object.
|
576
|
+
|
577
|
+
*/
|
578
|
+
|
581
579
|
VALUE
|
582
580
|
rb_ca_freeze (VALUE self)
|
583
581
|
{
|
@@ -598,6 +596,6 @@ Init_carray_test ()
|
|
598
596
|
rb_define_method(rb_cCArray, "freeze", rb_ca_freeze, 0);
|
599
597
|
|
600
598
|
rb_define_method(rb_cCArray, "==", rb_ca_equal, 1);
|
601
|
-
|
599
|
+
rb_define_alias(rb_cCArray, "eql?", "==");
|
602
600
|
rb_define_method(rb_cCArray, "hash", rb_ca_hash, 0);
|
603
601
|
}
|
data/ext/carray_undef.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_undef.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
|
|
data/ext/carray_utils.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
carray_utils.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
|
|
@@ -422,6 +420,11 @@ ca_bounds_normalize_index (int8_t bounds, ca_size_t size0, ca_size_t k)
|
|
422
420
|
}
|
423
421
|
}
|
424
422
|
|
423
|
+
/* @private
|
424
|
+
@overload scan_float (str, fill_value=nil)
|
425
|
+
|
426
|
+
*/
|
427
|
+
|
425
428
|
static VALUE
|
426
429
|
rb_ca_s_scan_float (int argc, VALUE *argv, VALUE self)
|
427
430
|
{
|
@@ -447,6 +450,11 @@ rb_ca_s_scan_float (int argc, VALUE *argv, VALUE self)
|
|
447
450
|
}
|
448
451
|
}
|
449
452
|
|
453
|
+
/* @private
|
454
|
+
@overload scan_int (str, fill_value=nil)
|
455
|
+
|
456
|
+
*/
|
457
|
+
|
450
458
|
static VALUE
|
451
459
|
rb_ca_s_scan_int (int argc, VALUE *argv, VALUE self)
|
452
460
|
{
|
@@ -564,7 +572,7 @@ rb_ca_guess_type_and_bytes (VALUE rtype, VALUE rbytes,
|
|
564
572
|
}
|
565
573
|
}
|
566
574
|
|
567
|
-
/*
|
575
|
+
/* @private
|
568
576
|
def CArray.guess_type_and_bytes (type, bytes=0)
|
569
577
|
end
|
570
578
|
*/
|
data/ext/extconf.rb
CHANGED
data/ext/mkmath.rb
CHANGED
data/ext/ruby_carray.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
ruby_carray.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
|
|
@@ -97,7 +95,7 @@ Init_carray_ext ()
|
|
97
95
|
rb_eCADataTypeError =
|
98
96
|
rb_define_class_under(rb_cCArray, "DataTypeError", rb_eStandardError);
|
99
97
|
|
100
|
-
/*
|
98
|
+
/* yard:
|
101
99
|
class CArray::DataTypeError # :nodoc:
|
102
100
|
end
|
103
101
|
*/
|
@@ -111,7 +109,7 @@ Init_carray_ext ()
|
|
111
109
|
|
112
110
|
/* -- version -- */
|
113
111
|
|
114
|
-
/*
|
112
|
+
/* yard:
|
115
113
|
class CArray
|
116
114
|
VERSION = nil # :nodoc:
|
117
115
|
VERSION_CODE = nil # :nodoc:
|
@@ -122,11 +120,17 @@ Init_carray_ext ()
|
|
122
120
|
end
|
123
121
|
*/
|
124
122
|
|
123
|
+
/* @private */
|
125
124
|
rb_define_const(rb_cCArray, "VERSION", rb_str_new2(CA_VERSION));
|
125
|
+
/* @private */
|
126
126
|
rb_define_const(rb_cCArray, "VERSION_CODE", INT2NUM(CA_VERSION_CODE));
|
127
|
+
/* @private */
|
127
128
|
rb_define_const(rb_cCArray, "VERSION_MAJOR", INT2NUM(CA_VERSION_MAJOR));
|
129
|
+
/* @private */
|
128
130
|
rb_define_const(rb_cCArray, "VERSION_MINOR", INT2NUM(CA_VERSION_MINOR));
|
131
|
+
/* @private */
|
129
132
|
rb_define_const(rb_cCArray, "VERSION_TEENY", INT2NUM(CA_VERSION_TEENY));
|
133
|
+
/* @private */
|
130
134
|
rb_define_const(rb_cCArray, "VERSION_DATE", rb_str_new2(CA_VERSION_DATE));
|
131
135
|
|
132
136
|
/* -- system -- */
|
@@ -135,8 +139,10 @@ Init_carray_ext ()
|
|
135
139
|
rb_define_const(rb_cObject, "CA_NIL", CA_NIL);
|
136
140
|
|
137
141
|
#ifdef HAVE_COMPLEX_H
|
142
|
+
/* @private */
|
138
143
|
rb_define_const(rb_cCArray, "HAVE_COMPLEX", Qtrue);
|
139
144
|
#else
|
145
|
+
/* @private */
|
140
146
|
rb_define_const(rb_cCArray, "HAVE_COMPLEX", Qfalse);
|
141
147
|
#endif
|
142
148
|
|
@@ -169,7 +175,6 @@ Init_carray_ext ()
|
|
169
175
|
rb_define_const(rb_cObject, "CA_DCOMPLEX", INT2NUM(CA_DCOMPLEX));
|
170
176
|
rb_define_const(rb_cObject, "CA_SIZE", INT2NUM(CA_SIZE));
|
171
177
|
|
172
|
-
|
173
178
|
rb_define_const(rb_cObject, "CA_ALIGN_VOIDP", INT2NUM(CA_ALIGN_VOIDP));
|
174
179
|
rb_define_const(rb_cObject, "CA_ALIGN_FIXLEN", INT2NUM(CA_ALIGN_INT8));
|
175
180
|
rb_define_const(rb_cObject, "CA_ALIGN_BOOLEAN", INT2NUM(CA_ALIGN_INT8));
|
data/ext/ruby_ccomplex.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
ruby_ccomplex.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
|
|
data/ext/ruby_float_func.c
CHANGED
@@ -3,10 +3,8 @@
|
|
3
3
|
ruby_numeric.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
|
|
data/ext/version.h
CHANGED
@@ -3,16 +3,14 @@
|
|
3
3
|
version.h
|
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
|
|
13
|
-
#define CA_VERSION "1.5.
|
14
|
-
#define CA_VERSION_CODE
|
11
|
+
#define CA_VERSION "1.5.2"
|
12
|
+
#define CA_VERSION_CODE 152
|
15
13
|
#define CA_VERSION_MAJOR 1
|
16
14
|
#define CA_VERSION_MINOR 5
|
17
|
-
#define CA_VERSION_TEENY
|
18
|
-
#define CA_VERSION_DATE "2020/07/
|
15
|
+
#define CA_VERSION_TEENY 2
|
16
|
+
#define CA_VERSION_DATE "2020/07/22"
|
data/lib/carray.rb
CHANGED
@@ -32,6 +32,7 @@ require 'carray/transform'
|
|
32
32
|
require 'carray/convert'
|
33
33
|
require 'carray/testing'
|
34
34
|
require 'carray/ordering'
|
35
|
+
require 'carray/broadcast'
|
35
36
|
|
36
37
|
require 'carray/math'
|
37
38
|
require 'carray/iterator'
|
@@ -46,6 +47,7 @@ require 'carray/obsolete'
|
|
46
47
|
# autoload
|
47
48
|
|
48
49
|
unless $CARRAY_NO_AUTOLOAD
|
50
|
+
|
49
51
|
require 'carray/autoload'
|
50
52
|
require 'carray/autoload/autoload_base'
|
51
53
|
require 'carray/autoload/autoload_io_imagemagick'
|
@@ -1,15 +1,15 @@
|
|
1
1
|
class CArray
|
2
|
-
autoload_method :to_numo,
|
3
|
-
autoload_method :numo,
|
4
|
-
autoload_method "self.as_numo",
|
2
|
+
autoload_method :to_numo, "carray-numo-narray"
|
3
|
+
autoload_method :numo, "carray-numo-narray"
|
4
|
+
autoload_method "self.as_numo", "carray-numo-narray"
|
5
5
|
autoload_method "self.as_numo!", "carray-numo-narray"
|
6
|
-
autoload_method :as_numo,
|
7
|
-
autoload_method :as_numo!,
|
6
|
+
autoload_method :as_numo, "carray-numo-narray"
|
7
|
+
autoload_method :as_numo!, "carray-numo-narray"
|
8
8
|
end
|
9
9
|
|
10
10
|
module Numo
|
11
11
|
class NArray
|
12
12
|
autoload_method :to_ca, "carray-numo-narray"
|
13
|
-
autoload_method :ca,
|
13
|
+
autoload_method :ca, "carray-numo-narray"
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
class CArray
|
3
|
+
def broadcast_to (*new_dim)
|
4
|
+
if new_dim.size < ndim
|
5
|
+
raise "can't broadcast to #{new_dim.inspect} because of mismatch in rank"
|
6
|
+
end
|
7
|
+
flag_unbound_repeat = false
|
8
|
+
sdim = []
|
9
|
+
([1]*(new_dim.size-ndim) + dim).each_with_index do |d, k|
|
10
|
+
if new_dim[k] == 1
|
11
|
+
sdim << 1
|
12
|
+
elsif d == 1
|
13
|
+
flag_unbound_repeat = true
|
14
|
+
sdim << :*
|
15
|
+
elsif d != new_dim[k]
|
16
|
+
raise "can't broadcast to #{new_dim.inspect} because of mismatch in #{d} for #{new_dim[k]} in #{k}th dim"
|
17
|
+
else
|
18
|
+
sdim << nil
|
19
|
+
end
|
20
|
+
end
|
21
|
+
return self[*sdim].bind(*new_dim) if flag_unbound_repeat
|
22
|
+
return self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class CScalar
|
27
|
+
def broadcast_to (*new_dim)
|
28
|
+
return self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class CAUnboundRepeat
|
33
|
+
alias broadcast_to bind
|
34
|
+
end
|
35
|
+
|
36
|
+
def CArray.broadcast (*argv)
|
37
|
+
sel = argv.select {|arg| arg.is_a?(CArray) }
|
38
|
+
return argv if sel.empty?
|
39
|
+
dim = []
|
40
|
+
ndim = sel.map(&:ndim).max
|
41
|
+
ndim.times do |k|
|
42
|
+
dim[k] = sel.map{|arg| arg.dim[k] || 1 }.max
|
43
|
+
end
|
44
|
+
return argv.map{|arg| arg.is_a?(CArray) ? arg.broadcast_to(*dim) : arg }
|
45
|
+
end
|