carray 1.5.8 → 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 536e992ddb82a26f4e24f300892a303306bff88fcd1596b872f418a17879f84c
4
- data.tar.gz: e41b0740aaf2319feea6c795a93b1e36c0f4138257429a224e33602c21175b99
3
+ metadata.gz: 172f193a4ae5241f1b91116374bb05bfa9c5ab184d8a72e7f3a1a564541eff1d
4
+ data.tar.gz: c6a650327904d42d22a56b148f6e381a1940a1d6d91099509e53080b857572c9
5
5
  SHA512:
6
- metadata.gz: 2ec6a48b80522cd0e583ee0c7feeda490dab810c3c1a8670fd106c654b50c8af3595aaef9dc848082b8d0bd79ee250d7f39d363b123024e93894c385ed93cfd8
7
- data.tar.gz: 59e38a1e1d8dc1030b1de81840c7c215df768f1ad15cdaa19e54015ffc6344fc6f2ac381d70509a2f74ba4f1d5dc9588b4b47340ca9e98b8cbb4456c51ce742e
6
+ metadata.gz: bf6e6cd9c71441d16f6342ff7cdef459a5fb9d229083650241035000ba2dfa0e313e0fab2fd47b0b401b7a4f82e92564d6aad97f975f6100063e17b8f7567dbb
7
+ data.tar.gz: 8fca46a6402dd6ad29841429551dafa128bf1146218eb527236aff2f5d8c29cb127b180c1b2c766b39dd8b26c69641d916d7570823a5e4fd590052c9f9bee411
data/NEWS.md CHANGED
@@ -1,6 +1,12 @@
1
1
  ChangeLog of Ruby/CArray
2
2
  ========================
3
3
 
4
+ 1.5.8 -> 1.5.9
5
+ --------------
6
+
7
+ * [New] Add new method 'CArray#vectorized_find_linear_addr'
8
+ * [Fix] Fixed invalid return value type in CArray##stddev
9
+
4
10
  1.5.7 -> 1.5.8
5
11
  --------------
6
12
 
@@ -14,7 +20,7 @@ ChangeLog of Ruby/CArray
14
20
  --------------
15
21
 
16
22
  * [Mod] Modify the methods 'CArray#first' and 'CArray#last' to return nil when the number of elements is zero
17
- * [Fix] Added check of having ArithmeticSeuqence in ruby_carray.c
23
+ * [Fix] Add check of having ArithmeticSeuqence in ruby_carray.c
18
24
 
19
25
  1.5.5 -> 1.5.6
20
26
  --------------
data/carray.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification::new do |s|
2
2
 
3
- version = "1.5.8"
3
+ version = "1.5.9"
4
4
 
5
5
  files = Dir.glob("**/*") + [".yardopts"] -
