Sha256: 22321583cbd87873ef209524785197d847591050daacfcade581d4469ce7289d

Contents?: true

Size: 1.36 KB

Versions: 19

Compression:

Stored size: 1.36 KB

Contents

static void
<%=c_iter%>(cumo_na_loop_t *const lp)
{
    size_t  i;
    dtype  x, y, a;

    CUMO_SHOW_SYNCHRONIZE_FIXME_WARNING_ONCE("<%=name%>", "<%=type_name%>");
    x = *(dtype*)(lp->args[0].ptr + lp->args[0].iter[0].pos);
    i = lp->narg - 2;
    y = *(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos);
    for (; --i;) {
        y = m_mul(x,y);
        a = *(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos);
        y = m_add(y,a);
    }
    i = lp->narg - 1;
    *(dtype*)(lp->args[i].ptr + lp->args[i].iter[0].pos) = y;
}

/*
  Polynomial.: a0 + a1*x + a2*x**2 + a3*x**3 + ... + an*x**n
  @overload <%=name%> a0, a1, ...
  @param [Cumo::NArray,Numeric] a0
  @param [Cumo::NArray,Numeric] a1 , ...
  @return [Cumo::<%=class_name%>]
*/
static VALUE
<%=c_func(-2)%>(VALUE self, VALUE args)
{
    int argc, i;
    VALUE *argv;
    volatile VALUE v, a;
    cumo_ndfunc_arg_out_t aout[1] = {{cT,0}};
    cumo_ndfunc_t ndf = { <%=c_iter%>, CUMO_NO_LOOP, 0, 1, 0, aout };

    argc = RARRAY_LEN(args);
    ndf.nin = argc+1;
    ndf.ain = ALLOCA_N(cumo_ndfunc_arg_in_t,argc+1);
    for (i=0; i<argc+1; i++) {
        ndf.ain[i].type = cT;
    }
    argv = ALLOCA_N(VALUE,argc+1);
    argv[0] = self;
    for (i=0; i<argc; i++) {
        argv[i+1] = RARRAY_PTR(args)[i];
    }
    a = rb_ary_new4(argc+1, argv);
    v = cumo_na_ndloop2(&ndf, a);
    return <%=type_name%>_extract(v);
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
cumo-0.4.3 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.4.2 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.4.1 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.4.0 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.5 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.4 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.3 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.2 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.1 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.0 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.3.0.pre1 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.5 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.4 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.3 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.2 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.1 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.2.0 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.1.2 ext/cumo/narray/gen/tmpl/poly.c
cumo-0.1.1 ext/cumo/narray/gen/tmpl/poly.c