numo-narray 0.9.0.1-x86-mingw32 → 0.9.0.3-x86-mingw32
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.
- checksums.yaml +4 -4
- data/README.md +11 -7
- data/Rakefile +21 -6
- data/ext/numo/narray/array.c +3 -3
- data/ext/numo/narray/data.c +102 -81
- data/ext/numo/narray/depend.erb +9 -7
- data/ext/numo/narray/extconf.rb +5 -24
- data/ext/numo/narray/gen/cogen.rb +19 -4
- data/ext/numo/narray/gen/def/bit.rb +31 -0
- data/ext/numo/narray/gen/def/robject.rb +1 -1
- data/ext/numo/narray/gen/dtype.erb.c +11 -257
- data/ext/numo/narray/gen/spec.rb +294 -0
- data/ext/numo/narray/gen/tmpl/aset.c +1 -1
- data/ext/numo/narray/gen/tmpl/each_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/eye.c +5 -5
- data/ext/numo/narray/gen/tmpl/logseq.c +82 -0
- data/ext/numo/narray/gen/tmpl/map_with_index.c +1 -1
- data/ext/numo/narray/gen/tmpl/rand.c +126 -5
- data/ext/numo/narray/gen/tmpl/seq.c +43 -12
- data/ext/numo/narray/gen/tmpl/store_bit.c +55 -0
- data/ext/numo/narray/gen/tmpl_bit/allocate.c +28 -0
- data/ext/numo/narray/gen/tmpl_bit/aref.c +53 -0
- data/ext/numo/narray/gen/tmpl_bit/aset.c +63 -0
- data/ext/numo/narray/gen/{tmpl/bit_binary.c → tmpl_bit/binary.c} +1 -1
- data/ext/numo/narray/gen/{tmpl → tmpl_bit}/bit_count.c +5 -3
- data/ext/numo/narray/gen/tmpl_bit/bit_reduce.c +128 -0
- data/ext/numo/narray/gen/tmpl_bit/cast.c +37 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_array.c +80 -0
- data/ext/numo/narray/gen/tmpl_bit/cast_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/coerce_cast.c +8 -0
- data/ext/numo/narray/gen/tmpl_bit/each.c +44 -0
- data/ext/numo/narray/gen/tmpl_bit/each_with_index.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/extract.c +25 -0
- data/ext/numo/narray/gen/tmpl_bit/fill.c +65 -0
- data/ext/numo/narray/gen/tmpl_bit/format.c +61 -0
- data/ext/numo/narray/gen/tmpl_bit/format_to_a.c +48 -0
- data/ext/numo/narray/gen/tmpl_bit/inspect.c +18 -0
- data/ext/numo/narray/gen/tmpl_bit/map_with_index.c +94 -0
- data/ext/numo/narray/gen/tmpl_bit/mask.c +117 -0
- data/ext/numo/narray/gen/tmpl_bit/none_p.c +14 -0
- data/ext/numo/narray/gen/tmpl_bit/store.c +32 -0
- data/ext/numo/narray/gen/tmpl_bit/store_array.c +5 -0
- data/ext/numo/narray/gen/tmpl_bit/store_bit.c +66 -0
- data/ext/numo/narray/gen/tmpl_bit/store_from.c +56 -0
- data/ext/numo/narray/gen/tmpl_bit/store_numeric.c +22 -0
- data/ext/numo/narray/gen/tmpl_bit/to_a.c +43 -0
- data/ext/numo/narray/gen/{tmpl/bit_unary.c → tmpl_bit/unary.c} +1 -1
- data/ext/numo/narray/gen/tmpl_bit/where.c +102 -0
- data/ext/numo/narray/gen/tmpl_bit/where2.c +37 -0
- data/ext/numo/narray/index.c +9 -7
- data/ext/numo/narray/math.c +6 -1
- data/ext/numo/narray/narray.c +307 -103
- data/ext/numo/narray/ndloop.c +21 -36
- data/ext/numo/narray/numo/intern.h +3 -3
- data/ext/numo/narray/numo/narray.h +5 -41
- data/ext/numo/narray/numo/template.h +2 -2
- data/ext/numo/narray/numo/types/bit.h +27 -13
- data/ext/numo/narray/numo/types/complex.h +2 -2
- data/ext/numo/narray/numo/types/complex_macro.h +19 -7
- data/ext/numo/narray/numo/types/dcomplex.h +9 -0
- data/ext/numo/narray/numo/types/dfloat.h +6 -0
- data/ext/numo/narray/numo/types/float_macro.h +9 -2
- data/ext/numo/narray/numo/types/int16.h +0 -1
- data/ext/numo/narray/numo/types/int32.h +0 -1
- data/ext/numo/narray/numo/types/int64.h +0 -1
- data/ext/numo/narray/numo/types/int8.h +0 -1
- data/ext/numo/narray/numo/types/int_macro.h +2 -1
- data/ext/numo/narray/numo/types/robj_macro.h +9 -2
- data/ext/numo/narray/numo/types/robject.h +6 -0
- data/ext/numo/narray/numo/types/scomplex.h +9 -0
- data/ext/numo/narray/numo/types/sfloat.h +6 -0
- data/ext/numo/narray/numo/types/uint16.h +0 -1
- data/ext/numo/narray/numo/types/uint32.h +0 -1
- data/ext/numo/narray/numo/types/uint64.h +0 -1
- data/ext/numo/narray/numo/types/uint8.h +0 -1
- data/ext/numo/narray/numo/types/uint_macro.h +2 -1
- data/ext/numo/narray/numo/types/xint_macro.h +6 -1
- data/ext/numo/narray/rand.c +2 -2
- data/ext/numo/narray/step.c +7 -7
- data/ext/numo/narray/struct.c +11 -12
- data/lib/2.0/numo/narray.so +0 -0
- data/lib/2.1/numo/narray.so +0 -0
- data/lib/2.2/numo/narray.so +0 -0
- data/lib/2.3/numo/narray.so +0 -0
- data/lib/2.4/numo/narray.so +0 -0
- data/lib/erbpp.rb +6 -2
- data/lib/erbpp/line_number.rb +1 -1
- data/lib/erbpp/narray_def.rb +23 -19
- data/numo-narray.gemspec +2 -2
- metadata +45 -10
- data/ext/numo/narray/gen/bit.erb.c +0 -811
@@ -52,7 +52,7 @@ static VALUE
|
|
52
52
|
a = na_aref_main(argc, argv, self, 0);
|
53
53
|
<%=c_func.sub(/_aset/,"_store")%>(a, argv[argc]);
|
54
54
|
} else {
|
55
|
-
ptr =
|
55
|
+
ptr = na_get_pointer_for_read_write(self) + pos;
|
56
56
|
*(dtype*)ptr = m_num_to_data(argv[argc]);
|
57
57
|
}
|
58
58
|
|
@@ -54,7 +54,7 @@ static VALUE
|
|
54
54
|
rb_raise(rb_eArgError,"too many arguments (%d for 0..2)",argc);
|
55
55
|
} else if (argc == 2) {
|
56
56
|
data = m_num_to_data(argv[0]);
|
57
|
-
kofs =
|
57
|
+
kofs = NUM2SSIZET(argv[1]);
|
58
58
|
} else if (argc == 1) {
|
59
59
|
data = m_num_to_data(argv[0]);
|
60
60
|
kofs = 0;
|
@@ -72,13 +72,13 @@ static VALUE
|
|
72
72
|
// Diagonal offset from the main diagonal.
|
73
73
|
if (kofs >= 0) {
|
74
74
|
if ((size_t)(kofs) >= na->shape[nd-1]) {
|
75
|
-
rb_raise(rb_eArgError,"invalid diagonal offset(%
|
76
|
-
"last dimension size(%
|
75
|
+
rb_raise(rb_eArgError,"invalid diagonal offset(%"SZF"d) for "
|
76
|
+
"last dimension size(%"SZF"d)",kofs,na->shape[nd-1]);
|
77
77
|
}
|
78
78
|
} else {
|
79
79
|
if ((size_t)(-kofs) >= na->shape[nd-2]) {
|
80
|
-
rb_raise(rb_eArgError,"invalid diagonal offset(%
|
81
|
-
"last-1 dimension size(%
|
80
|
+
rb_raise(rb_eArgError,"invalid diagonal offset(%"SZF"d) for "
|
81
|
+
"last-1 dimension size(%"SZF"d)",kofs,na->shape[nd-2]);
|
82
82
|
}
|
83
83
|
}
|
84
84
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
typedef struct {
|
2
|
+
seq_data_t beg;
|
3
|
+
seq_data_t step;
|
4
|
+
seq_data_t base;
|
5
|
+
seq_count_t count;
|
6
|
+
} logseq_opt_t;
|
7
|
+
|
8
|
+
static void
|
9
|
+
<%=c_iter%>(na_loop_t *const lp)
|
10
|
+
{
|
11
|
+
size_t i;
|
12
|
+
char *p1;
|
13
|
+
ssize_t s1;
|
14
|
+
size_t *idx1;
|
15
|
+
dtype x;
|
16
|
+
seq_data_t beg, step, base;
|
17
|
+
seq_count_t c;
|
18
|
+
logseq_opt_t *g;
|
19
|
+
|
20
|
+
INIT_COUNTER(lp, i);
|
21
|
+
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
22
|
+
g = (logseq_opt_t*)(lp->opt_ptr);
|
23
|
+
beg = g->beg;
|
24
|
+
step = g->step;
|
25
|
+
base = g->base;
|
26
|
+
c = g->count;
|
27
|
+
if (idx1) {
|
28
|
+
for (; i--;) {
|
29
|
+
x = f_seq(beg,step,c++);
|
30
|
+
*(dtype*)(p1+*idx1) = m_pow(base,x);
|
31
|
+
idx1++;
|
32
|
+
}
|
33
|
+
} else {
|
34
|
+
for (; i--;) {
|
35
|
+
x = f_seq(beg,step,c++);
|
36
|
+
*(dtype*)(p1) = m_pow(base,x);
|
37
|
+
p1 += s1;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
g->count = c;
|
41
|
+
}
|
42
|
+
|
43
|
+
/*
|
44
|
+
Set logarithmic sequence of numbers to self. The sequence is obtained from
|
45
|
+
base**(beg+i*step)
|
46
|
+
where i is 1-dimensional index.
|
47
|
+
Applicable classes: DFloat, SFloat, DComplex, SCopmplex.
|
48
|
+
|
49
|
+
@overload logseq(beg,step,[base])
|
50
|
+
@param [Numeric] beg The begining of sequence.
|
51
|
+
@param [Numeric] step The step of sequence.
|
52
|
+
@param [Numeric] base The base of log space. (default=10)
|
53
|
+
@return [Numo::<%=class_name%>] self.
|
54
|
+
|
55
|
+
@example
|
56
|
+
Numo::DFloat.new(5).logseq(4,-1,2)
|
57
|
+
=> Numo::DFloat#shape=[5]
|
58
|
+
[16, 8, 4, 2, 1]
|
59
|
+
Numo::DComplex.new(5).logseq(0,1i*Math::PI/3,Math::E)
|
60
|
+
=> Numo::DComplex#shape=[5]
|
61
|
+
[1+7.26156e-310i, 0.5+0.866025i, -0.5+0.866025i, -1+1.22465e-16i, ...]
|
62
|
+
*/
|
63
|
+
static VALUE
|
64
|
+
<%=c_func%>(int argc, VALUE *args, VALUE self)
|
65
|
+
{
|
66
|
+
logseq_opt_t *g;
|
67
|
+
VALUE vbeg, vstep, vbase;
|
68
|
+
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
|
69
|
+
ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 1,0, ain,0};
|
70
|
+
|
71
|
+
g = ALLOCA_N(logseq_opt_t,1);
|
72
|
+
rb_scan_args(argc, args, "21", &vbeg, &vstep, &vbase);
|
73
|
+
g->beg = m_num_to_data(vbeg);
|
74
|
+
g->step = m_num_to_data(vstep);
|
75
|
+
if (vbase==Qnil) {
|
76
|
+
g->base = m_from_real(10);
|
77
|
+
} else {
|
78
|
+
g->base = m_num_to_data(vbase);
|
79
|
+
}
|
80
|
+
na_ndloop3(&ndf, g, 1, self);
|
81
|
+
return self;
|
82
|
+
}
|
@@ -1,3 +1,76 @@
|
|
1
|
+
<%
|
2
|
+
if is_int && !is_object
|
3
|
+
if /Int64$/ =~ class_name
|
4
|
+
rand_bit = 64
|
5
|
+
else
|
6
|
+
rand_bit = 32
|
7
|
+
end
|
8
|
+
m_rand = "m_rand(max,shift)"
|
9
|
+
shift_def = "int shift;"
|
10
|
+
shift_set = "shift = #{rand_bit-1} - msb_pos(max);"
|
11
|
+
rand_type = "uint#{rand_bit}_t"
|
12
|
+
%>
|
13
|
+
|
14
|
+
#define HWID (sizeof(dtype)>>1)
|
15
|
+
|
16
|
+
static int msb_pos(<%=rand_type%> a)
|
17
|
+
{
|
18
|
+
int width = HWID;
|
19
|
+
int pos = 0;
|
20
|
+
<%=rand_type%> mask = (((dtype)1 << HWID)-1) << HWID;
|
21
|
+
|
22
|
+
if (a==0) {return -1;}
|
23
|
+
|
24
|
+
while (width) {
|
25
|
+
if (a & mask) {
|
26
|
+
pos += width;
|
27
|
+
} else {
|
28
|
+
mask >>= width;
|
29
|
+
}
|
30
|
+
width >>= 1;
|
31
|
+
mask &= mask << width;
|
32
|
+
}
|
33
|
+
return pos;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* generates a random number on [0,max) */
|
37
|
+
<% if rand_bit == 64 %>
|
38
|
+
inline static dtype m_rand(uint64_t max, int shift)
|
39
|
+
{
|
40
|
+
uint64_t x;
|
41
|
+
do {
|
42
|
+
x = gen_rand32();
|
43
|
+
x <<= 32;
|
44
|
+
x |= gen_rand32();
|
45
|
+
x >>= shift;
|
46
|
+
} while (x >= max);
|
47
|
+
return x;
|
48
|
+
}
|
49
|
+
<% else %>
|
50
|
+
inline static dtype m_rand(uint32_t max, int shift)
|
51
|
+
{
|
52
|
+
uint32_t x;
|
53
|
+
do {
|
54
|
+
x = gen_rand32();
|
55
|
+
x >>= shift;
|
56
|
+
} while (x >= max);
|
57
|
+
return x;
|
58
|
+
}
|
59
|
+
<% end %>
|
60
|
+
<%
|
61
|
+
else
|
62
|
+
m_rand = "m_rand(max)"
|
63
|
+
shift_def = ""
|
64
|
+
shift_set = ""
|
65
|
+
rand_type = "dtype"
|
66
|
+
end
|
67
|
+
%>
|
68
|
+
|
69
|
+
typedef struct {
|
70
|
+
dtype low;
|
71
|
+
<%=rand_type%> max;
|
72
|
+
} rand_opt_t;
|
73
|
+
|
1
74
|
static void
|
2
75
|
<%=c_iter%>(na_loop_t *const lp)
|
3
76
|
{
|
@@ -6,28 +79,76 @@ static void
|
|
6
79
|
ssize_t s1;
|
7
80
|
size_t *idx1;
|
8
81
|
dtype x;
|
82
|
+
rand_opt_t *g;
|
83
|
+
dtype low;
|
84
|
+
<%=rand_type%> max;
|
85
|
+
<%=shift_def%>
|
9
86
|
|
10
87
|
INIT_COUNTER(lp, i);
|
11
88
|
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
89
|
+
g = (rand_opt_t*)(lp->opt_ptr);
|
90
|
+
low = g->low;
|
91
|
+
max = g->max;
|
92
|
+
<%=shift_set%>
|
93
|
+
|
12
94
|
if (idx1) {
|
13
95
|
for (; i--;) {
|
14
|
-
x = m_rand;
|
96
|
+
x = m_add(<%=m_rand%>,low);
|
15
97
|
SET_DATA_INDEX(p1,idx1,dtype,x);
|
16
98
|
}
|
17
99
|
} else {
|
18
100
|
for (; i--;) {
|
19
|
-
x = m_rand;
|
101
|
+
x = m_add(<%=m_rand%>,low);
|
20
102
|
SET_DATA_STRIDE(p1,s1,dtype,x);
|
21
103
|
}
|
22
104
|
}
|
23
105
|
}
|
24
106
|
|
107
|
+
|
108
|
+
/*
|
109
|
+
Generate uniformly distributed random numbers on self narray.
|
110
|
+
@overload rand([[low],high])
|
111
|
+
@param [Numeric] low lower inclusive boundary of random numbers. (default=0)
|
112
|
+
@param [Numeric] high upper exclusive boundary of random numbers. (default=1)
|
113
|
+
@return [Numo::<%=class_name%>] self.
|
114
|
+
@example
|
115
|
+
Numo::DFloat.new(6).rand
|
116
|
+
=> Numo::DFloat#shape=[6]
|
117
|
+
[0.0617545, 0.373067, 0.794815, 0.201042, 0.116041, 0.344032]
|
118
|
+
Numo::DComplex.new(6).rand(5+5i)
|
119
|
+
=> Numo::DComplex#shape=[6]
|
120
|
+
[2.69974+3.68908i, 0.825443+0.254414i, 0.540323+0.34354i, 4.52061+2.39322i, ...]
|
121
|
+
Numo::Int32.new(6).rand(2,5)
|
122
|
+
=> Numo::Int32#shape=[6]
|
123
|
+
[4, 3, 3, 2, 4, 2]
|
124
|
+
*/
|
25
125
|
static VALUE
|
26
|
-
<%=c_func%>(VALUE self)
|
126
|
+
<%=c_func%>(int argc, VALUE *args, VALUE self)
|
27
127
|
{
|
128
|
+
rand_opt_t g;
|
129
|
+
VALUE v1=Qnil, v2=Qnil;
|
130
|
+
dtype high;
|
28
131
|
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
|
29
|
-
ndfunc_t ndf = {
|
132
|
+
ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 1,0, ain,0};
|
30
133
|
|
31
|
-
|
134
|
+
rb_scan_args(argc, args, "02", &v1, &v2);
|
135
|
+
if (v2==Qnil) {
|
136
|
+
g.low = m_zero;
|
137
|
+
if (v1==Qnil) {
|
138
|
+
g.max = high = m_one;
|
139
|
+
} else {
|
140
|
+
g.max = high = m_num_to_data(v1);
|
141
|
+
}
|
142
|
+
} else {
|
143
|
+
g.low = m_num_to_data(v1);
|
144
|
+
high = m_num_to_data(v2);
|
145
|
+
g.max = m_sub(high,g.low);
|
146
|
+
}
|
147
|
+
<% if is_int && !is_object %>
|
148
|
+
if (high <= g.low) {
|
149
|
+
rb_raise(rb_eArgError,"high must be larger than low");
|
150
|
+
}
|
151
|
+
<% end %>
|
152
|
+
na_ndloop3(&ndf, &g, 1, self);
|
32
153
|
return self;
|
33
154
|
}
|
@@ -1,3 +1,21 @@
|
|
1
|
+
<% if is_int && !is_object %>
|
2
|
+
typedef double seq_data_t;
|
3
|
+
<% else %>
|
4
|
+
typedef dtype seq_data_t;
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<% if is_object %>
|
8
|
+
typedef size_t seq_count_t;
|
9
|
+
<% else %>
|
10
|
+
typedef double seq_count_t;
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
typedef struct {
|
14
|
+
seq_data_t beg;
|
15
|
+
seq_data_t step;
|
16
|
+
seq_count_t count;
|
17
|
+
} seq_opt_t;
|
18
|
+
|
1
19
|
static void
|
2
20
|
<%=c_iter%>(na_loop_t *const lp)
|
3
21
|
{
|
@@ -5,8 +23,9 @@ static void
|
|
5
23
|
char *p1;
|
6
24
|
ssize_t s1;
|
7
25
|
size_t *idx1;
|
8
|
-
|
9
|
-
|
26
|
+
dtype x;
|
27
|
+
seq_data_t beg, step;
|
28
|
+
seq_count_t c;
|
10
29
|
seq_opt_t *g;
|
11
30
|
|
12
31
|
INIT_COUNTER(lp, i);
|
@@ -17,16 +36,14 @@ static void
|
|
17
36
|
c = g->count;
|
18
37
|
if (idx1) {
|
19
38
|
for (; i--;) {
|
20
|
-
x = beg
|
21
|
-
|
22
|
-
*(dtype*)(p1+*idx1) = y;
|
39
|
+
x = f_seq(beg,step,c++);
|
40
|
+
*(dtype*)(p1+*idx1) = x;
|
23
41
|
idx1++;
|
24
42
|
}
|
25
43
|
} else {
|
26
44
|
for (; i--;) {
|
27
|
-
x = beg
|
28
|
-
|
29
|
-
*(dtype*)(p1) = y;
|
45
|
+
x = f_seq(beg,step,c++);
|
46
|
+
*(dtype*)(p1) = x;
|
30
47
|
p1 += s1;
|
31
48
|
}
|
32
49
|
}
|
@@ -34,11 +51,20 @@ static void
|
|
34
51
|
}
|
35
52
|
|
36
53
|
/*
|
37
|
-
Set
|
54
|
+
Set linear sequence of numbers to self. The sequence is obtained from
|
55
|
+
beg+i*step
|
56
|
+
where i is 1-dimensional index.
|
38
57
|
@overload seq([beg,[step]])
|
39
58
|
@param [Numeric] beg begining of sequence. (default=0)
|
40
59
|
@param [Numeric] step step of sequence. (default=1)
|
41
60
|
@return [Numo::<%=class_name%>] self.
|
61
|
+
@example
|
62
|
+
Numo::DFloat.new(6).seq(1,-0.2)
|
63
|
+
=> Numo::DFloat#shape=[6]
|
64
|
+
[1, 0.8, 0.6, 0.4, 0.2, 0]
|
65
|
+
Numo::DComplex.new(6).seq(1,-0.2+0.2i)
|
66
|
+
=> Numo::DComplex#shape=[6]
|
67
|
+
[1+0i, 0.8+0.2i, 0.6+0.4i, 0.4+0.6i, 0.2+0.8i, 0+1i]
|
42
68
|
*/
|
43
69
|
static VALUE
|
44
70
|
<%=c_func%>(int argc, VALUE *args, VALUE self)
|
@@ -46,15 +72,20 @@ static VALUE
|
|
46
72
|
seq_opt_t *g;
|
47
73
|
VALUE vbeg=Qnil, vstep=Qnil;
|
48
74
|
ndfunc_arg_in_t ain[1] = {{OVERWRITE,0}};
|
49
|
-
ndfunc_t ndf = {
|
75
|
+
ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 1,0, ain,0};
|
50
76
|
|
51
77
|
g = ALLOCA_N(seq_opt_t,1);
|
52
|
-
g->beg =
|
53
|
-
g->step =
|
78
|
+
g->beg = m_zero;
|
79
|
+
g->step = m_one;
|
54
80
|
g->count = 0;
|
55
81
|
rb_scan_args(argc, args, "02", &vbeg, &vstep);
|
82
|
+
<% if is_int && !is_object %>
|
56
83
|
if (vbeg!=Qnil) {g->beg = NUM2DBL(vbeg);}
|
57
84
|
if (vstep!=Qnil) {g->step = NUM2DBL(vstep);}
|
85
|
+
<% else %>
|
86
|
+
if (vbeg!=Qnil) {g->beg = m_num_to_data(vbeg);}
|
87
|
+
if (vstep!=Qnil) {g->step = m_num_to_data(vstep);}
|
88
|
+
<% end %>
|
58
89
|
|
59
90
|
na_ndloop3(&ndf, g, 1, self);
|
60
91
|
return self;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
static void
|
2
|
+
<%=c_iter%>(na_loop_t *const lp)
|
3
|
+
{
|
4
|
+
size_t i;
|
5
|
+
char *p1;
|
6
|
+
size_t p2;
|
7
|
+
ssize_t s1, s2;
|
8
|
+
size_t *idx1, *idx2;
|
9
|
+
BIT_DIGIT *a2, x;
|
10
|
+
dtype y;
|
11
|
+
|
12
|
+
INIT_COUNTER(lp, i);
|
13
|
+
INIT_PTR_IDX(lp, 0, p1, s1, idx1);
|
14
|
+
INIT_PTR_BIT_IDX(lp, 1, a2, p2, s2, idx2);
|
15
|
+
if (idx2) {
|
16
|
+
if (idx1) {
|
17
|
+
for (; i--;) {
|
18
|
+
LOAD_BIT(a2, p2+*idx2, x); idx2++;
|
19
|
+
y = m_from_real(x);
|
20
|
+
SET_DATA_INDEX(p1,idx1,dtype,y);
|
21
|
+
}
|
22
|
+
} else {
|
23
|
+
for (; i--;) {
|
24
|
+
LOAD_BIT(a2, p2+*idx2, x); idx2++;
|
25
|
+
y = m_from_real(x);
|
26
|
+
SET_DATA_STRIDE(p1,s1,dtype,y);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
} else {
|
30
|
+
if (idx1) {
|
31
|
+
for (; i--;) {
|
32
|
+
LOAD_BIT(a2, p2, x); p2 += s2;
|
33
|
+
y = m_from_real(x);
|
34
|
+
SET_DATA_INDEX(p1,idx1,dtype,y);
|
35
|
+
}
|
36
|
+
} else {
|
37
|
+
for (; i--;) {
|
38
|
+
LOAD_BIT(a2, p2, x); p2 += s2;
|
39
|
+
y = m_from_real(x);
|
40
|
+
SET_DATA_STRIDE(p1,s1,dtype,y);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
|
+
static VALUE
|
48
|
+
<%=c_func%>(VALUE self, VALUE obj)
|
49
|
+
{
|
50
|
+
ndfunc_arg_in_t ain[2] = {{OVERWRITE,0},{Qnil,0}};
|
51
|
+
ndfunc_t ndf = {<%=c_iter%>, FULL_LOOP, 2,0, ain,0};
|
52
|
+
|
53
|
+
na_ndloop(&ndf, 2, self, obj);
|
54
|
+
return self;
|
55
|
+
}
|