carray 1.5.8 → 2.0.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.
- checksums.yaml +4 -4
- data/NEWS.md +17 -1
- data/TODO.md +1 -0
- data/carray.gemspec +1 -1
- data/ext/ca_iter_block.c +20 -5
- data/ext/ca_iter_dimension.c +21 -10
- data/ext/ca_iter_window.c +17 -5
- data/ext/ca_obj_array.c +73 -10
- data/ext/ca_obj_bitarray.c +21 -6
- data/ext/ca_obj_bitfield.c +21 -11
- data/ext/ca_obj_block.c +34 -10
- data/ext/ca_obj_fake.c +21 -6
- data/ext/ca_obj_farray.c +34 -5
- data/ext/ca_obj_field.c +23 -7
- data/ext/ca_obj_grid.c +36 -7
- data/ext/ca_obj_mapping.c +36 -7
- data/ext/ca_obj_object.c +35 -9
- data/ext/ca_obj_reduce.c +34 -5
- data/ext/ca_obj_refer.c +31 -10
- data/ext/ca_obj_repeat.c +35 -12
- data/ext/ca_obj_select.c +35 -9
- data/ext/ca_obj_shift.c +41 -12
- data/ext/ca_obj_transpose.c +36 -7
- data/ext/ca_obj_unbound_repeat.c +39 -14
- data/ext/ca_obj_window.c +46 -15
- data/ext/carray.h +97 -31
- data/ext/carray_access.c +25 -42
- data/ext/carray_attribute.c +35 -35
- data/ext/carray_call_cfunc.c +28 -28
- data/ext/carray_cast.c +25 -26
- data/ext/carray_cast_func.rb +1 -2
- data/ext/carray_conversion.c +7 -10
- data/ext/carray_copy.c +5 -5
- data/ext/carray_core.c +44 -7
- data/ext/carray_element.c +9 -9
- data/ext/carray_generate.c +7 -7
- data/ext/carray_iterator.c +33 -23
- data/ext/carray_loop.c +9 -9
- data/ext/carray_mask.c +38 -36
- data/ext/carray_math.rb +6 -6
- data/ext/carray_numeric.c +1 -1
- data/ext/carray_operator.c +31 -21
- data/ext/carray_order.c +320 -11
- data/ext/carray_sort_addr.c +2 -2
- data/ext/carray_stat.c +22 -22
- data/ext/carray_stat_proc.rb +15 -15
- data/ext/carray_test.c +8 -8
- data/ext/ruby_carray.c +7 -0
- data/ext/ruby_ccomplex.c +25 -11
- data/ext/version.h +6 -6
- data/lib/carray/inspect.rb +0 -3
- data/lib/carray/io/imagemagick.rb +8 -9
- data/lib/carray/mkmf.rb +1 -0
- data/lib/carray/time.rb +1 -1
- data/spec/Classes/ex1.rb +46 -0
- metadata +4 -6
data/ext/carray_stat_proc.rb
CHANGED
@@ -745,7 +745,7 @@ static void
|
|
745
745
|
ca_proc_stddev_<type> (ca_size_t elements, ca_size_t min_count,
|
746
746
|
boolean8_t *m, void *ptr, CAStatIterator *it,
|
747
747
|
int return_object, VALUE *retobj,
|
748
|
-
boolean8_t *retmask,
|
748
|
+
boolean8_t *retmask, float64_t *retval)
|
749
749
|
{
|
750
750
|
volatile <atype> sum = <azero>, sum2 = <azero>, ave, var, diff;
|
751
751
|
<type> *p = (<type> *) ptr;
|
@@ -802,7 +802,7 @@ ca_proc_stddev_<type> (ca_size_t elements, ca_size_t min_count,
|
|
802
802
|
if ( retmask ) {
|
803
803
|
*retmask = ( count > min_count ) ? 1 : 0;
|
804
804
|
}
|
805
|
-
*retval = sqrt_<op_type>(var);
|
805
|
+
*retval = <type2dbl>(sqrt_<op_type>(var));
|
806
806
|
}
|
807
807
|
}
|
808
808
|
|
@@ -1343,7 +1343,7 @@ rb_ca_stat_1d (VALUE self, VALUE rmc, VALUE vfval,
|
|
1343
1343
|
boolean8_t *m;
|
1344
1344
|
ca_size_t mc;
|
1345
1345
|
|
1346
|
-
|
1346
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1347
1347
|
|
1348
1348
|
if ( ! ca_proc[ca->data_type] ) {
|
1349
1349
|
rb_raise(rb_eCADataTypeError,
|
@@ -1411,7 +1411,7 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1411
1411
|
CArray *ca, *co;
|
1412
1412
|
ca_size_t mc, ndim;
|
1413
1413
|
|
1414
|
-
|
1414
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1415
1415
|
|
1416
1416
|
if ( ! ca_proc[ca->data_type] ) {
|
1417
1417
|
rb_raise(rb_eCADataTypeError,
|
@@ -1425,7 +1425,7 @@ rb_ca_stat_nd_contig (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1425
1425
|
}
|
1426
1426
|
|
1427
1427
|
out = rb_carray_new(data_type, ndim, ca->dim, 0, NULL);
|
1428
|
-
|
1428
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, co);
|
1429
1429
|
|
1430
1430
|
if ( ca_has_mask(ca) ) {
|
1431
1431
|
ca_create_mask(co);
|
@@ -1515,7 +1515,7 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1515
1515
|
ca_size_t mc;
|
1516
1516
|
ca_size_t i, k;
|
1517
1517
|
|
1518
|
-
|
1518
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1519
1519
|
|
1520
1520
|
for (i=0; i<ca->ndim; i++) {
|
1521
1521
|
dm[i] = 0;
|
@@ -1542,7 +1542,7 @@ rb_ca_stat_nd_discrete (VALUE self, VALUE vaxis, VALUE rmc, VALUE vfval,
|
|
1542
1542
|
}
|
1543
1543
|
|
1544
1544
|
out = rb_carray_new(data_type, out_ndim, out_dim, 0, NULL);
|
1545
|
-
|
1545
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, co);
|
1546
1546
|
|
1547
1547
|
first = carray_new(CA_SIZE, out_ndim, out_dim, 0, NULL);
|
1548
1548
|
first->ptr = realloc(first->ptr, first->bytes*(first->elements+1));
|
@@ -1619,7 +1619,7 @@ rb_ca_stat_general (int argc, VALUE *argv, VALUE self,
|
|
1619
1619
|
vfval = CA_NIL, vaxis;
|
1620
1620
|
CArray *ca;
|
1621
1621
|
|
1622
|
-
|
1622
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1623
1623
|
|
1624
1624
|
ropt = rb_pop_options(&argc, &argv);
|
1625
1625
|
rb_scan_options(ropt,
|
@@ -1746,7 +1746,7 @@ static VALUE
|
|
1746
1746
|
rb_ca_min (int argc, VALUE *argv, VALUE self)
|
1747
1747
|
{
|
1748
1748
|
CArray *ca;
|
1749
|
-
|
1749
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1750
1750
|
return rb_ca_stat_general(argc, argv, self, ca->data_type, ca_proc_min);
|
1751
1751
|
}
|
1752
1752
|
|
@@ -1760,7 +1760,7 @@ static VALUE
|
|
1760
1760
|
rb_ca_max (int argc, VALUE *argv, VALUE self)
|
1761
1761
|
{
|
1762
1762
|
CArray *ca;
|
1763
|
-
|
1763
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1764
1764
|
return rb_ca_stat_general(argc, argv, self, ca->data_type, ca_proc_max);
|
1765
1765
|
}
|
1766
1766
|
|
@@ -1774,7 +1774,7 @@ static VALUE
|
|
1774
1774
|
rb_ca_accum (int argc, VALUE *argv, VALUE self)
|
1775
1775
|
{
|
1776
1776
|
CArray *ca;
|
1777
|
-
|
1777
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1778
1778
|
return rb_ca_stat_general(argc, argv, self, ca->data_type, ca_proc_accum);
|
1779
1779
|
}
|
1780
1780
|
|
@@ -1788,7 +1788,7 @@ rb_ca_stat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1788
1788
|
|
1789
1789
|
rb_scan_args(argc, argv, "02", (VALUE *) &rmc, (VALUE *) &rfval);
|
1790
1790
|
|
1791
|
-
|
1791
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1792
1792
|
|
1793
1793
|
if ( ! ca_proc[ca->data_type] ) {
|
1794
1794
|
rb_raise(rb_eCADataTypeError,
|
@@ -1797,7 +1797,7 @@ rb_ca_stat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1797
1797
|
}
|
1798
1798
|
|
1799
1799
|
out = rb_carray_new(data_type, 1, &ca->elements, 0, NULL);
|
1800
|
-
|
1800
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, co);
|
1801
1801
|
|
1802
1802
|
if ( ca->elements == 0 ) {
|
1803
1803
|
;
|
@@ -1893,7 +1893,7 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1893
1893
|
|
1894
1894
|
rb_scan_args(argc, argv, "12", (VALUE *) &rndim, (VALUE *) &rmc, (VALUE *) &rfval);
|
1895
1895
|
|
1896
|
-
|
1896
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
1897
1897
|
|
1898
1898
|
if ( ! ca_proc[ca->data_type] ) {
|
1899
1899
|
rb_raise(rb_eCADataTypeError,
|
@@ -1914,7 +1914,7 @@ rb_ca_dimstat_type2 (int argc, VALUE *argv, VALUE self,
|
|
1914
1914
|
odim[ndim] = ca->elements/n;
|
1915
1915
|
|
1916
1916
|
out = rb_carray_new(data_type, ndim+1, odim, 0, NULL);
|
1917
|
-
|
1917
|
+
TypedData_Get_Struct(out, CArray, &carray_data_type, co);
|
1918
1918
|
|
1919
1919
|
if ( ca_has_mask(ca) ) {
|
1920
1920
|
ca_create_mask(co);
|
data/ext/carray_test.c
CHANGED
@@ -173,7 +173,7 @@ rb_ca_is_type (VALUE arg, int type)
|
|
173
173
|
if ( ! rb_obj_is_carray(arg) ) {
|
174
174
|
rb_raise(rb_eRuntimeError, "CArray required");
|
175
175
|
}
|
176
|
-
|
176
|
+
TypedData_Get_Struct(arg, CArray, &carray_data_type, ca);
|
177
177
|
return ca->data_type == type;
|
178
178
|
}
|
179
179
|
|
@@ -237,7 +237,7 @@ rb_ca_is_valid_index (int argc, VALUE *argv, VALUE self)
|
|
237
237
|
ca_size_t idx;
|
238
238
|
int i;
|
239
239
|
|
240
|
-
|
240
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
241
241
|
|
242
242
|
if ( argc != ca->ndim ) {
|
243
243
|
rb_raise(rb_eArgError,
|
@@ -270,7 +270,7 @@ rb_ca_is_valid_addr (VALUE self, VALUE raddr)
|
|
270
270
|
CArray *ca;
|
271
271
|
ca_size_t addr;
|
272
272
|
|
273
|
-
|
273
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
274
274
|
addr = NUM2SIZE(raddr);
|
275
275
|
/*
|
276
276
|
if ( addr < 0 ) {
|
@@ -295,7 +295,7 @@ static VALUE
|
|
295
295
|
rb_ca_has_same_shape (VALUE self, VALUE other)
|
296
296
|
{
|
297
297
|
CArray *ca, *cb;
|
298
|
-
|
298
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
299
299
|
cb = ca_wrap_readonly(other, ca->data_type);
|
300
300
|
return ca_has_same_shape(ca, cb) ? Qtrue : Qfalse;
|
301
301
|
}
|
@@ -486,8 +486,8 @@ rb_ca_equal (VALUE self, VALUE other)
|
|
486
486
|
}
|
487
487
|
}
|
488
488
|
|
489
|
-
|
490
|
-
|
489
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
490
|
+
TypedData_Get_Struct(other, CArray, &carray_data_type, cb);
|
491
491
|
|
492
492
|
return ( ca_equal(ca, cb) ) ? Qtrue : Qfalse;
|
493
493
|
}
|
@@ -560,7 +560,7 @@ rb_ca_hash (VALUE self)
|
|
560
560
|
CArray *ca;
|
561
561
|
int32_t hash;
|
562
562
|
|
563
|
-
|
563
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
564
564
|
hash = ca_hash(ca);
|
565
565
|
return ULONG2NUM(hash);
|
566
566
|
}
|
@@ -590,7 +590,7 @@ VALUE
|
|
590
590
|
rb_ca_freeze (VALUE self)
|
591
591
|
{
|
592
592
|
CArray *ca;
|
593
|
-
|
593
|
+
TypedData_Get_Struct(self, CArray, &carray_data_type, ca);
|
594
594
|
ca_set_flag(ca, CA_FLAG_READ_ONLY);
|
595
595
|
return rb_obj_freeze(self);
|
596
596
|
}
|
data/ext/ruby_carray.c
CHANGED
@@ -101,6 +101,13 @@ Init_carray_ext ()
|
|
101
101
|
rb_cCARepeat = rb_define_class("CARepeat", rb_cCAVirtual);
|
102
102
|
rb_cCAUnboundRepeat = rb_define_class("CAUnboundRepeat", rb_cCAVirtual);
|
103
103
|
|
104
|
+
rb_cCArrayMask = rb_define_class("CArrayMask", rb_cCArray);
|
105
|
+
rb_cCAReferMask = rb_define_class("CAReferMask", rb_cCARefer);
|
106
|
+
rb_cCABlockMask = rb_define_class("CABlockMask", rb_cCABlock);
|
107
|
+
rb_cCASelectMask = rb_define_class("CASelectMask", rb_cCASelect);
|
108
|
+
rb_cCARepeatMask = rb_define_class("CARepeatMask", rb_cCARepeat);
|
109
|
+
rb_cCAUnboundRepeatMask = rb_define_class("CAUnboundRepeatMask", rb_cCAUnboundRepeat);
|
110
|
+
|
104
111
|
/* -- Exception class -- */
|
105
112
|
|
106
113
|
rb_eCADataTypeError =
|
data/ext/ruby_ccomplex.c
CHANGED
@@ -19,6 +19,20 @@
|
|
19
19
|
static VALUE rb_cComplex;
|
20
20
|
#endif
|
21
21
|
|
22
|
+
extern const rb_data_type_t ccomplex_data_type;
|
23
|
+
|
24
|
+
const rb_data_type_t ccomplex_data_type = {
|
25
|
+
.parent = NULL,
|
26
|
+
.wrap_struct_name = "CComplex",
|
27
|
+
.function = {
|
28
|
+
.dmark = NULL,
|
29
|
+
.dfree = xfree,
|
30
|
+
.dsize = NULL,
|
31
|
+
.dcompact = NULL
|
32
|
+
},
|
33
|
+
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
|
34
|
+
};
|
35
|
+
|
22
36
|
VALUE rb_cCComplex;
|
23
37
|
|
24
38
|
VALUE rb_ccomplex_new2 (double re, double im);
|
@@ -69,7 +83,7 @@ rb_num2cc(VALUE num)
|
|
69
83
|
{
|
70
84
|
if ( rb_obj_is_kind_of(num, rb_cCComplex) ) {
|
71
85
|
double complex *cp;
|
72
|
-
|
86
|
+
TypedData_Get_Struct(num, double complex, &ccomplex_data_type, cp);
|
73
87
|
return *cp;
|
74
88
|
}
|
75
89
|
switch ( TYPE(num) ) {
|
@@ -101,7 +115,7 @@ rb_num_to_cc (VALUE num)
|
|
101
115
|
if ( rb_obj_is_kind_of(num, rb_cCComplex) ) {
|
102
116
|
double complex cc = 0.0, *cp;
|
103
117
|
cp = &cc;
|
104
|
-
|
118
|
+
TypedData_Get_Struct(num, double complex, &ccomplex_data_type, cp);
|
105
119
|
return rb_ccomplex_new(cc);
|
106
120
|
}
|
107
121
|
switch ( TYPE(num) ) {
|
@@ -129,7 +143,7 @@ rb_ccomplex_new (double complex c)
|
|
129
143
|
{
|
130
144
|
VALUE obj;
|
131
145
|
double complex *cp;
|
132
|
-
obj =
|
146
|
+
obj = TypedData_Make_Struct(rb_cCComplex, double complex, &ccomplex_data_type, cp);
|
133
147
|
*cp = c;
|
134
148
|
return obj;
|
135
149
|
}
|
@@ -171,7 +185,7 @@ rb_cc_initialize (int argc, VALUE *argv, VALUE self)
|
|
171
185
|
volatile VALUE rre, rim;
|
172
186
|
double complex *cp;
|
173
187
|
|
174
|
-
|
188
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
175
189
|
|
176
190
|
rb_scan_args(argc, argv, "11", (VALUE *)&rre, (VALUE *)&rim);
|
177
191
|
|
@@ -189,7 +203,7 @@ static VALUE
|
|
189
203
|
rb_cc_to_c (VALUE self)
|
190
204
|
{
|
191
205
|
double complex *cp;
|
192
|
-
|
206
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
193
207
|
return rb_Complex(rb_float_new(creal(*cp)), rb_float_new(cimag(*cp)));
|
194
208
|
}
|
195
209
|
|
@@ -210,7 +224,7 @@ rb_cc_real(VALUE self)
|
|
210
224
|
{
|
211
225
|
double complex *cp;
|
212
226
|
|
213
|
-
|
227
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
214
228
|
|
215
229
|
return rb_float_new(creal(*cp));
|
216
230
|
}
|
@@ -220,7 +234,7 @@ rb_cc_imag(VALUE self)
|
|
220
234
|
{
|
221
235
|
double complex *cp;
|
222
236
|
|
223
|
-
|
237
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
224
238
|
|
225
239
|
return rb_float_new(cimag(*cp));
|
226
240
|
}
|
@@ -232,7 +246,7 @@ rb_cc_inspect (VALUE self)
|
|
232
246
|
double complex *cp;
|
233
247
|
double re, im;
|
234
248
|
|
235
|
-
|
249
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
236
250
|
|
237
251
|
re = creal(*cp);
|
238
252
|
im = cimag(*cp);
|
@@ -256,7 +270,7 @@ rb_cc_conj(VALUE self)
|
|
256
270
|
{
|
257
271
|
double complex *cp;
|
258
272
|
|
259
|
-
|
273
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
260
274
|
|
261
275
|
return CC2NUM(conj(*cp));
|
262
276
|
}
|
@@ -266,7 +280,7 @@ rb_cc_arg(VALUE self)
|
|
266
280
|
{
|
267
281
|
double complex *cp;
|
268
282
|
|
269
|
-
|
283
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
270
284
|
|
271
285
|
return rb_float_new(carg(*cp));
|
272
286
|
}
|
@@ -276,7 +290,7 @@ rb_cc_abs(VALUE self)
|
|
276
290
|
{
|
277
291
|
double complex *cp;
|
278
292
|
|
279
|
-
|
293
|
+
TypedData_Get_Struct(self, double complex, &ccomplex_data_type, cp);
|
280
294
|
|
281
295
|
return rb_float_new(cabs(*cp));
|
282
296
|
}
|
data/ext/version.h
CHANGED
@@ -8,9 +8,9 @@
|
|
8
8
|
|
9
9
|
---------------------------------------------------------------------------- */
|
10
10
|
|
11
|
-
#define CA_VERSION "
|
12
|
-
#define CA_VERSION_CODE
|
13
|
-
#define CA_VERSION_MAJOR
|
14
|
-
#define CA_VERSION_MINOR
|
15
|
-
#define CA_VERSION_TEENY
|
16
|
-
#define CA_VERSION_DATE "
|
11
|
+
#define CA_VERSION "2.0.0"
|
12
|
+
#define CA_VERSION_CODE 200
|
13
|
+
#define CA_VERSION_MAJOR 2
|
14
|
+
#define CA_VERSION_MINOR 0
|
15
|
+
#define CA_VERSION_TEENY 0
|
16
|
+
#define CA_VERSION_DATE "2025/06/03"
|
data/lib/carray/inspect.rb
CHANGED
@@ -87,19 +87,18 @@ class CArray
|
|
87
87
|
else
|
88
88
|
raise "invalid data_type"
|
89
89
|
end
|
90
|
-
tempfile = "CA_Magick_#{$$}_#{@@magick_tempfile_count}.dat"
|
91
|
-
@@magick_tempfile_count += 1
|
90
|
+
# tempfile = "CA_Magick_#{$$}_#{@@magick_tempfile_count}.dat"
|
91
|
+
# @@magick_tempfile_count += 1
|
92
92
|
stream_command = [
|
93
93
|
"stream",
|
94
94
|
"-storage-type #{storage_type}",
|
95
95
|
"-map #{imap}",
|
96
96
|
filename,
|
97
|
-
|
97
|
+
"-",
|
98
98
|
"2>/dev/null"
|
99
99
|
].join(" ")
|
100
100
|
begin
|
101
|
-
|
102
|
-
return open(tempfile) { |io|
|
101
|
+
return IO.popen(stream_command) { |io|
|
103
102
|
if imap.size == 1
|
104
103
|
CArray.new(data_type, [height, width]).load_binary(io)
|
105
104
|
else
|
@@ -109,9 +108,9 @@ class CArray
|
|
109
108
|
rescue
|
110
109
|
raise "ImageMagick's stream command failed to read image file '#{filename}'"
|
111
110
|
ensure
|
112
|
-
if File.exist?(tempfile)
|
113
|
-
File.unlink(tempfile)
|
114
|
-
end
|
111
|
+
# if File.exist?(tempfile)
|
112
|
+
# File.unlink(tempfile)
|
113
|
+
# end
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
@@ -171,7 +170,7 @@ class CArray
|
|
171
170
|
depth = "-depth 8"
|
172
171
|
end
|
173
172
|
convert_command = [
|
174
|
-
"convert",
|
173
|
+
"magick convert",
|
175
174
|
depth,
|
176
175
|
"-size " + [dim1, dim0].join("x"),
|
177
176
|
quantum_format,
|
data/lib/carray/mkmf.rb
CHANGED
@@ -112,6 +112,7 @@ def possible_prefix (*postfixes)
|
|
112
112
|
File.expand_path("~/local"), ### user's home / local
|
113
113
|
File.expand_path("~"), ### user's home
|
114
114
|
"/opt/local", ### MacPorts
|
115
|
+
"/opt/homebrew", ### Homebrew
|
115
116
|
"/opt", ### UNIX
|
116
117
|
"/sw/local", ### Mac Fink
|
117
118
|
"/sw/", ### Mac Fink
|
data/lib/carray/time.rb
CHANGED
data/spec/Classes/ex1.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative "../../lib/carray"
|
2
|
+
#require_relative "../../ext/carray_ext"
|
3
|
+
|
4
|
+
class CArray
|
5
|
+
|
6
|
+
def count_masked (*axis)
|
7
|
+
p "rw"
|
8
|
+
if has_mask?
|
9
|
+
p "rb"
|
10
|
+
p self.class
|
11
|
+
p self.mask.ndim
|
12
|
+
p "rk"
|
13
|
+
# j=self.mask
|
14
|
+
p "rj"
|
15
|
+
#p mask.int64
|
16
|
+
#return mask.int64.accumulate(*axis)
|
17
|
+
else
|
18
|
+
if axis.empty?
|
19
|
+
return 0
|
20
|
+
else
|
21
|
+
spec = shape.map{:i}
|
22
|
+
axis.each do |k|
|
23
|
+
spec[k] = nil
|
24
|
+
end
|
25
|
+
return self[*spec].ca.template(:int64) { 0 }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
a = CArray.int(3).seq!
|
32
|
+
a[1] = UNDEF
|
33
|
+
r1 = a[3,:%]
|
34
|
+
x1 = r1.to_ca
|
35
|
+
3 == x1.count_masked
|
36
|
+
p "ro"
|
37
|
+
#is_asserted_by { 3 == r1[nil, 1].count_masked }
|
38
|
+
#is_asserted_by { 3 == x1.count_masked }
|
39
|
+
#is_asserted_by { 3 == x1[nil, 1].count_masked }
|
40
|
+
|
41
|
+
#r2 = a[:%,3]
|
42
|
+
#x2 = r2.to_ca
|
43
|
+
#is_asserted_by { 3 == r2.count_masked }
|
44
|
+
#is_asserted_by { 3 == r2[1, nil].count_masked }
|
45
|
+
#is_asserted_by { 3 == x2.count_masked }
|
46
|
+
#is_asserted_by { 3 == x2[1, nil].count_masked }
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroki Motoyoshi
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-06-03 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: |2
|
14
13
|
Ruby/CArray is an extension library for the multi-dimensional numerical array
|
@@ -154,6 +153,7 @@ files:
|
|
154
153
|
- spec/Classes/CAWrap_spec.rb
|
155
154
|
- spec/Classes/CArray_spec.rb
|
156
155
|
- spec/Classes/CScalar_spec.rb
|
156
|
+
- spec/Classes/ex1.rb
|
157
157
|
- spec/Features/feature_130_spec.rb
|
158
158
|
- spec/Features/feature_attributes_spec.rb
|
159
159
|
- spec/Features/feature_boolean_spec.rb
|
@@ -207,7 +207,6 @@ homepage: https://github.com/himotoyoshi/carray
|
|
207
207
|
licenses:
|
208
208
|
- MIT
|
209
209
|
metadata: {}
|
210
|
-
post_install_message:
|
211
210
|
rdoc_options: []
|
212
211
|
require_paths:
|
213
212
|
- lib
|
@@ -222,8 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
222
221
|
- !ruby/object:Gem::Version
|
223
222
|
version: '0'
|
224
223
|
requirements: []
|
225
|
-
rubygems_version: 3.
|
226
|
-
signing_key:
|
224
|
+
rubygems_version: 3.6.2
|
227
225
|
specification_version: 4
|
228
226
|
summary: Multi-dimesional array class for Ruby
|
229
227
|
test_files: []
|