6
6
  [
data/ext/carray_order.c CHANGED
@@ -1238,6 +1238,108 @@ rb_ca_fetch_linear_addr (volatile VALUE self, volatile VALUE vx)
1238
1238
  */
1239
1239
 
1240
1240
 
1241
+ static VALUE
1242
+ rb_ca_find_linear_addr_vectorized (volatile VALUE self, volatile VALUE vx)
1243
+ {
1244
+ volatile VALUE out, out0;
1245
+ CArray *ca, *sc, *cx, *co0, *co;
1246
+ double *x;
1247
+ double *px;
1248
+ double *po;
1249
+ ca_size_t nseri, nlist, nreq, xnseri;
1250
+ ca_size_t i, k;
1251
+ boolean8_t *mx, *mo;
1252
+
1253
+ Data_Get_Struct(self, CArray, ca);
1254
+
1255
+ if ( rb_ca_is_any_masked(self) ) {
1256
+ rb_raise(rb_eRuntimeError, "self should not have any masked elements");
1257
+ }
1258
+
1259
+ sc = ca_wrap_readonly(self, CA_FLOAT64);
1260
+ cx = ca_wrap_readonly(vx, CA_FLOAT64);
1261
+
1262
+ if ( sc->ndim < 2 ) {
1263
+ rb_raise(rb_eRuntimeError, "ndim of self should be larger than 2");
1264
+ }
1265
+
1266
+ nseri = 1;
1267
+ for (i=0; i<sc->ndim-1; i++) {
1268
+ nseri *= sc->dim[i];
1269
+ }
1270
+ nlist = sc->dim[sc->ndim-1];
1271
+
1272
+ if ( cx->ndim < sc->ndim - 1 ) {
1273
+ rb_raise(rb_eRuntimeError, "ndim of first argument should be larger than (ndim - 1) of self");
1274
+ }
1275
+
1276
+ xnseri = 1;
1277
+ for (i=0; i<sc->ndim-1; i++) {
1278
+ xnseri *= cx->dim[i];
1279
+ }
1280
+
1281
+ if ( xnseri != nseri ) {
1282
+ rb_raise(rb_eRuntimeError, "1st dimension should be same between self and 1st argument");
1283
+ }
1284
+
1285
+ if ( cx->ndim == sc->ndim - 1 ) {
1286
+ nreq = 1;
1287
+ }
1288
+ else {
1289
+ nreq = cx->dim[cx->ndim-1];
1290
+ }
1291
+
1292
+ co0 = carray_new(ca->data_type, cx->ndim, cx->dim, 0, NULL);
1293
+ out = out0 = ca_wrap_struct(co0);
1294
+ co = ca_wrap_writable(out, CA_FLOAT64);
1295
+
1296
+ ca_attach_n(3, sc, cx, co);
1297
+
1298
+ x = (double*) sc->ptr;
1299
+ px = (double*) cx->ptr;
1300
+ po = (double*) co->ptr;
1301
+
1302
+ ca_create_mask(co);
1303
+ ca_update_mask(cx);
1304
+
1305
+ if ( cx->mask ) {
1306
+ mx = (boolean8_t *) cx->mask->ptr;
1307
+ mo = (boolean8_t *) co->mask->ptr;
1308
+ for (k=0; k<nseri; k++) {
1309
+ for (i=0; i<nreq; i++) {
1310
+ if ( ! *mx ) {
1311
+ if ( linear_index(nlist, x, *px, po) ) {
1312
+ *mo = 1;
1313
+ }
1314
+ }
1315
+ else {
1316
+ *mo = 1;
1317
+ }
1318
+ mx++; mo++; px++, po++;
1319
+ }
1320
+ x += nlist;
1321
+ }
1322
+ }
1323
+ else {
1324
+ mo = (boolean8_t *) co->mask->ptr;
1325
+ for (k=0; k<nseri; k++) {
1326
+ for (i=0; i<nreq; i++) {
1327
+ if ( linear_index(nlist, x, *px, po) ) {
1328
+ *mo = 1;
1329
+ }
1330
+ mo++; px++; po++;
1331
+ }
1332
+ x += nlist;
1333
+ }
1334
+ }
1335
+
1336
+ ca_sync(co);
1337
+ ca_detach_n(3, sc, cx, co);
1338
+
1339
+ return out0;
1340
+ }
1341
+
1342
+
1241
1343
  static VALUE
1242
1344
  rb_ca_fetch_linear_addr_vectorized (volatile VALUE self, volatile VALUE vx)
1243
1345
  {
@@ -1372,6 +1474,9 @@ Init_carray_order ()
1372
1474
  rb_define_method(rb_cCArray, "fetch_linear_addr",
1373
1475
  rb_ca_fetch_linear_addr, 1);
1374
1476
 
1477
+ rb_define_method(rb_cCArray, "vectorized_find_linear_addr",
1478
+ rb_ca_find_linear_addr_vectorized, 1);
1479
+
1375
1480
  rb_define_method(rb_cCArray, "vectorized_fetch_linear_addr",
1376
1481
  rb_ca_fetch_linear_addr_vectorized, 1);
1377
1482
 
@@ -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, <atype> *retval)
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
 
data/ext/version.h CHANGED
@@ -8,9 +8,9 @@
8
8
 
9
9
  ---------------------------------------------------------------------------- */
10
10
 
11
- #define CA_VERSION "1.5.8"
12
- #define CA_VERSION_CODE 158
11
+ #define CA_VERSION "1.5.9"
12
+ #define CA_VERSION_CODE 159
13
13
  #define CA_VERSION_MAJOR 1
14
14
  #define CA_VERSION_MINOR 5
15
- #define CA_VERSION_TEENY 8
16
- #define CA_VERSION_DATE "2023/01/13"
15
+ #define CA_VERSION_TEENY 9
16
+ #define CA_VERSION_DATE "2023/06/19"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carray
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.8
4
+ version: 1.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-13 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Ruby/CArray is an extension library for the multi-dimensional numerical array