Sha256: 41b32fe029d241ee21fe2c09babe3ef22c7c6ad5be4b18a92c5d9dd47364dad4

Contents?: true

Size: 641 Bytes

Versions: 7

Compression:

Stored size: 641 Bytes

Contents

#include "xint_macro.h"

#define m_abs(x)     ((x<0)?-x:x)
#define m_sign(x)    (((x)==0) ? 0 : (((x)>0) ? 1 : -1))

static inline dtype int_reciprocal(dtype x) {
    switch (x) {
    case 1:
        return 1;
    case -1:
        return -1;
    case 0:
        rb_raise(rb_eZeroDivError, "divided by 0");
    default:
        return 0;
    }
}

static dtype pow_int(dtype x, int p)
{
    dtype r = m_one;
    switch(p) {
    case 0: return 1;
    case 1: return x;
    case 2: return x*x;
    case 3: return x*x*x;
    }
    if (p<0) return 0;
    while (p) {
        if (p&1) r *= x;
        x *= x;
        p >>= 1;
    }
    return r;
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
numo-narray-0.9.0.7 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.6 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.5 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.4 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.3-x86-mingw32 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.3-x64-mingw32 ext/numo/narray/numo/types/int_macro.h
numo-narray-0.9.0.3 ext/numo/narray/numo/types/int_macro.h