numo-narray 0.9.0.1-x64-mingw32 → 0.9.0.3-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -7
  3. data/Rakefile +20 -5
  4. data/ext/numo/narray/array.c +3 -3
  5. data/ext/numo/narray/data.c +102 -81
  6. data/ext/numo/narray/depend.erb +9 -7
  7. data/ext/numo/narray/extconf.rb +5 -24
  8. data/ext/numo/narray/gen/cogen.rb +19 -4
  9. data/ext/numo/narray/gen/def/bit.rb +31 -0
  10. data/ext/numo/narray/gen/def/robject.rb +1 -1
  11. data/ext/numo/narray/gen/dtype.erb.c +11 -257
  12. data/ext/numo/narray/gen/spec.rb +294 -0
  13. data/ext/numo/narray/gen/tmpl/aset.c +1 -1
  14. data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
  15. data/ext/numo/narray/gen/tmpl/eye.c +5 -5
  16. data/ext/numo/narray/gen/tmpl/logseq.c +82 -0
  17. data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
  18. data/ext/numo/narray/gen/tmpl/rand.c +126 -5
  19. data/ext/numo/narray/gen/tmpl/seq.c +43 -12
  20. data/ext/numo/narray/gen/tmpl/store_bit.c +55 -0
  21. data/ext/numo/narray/gen/tmpl_bit/allocate.c +28 -0
  22. data/ext/numo/narray/gen/tmpl_bit/aref.c +53 -0
  23. data/ext/numo/narray/gen/tmpl_bit/aset.c +63 -0
  24. data/ext/numo/narray/gen/{tmpl/bit_binary.c → tmpl_bit/binary.c} +1 -1
  25. data/ext/numo/narray/gen/{tmpl → tmpl_bit}/bit_count.c +5 -3
  26. data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +128 -0
  27. data/ext/numo/narray/gen/tmpl_bit/cast.c +37 -0
  28. data/ext/numo/narray/gen/tmpl_bit/cast_array.c +80 -0
  29. data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +22 -0
  30. data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +8 -0
  31. data/ext/numo/narray/gen/tmpl_bit/each.c +44 -0
  32. data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +66 -0
  33. data/ext/numo/narray/gen/tmpl_bit/extract.c +25 -0
  34. data/ext/numo/narray/gen/tmpl_bit/fill.c +65 -0
  35. data/ext/numo/narray/gen/tmpl_bit/format.c +61 -0
  36. data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +48 -0
  37. data/ext/numo/narray/gen/tmpl_bit/inspect.c +18 -0
  38. data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +94 -0
  39. data/ext/numo/narray/gen/tmpl_bit/mask.c +117 -0
  40. data/ext/numo/narray/gen/tmpl_bit/none_p.c +14 -0
  41. data/ext/numo/narray/gen/tmpl_bit/store.c +32 -0
  42. data/ext/numo/narray/gen/tmpl_bit/store_array.c +5 -0
  43. data/ext/numo/narray/gen/tmpl_bit/store_bit.c +66 -0
  44. data/ext/numo/narray/gen/tmpl_bit/store_from.c +56 -0
  45. data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +22 -0
  46. data/ext/numo/narray/gen/tmpl_bit/to_a.c +43 -0
  47. data/ext/numo/narray/gen/{tmpl/bit_unary.c → tmpl_bit/unary.c} +1 -1
  48. data/ext/numo/narray/gen/tmpl_bit/where.c +102 -0
  49. data/ext/numo/narray/gen/tmpl_bit/where2.c +37 -0
  50. data/ext/numo/narray/index.c +9 -7
  51. data/ext/numo/narray/math.c +6 -1
  52. data/ext/numo/narray/narray.c +307 -103
  53. data/ext/numo/narray/ndloop.c +21 -36
  54. data/ext/numo/narray/numo/intern.h +3 -3
  55. data/ext/numo/narray/numo/narray.h +5 -41
  56. data/ext/numo/narray/numo/template.h +2 -2
  57. data/ext/numo/narray/numo/types/bit.h +27 -13
  58. data/ext/numo/narray/numo/types/complex.h +2 -2
  59. data/ext/numo/narray/numo/types/complex_macro.h +19 -7
  60. data/ext/numo/narray/numo/types/dcomplex.h +9 -0
  61. data/ext/numo/narray/numo/types/dfloat.h +6 -0
  62. data/ext/numo/narray/numo/types/float_macro.h +9 -2
  63. data/ext/numo/narray/numo/types/int16.h +0 -1
  64. data/ext/numo/narray/numo/types/int32.h +0 -1
  65. data/ext/numo/narray/numo/types/int64.h +0 -1
  66. data/ext/numo/narray/numo/types/int8.h +0 -1
  67. data/ext/numo/narray/numo/types/int_macro.h +2 -1
  68. data/ext/numo/narray/numo/types/robj_macro.h +9 -2
  69. data/ext/numo/narray/numo/types/robject.h +6 -0
  70. data/ext/numo/narray/numo/types/scomplex.h +9 -0
  71. data/ext/numo/narray/numo/types/sfloat.h +6 -0
  72. data/ext/numo/narray/numo/types/uint16.h +0 -1
  73. data/ext/numo/narray/numo/types/uint32.h +0 -1
  74. data/ext/numo/narray/numo/types/uint64.h +0 -1
  75. data/ext/numo/narray/numo/types/uint8.h +0 -1
  76. data/ext/numo/narray/numo/types/uint_macro.h +2 -1
  77. data/ext/numo/narray/numo/types/xint_macro.h +6 -1
  78. data/ext/numo/narray/rand.c +2 -2
  79. data/ext/numo/narray/step.c +7 -7
  80. data/ext/numo/narray/struct.c +11 -12
  81. data/lib/2.0/numo/narray.so +0 -0
  82. data/lib/2.1/numo/narray.so +0 -0
  83. data/lib/2.2/numo/narray.so +0 -0
  84. data/lib/2.3/numo/narray.so +0 -0
  85. data/lib/2.4/numo/narray.so +0 -0
  86. data/lib/erbpp.rb +6 -2
  87. data/lib/erbpp/line_number.rb +1 -1
  88. data/lib/erbpp/narray_def.rb +23 -19
  89. data/numo-narray.gemspec +2 -2
  90. metadata +45 -10
  91. data/ext/numo/narray/gen/bit.erb.c +0 -811
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ba9387322df645be933895e871e8cfc22405fbb
4
- data.tar.gz: 6aa7706cac725c3daec4dc417189fe364a37bb82
3
+ metadata.gz: 1214879d114107330abbe27eb03843915badfadc
4
+ data.tar.gz: '028c8513bd1dc3ac69c9da71400a497ee175fee2'
5
5
  SHA512:
