Sha256: 1563a49ec4384cfea3650630f312d89d6d6c4649bb08aa517291598ba3c4fac6

Contents?: true

Size: 362 Bytes

Versions: 37

Compression:

Stored size: 362 Bytes

Contents

static dtype pow_<%=type_name%>(dtype x, int p)
{
    dtype r = m_one;
    switch(p) {
    case 2: return m_square(x);
    case 3: return m_mul(m_square(x),x);
    case 1: return x;
    case 0: return m_one;
    }
    if (p<0)  return m_zero;
    while (p) {
        if ((p%2) == 1) r = m_mul(r,x);
        x = m_square(x);
        p /= 2;
    }
    return r;
}

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
numo-narray-0.9.2.1 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.2.0 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.9 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.8 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.7 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.6 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.5 ext/numo/narray/gen/tmpl/powint.c
cumo-0.4.3 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.4.2 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.4.1 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.4.0 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.5 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.4 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.3 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.2 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.1 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.0 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.3.0.pre1 ext/cumo/narray/gen/tmpl/powint.c
cumo-0.2.5 ext/cumo/narray/gen/tmpl/powint.c
numo-narray-0.9.1.4 ext/numo/narray/gen/tmpl/powint.c