narray 0.5.9.4 → 0.5.9.5
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.
- data/src/ChangeLog +29 -0
- data/src/MANIFEST +7 -36
- data/src/README.en +1 -5
- data/src/README.ja +1 -2
- data/src/SPEC.en +15 -8
- data/src/SPEC.ja +5 -2
- data/src/bench/all.rb +88 -0
- data/src/bench/bench.m +61 -0
- data/src/bench/bench.py +89 -0
- data/src/bench/bench.rb +59 -0
- data/src/bench/dummy.m +0 -0
- data/src/bench/dummy.py +13 -0
- data/src/bench/dummy.rb +0 -0
- data/src/lib/narray_ext.rb +36 -2
- data/src/mkmath.rb +4 -4
- data/src/mkop.rb +16 -16
- data/src/na_array.c +32 -32
- data/src/na_func.c +50 -50
- data/src/na_index.c +26 -32
- data/src/na_linalg.c +23 -26
- data/src/na_random.c +15 -18
- data/src/narray.c +22 -32
- data/src/narray.h +3 -3
- data/src/narray_local.h +1 -1
- metadata +10 -39
- data/src/nimage/README.en +0 -38
- data/src/nimage/demo/fits.rb +0 -97
- data/src/nimage/demo/fits_convol.rb +0 -28
- data/src/nimage/demo/fits_fftdemo.rb +0 -27
- data/src/nimage/demo/fitsdemo1.rb +0 -13
- data/src/nimage/demo/fitsdemo2.rb +0 -30
- data/src/nimage/demo/fitsdemo3.rb +0 -26
- data/src/nimage/demo/fitsmorph.rb +0 -39
- data/src/nimage/demo/life_na.rb +0 -57
- data/src/nimage/demo/mandel.rb +0 -41
- data/src/nimage/extconf.rb +0 -12
- data/src/nimage/lib/nimage.rb +0 -51
- data/src/nimage/nimage.c +0 -328
- data/src/speed/add.py +0 -12
- data/src/speed/add.rb +0 -8
- data/src/speed/add_int.py +0 -12
- data/src/speed/add_int.rb +0 -9
- data/src/speed/lu.m +0 -14
- data/src/speed/lu.rb +0 -22
- data/src/speed/mat.m +0 -23
- data/src/speed/mat.rb +0 -28
- data/src/speed/mul.py +0 -12
- data/src/speed/mul.rb +0 -9
- data/src/speed/mul2.py +0 -15
- data/src/speed/mul2.rb +0 -13
- data/src/speed/mul_comp.py +0 -12
- data/src/speed/mul_comp.rb +0 -9
- data/src/speed/mul_int.py +0 -12
- data/src/speed/mul_int.rb +0 -9
- data/src/speed/mybench.py +0 -15
- data/src/speed/mybench.rb +0 -31
- data/src/speed/solve.m +0 -18
- data/src/speed/solve.py +0 -16
- data/src/speed/solve.rb +0 -21
data/src/bench/dummy.m
ADDED
File without changes
|
data/src/bench/dummy.py
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
import sys
|
2
|
+
|
3
|
+
MODULE = sys.argv[1]
|
4
|
+
|
5
|
+
if MODULE=="numeric":
|
6
|
+
from Numeric import *
|
7
|
+
from LinearAlgebra import *
|
8
|
+
elif MODULE=="numarray":
|
9
|
+
from numarray import *
|
10
|
+
from LinearAlgebra import *
|
11
|
+
elif MODULE=="numpy":
|
12
|
+
from numpy import *
|
13
|
+
from numpy.linalg import solve
|
data/src/bench/dummy.rb
ADDED
File without changes
|
data/src/lib/narray_ext.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Numerical Array Extention for Ruby
|
2
|
-
# (C) Copyright 2000-
|
2
|
+
# (C) Copyright 2000-2008 by Masahiro TANAKA
|
3
3
|
#
|
4
4
|
# This program is free software.
|
5
5
|
# You can distribute/modify this program
|
@@ -71,7 +71,41 @@ class NArray
|
|
71
71
|
end
|
72
72
|
a = NArray.ref(a)
|
73
73
|
n = rank_total(*ranks)
|
74
|
-
|
74
|
+
if complex?
|
75
|
+
NMath::sqrt( (( a-a.accum(*ranks).div!(n) ).abs**2).sum(*ranks)/(n-1) )
|
76
|
+
else
|
77
|
+
NMath::sqrt( (( a-a.accum(*ranks).div!(n) )**2).sum(*ranks)/(n-1) )
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def rms(*ranks)
|
82
|
+
if integer?
|
83
|
+
a = self.to_f
|
84
|
+
else
|
85
|
+
a = self
|
86
|
+
end
|
87
|
+
a = NArray.ref(a)
|
88
|
+
n = rank_total(*ranks)
|
89
|
+
if complex?
|
90
|
+
NMath::sqrt( (a.abs**2).sum(*ranks)/n )
|
91
|
+
else
|
92
|
+
NMath::sqrt( (a**2).sum(*ranks)/n )
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def rmsdev(*ranks)
|
97
|
+
if integer?
|
98
|
+
a = self.to_f
|
99
|
+
else
|
100
|
+
a = self
|
101
|
+
end
|
102
|
+
a = NArray.ref(a)
|
103
|
+
n = rank_total(*ranks)
|
104
|
+
if complex?
|
105
|
+
NMath::sqrt( (( a-a.accum(*ranks).div!(n) ).abs**2).sum(*ranks)/n )
|
106
|
+
else
|
107
|
+
NMath::sqrt( (( a-a.accum(*ranks).div!(n) )**2).sum(*ranks)/n )
|
108
|
+
end
|
75
109
|
end
|
76
110
|
|
77
111
|
def median(rank=nil)
|
data/src/mkmath.rb
CHANGED
@@ -9,7 +9,7 @@ print <<EOM
|
|
9
9
|
#{fname}
|
10
10
|
Automatically generated code
|
11
11
|
Numerical Array Extention for Ruby
|
12
|
-
(C) Copyright 1999-
|
12
|
+
(C) Copyright 1999-2008 by Masahiro TANAKA
|
13
13
|
|
14
14
|
This program is free software.
|
15
15
|
You can distribute/modify this program
|
@@ -571,7 +571,7 @@ end
|
|
571
571
|
$func_body =
|
572
572
|
"static void #name#C(int n, char *p1, int i1, char *p2, int i2)
|
573
573
|
{
|
574
|
-
for (; n; n
|
574
|
+
for (; n; --n) {
|
575
575
|
OPERATION
|
576
576
|
p1+=i1; p2+=i2;
|
577
577
|
}
|
@@ -650,7 +650,7 @@ end
|
|
650
650
|
$func_body =
|
651
651
|
"static void #name#CC(int n, char *p1, int i1, char *p2, int i2, char *p3, int i3)
|
652
652
|
{
|
653
|
-
for (; n; n
|
653
|
+
for (; n; --n) {
|
654
654
|
OPERATION
|
655
655
|
p1+=i1; p2+=i2; p3+=i3;
|
656
656
|
}
|
@@ -658,7 +658,7 @@ $func_body =
|
|
658
658
|
"
|
659
659
|
mkpowfuncs('Pow',
|
660
660
|
[
|
661
|
-
[/[O]/,/[O]/, "*p1 = rb_funcall(*
|
661
|
+
[/[O]/,/[O]/, "*p1 = rb_funcall(*p2,na_id_power,1,*p3);"],
|
662
662
|
[/[BIL]/,/[BIL]/, "*p1 = powInt(*p2,*p3);"],
|
663
663
|
[/[FD]/,/[BIL]/, "*p1 = pow#Ci(*p2,*p3);"],
|
664
664
|
[/[BILFD]/,/[FD]/,"*p1 = pow(*p2,*p3);"],
|
data/src/mkop.rb
CHANGED
@@ -10,7 +10,7 @@ print <<EOM
|
|
10
10
|
#{fname}
|
11
11
|
Automatically generated code
|
12
12
|
Numerical Array Extention for Ruby
|
13
|
-
(C) Copyright 1999-
|
13
|
+
(C) Copyright 1999-2008 by Masahiro TANAKA
|
14
14
|
|
15
15
|
This program is free software.
|
16
16
|
You can distribute/modify this program
|
@@ -80,7 +80,7 @@ data = [
|
|
80
80
|
$func_body =
|
81
81
|
"static void #name#CC(int n, char *p1, int i1, char *p2, int i2)
|
82
82
|
{
|
83
|
-
for (; n; n
|
83
|
+
for (; n; --n) {
|
84
84
|
OPERATION
|
85
85
|
p1+=i1; p2+=i2;
|
86
86
|
}
|
@@ -96,7 +96,7 @@ mksetfuncs('Set','','',data)
|
|
96
96
|
$func_body =
|
97
97
|
"static void #name#C(int n, char *p1, int i1, char *p2, int i2)
|
98
98
|
{
|
99
|
-
for (; n; n
|
99
|
+
for (; n; --n) {
|
100
100
|
OPERATION
|
101
101
|
p1+=i1; p2+=i2;
|
102
102
|
}
|
@@ -307,7 +307,7 @@ mksortfuncs('SortIdx', $data_types, $data_types, [nil] +
|
|
307
307
|
$func_body =
|
308
308
|
"static void #name#C(int n, char *p1, int i1, int p2, int i2)
|
309
309
|
{
|
310
|
-
for (; n; n
|
310
|
+
for (; n; --n) {
|
311
311
|
OPERATION
|
312
312
|
p1+=i1; p2+=i2;
|
313
313
|
}
|
@@ -332,36 +332,36 @@ $func_body =
|
|
332
332
|
mkfuncs('ToStr',['']+[$data_types[8]]*8,$data_types,
|
333
333
|
[nil] +
|
334
334
|
["char buf[22];
|
335
|
-
for (; n; n
|
335
|
+
for (; n; --n) {
|
336
336
|
sprintf(buf,\"%i\",(int)*p2);
|
337
337
|
*p1 = rb_str_new2(buf);
|
338
338
|
p1+=i1; p2+=i2;
|
339
339
|
}"]*3 +
|
340
340
|
["char buf[24];
|
341
|
-
for (; n; n
|
341
|
+
for (; n; --n) {
|
342
342
|
sprintf(buf,\"%.5g\",(double)*p2);
|
343
343
|
*p1 = rb_str_new2(buf);
|
344
344
|
p1+=i1; p2+=i2;
|
345
345
|
}"] +
|
346
346
|
["char buf[24];
|
347
|
-
for (; n; n
|
347
|
+
for (; n; --n) {
|
348
348
|
sprintf(buf,\"%.8g\",(double)*p2);
|
349
349
|
*p1 = rb_str_new2(buf);
|
350
350
|
p1+=i1; p2+=i2;
|
351
351
|
}"] +
|
352
352
|
["char buf[50];
|
353
|
-
for (; n; n
|
353
|
+
for (; n; --n) {
|
354
354
|
sprintf(buf,\"%.5g%+.5gi\",(double)p2->r,(double)p2->i);
|
355
355
|
*p1 = rb_str_new2(buf);
|
356
356
|
p1+=i1; p2+=i2;
|
357
357
|
}"] +
|
358
358
|
["char buf[50];
|
359
|
-
for (; n; n
|
359
|
+
for (; n; --n) {
|
360
360
|
sprintf(buf,\"%.8g%+.8gi\",(double)p2->r,(double)p2->i);
|
361
361
|
*p1 = rb_str_new2(buf);
|
362
362
|
p1+=i1; p2+=i2;
|
363
363
|
}"] +
|
364
|
-
["for (; n; n
|
364
|
+
["for (; n; --n) {
|
365
365
|
*p1 = rb_obj_as_string(*p2);
|
366
366
|
p1+=i1; p2+=i2;
|
367
367
|
}"]
|
@@ -373,7 +373,7 @@ print <<EOM
|
|
373
373
|
/* from numeric.c */
|
374
374
|
static void na_str_append_fp(char *buf)
|
375
375
|
{
|
376
|
-
if (buf[0]=='-' || buf[0]=='+') buf
|
376
|
+
if (buf[0]=='-' || buf[0]=='+') ++buf;
|
377
377
|
if (ISALPHA(buf[0])) return; /* NaN or Inf */
|
378
378
|
if (strchr(buf, '.') == 0) {
|
379
379
|
int len = strlen(buf);
|
@@ -441,11 +441,11 @@ $func_body =
|
|
441
441
|
int i;
|
442
442
|
if (i1==sizeof(type1) && i2==sizeof(type1) && i3==sizeof(type1)) {
|
443
443
|
type1 *a1=p1, *a2=p2, *a3=p3;
|
444
|
-
for (i=0; n; n
|
445
|
-
*a1 = *a2 * *a3; a1
|
444
|
+
for (i=0; n; --n,++i) {
|
445
|
+
*a1 = *a2 * *a3; +++a1;++a2;++a3;
|
446
446
|
}
|
447
447
|
} else
|
448
|
-
for (; n; n
|
448
|
+
for (; n; --n) {
|
449
449
|
OPERATION
|
450
450
|
p1+=i1; p2+=i2; p3+=i3;
|
451
451
|
}
|
@@ -460,7 +460,7 @@ mkfuncs('MulB', $data_types, $data_types,
|
|
460
460
|
$func_body =
|
461
461
|
"static void #name#C(int n, char *p1, int i1, char *p2, int i2, char *p3, int i3)
|
462
462
|
{
|
463
|
-
for (; n; n
|
463
|
+
for (; n; --n) {
|
464
464
|
OPERATION
|
465
465
|
p1+=i1; p2+=i2; p3+=i3;
|
466
466
|
}
|
@@ -620,7 +620,7 @@ mkfuncs('atan2', $data_types, $data_types,
|
|
620
620
|
$func_body =
|
621
621
|
"static void #name#C(int n, char *p1, int i1, char *p2, int i2, char *p3, int i3)
|
622
622
|
{
|
623
|
-
for (; n; n
|
623
|
+
for (; n; --n) {
|
624
624
|
OPERATION
|
625
625
|
}
|
626
626
|
}
|
data/src/na_array.c
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
na_array.c
|
3
3
|
Numerical Array Extention for Ruby
|
4
|
-
(C) Copyright 1999-
|
4
|
+
(C) Copyright 1999-2008 by Masahiro TANAKA
|
5
5
|
|
6
6
|
This program is free software.
|
7
7
|
You can distribute/modify this program
|
@@ -63,13 +63,13 @@ static na_mdai_t *
|
|
63
63
|
mdai = ALLOC(na_mdai_t);
|
64
64
|
mdai->n = n;
|
65
65
|
mdai->item = ALLOC_N( na_mdai_item_t, n );
|
66
|
-
for (i=0; i<n; i
|
66
|
+
for (i=0; i<n; ++i) {
|
67
67
|
mdai->item[i].shape = 0;
|
68
68
|
mdai->item[i].val = Qnil;
|
69
69
|
}
|
70
70
|
mdai->item[0].val = ary;
|
71
71
|
mdai->type = ALLOC_N( int, NA_NTYPES );
|
72
|
-
for (i=0; i<NA_NTYPES; i
|
72
|
+
for (i=0; i<NA_NTYPES; ++i)
|
73
73
|
mdai->type[i]=0;
|
74
74
|
|
75
75
|
return mdai;
|
@@ -84,7 +84,7 @@ static void
|
|
84
84
|
mdai->n += n_extra;
|
85
85
|
n = mdai->n;
|
86
86
|
REALLOC_N( mdai->item, na_mdai_item_t, n );
|
87
|
-
for (; i<n; i
|
87
|
+
for (; i<n; ++i) {
|
88
88
|
mdai->item[i].shape = 0;
|
89
89
|
mdai->item[i].val = Qnil;
|
90
90
|
}
|
@@ -96,15 +96,15 @@ static int *
|
|
96
96
|
int i, t, r;
|
97
97
|
int *shape;
|
98
98
|
|
99
|
-
for (t=i=NA_BYTE; i<NA_NTYPES; i
|
99
|
+
for (t=i=NA_BYTE; i<NA_NTYPES; ++i) {
|
100
100
|
if ( mdai->type[i] > 0 )
|
101
101
|
t = na_upcast[t][i];
|
102
102
|
}
|
103
103
|
*type = t;
|
104
|
-
for (i=0; i < mdai->n && mdai->item[i].shape > 0; i
|
104
|
+
for (i=0; i < mdai->n && mdai->item[i].shape > 0; ++i) ;
|
105
105
|
*rank = r = i;
|
106
106
|
shape = ALLOC_N(int,r);
|
107
|
-
for (i=0; r-->0; i
|
107
|
+
for (i=0; r-->0; ++i) {
|
108
108
|
shape[i] = mdai->item[r].shape;
|
109
109
|
}
|
110
110
|
xfree(mdai->type);
|
@@ -129,17 +129,17 @@ static void
|
|
129
129
|
/* direction */
|
130
130
|
if (len>0) {
|
131
131
|
*step = 1;
|
132
|
-
if (EXCL(obj)) end
|
132
|
+
if (EXCL(obj)) --end; else ++len;
|
133
133
|
}
|
134
134
|
else if (len<0) {
|
135
135
|
len = -len;
|
136
136
|
*step = -1;
|
137
|
-
if (EXCL(obj)) end
|
137
|
+
if (EXCL(obj)) ++end; else ++len;
|
138
138
|
}
|
139
139
|
else /*if(len==0)*/ {
|
140
140
|
*step = 0;
|
141
141
|
if (!EXCL(obj)) {
|
142
|
-
len
|
142
|
+
++len;
|
143
143
|
}
|
144
144
|
}
|
145
145
|
*n = len;
|
@@ -157,13 +157,13 @@ static int
|
|
157
157
|
ary = RARRAY(mdai->item[rank-1].val);
|
158
158
|
len = ary->len;
|
159
159
|
|
160
|
-
for (i=0; i < ary->len; i
|
160
|
+
for (i=0; i < ary->len; ++i) {
|
161
161
|
|
162
162
|
v = ary->ptr[i];
|
163
163
|
|
164
164
|
if (TYPE(v) == T_ARRAY) {
|
165
165
|
/* check recursive array */
|
166
|
-
for (j=0; j<rank; j
|
166
|
+
for (j=0; j<rank; ++j) {
|
167
167
|
if (mdai->item[j].val == v)
|
168
168
|
rb_raise(rb_eStandardError,"converting recursive Array to NArray");
|
169
169
|
}
|
@@ -172,7 +172,7 @@ static int
|
|
172
172
|
}
|
173
173
|
mdai->item[rank].val = v;
|
174
174
|
if ( na_do_mdai(mdai,rank+1) ) {
|
175
|
-
len
|
175
|
+
--len; /* Array is empty */
|
176
176
|
}
|
177
177
|
}
|
178
178
|
else
|
@@ -191,12 +191,12 @@ static int
|
|
191
191
|
struct NARRAY *na; GetNArray(v,na);
|
192
192
|
|
193
193
|
if ( na->rank == 0 ) {
|
194
|
-
len
|
194
|
+
--len; /* NArray is empty */
|
195
195
|
} else {
|
196
196
|
if ( rank+na->rank > mdai->n ) {
|
197
197
|
na_realloc_mdai(mdai,((na->rank-1)/4+1)*4);
|
198
198
|
}
|
199
|
-
for ( j=na->rank, r=rank; j
|
199
|
+
for ( j=na->rank, r=rank; --j > 0 ; ++r ) {
|
200
200
|
if ( mdai->item[r].shape < na->shape[j] )
|
201
201
|
mdai->item[r].shape = na->shape[j];
|
202
202
|
}
|
@@ -245,19 +245,19 @@ static void
|
|
245
245
|
n = thisrank - src->rank + 1;
|
246
246
|
|
247
247
|
s = ALLOCA_N(struct slice, dst->rank+1);
|
248
|
-
for (i=0; i < n; i
|
248
|
+
for (i=0; i < n; ++i) {
|
249
249
|
s[i].n = 1;
|
250
250
|
s[i].beg = 0;
|
251
251
|
s[i].step = 0;
|
252
252
|
s[i].idx = NULL;
|
253
253
|
}
|
254
|
-
for ( ; i <= thisrank; i
|
254
|
+
for ( ; i <= thisrank; ++i) {
|
255
255
|
s[i].n = src->shape[i-n];
|
256
256
|
s[i].beg = 0;
|
257
257
|
s[i].step = 1;
|
258
258
|
s[i].idx = NULL;
|
259
259
|
}
|
260
|
-
for ( ; i < dst->rank; i
|
260
|
+
for ( ; i < dst->rank; ++i) {
|
261
261
|
s[i].n = 1;
|
262
262
|
s[i].beg = idx[i];
|
263
263
|
s[i].step = 0;
|
@@ -276,7 +276,7 @@ static void
|
|
276
276
|
VALUE v;
|
277
277
|
|
278
278
|
if (thisrank==0) {
|
279
|
-
for (i = idx[0] = 0; i < ary->len; i
|
279
|
+
for (i = idx[0] = 0; i < ary->len; ++i) {
|
280
280
|
v = ary->ptr[i];
|
281
281
|
if (rb_obj_is_kind_of(v, rb_cRange)) {
|
282
282
|
na_range_to_sequence(v,&len,&start,&dir);
|
@@ -299,15 +299,15 @@ static void
|
|
299
299
|
}
|
300
300
|
else /* thisrank > 0 */
|
301
301
|
{
|
302
|
-
for (i = idx[thisrank] = 0; i < ary->len; i
|
302
|
+
for (i = idx[thisrank] = 0; i < ary->len; ++i) {
|
303
303
|
v = ary->ptr[i];
|
304
304
|
if (TYPE(v) == T_ARRAY) {
|
305
305
|
na_copy_ary_to_nary(RARRAY(v),na,thisrank-1,idx,type);
|
306
|
-
if (idx[thisrank-1]>0) idx[thisrank]
|
306
|
+
if (idx[thisrank-1]>0) ++idx[thisrank];
|
307
307
|
}
|
308
308
|
else if (IsNArray(v)) {
|
309
309
|
na_copy_nary_to_nary(v,na,thisrank-1,idx);
|
310
|
-
idx[thisrank]
|
310
|
+
++idx[thisrank];
|
311
311
|
}
|
312
312
|
else {
|
313
313
|
for (j=thisrank; j; ) idx[--j] = 0;
|
@@ -316,7 +316,7 @@ static void
|
|
316
316
|
na_range_to_sequence(v,&len,&start,&dir);
|
317
317
|
if (len>0) {
|
318
318
|
pos = na_index_pos(na,idx);
|
319
|
-
idx[thisrank]
|
319
|
+
++idx[thisrank];
|
320
320
|
step = na_index_pos(na,idx)-pos;
|
321
321
|
IndGenFuncs[type]( len, NA_PTR(na,pos), na_sizeof[type]*step,
|
322
322
|
start, dir );
|
@@ -326,7 +326,7 @@ static void
|
|
326
326
|
else {
|
327
327
|
pos = na_index_pos(na,idx);
|
328
328
|
SetFuncs[type][NA_ROBJ]( 1, NA_PTR(na,pos), 0, ary->ptr+i, 0 );
|
329
|
-
idx[thisrank]
|
329
|
+
++idx[thisrank];
|
330
330
|
}
|
331
331
|
/* copy here */
|
332
332
|
}
|
@@ -357,7 +357,7 @@ static VALUE
|
|
357
357
|
/*
|
358
358
|
printf("rank=%i\n", rank);
|
359
359
|
printf("type=%i\n", type);
|
360
|
-
for (i=0; i<rank; i
|
360
|
+
for (i=0; i<rank; ++i) {
|
361
361
|
printf("shape[%i]=%i\n", i, shape[i]);
|
362
362
|
}
|
363
363
|
*/
|
@@ -378,7 +378,7 @@ static VALUE
|
|
378
378
|
na_clear_data(na);
|
379
379
|
|
380
380
|
idx = ALLOCA_N(int,rank);
|
381
|
-
for (i=0; i<rank; i
|
381
|
+
for (i=0; i<rank; ++i) idx[i]=0;
|
382
382
|
|
383
383
|
na_copy_ary_to_nary( RARRAY(ary), na, rank-1, idx, type );
|
384
384
|
|
@@ -520,14 +520,14 @@ static VALUE
|
|
520
520
|
if (thisrank == 0) {
|
521
521
|
ptr = NA_PTR( na, na_index_pos(na,idx) );
|
522
522
|
elmsz = na_sizeof[na->type];
|
523
|
-
for (i = na->shape[0]; i; i
|
523
|
+
for (i = na->shape[0]; i; --i) {
|
524
524
|
(*func)( 1, &val, 0, ptr, 0 );
|
525
525
|
ptr += elmsz;
|
526
526
|
rb_ary_push( ary, val );
|
527
527
|
}
|
528
528
|
}
|
529
529
|
else {
|
530
|
-
for (i = 0; i < na->shape[thisrank]; i
|
530
|
+
for (i = 0; i < na->shape[thisrank]; ++i) {
|
531
531
|
idx[thisrank] = i;
|
532
532
|
rb_ary_push( ary, na_to_array0(na,idx,thisrank-1,func) );
|
533
533
|
}
|
@@ -549,7 +549,7 @@ VALUE
|
|
549
549
|
return rb_ary_new();
|
550
550
|
|
551
551
|
idx = ALLOCA_N(int,na->rank);
|
552
|
-
for (i = 0; i<na->rank; i
|
552
|
+
for (i = 0; i<na->rank; ++i) idx[i] = 0;
|
553
553
|
return na_to_array0(na,idx,na->rank-1,SetFuncs[NA_ROBJ][na->type]);
|
554
554
|
}
|
555
555
|
|
@@ -565,7 +565,7 @@ static VALUE
|
|
565
565
|
if (n>0)
|
566
566
|
(*tostr)(&str,p2);
|
567
567
|
|
568
|
-
for (n--; n>0; n
|
568
|
+
for (n--; n>0; --n) {
|
569
569
|
p2 += p2step;
|
570
570
|
(*tostr)(&tmp,p2);
|
571
571
|
|
@@ -613,7 +613,7 @@ VALUE
|
|
613
613
|
for(;;) {
|
614
614
|
/* set pointers */
|
615
615
|
while (i > 0) {
|
616
|
-
i
|
616
|
+
--i;
|
617
617
|
rb_str_cat(val, "[ ", 2);
|
618
618
|
s1[i].p = s1[i].pbeg + s1[i+1].p;
|
619
619
|
si[i] = s1[i].n;
|
@@ -638,7 +638,7 @@ VALUE
|
|
638
638
|
return val;
|
639
639
|
}
|
640
640
|
/* indent */
|
641
|
-
for (ii=i; ii<rank; ii
|
641
|
+
for (ii=i; ii<rank; ++ii)
|
642
642
|
rb_str_cat(val, " ", 2);
|
643
643
|
}
|
644
644
|
}
|