6
- metadata.gz: bdb2934fa9249928968f35cf6eb437995281f32180d482f36960422bd1b79d2e1cd55f9481c1d7cbeb7592ffd8ea407fa5cc3bd4386c3f276f5994a364d5038b
7
- data.tar.gz: 956176ac05733f08f251cb5ff177b20f393ac159d129e7b59daf2e6c9ec2e12f3ee134037b834d6e6cfe539ffbf204e29c0149f9a97b8476b18314a17ad213a1
6
+ metadata.gz: a922d131ec23008c270adea1dee0054816d26399b9c1f3e96cf175aa0d3c0758922c51db5e835e5e1cb878214c1de1f03aa636605d396a544382cbc73c729ba8
7
+ data.tar.gz: c629c7a5328f381bf79d31571e7534e9bfb36ad01d949fb635464c9f1053ac54e8c56b814320d68abffa3a2efa14e693087f4cbab4d15c1afa45b35b4c06088b
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  # Numo::NArray - New NArray class library for Ruby/Numo (NUmerical MOdule)
2
2
 
3
+ [![Binder](http://mybinder.org/badge.svg)](http://mybinder.org/repo/ruby-numo/narray)
3
4
  [![Build Status](https://travis-ci.org/ruby-numo/narray.svg?branch=master)](https://travis-ci.org/ruby-numo/narray)
4
5
 
5
6
  under development
6
7
 
7
8
  ## Related Projects
8
- * [Numo::Linalg](https://github.com/ruby-numo/linalg): Linear Algebra library with [LAPACK](http://www.netlib.org/lapack/).
9
- * [Numo::GSL](https://github.com/ruby-numo/gsl): Ruby interface for [GSL (GNU Scientific Library)](http://www.gnu.org/software/gsl/).
10
- * [Numo::FFTE](https://github.com/ruby-numo/ffte): Ruby interface for [FFTE (A Fast Fourier Transform library with radix-2,3,5)](http://www.ffte.jp/).
9
+ * [Numo::Linalg](https://github.com/ruby-numo/linalg) - Linear Algebra library with [LAPACK](http://www.netlib.org/lapack/).
10
+ * [Numo::GSL](https://github.com/ruby-numo/gsl) - Ruby interface for [GSL (GNU Scientific Library)](http://www.gnu.org/software/gsl/).
11
+ * [Numo::FFTE](https://github.com/ruby-numo/ffte) - Ruby interface for [FFTE (A Fast Fourier Transform library with radix-2,3,5)](http://www.ffte.jp/).
12
+ * [Numo::Gnuplot](https://github.com/ruby-numo/gnuplot) - Simple and easy-to-use Gnuplot interface.
11
13
 
12
14
  ## Installation
13
15
  ### Ubuntu, Debian
@@ -16,7 +18,7 @@ apt install -y git ruby gcc ruby-dev rake make
16
18
  git clone git://github.com/ruby-numo/narray
17
19
  cd narray
18
20
  gem build numo-narray.gemspec
19
- gem install numo-narray-0.9.0.1.gem
21
+ gem install numo-narray-0.9.0.2.gem
20
22
  ```
21
23
 
22
24
  ## Quick start
@@ -40,8 +42,10 @@ An example
40
42
  ```
41
43
  For more examples, check out this [narray version of 100 numpy exercises](https://github.com/ruby-numo/narray/wiki/100-narray-exercises).
42
44
 
43
- ## numo-array status compared to numpy
45
+ ## Documentation
44
46
 
45
- https://github.com/ruby-numo/narray/wiki/Numo-vs-numpy
47
+ All documents are primitive.
46
48
 
47
- ## [NArray Tentative API Document](http://ruby-numo.github.io/narray/narray/frames.html)
49
+ * [Numo::NArray API Doc](http://ruby-numo.github.io/narray/narray/frames.html)
50
+ * [Numo::NArray概要](https://github.com/ruby-numo/narray/wiki/Numo::NArray%E6%A6%82%E8%A6%81) (in Japanese)
51
+ * [Numo::NArray vs numpy](https://github.com/ruby-numo/narray/wiki/Numo-vs-numpy)
data/Rakefile CHANGED
@@ -1,23 +1,27 @@
1
1
  require "bundler/gem_tasks"
2
+ begin
2
3
  require "rake/extensiontask"
3
4
  require "rake_compiler_dock"
4
5
  require "shellwords"
5
6
 
6
7
  spec = Bundler::GemHelper.gemspec
7
8
 
9
+ cross_platforms = ["x86-mingw32", "x64-mingw32"]
8
10
  Rake::ExtensionTask.new("numo/narray", spec) do |ext|
9
11
  ext.cross_compile = true
10
- ext.cross_platform = ["x86-mingw32", "x64-mingw32"]
12
+ ext.cross_platform = cross_platforms
13
+ end
14
+
15
+ pkg_dir = "pkg"
16
+ windows_gem_paths = cross_platforms.collect do |platform|
17
+ File.join(pkg_dir, "#{spec.full_name}-#{platform}.gem")
11
18
  end
12
19
 
13
20
  namespace :build do
14
- pkg_dir = "pkg"
15
21
  directory pkg_dir
16
22
 
17
23
  desc "Build gems for Windows into the pkg directory"
18
24
  task :windows => pkg_dir do
19
- ruby_versions = "2.1.6:2.2.2:2.3.0"
20
-
21
25
  build_dir = "tmp/windows"
22
26
  rm_rf build_dir
23
27
  mkdir_p build_dir
@@ -26,7 +30,7 @@ namespace :build do
26
30
  ["git", "clone", "file://#{Dir.pwd}/.git", build_dir],
27
31
  ["cd", build_dir],
28
32
  ["bundle"],
29
- ["rake", "cross", "native", "gem", "RUBY_CC_VERSION=#{ruby_versions}"],
33
+ ["rake", "cross", "native", "gem"],
30
34
  ]
31
35
  raw_commands = commands.collect do |command|
32
36
  Shellwords.join(command)
@@ -39,3 +43,14 @@ namespace :build do
39
43
  "#{pkg_dir}/")
40
44
  end
41
45
  end
46
+
47
+ namespace :release do
48
+ task :windows => "build:windows" do
49
+ windows_gem_paths.each do |path|
50
+ ruby("-S", "gem", "push", path)
51
+ end
52
+ end
53
+ end
54
+
55
+ rescue LoadError
56
+ end
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  array.c
3
3
  Numerical Array Extension for Ruby
4
- (C) Copyright 1999-2011 by Masahiro TANAKA
4
+ (C) Copyright 1999-2016 by Masahiro TANAKA
5
5
 
6
6
  This program is free software.
7
7
  You can distribute/modify this program
@@ -268,7 +268,7 @@ na_mdai_result(na_mdai_t *mdai, na_compose_t *nc)
268
268
  for (i=0; i<ndim; i++) {
269
269
  shape[i] = mdai->item[i].shape;
270
270
  //printf("shape[%d]=%d\n",i,shape[i]);
271
- //rb_ary_push( shape, SIZE2NUM(mdai->item[i].shape) );
271
+ //rb_ary_push( shape, SIZET2NUM(mdai->item[i].shape) );
272
272
  }
273
273
 
274
274
  // DataType
@@ -355,7 +355,7 @@ na_s_array_shape(VALUE mod, VALUE ary)
355
355
  Data_Get_Struct(vnc, na_compose_t, nc);
356
356
  shape = rb_ary_new2(nc->ndim);
357
357
  for (i=0; i<nc->ndim; i++) {
358
- rb_ary_push( shape, SIZE2NUM(nc->shape[i]) );
358
+ rb_ary_push( shape, SIZET2NUM(nc->shape[i]) );
359
359
  }
360
360
  return shape;
361
361
  }
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  data.c
3
3
  Numerical Array Extension for Ruby
4
- (C) Copyright 1999-2011,2013 by Masahiro TANAKA
4
+ (C) Copyright 1999-2016 by Masahiro TANAKA
5
5
 
6
6
  This program is free software.
7
7
  You can distribute/modify this program
@@ -76,7 +76,6 @@ na_copy(VALUE self)
76
76
  return v;
77
77
  }
78
78
 
79
-
80
79
  VALUE
81
80
  na_store(VALUE self, VALUE src)
82
81
  {
@@ -198,65 +197,72 @@ na_transpose_map(VALUE self, int *map)
198
197
  VALUE
199
198
  na_transpose(int argc, VALUE *argv, VALUE self)
200
199
  {
201
- int ndim, *map, tmp;
202
- int row_major;
203
- int i, j, c, r;
204
- size_t len;
205
- ssize_t beg, step;
206
- volatile VALUE v, view;
200
+ int ndim, *map, *permute;
201
+ int i, d;
202
+ bool is_positive, is_negative;
207
203
  narray_t *na1;
208
204
 
209
205
  GetNArray(self,na1);
210
206
  ndim = na1->ndim;
211
- row_major = TEST_COLUMN_MAJOR( self );
212
-
207
+ if (ndim < 2) {
208
+ if (argc > 0) {
209
+ rb_raise(rb_eArgError, "unnecessary argument for 1-d array");
210
+ }
211
+ return na_make_view(self);
212
+ }
213
213
  map = ALLOCA_N(int,ndim);
214
- for (i=0;i<ndim;i++) {
215
- map[i] = i;
216
- }
217
- if (argc==0) {
218
- SWAP(map[ndim-1], map[ndim-2], tmp);
219
- goto new_object;
220
- }
221
- if (argc==2) {
222
- if (TYPE(argv[0])==T_FIXNUM && TYPE(argv[1])==T_FIXNUM) {
223
- i = FIX2INT(argv[0]);
224
- j = FIX2INT(argv[1]);
225
- if (row_major) {
226
- i = ndim-1-i;
227
- j = ndim-1-j;
228
- }
229
- SWAP( map[i], map[j], tmp );
230
- goto new_object;
231
- }
214
+ if (argc == 0) {
215
+ for (i=0; i < ndim; i++) {
216
+ map[i] = ndim-1-i;
217
+ }
218
+ return na_transpose_map(self,map);
232
219
  }
233
- for (i=argc,c=ndim-1; i;) {
234
- v = argv[--i];
235
- if (TYPE(v)==T_FIXNUM) {
236
- beg = FIX2INT(v);
237
- len = 1;
238
- step = 0;
239
- } else if (rb_obj_is_kind_of(v,rb_cRange) || rb_obj_is_kind_of(v,na_cStep)) {
240
- // write me
241
- nary_step_array_index(v, ndim, &len, &beg, &step);
242
- //printf("len=%d beg=%d step=%d\n",len,beg,step);
243
- }
244
- for (j=len; j; ) {
245
- r = beg + step*(--j);
246
- if (row_major) {
247
- r = ndim-1-r;
220
+ // with argument
221
+ if (argc > ndim) {
222
+ rb_raise(rb_eArgError, "more arguments than ndim");
223
+ }
224
+ for (i=0; i < ndim; i++) {
225
+ map[i] = i;
226
+ }
227
+ permute = ALLOCA_N(int,argc);
228
+ for (i=0; i < argc; i++) {
229
+ permute[i] = 0;
230
+ }
231
+ is_positive = is_negative = 0;
232
+ for (i=0; i < argc; i++) {
233
+ if (TYPE(argv[i]) != T_FIXNUM) {
234
+ rb_raise(rb_eArgError, "invalid argument");
235
+ }
236
+ d = FIX2INT(argv[i]);
237
+ if (d >= 0) {
238
+ if (d >= argc) {
239
+ rb_raise(rb_eArgError, "out of dimension range");
248
240
  }
249
- if ( c < 0 ) {
250
- rb_raise(rb_eArgError, "too many dims");
241
+ if (is_negative) {
242
+ rb_raise(rb_eArgError, "dimension must be non-negative only or negative only");
251
243
  }
252
- map[c--] = r;
253
- //printf("r=%d\n",r);
254
- }
244
+ if (permute[d]) {
245
+ rb_raise(rb_eArgError, "not permutation");
246
+ }
247
+ map[i] = d;
248
+ permute[d] = 1;
249
+ is_positive = 1;
250
+ } else {
251
+ if (d < -argc) {
252
+ rb_raise(rb_eArgError, "out of dimension range");
253
+ }
254
+ if (is_positive) {
255
+ rb_raise(rb_eArgError, "dimension must be non-negative only or negative only");
256
+ }
257
+ if (permute[argc+d]) {
258
+ rb_raise(rb_eArgError, "not permutation");
259
+ }
260
+ map[ndim-argc+i] = ndim+d;
261
+ permute[argc+d] = 1;
262
+ is_negative = 1;
263
+ }
255
264
  }
256
-
257
- new_object:
258
- view = na_transpose_map(self,map);
259
- return view;
265
+ return na_transpose_map(self,map);
260
266
  }
261
267
 
262
268
  //----------------------------------------------------------------------
@@ -304,7 +310,7 @@ na_reshape(int argc, VALUE *argv, VALUE self)
304
310
  rb_raise(rb_eArgError, "Total size must be same");
305
311
  }
306
312
 
307
- copy = na_copy(self);
313
+ copy = rb_funcall(self,rb_intern("copy"),0);
308
314
  GetNArray(copy,na);
309
315
  //shape_save = NA_SHAPE(na);
310
316
  na_setup_shape(na,argc,shape);
@@ -592,7 +598,7 @@ na_diagonal(int argc, VALUE *argv, VALUE self)
592
598
  }
593
599
 
594
600
  if (vofs) {
595
- kofs = NUM2SSIZE(vofs);
601
+ kofs = NUM2SSIZET(vofs);
596
602
  } else {
597
603
  kofs = 0;
598
604
  }
@@ -627,15 +633,15 @@ na_diagonal(int argc, VALUE *argv, VALUE self)
627
633
  k0 = 0;
628
634
  k1 = kofs;
629
635
  if (k1 >= na->shape[ax[1]]) {
630
- rb_raise(rb_eArgError,"invalid diagonal offset(%ld) for "
631
- "last dimension size(%ld)",kofs,na->shape[ax[1]]);
636
+ rb_raise(rb_eArgError,"invalid diagonal offset(%"SZF"d) for "
637
+ "last dimension size(%"SZF"d)",kofs,na->shape[ax[1]]);
632
638
  }
633
639
  } else {
634
640
  k0 = -kofs;
635
641
  k1 = 0;
636
642
  if (k0 >= na->shape[ax[0]]) {
637
- rb_raise(rb_eArgError,"invalid diagonal offset(=%ld) for "
638
- "last-1 dimension size(%ld)",kofs,na->shape[ax[0]]);
643
+ rb_raise(rb_eArgError,"invalid diagonal offset(=%"SZF"d) for "
644
+ "last-1 dimension size(%"SZF"d)",kofs,na->shape[ax[0]]);
639
645
  }
640
646
  }
641
647
 
@@ -749,7 +755,7 @@ na_diagonal(int argc, VALUE *argv, VALUE self)
749
755
  static VALUE
750
756
  na_new_dimension_for_dot(VALUE self, int pos, int len, bool transpose)
751
757
  {
752
- int i, k, nd;
758
+ int i, k, l, nd;
753
759
  size_t j;
754
760
  size_t *idx1, *idx2;
755
761
  size_t *shape;
@@ -775,27 +781,25 @@ na_new_dimension_for_dot(VALUE self, int pos, int len, bool transpose)
775
781
  }
776
782
  nd += len;
777
783
  shape = ALLOCA_N(size_t,nd);
778
- i = k = 0;
779
- while (i < nd) {
780
- if (i == pos) {
781
- for (; len; len--) {
782
- shape[i++] = 1;
783
- }
784
- pos = -1; // new axis done
785
- } else {
786
- shape[i++] = na->shape[k++];
787
- }
788
- }
789
-
790
- na_setup_shape((narray_t*)na2, nd, shape);
791
784
  na2->stridx = ALLOC_N(stridx_t,nd);
792
785
 
793
786
  switch(na->type) {
794
787
  case NARRAY_DATA_T:
795
788
  case NARRAY_FILEMAP_T:
789
+ i = k = 0;
790
+ while (i < nd) {
791
+ if (i == pos && len > 0) {
792
+ for (l=0; l<len; l++) {
793
+ shape[i++] = 1;
794
+ }
795
+ } else {
796
+ shape[i++] = na->shape[k++];
797
+ }
798
+ }
799
+ na_setup_shape((narray_t*)na2, nd, shape);
796
800
  stride = na_get_elmsz(self);
797
801
  for (i=nd; i--;) {
798
- SDX_SET_STRIDE(na2->stridx[i],stride);
802
+ SDX_SET_STRIDE(na2->stridx[i], stride);
799
803
  stride *= shape[i];
800
804
  }
801
805
  na2->offset = 0;
@@ -803,18 +807,35 @@ na_new_dimension_for_dot(VALUE self, int pos, int len, bool transpose)
803
807
  break;
804
808
  case NARRAY_VIEW_T:
805
809
  GetNArrayView(self, na1);
806
- for (i=0; i<nd; i++) {
807
- if (SDX_IS_INDEX(na1->stridx[i])) {
808
- idx1 = SDX_GET_INDEX(na1->stridx[i]);
809
- idx2 = ALLOC_N(size_t,na1->base.shape[i]);
810
- for (j=0; j<na1->base.shape[i]; j++) {
811
- idx2[j] = idx1[j];
810
+ i = k = 0;
811
+ while (i < nd) {
812
+ if (i == pos && len > 0) {
813
+ if (SDX_IS_INDEX(na1->stridx[k])) {
814
+ stride = SDX_GET_INDEX(na1->stridx[k])[0];
815
+ } else {
816
+ stride = SDX_GET_STRIDE(na1->stridx[k]);
817
+ }
818
+ for (l=0; l<len; l++) {
819
+ shape[i] = 1;
820
+ SDX_SET_STRIDE(na2->stridx[i], stride);
821
+ i++;
812
822
  }
813
- SDX_SET_INDEX(na2->stridx[i],idx2);
814
823
  } else {
815
- na2->stridx[i] = na1->stridx[i];
824
+ shape[i] = na1->base.shape[k];
825
+ if (SDX_IS_INDEX(na1->stridx[k])) {
826
+ idx1 = SDX_GET_INDEX(na1->stridx[k]);
827
+ idx2 = ALLOC_N(size_t,na1->base.shape[k]);
828
+ for (j=0; j<na1->base.shape[k]; j++) {
829
+ idx2[j] = idx1[j];
830
+ }
831
+ SDX_SET_INDEX(na2->stridx[i], idx2);
832
+ } else {
833
+ na2->stridx[i] = na1->stridx[k];
834
+ }
835
+ i++; k++;
816
836
  }
817
837
  }
838
+ na_setup_shape((narray_t*)na2, nd, shape);
818
839
  na2->offset = na1->offset;
819
840
  na2->data = na1->data;
820
841
  break;
@@ -17,17 +17,19 @@ C_TMPL = <%=Dir.glob("#{__dir__}/gen/tmpl/*.c").join(" ")%>
17
17
 
18
18
  COGEN = <%= __dir__ %>/gen/cogen.rb
19
19
  DTYPE = <%= __dir__ %>/gen/dtype.erb.c
20
- COGEN_DTYPE = $(COGEN) -l $(DTYPE)
21
20
  DEPENDS = $(C_TMPL) $(DTYPE) <%= __dir__ %>/gen/*.rb
22
21
 
23
- <% Dir.glob("#{__dir__}/gen/def/*.rb") do |s| %>
24
- types/<%=File.basename(s,".rb")%>.c: <%=s%> $(DEPENDS)
22
+ <%
23
+ type_c = ["types/bit.c"]
24
+ type_rb = Dir.glob("#{__dir__}/gen/def/*.rb")
25
+ type_rb.each do |s|
26
+ type_c << c = "types/"+File.basename(s,".rb")+".c"
27
+ %>
28
+ <%=c%>: <%=s%> $(DEPENDS)
25
29
  $(MAKEDIRS) $(@D) types
26
- ruby $(COGEN_DTYPE) <%=s%> > $@
30
+ ruby $(COGEN) -l -o $@ $(DTYPE) <%=s%>
27
31
  <% end %>
28
32
 
29
- types/bit.c: <%= __dir__ %>/gen/bit.erb.c $(DEPENDS)
30
- $(MAKEDIRS) $(@D) types
31
- ruby $(COGEN) -l <%= __dir__ %>/gen/bit.erb.c > $@
33
+ src : <%= type_c.join(" ") %>
32
34
 
33
35
  CLEANOBJS = *.o */*.o *.bak types/*.c
@@ -1,9 +1,5 @@
1
1
  require 'rbconfig.rb'
2
-
3
- #RbConfig::MAKEFILE_CONFIG["optflags"] = "-g3 -gdwarf-2"
4
-
5
2
  require 'mkmf'
6
-
7
3
  require "erb"
8
4
 
9
5
  if RUBY_VERSION < "2.0.0"
@@ -11,12 +7,15 @@ if RUBY_VERSION < "2.0.0"
11
7
  exit(1)
12
8
  end
13
9
 
10
+ rm_f 'numo/extconf.h'
11
+
14
12
  #$CFLAGS="-g3 -O0 -Wall"
15
13
  #$CFLAGS=" $(cflags) -O3 -m64 -msse2 -funroll-loops"
16
14
  #$CFLAGS=" $(cflags) -O3"
17
15
  $INCFLAGS = "-Itypes #$INCFLAGS"
18
16
 
19
17
  $INSTALLFILES = Dir.glob(%w[numo/*.h numo/types/*.h]).map{|x| [x,'$(archdir)'] }
18
+ $INSTALLFILES << ['numo/extconf.h','$(archdir)']
20
19
  if /cygwin|mingw/ =~ RUBY_PLATFORM
21
20
  $INSTALLFILES << ['libnarray.a', '$(archdir)']
22
21
  end
@@ -48,20 +47,6 @@ struct
48
47
  rand
49
48
  )
50
49
 
51
- =begin
52
- have_header("atlas/cblas.h")
53
- have_library("atlas")
54
-
55
- if have_library("blas")
56
- if have_library("lapack")
57
- srcs.push "linalg"
58
- $defs.push "-DHAVE_LAPACK"
59
- else
60
- #$defs.delete "-DHAVE_LAPACK"
61
- end
62
- end
63
- =end
64
-
65
50
  if have_header("stdbool.h")
66
51
  stdbool = "stdbool.h"
67
52
  else
@@ -91,18 +76,14 @@ have_type("int64_t", stdint)
91
76
  unless have_type("u_int64_t", stdint)
92
77
  have_type("uint64_t", stdint)
93
78
  end
94
- #have_library("m")
95
- #have_func("sincos")
96
- #have_func("asinh")
97
79
  have_func("exp10")
98
80
 
99
81
  have_var("rb_cComplex")
100
- #have_func("rb_alloc_tmp_buffer", "ruby.h")
101
- #have_func("rb_free_tmp_buffer", "ruby.h")
82
+ have_var("rb_cFixnum")
102
83
 
103
84
  $objs = srcs.collect{|i| i+".o"}
104
85
 
105
- create_header
86
+ create_header('numo/extconf.h')
106
87
 
107
88
  depend_path = File.join(__dir__, "depend")
108
89
  File.open(depend_path, "w") do |depend|