carray 1.3.7 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -7
- data/Rakefile +31 -0
- data/carray.gemspec +9 -14
- data/carray.h +4 -0
- data/carray_access.c +50 -8
- data/carray_conversion.c +3 -3
- data/carray_generate.c +67 -1
- data/carray_math.rb +22 -22
- data/carray_operator.c +23 -0
- data/devel/im2col.rb +17 -0
- data/lib/carray.rb +32 -1
- data/lib/carray/autoload/autoload_base.rb +0 -4
- data/lib/carray/autoload/autoload_gem_cairo.rb +9 -0
- data/lib/carray/autoload/autoload_gem_ffi.rb +9 -0
- data/lib/carray/autoload/autoload_gem_gnuplot.rb +2 -0
- data/lib/carray/autoload/autoload_gem_io_csv.rb +14 -0
- data/lib/carray/autoload/autoload_gem_io_pg.rb +6 -0
- data/lib/carray/autoload/autoload_gem_io_sqlite3.rb +12 -0
- data/lib/carray/autoload/autoload_gem_narray.rb +10 -0
- data/lib/carray/autoload/autoload_gem_numo_narray.rb +14 -0
- data/lib/carray/autoload/autoload_gem_opencv.rb +16 -0
- data/lib/carray/autoload/autoload_gem_rmagick.rb +23 -0
- data/lib/carray/autoload/{autoload_graphics_zimg.rb → autoload_gem_zimg.rb} +0 -0
- data/lib/carray/base/autoload.rb +47 -5
- data/lib/carray/base/basic.rb +58 -2
- data/lib/carray/base/math.rb +1 -1
- data/lib/carray/base/string.rb +242 -0
- data/mkmath.rb +12 -2
- data/version.h +5 -5
- metadata +29 -109
- data/Gemfile +0 -8
- data/Gemfile.lock +0 -33
- data/ext/calculus/lib/autoload/autoload_math_calculus.rb +0 -2
- data/ext/fortio/extconf.rb +0 -3
- data/ext/fortio/lib/carray/autoload/autoload_fortran_format.rb +0 -5
- data/ext/fortio/lib/carray/io/fortran_format.rb +0 -43
- data/ext/fortio/lib/fortio.rb +0 -3
- data/ext/fortio/lib/fortio/fortran_format.rb +0 -605
- data/ext/fortio/lib/fortio/fortran_format.tab.rb +0 -536
- data/ext/fortio/lib/fortio/fortran_format.y +0 -215
- data/ext/fortio/lib/fortio/fortran_namelist.rb +0 -151
- data/ext/fortio/lib/fortio/fortran_namelist.tab.rb +0 -470
- data/ext/fortio/lib/fortio/fortran_namelist.y +0 -213
- data/ext/fortio/lib/fortio/fortran_sequential.rb +0 -345
- data/ext/fortio/ruby_fortio.c +0 -182
- data/ext/fortio/test/test_H.rb +0 -5
- data/ext/fortio/test/test_T.rb +0 -7
- data/ext/fortio/test/test_fortran_format.rb +0 -86
- data/ext/fortio/test/test_namelist.rb +0 -25
- data/ext/fortio/test/test_namelist_write.rb +0 -10
- data/ext/fortio/test/test_sequential.rb +0 -13
- data/ext/fortio/test/test_sequential2.rb +0 -13
- data/ext/fortio/work/test.rb +0 -10
- data/ext/fortio/work/test_e.rb +0 -19
- data/ext/fortio/work/test_ep.rb +0 -10
- data/ext/fortio/work/test_parse.rb +0 -12
- data/ext/mathfunc/lib/autoload/autoload_math_mathfunc.rb +0 -1
- data/ext/mathfunc/lib/math/mathfunc.rb +0 -15
- data/ext/narray/README +0 -22
- data/ext/narray/ca_wrap_narray.c +0 -500
- data/ext/narray/carray_narray.c +0 -21
- data/ext/narray/extconf.rb +0 -57
- data/ext/narray/lib/autoload/autoload_math_narray.rb +0 -1
- data/ext/narray/lib/autoload/autoload_math_narray_miss.rb +0 -11
- data/ext/narray/lib/math/narray.rb +0 -17
- data/ext/narray/lib/math/narray_miss.rb +0 -45
- data/lib/carray/autoload/autoload_graphics_gnuplot.rb +0 -2
- data/lib/carray/autoload/autoload_io_csv.rb +0 -14
- data/lib/carray/autoload/autoload_io_numo.rb +0 -9
- data/lib/carray/autoload/autoload_io_pg.rb +0 -6
- data/lib/carray/autoload/autoload_io_sqlite3.rb +0 -12
- data/lib/carray/graphics/gnuplot.rb +0 -2141
- data/lib/carray/graphics/zimg.rb +0 -296
- data/lib/carray/io/csv.rb +0 -572
- data/lib/carray/io/numo.rb +0 -52
- data/lib/carray/io/pg.rb +0 -101
- data/lib/carray/io/sqlite3.rb +0 -215
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19670c9fa370952b777655dbbfc938a93deecbbe62452559f572951d8a083078
|
4
|
+
data.tar.gz: bc7dae442eee84400725a45c804332426f72a0405299d785ecccb3cae27f1d2b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1f76a7cdc3448844557c05c0375b01221a2d7a6d9d48ed36223cbc3a39b379e3dab966a48c8a6aaa57d0d6521e4222f2849dca8749e7137e693ec9379d12b9f
|
7
|
+
data.tar.gz: 82b3ff4f50775df6f6699533826e8494a29a34f15256d2874b271dc6cd64f1c24878d4639185c4837a66ee15daf33fa25c1ec3f0bf80c487b80553c353939cbd
|
data/README.md
CHANGED
@@ -10,14 +10,7 @@ Requirements
|
|
10
10
|
* C compiler
|
11
11
|
+ IEEE754 floating point number
|
12
12
|
+ C99 complex number
|
13
|
-
* Optionally required gems
|
14
|
-
+ narray
|
15
|
-
+ narray_miss
|
16
|
-
+ axlsx
|
17
|
-
+ spreadsheet
|
18
|
-
+ sqlite3
|
19
13
|
* Optional command
|
20
|
-
+ Gnuplot
|
21
14
|
+ ImageMagick (stream, convert, display, identify)
|
22
15
|
|
23
16
|
Directories
|
data/Rakefile
CHANGED
@@ -2,12 +2,43 @@
|
|
2
2
|
#
|
3
3
|
#
|
4
4
|
|
5
|
+
GEMSPEC = "carray.gemspec"
|
6
|
+
|
7
|
+
task :install do
|
8
|
+
spec = eval File.read(GEMSPEC)
|
9
|
+
version_h = `ruby version.rb`.chomp
|
10
|
+
if spec.version.to_s != version_h
|
11
|
+
STDERR.puts "Mismatch in version between carray.gemspec and version.h"
|
12
|
+
STDERR.puts " carray.gemspec - #{spec.version.to_s }"
|
13
|
+
STDERR.puts " version.h - #{version_h}"
|
14
|
+
STDERR.puts "Please check!"
|
15
|
+
exit(1)
|
16
|
+
end
|
17
|
+
system %{
|
18
|
+
gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rspec/core/rake_task'
|
23
|
+
RSpec::Core::RakeTask.new
|
24
|
+
|
25
|
+
|
26
|
+
__END__
|
5
27
|
require 'rake'
|
6
28
|
require 'rake/testtask'
|
7
29
|
require 'rspec/core/rake_task'
|
8
30
|
|
9
31
|
task :default => :test
|
10
32
|
|
33
|
+
GEMSPEC = "carray.gemspec"
|
34
|
+
|
35
|
+
task :install do
|
36
|
+
spec = eval File.read(GEMSPEC)
|
37
|
+
system %{
|
38
|
+
gem build #{GEMSPEC}; gem install #{spec.full_name}.gem
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
11
42
|
desc "Run the tests"
|
12
43
|
Rake::TestTask::new(:test) do |t|
|
13
44
|
t.test_files = FileList['test/test_ALL.rb']
|
data/carray.gemspec
CHANGED
@@ -1,17 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
Gem::Specification::new do |s|
|
4
|
-
|
5
|
-
|
6
|
-
version, date = carray_version()
|
2
|
+
|
3
|
+
version = "1.4.0"
|
7
4
|
|
8
5
|
files = Dir.glob("**/*") - [
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
Dir.glob("carray-*.gem"),
|
7
|
+
Dir.glob("ext/**/{Makefile,mkmf.log}"),
|
8
|
+
Dir.glob("**/*.{o,so,bundle}"),
|
9
|
+
Dir.glob("**/*~"),
|
10
|
+
Dir.glob("doc/**/*"),
|
11
|
+
].flatten
|
15
12
|
|
16
13
|
s.platform = Gem::Platform::RUBY
|
17
14
|
s.name = "carray"
|
@@ -38,7 +35,5 @@ Gem::Specification::new do |s|
|
|
38
35
|
Dir.glob("lib/carray/**/*.rb"),
|
39
36
|
].flatten
|
40
37
|
s.required_ruby_version = ">= 1.8.1"
|
41
|
-
s.add_runtime_dependency 'narray', '~> 0.6.1.1'
|
42
|
-
s.add_runtime_dependency 'narray_miss', '~> 1.3'
|
43
|
-
s.add_runtime_dependency 'sqlite3', '~> 1.3'
|
44
38
|
end
|
39
|
+
|
data/carray.h
CHANGED
@@ -710,6 +710,7 @@ enum {
|
|
710
710
|
CA_REG_METHOD_CALL,
|
711
711
|
CA_REG_UNBOUND_REPEAT,
|
712
712
|
CA_REG_MEMBER,
|
713
|
+
CA_REG_ATTRIBUTE,
|
713
714
|
}; /* CA_REGION_TYPE */
|
714
715
|
|
715
716
|
enum {
|
@@ -1070,7 +1071,10 @@ int rb_ca_is_type (VALUE arg, int type);
|
|
1070
1071
|
void rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t elements,
|
1071
1072
|
long argc, VALUE *argv, CAIndexInfo *info);
|
1072
1073
|
|
1074
|
+
|
1073
1075
|
/* cast */
|
1076
|
+
int rb_ca_test_castable (VALUE other);
|
1077
|
+
VALUE rb_ca_binop_pass_to_other (VALUE self, VALUE other, ID method);
|
1074
1078
|
void rb_ca_cast_self (volatile VALUE *self);
|
1075
1079
|
void rb_ca_cast_self_or_other (volatile VALUE *self, volatile VALUE *other);
|
1076
1080
|
void rb_ca_cast_other (VALUE *self, volatile VALUE *other);
|
data/carray_access.c
CHANGED
@@ -510,9 +510,15 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
|
|
510
510
|
}
|
511
511
|
}
|
512
512
|
|
513
|
-
if ( TYPE(arg) == T_STRING ) {
|
514
|
-
|
515
|
-
|
513
|
+
if ( TYPE(arg) == T_STRING ) {
|
514
|
+
if ( StringValuePtr(arg)[0] == '@' ) { /* ca["@name"] -> CA_REG_ATTRIBUTE */
|
515
|
+
info->type = CA_REG_ATTRIBUTE;
|
516
|
+
info->symbol = rb_str_new2(StringValuePtr(arg)+1);
|
517
|
+
}
|
518
|
+
else { /* ca["field"] -> CA_REG_MEMBER */
|
519
|
+
info->type = CA_REG_MEMBER;
|
520
|
+
info->symbol = ID2SYM(rb_intern(StringValuePtr(arg)));
|
521
|
+
}
|
516
522
|
return;
|
517
523
|
}
|
518
524
|
|
@@ -612,8 +618,18 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
|
|
612
618
|
iv_end = RANGE_END(arg);
|
613
619
|
iv_excl = RANGE_EXCL(arg);
|
614
620
|
index_type[i] = CA_IDX_BLOCK; /* convert to block */
|
615
|
-
|
616
|
-
|
621
|
+
if ( NIL_P(iv_beg) ) {
|
622
|
+
first = 0;
|
623
|
+
}
|
624
|
+
else {
|
625
|
+
first = NUM2SIZE(iv_beg);
|
626
|
+
}
|
627
|
+
if ( NIL_P(iv_end) ) {
|
628
|
+
last = -1;
|
629
|
+
}
|
630
|
+
else {
|
631
|
+
last = NUM2SIZE(iv_end);
|
632
|
+
}
|
617
633
|
excl = RTEST(iv_excl);
|
618
634
|
CA_CHECK_INDEX_AT(first, ca_dim[i], i);
|
619
635
|
|
@@ -687,9 +703,23 @@ rb_ca_scan_index (int ca_rank, ca_size_t *ca_dim, ca_size_t ca_elements,
|
|
687
703
|
}
|
688
704
|
else if ( rb_obj_is_kind_of(arg0, rb_cRange) ) { /* ca[--,[i..j,k],--]*/
|
689
705
|
ca_size_t start, last, excl, count, step, bound;
|
690
|
-
|
691
|
-
|
692
|
-
|
706
|
+
volatile VALUE iv_beg, iv_end, iv_excl;
|
707
|
+
iv_beg = RANGE_BEG(arg0);
|
708
|
+
iv_end = RANGE_END(arg0);
|
709
|
+
iv_excl = RANGE_EXCL(arg0);
|
710
|
+
if ( NIL_P(iv_beg) ) {
|
711
|
+
start = 0;
|
712
|
+
}
|
713
|
+
else {
|
714
|
+
start = NUM2SIZE(iv_beg);
|
715
|
+
}
|
716
|
+
if ( NIL_P(iv_end) ) {
|
717
|
+
last = -1;
|
718
|
+
}
|
719
|
+
else {
|
720
|
+
last = NUM2SIZE(iv_end);
|
721
|
+
}
|
722
|
+
excl = RTEST(iv_excl);
|
693
723
|
step = NUM2SIZE(arg1);
|
694
724
|
if ( step == 0 ) {
|
695
725
|
rb_raise(rb_eRuntimeError,
|
@@ -1298,6 +1328,11 @@ rb_ca_fetch_method (int argc, VALUE *argv, VALUE self)
|
|
1298
1328
|
}
|
1299
1329
|
break;
|
1300
1330
|
}
|
1331
|
+
case CA_REG_ATTRIBUTE: {
|
1332
|
+
obj = rb_funcall(self, rb_intern("attribute"), 0);
|
1333
|
+
obj = rb_hash_aref(obj, info.symbol);
|
1334
|
+
break;
|
1335
|
+
}
|
1301
1336
|
default:
|
1302
1337
|
rb_raise(rb_eIndexError, "invalid index specified");
|
1303
1338
|
}
|
@@ -1403,6 +1438,11 @@ rb_ca_store_method (int argc, VALUE *argv, VALUE self)
|
|
1403
1438
|
}
|
1404
1439
|
break;
|
1405
1440
|
}
|
1441
|
+
case CA_REG_ATTRIBUTE: {
|
1442
|
+
obj = rb_funcall(self, rb_intern("attribute"), 0);
|
1443
|
+
obj = rb_hash_aset(obj, info.symbol, rval);
|
1444
|
+
break;
|
1445
|
+
}
|
1406
1446
|
}
|
1407
1447
|
return obj;
|
1408
1448
|
}
|
@@ -1547,6 +1587,7 @@ rb_ca_s_scan_index (VALUE self, VALUE rdim, VALUE ridx)
|
|
1547
1587
|
case CA_REG_METHOD_CALL:
|
1548
1588
|
case CA_REG_UNBOUND_REPEAT:
|
1549
1589
|
case CA_REG_MEMBER:
|
1590
|
+
case CA_REG_ATTRIBUTE:
|
1550
1591
|
break;
|
1551
1592
|
default:
|
1552
1593
|
rb_raise(rb_eArgError, "unknown index specification");
|
@@ -1828,6 +1869,7 @@ Init_carray_access ()
|
|
1828
1869
|
rb_define_const(rb_cObject, "CA_REG_UNBOUND_REPEAT",
|
1829
1870
|
INT2NUM(CA_REG_UNBOUND_REPEAT));
|
1830
1871
|
rb_define_const(rb_cObject, "CA_REG_MEMBER", INT2NUM(CA_REG_MEMBER));
|
1872
|
+
rb_define_const(rb_cObject, "CA_REG_ATTRIBUTE", INT2NUM(CA_REG_ATTRIBUTE));
|
1831
1873
|
|
1832
1874
|
}
|
1833
1875
|
|
data/carray_conversion.c
CHANGED
@@ -508,10 +508,10 @@ Init_carray_conversion ()
|
|
508
508
|
/* DO NOT define CArray#to_ary, it makes trouble with various situations */
|
509
509
|
/* rb_define_method(rb_cCArray, "to_ary", rb_ca_to_a, 0); */
|
510
510
|
|
511
|
-
rb_define_method(rb_cCArray, "
|
511
|
+
rb_define_method(rb_cCArray, "str_format", rb_ca_format, -1);
|
512
512
|
|
513
|
-
rb_define_method(rb_cCArray, "
|
514
|
-
rb_define_method(rb_cCArray, "
|
513
|
+
rb_define_method(rb_cCArray, "str_strptime", rb_ca_strptime, 1);
|
514
|
+
rb_define_method(rb_cCArray, "str_strftime", rb_ca_strftime, 1);
|
515
515
|
|
516
516
|
rb_define_method(rb_cCArray, "test_ca_to_cptr", rb_test_ca_to_cptr, 0);
|
517
517
|
|
data/carray_generate.c
CHANGED
@@ -562,7 +562,7 @@ rb_ca_swap_bytes (VALUE self)
|
|
562
562
|
|
563
563
|
/* ----------------------------------------------------------------- */
|
564
564
|
|
565
|
-
#define
|
565
|
+
#define proc_trim_bang2(type, from) \
|
566
566
|
{ \
|
567
567
|
type *ptr = (type *) ca->ptr; \
|
568
568
|
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
@@ -601,6 +601,72 @@ rb_ca_swap_bytes (VALUE self)
|
|
601
601
|
} \
|
602
602
|
}
|
603
603
|
|
604
|
+
#define proc_trim_bang(type, from) \
|
605
|
+
{ \
|
606
|
+
type *ptr = (type *) ca->ptr; \
|
607
|
+
boolean8_t *m = (ca->mask) ? (boolean8_t*) ca->mask->ptr : NULL; \
|
608
|
+
if ( ! NIL_P(rmin) ) { \
|
609
|
+
type min = (type) from(rmin); \
|
610
|
+
ca_size_t i; \
|
611
|
+
if ( m && rfval == CA_UNDEF) { \
|
612
|
+
for (i=ca->elements; i; i--, ptr++, m++) { \
|
613
|
+
if ( ! *m ) { \
|
614
|
+
if ( *ptr < min ) \
|
615
|
+
*m = 1; \
|
616
|
+
} \
|
617
|
+
} \
|
618
|
+
} \
|
619
|
+
else { \
|
620
|
+
int has_fill = ! ( NIL_P(rfval) ); \
|
621
|
+
type fill = (has_fill) ? (type) from(rfval) : (type) 0; \
|
622
|
+
if ( m ) { \
|
623
|
+
for (i=ca->elements; i; i--, ptr++) { \
|
624
|
+
if ( ! *m++ ) { \
|
625
|
+
if ( *ptr < min ) \
|
626
|
+
*ptr = (has_fill) ? fill : min; \
|
627
|
+
} \
|
628
|
+
} \
|
629
|
+
} \
|
630
|
+
else { \
|
631
|
+
for (i=ca->elements; i; i--, ptr++) { \
|
632
|
+
if ( *ptr < min ) \
|
633
|
+
*ptr = (has_fill) ? fill : min; \
|
634
|
+
} \
|
635
|
+
} \
|
636
|
+
} \
|
637
|
+
} \
|
638
|
+
if ( ! NIL_P(rmax) ) { \
|
639
|
+
type max = (type) from(rmax); \
|
640
|
+
ca_size_t i; \
|
641
|
+
if ( m && rfval == CA_UNDEF) { \
|
642
|
+
for (i=ca->elements; i; i--, ptr++, m++) { \
|
643
|
+
if ( ! *m ) { \
|
644
|
+
if ( *ptr >= max ) \
|
645
|
+
*m = 1; \
|
646
|
+
} \
|
647
|
+
} \
|
648
|
+
} \
|
649
|
+
else { \
|
650
|
+
int has_fill = ! ( NIL_P(rfval) ); \
|
651
|
+
type fill = (has_fill) ? (type) from(rfval) : (type) 0; \
|
652
|
+
if ( m ) { \
|
653
|
+
for (i=ca->elements; i; i--, ptr++) { \
|
654
|
+
if ( ! *m++ ) { \
|
655
|
+
if ( *ptr >= max ) \
|
656
|
+
*ptr = (has_fill) ? fill : max; \
|
657
|
+
} \
|
658
|
+
} \
|
659
|
+
} \
|
660
|
+
else { \
|
661
|
+
for (i=ca->elements; i; i--, ptr++) { \
|
662
|
+
if ( *ptr >= max ) \
|
663
|
+
*ptr = (has_fill) ? fill : max; \
|
664
|
+
} \
|
665
|
+
} \
|
666
|
+
} \
|
667
|
+
} \
|
668
|
+
}
|
669
|
+
|
604
670
|
/* rdoc:
|
605
671
|
class CArray
|
606
672
|
# trims the data into the range between min and max. If `fill_value`
|
data/carray_math.rb
CHANGED
@@ -228,22 +228,22 @@ binop("pmin", "pmin",
|
|
228
228
|
CMPLX_TYPES => nil,
|
229
229
|
OBJ_TYPES =>'(#3) = rb_funcall(rb_assoc_new((#1),(#2)), rb_intern("min"), 0);')
|
230
230
|
|
231
|
-
binop("
|
231
|
+
binop("+", "add",
|
232
232
|
ALL_TYPES =>"(#3) = (#1) + (#2);",
|
233
233
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) + (#2);" : nil,
|
234
234
|
OBJ_TYPES =>'(#3) = rb_funcall((#1), id_plus, 1, (#2));')
|
235
235
|
|
236
|
-
binop("
|
236
|
+
binop("-", "sub",
|
237
237
|
ALL_TYPES => "(#3) = (#1) - (#2);",
|
238
238
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) - (#2);" : nil,
|
239
239
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_minus, 1, (#2));')
|
240
240
|
|
241
|
-
binop("
|
241
|
+
binop("*", "mul",
|
242
242
|
ALL_TYPES => "(#3) = (#1) * (#2);",
|
243
243
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) * (#2);" : nil,
|
244
244
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_star, 1, (#2));')
|
245
245
|
|
246
|
-
binop("
|
246
|
+
binop("/", "div",
|
247
247
|
INT_TYPES => "if ((#2)==0) {ca_zerodiv();}; (#3) = (#1) / (#2);",
|
248
248
|
FLOAT_TYPES => "(#3) = (#1) / (#2);",
|
249
249
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#1) / (#2);" : nil,
|
@@ -258,21 +258,21 @@ binop("rcp_mul", "rcp_mul",
|
|
258
258
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = (#2) / (#1);" : nil,
|
259
259
|
OBJ_TYPES => '(#3) = rb_funcall((#2), id_slash, 1, (#1));')
|
260
260
|
|
261
|
-
binop("
|
261
|
+
binop("%", "mod",
|
262
262
|
INT_TYPES => "if ((#2)==0) {ca_zerodiv();}; (#3) = (#1) % (#2);",
|
263
263
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_percent, 1, (#2));')
|
264
264
|
|
265
|
-
binop("
|
265
|
+
binop("&", "bit_and_i",
|
266
266
|
BOOL_TYPES => "(#3) = (#1) & (#2);",
|
267
267
|
INT_TYPES => "(#3) = (#1) & (#2);",
|
268
268
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_and, 1, (#2));')
|
269
269
|
|
270
|
-
binop("
|
270
|
+
binop("|", "bit_or_i",
|
271
271
|
BOOL_TYPES => "(#3) = (#1) | (#2);",
|
272
272
|
INT_TYPES => "(#3) = (#1) | (#2);",
|
273
273
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_or, 1, (#2));')
|
274
274
|
|
275
|
-
binop("
|
275
|
+
binop("^", "bit_xor_i",
|
276
276
|
BOOL_TYPES => "(#3) = ((#1) != (#2)) ? 1 : 0;",
|
277
277
|
INT_TYPES => "(#3) = (#1) ^ (#2);",
|
278
278
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_xor, 1, (#2));')
|
@@ -329,11 +329,11 @@ METHODS << %{
|
|
329
329
|
rb_define_method(rb_cCArray, "bit_xor", rb_ca_bit_xor, 1);
|
330
330
|
}
|
331
331
|
|
332
|
-
binop("
|
332
|
+
binop("<<", "bit_lshift",
|
333
333
|
INT_TYPES => "(#3) = (#1) << (#2);",
|
334
334
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_lshift, 1, (#2));')
|
335
335
|
|
336
|
-
binop("
|
336
|
+
binop(">>", "bit_rshift",
|
337
337
|
INT_TYPES => "(#3) = (#1) >> (#2);",
|
338
338
|
OBJ_TYPES => '(#3) = rb_funcall((#1), id_rshift, 1, (#2));')
|
339
339
|
|
@@ -461,16 +461,16 @@ METHODS << %{
|
|
461
461
|
rb_define_method(rb_cCArray, "xor", rb_ca_xor, 1);
|
462
462
|
}
|
463
463
|
|
464
|
-
alias_op("
|
465
|
-
alias_op("
|
466
|
-
alias_op("
|
467
|
-
alias_op("
|
468
|
-
alias_op("
|
469
|
-
alias_op("
|
470
|
-
alias_op("
|
471
|
-
alias_op("
|
472
|
-
alias_op("
|
473
|
-
alias_op("
|
464
|
+
alias_op("add", "+")
|
465
|
+
alias_op("sub", "-")
|
466
|
+
alias_op("mul", "*")
|
467
|
+
alias_op("div", "/")
|
468
|
+
alias_op("mod", "%")
|
469
|
+
alias_op("bit_and", "&")
|
470
|
+
alias_op("bit_or", "|")
|
471
|
+
alias_op("bit_xor", "^")
|
472
|
+
alias_op("bit_lshift", "<<")
|
473
|
+
alias_op("bit_rshift", ">>")
|
474
474
|
|
475
475
|
#alias_op("==", "eq")
|
476
476
|
#alias_op("!=", "ne")
|
@@ -752,7 +752,7 @@ rb_ca_ipower_bang (VALUE self, VALUE other)
|
|
752
752
|
|
753
753
|
}
|
754
754
|
|
755
|
-
binop("
|
755
|
+
binop("**", "power",
|
756
756
|
INT_TYPES => "(#3) = op_powi_<type>((#1), (#2));",
|
757
757
|
FLOAT_TYPES => "(#3) = pow((#1), (#2));",
|
758
758
|
CMPLX_TYPES => HAVE_COMPLEX ? "(#3) = cpow((#1), (#2));" : nil,
|
@@ -803,7 +803,7 @@ METHODS << %{
|
|
803
803
|
rb_define_method(rb_cCArray, "pow!", rb_ca_pow_bang, 1);
|
804
804
|
}
|
805
805
|
|
806
|
-
alias_op("
|
806
|
+
alias_op("pow", "**")
|
807
807
|
|
808
808
|
METHODS << %{
|
809
809
|
id_equal = rb_intern("==");
|
data/carray_operator.c
CHANGED
@@ -84,6 +84,29 @@ rb_ca_call_monop_bang (VALUE self, ca_monop_func_t func[])
|
|
84
84
|
return self;
|
85
85
|
}
|
86
86
|
|
87
|
+
int
|
88
|
+
rb_ca_test_castable (VALUE other)
|
89
|
+
{
|
90
|
+
volatile VALUE retval;
|
91
|
+
if ( rb_respond_to(other, rb_intern("castable_to_carray?")) ) {
|
92
|
+
retval = rb_funcall(other, rb_intern("castable_to_carray?"), 0);
|
93
|
+
return RTEST(retval);
|
94
|
+
}
|
95
|
+
else {
|
96
|
+
return 1;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
VALUE
|
101
|
+
rb_ca_binop_pass_to_other (VALUE self, VALUE other, ID method)
|
102
|
+
{
|
103
|
+
volatile VALUE pair;
|
104
|
+
pair = rb_funcall(other, rb_intern("coerce"), 1, self);
|
105
|
+
self = rb_ary_entry(pair, 0);
|
106
|
+
other = rb_ary_entry(pair, 1);
|
107
|
+
return rb_funcall(self, method, 1, other);
|
108
|
+
}
|
109
|
+
|
87
110
|
VALUE
|
88
111
|
rb_ca_call_binop (volatile VALUE self, volatile VALUE other,
|
89
112
|
ca_binop_func_t func[])
|