carray 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +0 -1
  3. data/ca_iter_block.c +32 -30
  4. data/ca_iter_dimension.c +24 -22
  5. data/ca_iter_window.c +25 -23
  6. data/ca_obj_array.c +58 -56
  7. data/ca_obj_bitarray.c +27 -27
  8. data/ca_obj_bitfield.c +46 -45
  9. data/ca_obj_block.c +77 -72
  10. data/ca_obj_fake.c +20 -20
  11. data/ca_obj_farray.c +22 -22
  12. data/ca_obj_field.c +31 -30
  13. data/ca_obj_grid.c +63 -62
  14. data/ca_obj_mapping.c +35 -32
  15. data/ca_obj_object.c +54 -54
  16. data/ca_obj_reduce.c +13 -13
  17. data/ca_obj_refer.c +42 -39
  18. data/ca_obj_repeat.c +50 -47
  19. data/ca_obj_select.c +24 -24
  20. data/ca_obj_shift.c +61 -58
  21. data/ca_obj_transpose.c +52 -51
  22. data/ca_obj_unbound_repeat.c +28 -27
  23. data/ca_obj_window.c +77 -72
  24. data/carray.gemspec +0 -2
  25. data/carray.h +190 -163
  26. data/carray_access.c +137 -136
  27. data/carray_attribute.c +24 -13
  28. data/carray_call_cfunc.c +21 -21
  29. data/carray_cast.c +106 -110
  30. data/carray_cast_func.rb +17 -17
  31. data/carray_class.c +3 -3
  32. data/carray_conversion.c +15 -15
  33. data/carray_copy.c +27 -27
  34. data/carray_core.c +22 -21
  35. data/carray_element.c +55 -47
  36. data/carray_generate.c +32 -32
  37. data/carray_iterator.c +36 -35
  38. data/carray_loop.c +37 -37
  39. data/carray_mask.c +21 -21
  40. data/carray_math.rb +18 -18
  41. data/carray_numeric.c +1 -1
  42. data/carray_operator.c +19 -18
  43. data/carray_order.c +30 -30
  44. data/carray_random.c +34 -32
  45. data/carray_sort_addr.c +12 -12
  46. data/carray_stat.c +127 -127
  47. data/carray_stat_proc.rb +152 -141
  48. data/carray_test.c +16 -16
  49. data/carray_utils.c +58 -56
  50. data/ext/calculus/carray_calculus.c +19 -20
  51. data/ext/calculus/carray_interp.c +12 -11
  52. data/ext/fortio/lib/fortio/fortran_sequential.rb +2 -2
  53. data/ext/fortio/ruby_fortio.c +1 -1
  54. data/ext/imagemap/carray_imagemap.c +14 -14
  55. data/ext/narray/ca_wrap_narray.c +30 -21
  56. data/extconf.rb +5 -0
  57. data/lib/carray/base/basic.rb +4 -3
  58. data/lib/carray/base/serialize.rb +3 -3
  59. data/lib/carray/graphics/gnuplot.rb +10 -7
  60. data/lib/carray/io/csv.rb +14 -9
  61. data/lib/carray/io/imagemagick.rb +7 -0
  62. data/lib/carray/io/sqlite3.rb +6 -4
  63. data/mkmath.rb +20 -20
  64. data/ruby_carray.c +2 -0
  65. data/ruby_ccomplex.c +3 -3
  66. data/test/test_130.rb +23 -0
  67. data/test/test_ALL.rb +2 -1
  68. data/test/test_order.rb +3 -3
  69. data/test/test_stat.rb +2 -2
  70. data/version.h +4 -4
  71. metadata +4 -37
  72. data/examples/ex001.rb +0 -10
  73. data/examples/test-int.rb +0 -13
  74. data/lib/carray/autoload/autoload_io_excel.rb +0 -5
  75. data/lib/carray/io/excel.rb +0 -26
@@ -163,6 +163,10 @@ class CArray
163
163
  depth = "-depth 8"
164
164
  when CA_INT16, CA_UINT16
165
165
  depth = "-depth 16"
