ext/cumo/narray/gen/tmpl/bincount.c in cumo-0.1.0 vs ext/cumo/narray/gen/tmpl/bincount.c in cumo-0.1.1
- old
+ new
@@ -3,51 +3,51 @@
[32,64].each do |bits|
cnt_cT = "cumo_cUInt#{bits}"
cnt_type = "u_int#{bits}_t"
%>
static void
-<%=c_iter%>_<%=bits%>(na_loop_t *const lp)
+<%=c_iter%>_<%=bits%>(cumo_na_loop_t *const lp)
{
size_t i, x, n;
char *p1, *p2;
ssize_t s1, s2;
size_t *idx1;
- INIT_PTR_IDX(lp, 0, p1, s1, idx1);
- INIT_PTR(lp, 1, p2, s2);
+ CUMO_INIT_PTR_IDX(lp, 0, p1, s1, idx1);
+ CUMO_INIT_PTR(lp, 1, p2, s2);
i = lp->args[0].shape[0];
n = lp->args[1].shape[0];
// initialize
for (x=0; x < n; x++) {
*(<%=cnt_type%>*)(p2 + s2*x) = 0;
}
- SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_<%=bits%>", "<%=type_name%>");
+ CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>_<%=bits%>", "<%=type_name%>");
if (idx1) {
for (; i--;) {
- GET_DATA_INDEX(p1,idx1,dtype,x);
+ CUMO_GET_DATA_INDEX(p1,idx1,dtype,x);
(*(<%=cnt_type%>*)(p2 + s2*x))++;
}
} else {
for (; i--;) {
- GET_DATA_STRIDE(p1,s1,dtype,x);
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
(*(<%=cnt_type%>*)(p2 + s2*x))++;
}
}
}
static VALUE
<%=c_func%>_<%=bits%>(VALUE self, size_t length)
{
size_t shape_out[1] = {length};
- ndfunc_arg_in_t ain[1] = {{cT,1}};
- ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
- ndfunc_t ndf = {<%=c_iter%>_<%=bits%>, NO_LOOP|NDF_STRIDE_LOOP|NDF_INDEX_LOOP,
+ cumo_ndfunc_arg_in_t ain[1] = {{cT,1}};
+ cumo_ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
+ cumo_ndfunc_t ndf = {<%=c_iter%>_<%=bits%>, CUMO_NO_LOOP|CUMO_NDF_STRIDE_LOOP|CUMO_NDF_INDEX_LOOP,
1, 1, ain, aout};
- return na_ndloop(&ndf, 1, self);
+ return cumo_na_ndloop(&ndf, 1, self);
}
<% end %>
// ------- end of Integer count without weights -------
// ------- Float count with weights -------
@@ -56,50 +56,50 @@
["DF","double"]].each do |fn,cnt_type|
cnt_cT = "cumo_c#{fn}loat"
fn = fn.downcase
%>
static void
-<%=c_iter%>_<%=fn%>(na_loop_t *const lp)
+<%=c_iter%>_<%=fn%>(cumo_na_loop_t *const lp)
{
<%=cnt_type%> w;
size_t i, x, n, m;
char *p1, *p2, *p3;
ssize_t s1, s2, s3;
- INIT_PTR(lp, 0, p1, s1);
- INIT_PTR(lp, 1, p2, s2);
- INIT_PTR(lp, 2, p3, s3);
+ CUMO_INIT_PTR(lp, 0, p1, s1);
+ CUMO_INIT_PTR(lp, 1, p2, s2);
+ CUMO_INIT_PTR(lp, 2, p3, s3);
i = lp->args[0].shape[0];
m = lp->args[1].shape[0];
n = lp->args[2].shape[0];
if (i != m) {
- rb_raise(nary_eShapeError,
+ rb_raise(cumo_na_eShapeError,
"size mismatch along last axis between self and weight");
}
// initialize
for (x=0; x < n; x++) {
*(<%=cnt_type%>*)(p3 + s3*x) = 0;
}
for (; i--;) {
- GET_DATA_STRIDE(p1,s1,dtype,x);
- GET_DATA_STRIDE(p2,s2,<%=cnt_type%>,w);
+ CUMO_GET_DATA_STRIDE(p1,s1,dtype,x);
+ CUMO_GET_DATA_STRIDE(p2,s2,<%=cnt_type%>,w);
(*(<%=cnt_type%>*)(p3 + s3*x)) += w;
}
}
static VALUE
<%=c_func%>_<%=fn%>(VALUE self, VALUE weight, size_t length)
{
size_t shape_out[1] = {length};
- ndfunc_arg_in_t ain[2] = {{cT,1},{<%=cnt_cT%>,1}};
- ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
- ndfunc_t ndf = {<%=c_iter%>_<%=fn%>, NO_LOOP|NDF_STRIDE_LOOP,
+ cumo_ndfunc_arg_in_t ain[2] = {{cT,1},{<%=cnt_cT%>,1}};
+ cumo_ndfunc_arg_out_t aout[1] = {{<%=cnt_cT%>,1,shape_out}};
+ cumo_ndfunc_t ndf = {<%=c_iter%>_<%=fn%>, CUMO_NO_LOOP|CUMO_NDF_STRIDE_LOOP,
2, 1, ain, aout};
- return na_ndloop(&ndf, 2, self, weight);
+ return cumo_na_ndloop(&ndf, 2, self, weight);
}
<% end %>
// ------- end of Float count with weights -------
/*
@@ -138,11 +138,11 @@
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
{
VALUE weight=Qnil, kw=Qnil;
VALUE opts[1] = {Qundef};
VALUE v, wclass;
- ID table[1] = {id_minlength};
+ ID table[1] = {cumo_id_minlength};
size_t length, minlength;
rb_scan_args(argc, argv, "01:", &weight, &kw);
rb_get_kwargs(kw, table, 0, 1, opts);
@@ -169,10 +169,10 @@
return <%=c_func%>_64(self, length);
} else {
return <%=c_func%>_32(self, length);
}
} else {
- wclass = CLASS_OF(weight);
+ wclass = rb_obj_class(weight);
if (wclass == cumo_cSFloat) {
return <%=c_func%>_sf(self, weight, length);
} else {
return <%=c_func%>_df(self, weight, length);
}