Sha256: 621b6e06d41da6344ddd033f7699b94a1423ebb993e9caf474d088f68976556d

Contents?: true

Size: 1.15 KB

Versions: 10

Compression:

Stored size: 1.15 KB

Contents

static void
<%=c_iter%>(na_loop_t *const lp)
{
    size_t  i;
    char   *p1;
    ssize_t s1;
    size_t *idx1;
    dtype *x;
    VALUE y;
    volatile VALUE a;
    VALUE fmt = lp->option;
    INIT_COUNTER(lp, i);
    INIT_PTR_IDX(lp, 0, p1, s1, idx1);
    a = rb_ary_new2(i);
    rb_ary_push(lp->args[1].value, a);
    if (idx1) {
        for (; i--;) {
            x = (dtype*)(p1 + *idx1);  idx1++;
            y = format_<%=type_name%>(fmt, x);
            rb_ary_push(a,y);
        }
    } else {
        for (; i--;) {
            x = (dtype*)p1;  p1+=s1;
            y = format_<%=type_name%>(fmt, x);
            rb_ary_push(a,y);
        }
    }
}

/*
  Format elements into strings.
  @overload <%=name%> format
  @param [String] format
  @return [Array] array of formated strings.
*/
static VALUE
<%=c_func(-1)%>(int argc, VALUE *argv, VALUE self)
{
    VALUE fmt=Qnil;
    ndfunc_arg_in_t ain[3] = {{Qnil,0},{sym_loop_opt},{sym_option}};
    ndfunc_arg_out_t aout[1] = {{rb_cArray,0}}; // dummy?
    ndfunc_t ndf = { <%=c_iter%>, FULL_LOOP_NIP, 3, 1, ain, aout };

    rb_scan_args(argc, argv, "01", &fmt);
    return na_ndloop_cast_narray_to_rarray(&ndf, self, fmt);
}

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
numo-narray-0.9.2.1 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.2.0 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.9 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.8 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.7 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.6 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.5 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.4 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.3 ext/numo/narray/gen/tmpl/format_to_a.c
numo-narray-0.9.1.2 ext/numo/narray/gen/tmpl/format_to_a.c