166
+ when CA_FLOAT32
167
+ depth = "-depth 32"
168
+ when CA_FLOAT64
169
+ depth = "-depth 64"
166
170
  when CA_FIXLEN
167
171
  depth = "-depth #{8*bytes}"
168
172
  else
@@ -229,3 +233,6 @@ end
229
233
 
230
234
 
231
235
 
236
+
237
+
238
+
@@ -70,11 +70,13 @@ class CArray
70
70
  else
71
71
  begin
72
72
  dim0.times do |i|
73
- insert.execute self[i,nil].to_a
73
+ begin
74
+ insert.execute self[i,nil].to_a
75
+ rescue
76
+ puts self[i,nil].to_a
77
+ raise $!
78
+ end
74
79
  end
75
- rescue
76
- puts self[i,nil].to_a
77
- raise $!
78
80
  end
79
81
  end
80
82
  database.commit if transaction
data/mkmath.rb CHANGED
@@ -27,11 +27,11 @@ def monfunc (op, name, hash)
27
27
  omp_ok = ( type != "VALUE" ) ? 1 : 0
28
28
  io.print %{
29
29
  static void
30
- ca_monop_#{name}_#{type} (int32_t n, boolean8_t *m, char *ptr1, int32_t i1, char *ptr2, int32_t i2)
30
+ ca_monop_#{name}_#{type} (ca_size_t n, boolean8_t *m, char *ptr1, ca_size_t i1, char *ptr2, ca_size_t i2)
31
31
  {
32
32
  #{type} *q1 = (#{type} *) ptr1, *q2 = (#{type} *) ptr2;
33
33
  #{type} *p1 = q1, *p2 = q2;
34
- int32_t k;
34
+ ca_size_t k;
35
35
  if ( m ) {
36
36
  boolean8_t *pm;
37
37
  #if defined(_OPENMP) && #{omp_ok}
@@ -94,7 +94,7 @@ static VALUE rb_ca_#{name} (VALUE self)
94
94
  static VALUE rb_ca_#{name} (VALUE self)
95
95
  {
96
96
  if ( rb_ca_is_integer_type(self) ) {
97
- self = rb_ca_wrap_readonly(self, INT2FIX(CA_FLOAT64));
97
+ self = rb_ca_wrap_readonly(self, INT2NUM(CA_FLOAT64));
98
98
  }
99
99
  return rb_ca_call_monop(self, ca_monop_#{name});
100
100
  }
@@ -138,11 +138,11 @@ def monop (op, name, hash)
138
138
  omp_ok = ( type != "VALUE" ) ? 1 : 0
139
139
  io.print %{
140
140
  static void
141
- ca_monop_#{name}_#{type} (int32_t n, boolean8_t *m, char *ptr1, int32_t i1, char *ptr2, int32_t i2)
141
+ ca_monop_#{name}_#{type} (ca_size_t n, boolean8_t *m, char *ptr1, ca_size_t i1, char *ptr2, ca_size_t i2)
142
142
  {
143
143
  #{type} *q1 = (#{type} *) ptr1, *q2 = (#{type} *) ptr2;
144
144
  #{type} *p1 = q1, *p2 = q2;
145
- int32_t k;
145
+ ca_size_t k;
146
146
  if ( m ) {
147
147
  boolean8_t *pm;
148
148
  #if defined(_OPENMP) && #{omp_ok}
@@ -228,11 +228,11 @@ def binop (op, name, hash)
228
228
  omp_ok = ( type != "VALUE" ) ? 1 : 0
229
229
  io.print %{
230
230
  static void
231
- ca_binop_#{name}_#{type} (int32_t n, boolean8_t *m, char *ptr1, int32_t i1, char *ptr2, int32_t i2, char *ptr3, int32_t i3)
231
+ ca_binop_#{name}_#{type} (ca_size_t n, boolean8_t *m, char *ptr1, ca_size_t i1, char *ptr2, ca_size_t i2, char *ptr3, ca_size_t i3)
232
232
  {
233
233
  #{type} *q1 = (#{type} *) ptr1, *q2 = (#{type} *) ptr2, *q3 = (#{type} *) ptr3;
234
234
  #{type} *p1 = q1, *p2 = q2, *p3 = q3;
235
- int32_t k;
235
+ ca_size_t k;
236
236
  if ( m ) {
237
237
  boolean8_t *pm;
238
238
  #if defined(_OPENMP) && #{omp_ok}
@@ -320,13 +320,13 @@ def moncmp (op, name, hash)
320
320
  omp_ok = ( type != "VALUE" ) ? 1 : 0
321
321
  io.print %{
322
322
  static void
323
- ca_moncmp_#{name}_#{type} (int32_t n, boolean8_t *m, char *ptr1, int32_t i1, boolean8_t *ptr2, int32_t i2)
323
+ ca_moncmp_#{name}_#{type} (ca_size_t n, boolean8_t *m, char *ptr1, ca_size_t i1, boolean8_t *ptr2, ca_size_t i2)
324
324
  {
325
325
  #{type} *q1 = (#{type} *) ptr1;
326
326
  #{type} *p1 = q1;
327
327
  boolean8_t *q2 = (boolean8_t *) ptr2;
328
328
  boolean8_t *p2 = q2;
329
- int32_t k;
329
+ ca_size_t k;
330
330
  if ( m ) {
331
331
  boolean8_t *pm = m;
332
332
  #if defined(_OPENMP) && #{omp_ok}
@@ -415,16 +415,16 @@ def bincmp (op, name, hash)
415
415
  omp_ok = ( type != "VALUE" ) ? 1 : 0
416
416
  io.print %{
417
417
  static void
418
- ca_bincmp_#{name}_#{type} (int32_t n, boolean8_t *m,
419
- char *ptr1, int32_t b1, int32_t i1,
420
- char *ptr2, int32_t b2, int32_t i2,
421
- char *ptr3, int32_t b3, int32_t i3)
418
+ ca_bincmp_#{name}_#{type} (ca_size_t n, boolean8_t *m,
419
+ char *ptr1, ca_size_t b1, ca_size_t i1,
420
+ char *ptr2, ca_size_t b2, ca_size_t i2,
421
+ char *ptr3, ca_size_t b3, ca_size_t i3)
422
422
  {
423
423
  #{type} *q1 = (#{type} *) ptr1, *q2 = (#{type} *) ptr2;
424
424
  #{type} *p1 = q1, *p2 = q2;
425
425
  boolean8_t *q3 = (boolean8_t *) ptr3;
426
426
  boolean8_t *p3 = q3;
427
- int32_t k;
427
+ ca_size_t k;
428
428
  if ( m ) {
429
429
  boolean8_t *pm = m;
430
430
  #if defined(_OPENMP) && #{omp_ok}
@@ -461,17 +461,17 @@ ca_bincmp_#{name}_#{type} (int32_t n, boolean8_t *m,
461
461
  omp_ok = 1
462
462
  io.print %{
463
463
  static void
464
- ca_bincmp_#{name}_#{type} (int32_t n, boolean8_t *m,
465
- char *ptr1, int32_t b1, int32_t i1,
466
- char *ptr2, int32_t b2, int32_t i2,
467
- char *ptr3, int32_t b3, int32_t i3)
464
+ ca_bincmp_#{name}_#{type} (ca_size_t n, boolean8_t *m,
465
+ char *ptr1, ca_size_t b1, ca_size_t i1,
466
+ char *ptr2, ca_size_t b2, ca_size_t i2,
467
+ char *ptr3, ca_size_t b3, ca_size_t i3)
468
468
  {
469
469
  char *q1 = ptr1, *q2 = ptr2;
470
470
  char *p1 = q1, *p2 = q2;
471
471
  boolean8_t *q3 = (boolean8_t *) ptr3;
472
472
  boolean8_t *p3 = q3;
473
- int32_t s1 = b1*i1, s2 = b2*i2, s3 = b3*i3;
474
- int32_t k;
473
+ ca_size_t s1 = b1*i1, s2 = b2*i2, s3 = b3*i3;
474
+ ca_size_t k;
475
475
  if ( m ) {
476
476
  boolean8_t *pm = m;
477
477
  #if defined(_OPENMP) && #{omp_ok}
data/ruby_carray.c CHANGED
@@ -164,6 +164,8 @@ Init_carray_ext ()
164
164
  rb_define_const(rb_cObject, "CA_DOUBLE", INT2NUM(CA_DOUBLE));
165
165
  rb_define_const(rb_cObject, "CA_COMPLEX", INT2NUM(CA_COMPLEX));
166
166
  rb_define_const(rb_cObject, "CA_DCOMPLEX", INT2NUM(CA_DCOMPLEX));
167
+ rb_define_const(rb_cObject, "CA_SIZE", INT2NUM(CA_SIZE));
168
+
167
169
 
168
170
  rb_define_const(rb_cObject, "CA_ALIGN_VOIDP", INT2NUM(CA_ALIGN_VOIDP));
169
171
  rb_define_const(rb_cObject, "CA_ALIGN_FIXLEN", INT2NUM(CA_ALIGN_INT8));
data/ruby_ccomplex.c CHANGED
@@ -76,7 +76,7 @@ rb_num2cc(VALUE num)
76
76
  }
77
77
  switch ( TYPE(num) ) {
78
78
  case T_FIXNUM:
79
- return (double complex) FIX2LONG(num);
79
+ return (double complex) NUM2LONG(num);
80
80
  case T_BIGNUM:
81
81
  return (double complex) rb_big2dbl(num);
82
82
  case T_FLOAT:
@@ -108,7 +108,7 @@ rb_num_to_cc (VALUE num)
108
108
  }
109
109
  switch ( TYPE(num) ) {
110
110
  case T_FIXNUM:
111
- return rb_ccomplex_new((double complex) FIX2LONG(num));
111
+ return rb_ccomplex_new((double complex) NUM2LONG(num));
112
112
  case T_BIGNUM:
113
113
  return rb_ccomplex_new((double complex) rb_big2dbl(num));
114
114
  case T_FLOAT:
@@ -175,7 +175,7 @@ rb_cc_initialize (int argc, VALUE *argv, VALUE self)
175
175
 
176
176
  Data_Get_Struct(self, double complex, cp);
177
177
 
178
- rb_scan_args(argc, argv, "11", &rre, &rim);
178
+ rb_scan_args(argc, argv, "11", (VALUE *)&rre, (VALUE *)&rim);
179
179
 
180
180
  if ( NIL_P(rim) ) {
181
181
  *cp = NUM2DBL(rre);
data/test/test_130.rb ADDED
@@ -0,0 +1,23 @@
1
+ $:.unshift("../lib", "..")
2
+
3
+ require 'test/unit'
4
+ require 'carray'
5
+
6
+ class Test130 < Test::Unit::TestCase
7
+
8
+ def test_float_arithmetic
9
+ assert_equal((CA_FLOAT([100])+1)[0], 101.0)
10
+ end
11
+
12
+ def test_int64
13
+ assert_raise(RangeError) { CA_INT64([0xffffffffffffffff]) }
14
+ assert_equal(CA_INT64([0x7fffffffffffffff])[0],
15
+ 0x7fffffffffffffff)
16
+ assert_equal(CA_INT64([0x7fffffffffffffff])+1,
17
+ CA_INT64([-0x8000000000000000]))
18
+ assert_equal(CA_INT64([0x7fffffffffffffff, 0x7fffffffffffffff]).sum,
19
+ (2*0x7fffffffffffffff).to_f)
20
+ end
21
+
22
+
23
+ end
data/test/test_ALL.rb CHANGED
@@ -37,7 +37,7 @@ load 'test_extream.rb'
37
37
  load 'test_generate.rb'
38
38
  load 'test_index.rb'
39
39
  load 'test_mask.rb'
40
- #load 'test_math.rb'
40
+ load 'test_math.rb'
41
41
  load 'test_narray.rb' if defined?(CArray::HAVE_NARRAY)
42
42
  load 'test_order.rb'
43
43
  load 'test_random.rb'
@@ -48,3 +48,4 @@ load 'test_virtual.rb'
48
48
  #
49
49
  load 'test_creation.rb'
50
50
  #
51
+ load 'test_130.rb'
data/test/test_order.rb CHANGED
@@ -9,7 +9,7 @@ class TestCArrayOrder < Test::Unit::TestCase
9
9
  # ---
10
10
  a = CArray.int(3,3).seq!
11
11
  c = (a % 2).eq(0)
12
- assert_equal(a[c], c.where)
12
+ assert_equal(a[c], c.where.int)
13
13
  end
14
14
 
15
15
  def test_index
@@ -66,14 +66,14 @@ class TestCArrayOrder < Test::Unit::TestCase
66
66
  [0,1,2],
67
67
  [8,7,6]])
68
68
  # ---
69
- assert_equal(CA_INT32([[3,4,5],
69
+ assert_equal(CA_SIZE([[3,4,5],
70
70
  [2,1,0],
71
71
  [8,7,6]]), a.sort_addr)
72
72
  assert_equal(CA_INT32([[5,4,3],
73
73
  [0,1,2],
74
74
  [8,7,6]]), a.order)
75
75
  # ---
76
- assert_equal(CA_INT32([[6,7,8],
76
+ assert_equal(CA_SIZE([[6,7,8],
77
77
  [0,1,2],
78
78
  [5,4,3]]), a.sort_addr.reverse)
79
79
  assert_equal(CA_INT32([[3,4,5],
data/test/test_stat.rb CHANGED
@@ -9,7 +9,7 @@ class TestCArrayStat < Test::Unit::TestCase
9
9
  # ---
10
10
  a = CArray.int32(10).seq!(1) ### [1, 2, ..., 10]
11
11
  s = a.min
12
- assert_instance_of(Fixnum, s)
12
+ #assert_instance_of(Integer, s)
13
13
  assert_equal(1, s)
14
14
 
15
15
  # ---
@@ -53,7 +53,7 @@ class TestCArrayStat < Test::Unit::TestCase
53
53
  # ---
54
54
  a = CArray.int32(10).seq!(1) ### [1, 2, ..., 10]
55
55
  s = a.max
56
- assert_instance_of(Fixnum, s)
56
+ #assert_instance_of(Integer, s)
57
57
  assert_equal(10, s)
58
58
 
59
59
  # ---
data/version.h CHANGED
@@ -10,9 +10,9 @@
10
10
 
11
11
  ---------------------------------------------------------------------------- */
12
12
 
13
- #define CA_VERSION "1.2.0"
14
- #define CA_VERSION_CODE 120
13
+ #define CA_VERSION "1.3.0"
14
+ #define CA_VERSION_CODE 130
15
15
  #define CA_VERSION_MAJOR 1
16
- #define CA_VERSION_MINOR 2
16
+ #define CA_VERSION_MINOR 3
17
17
  #define CA_VERSION_TEENY 0
18
- #define CA_VERSION_DATE "2017/02/09"
18
+ #define CA_VERSION_DATE "2017/11/18"
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.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-09 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
@@ -38,34 +38,6 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.3'
41
- - !ruby/object:Gem::Dependency
42
- name: axlsx
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '2.0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- - !ruby/object:Gem::Dependency
56
- name: spreadsheet
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.1'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.1'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: sqlite3
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -154,8 +126,6 @@ files:
154
126
  - carray_undef.c
155
127
  - carray_utils.c
156
128
  - devel/guess_shape.rb
157
- - examples/ex001.rb
158
- - examples/test-int.rb
159
129
  - ext/calculus/carray_calculus.c
160
130
  - ext/calculus/carray_interp.c
161
131
  - ext/calculus/extconf.rb
@@ -222,7 +192,6 @@ files:
222
192
  - lib/carray/autoload/autoload_graphics_gnuplot.rb
223
193
  - lib/carray/autoload/autoload_graphics_zimg.rb
224
194
  - lib/carray/autoload/autoload_io_csv.rb
225
- - lib/carray/autoload/autoload_io_excel.rb
226
195
  - lib/carray/autoload/autoload_io_imagemagick.rb
227
196
  - lib/carray/autoload/autoload_io_pg.rb
228
197
  - lib/carray/autoload/autoload_io_sqlite3.rb
@@ -245,7 +214,6 @@ files:
245
214
  - lib/carray/graphics/zimg.rb
246
215
  - lib/carray/info.rb
247
216
  - lib/carray/io/csv.rb
248
- - lib/carray/io/excel.rb
249
217
  - lib/carray/io/imagemagick.rb
250
218
  - lib/carray/io/pg.rb
251
219
  - lib/carray/io/sqlite3.rb
@@ -278,6 +246,7 @@ files:
278
246
  - spec/CArray/object/s_new_spec.rb
279
247
  - spec/CArray/serialize/Serialization_spec.rb
280
248
  - spec/spec_all.rb
249
+ - test/test_130.rb
281
250
  - test/test_ALL.rb
282
251
  - test/test_CABitfield.rb
283
252
  - test/test_CABlock.rb
@@ -343,7 +312,6 @@ rdoc_options:
343
312
  - lib/carray/autoload/autoload_graphics_gnuplot.rb
344
313
  - lib/carray/autoload/autoload_graphics_zimg.rb
345
314
  - lib/carray/autoload/autoload_io_csv.rb
346
- - lib/carray/autoload/autoload_io_excel.rb
347
315
  - lib/carray/autoload/autoload_io_imagemagick.rb
348
316
  - lib/carray/autoload/autoload_io_pg.rb
349
317
  - lib/carray/autoload/autoload_io_sqlite3.rb
@@ -366,7 +334,6 @@ rdoc_options:
366
334
  - lib/carray/graphics/zimg.rb
367
335
  - lib/carray/info.rb
368
336
  - lib/carray/io/csv.rb
369
- - lib/carray/io/excel.rb
370
337
  - lib/carray/io/imagemagick.rb
371
338
  - lib/carray/io/pg.rb
372
339
  - lib/carray/io/sqlite3.rb
@@ -393,7 +360,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
393
360
  version: '0'
394
361
  requirements: []
395
362
  rubyforge_project:
396
- rubygems_version: 2.6.8
363
+ rubygems_version: 2.6.11
397
364
  signing_key:
398
365
  specification_version: 4
399
366
  summary: Multi-dimesional array class
data/examples/ex001.rb DELETED
@@ -1,10 +0,0 @@
1
- require "carray"
2
-
3
- data = <<HERE_END
4
- time,temp,humidity
5
-
6
-
7
- HERE_END
8
-
9
- ca = CArray.int(3,3).seq!
10
-
data/examples/test-int.rb DELETED
@@ -1,13 +0,0 @@
1
- require "carray"
2
-
3
- a = CArray.double(10).seq(0.1,0.1)
4
- b = CA_DOUBLE([0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1])
5
- a1 = (a/0.1)
6
- b1 = (b/0.1)
7
-
8
- p a
9
- p b
10
- p a1
11
- p b1
12
- p a1.int
13
- p b1.int
@@ -1,5 +0,0 @@
1
- autoload_method "CArray.load_excel", "carray/io/excel"
2
-
3
- class CArray
4
- autoload_method "save_excel", "carray/io/excel"
5
- end
@@ -1,26 +0,0 @@
1
- require "spreadsheet"
2
-
3
- class CArray
4
-
5
- def save_excel (filename, &block)
6
- if self.rank >= 3
7
- raise "too large rank (>2) to write excel file"
8
- end
9
- book = Spreadsheet::Workbook.new
10
- worksheet = book.create_worksheet
11
- self.dim0.times do |i|
12
- worksheet.row(i).push *self[i,nil]
13
- end
14
- if block
15
- block.call(worksheet)
16
- end
17
- book.write(filename)
18
- end
19
-
20
- def self.load_excel (filename, sheet=0)
21
- book = Spreadsheet.open(filename)
22
- sheet = book.worksheet(sheet)
23
- return sheet.map(&:to_a).to_ca
24
- end
25
-
26
- end