Sha256: c5280d5c2111364d8c74436f3b47e7bde23418cd7505e13e5a75b3add350f8c4

Contents?: true

Size: 558 Bytes

Versions: 51

Compression:

Stored size: 558 Bytes

Contents

#include "xint_macro.h"

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

static inline dtype int_reciprocal(dtype x) {
    switch (x) {
    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;
    }
    while (p) {
        if (p&1) r *= x;
        x *= x;
        p >>= 1;
    }
    return r;
}

Version data entries

51 entries across 28 versions & 2 rubygems

Version Path
ruby-dnn-0.4.0 lib/dnn/ext/rb_stb_image/numo/types/uint_macro.h
ruby-dnn-0.4.0 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.3.2 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.3.2 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.3.1 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.3.1 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.3.0 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.3.0 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.2.2 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.2.2 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.2.1 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.2.1 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.2.0 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.2.0 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.1.8 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.1.8 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.1.7 lib/dnn/ext/dataset_loader/numo/types/uint_macro.h
ruby-dnn-0.1.7 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.1.6 lib/dnn/ext/image_io/numo/types/uint_macro.h
ruby-dnn-0.1.6 lib/dnn/ext/mnist/numo/types/uint_macro.h