Sha256: d45524292581f90a6ca745a2c58827844ff5288639ef046c5f8acf0fd9dc744f

Contents?: true

Size: 355 Bytes

Versions: 7

Compression:

Stored size: 355 Bytes

Contents

static dtype pow_<%=tp%>(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

7 entries across 7 versions & 1 rubygems

Version Path
numo-narray-0.9.0.4 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.3-x86-mingw32 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.3-x64-mingw32 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.3 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.1-x64-mingw32 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.1 ext/numo/narray/gen/tmpl/powint.c
numo-narray-0.9.0.1-x86-mingw32 ext/numo/narray/gen/tmpl/powint.c