Sha256: eb6d17991b7f61ca32d056900a62d9f9912a8fe7aa24e5a8a752ff2b5247789a

Contents?: true

Size: 1.1 KB

Versions: 54

Compression:

Stored size: 1.1 KB

Contents

typedef dcomplex dtype;
typedef double rtype;
#define cT  numo_cDComplex
#define cRT numo_cDFloat
#define mTM numo_mDComplexMath

#include "complex_macro.h"

static inline bool c_nearly_eq(dtype x, dtype y) {
    return c_abs(c_sub(x,y)) <= (c_abs(x)+c_abs(y))*DBL_EPSILON*2;
}

#ifdef SFMT_H
/* generates a random number on [0,1)-real-interval */
inline static dtype m_rand(dtype max)
{
    dtype z;
    REAL(z) = genrand_res53_mix() * REAL(max);
    IMAG(z) = genrand_res53_mix() * IMAG(max);
    return z;
}

/* generates random numbers from the normal distribution
   using Box-Muller Transformation.
 */
inline static void m_rand_norm(dtype mu, rtype sigma, dtype *a0)
{
    rtype x1, x2, w;
    do {
	x1 = genrand_res53_mix();
	x1 = x1*2-1;
	x2 = genrand_res53_mix();
	x2 = x2*2-1;
	w = x1 * x1 + x2 * x2;
    } while (w>=1);
    w = sqrt( (-2*log(w)) / w );
    REAL(*a0) = x1*w * sigma + REAL(mu);
    IMAG(*a0) = x2*w * sigma + IMAG(mu);
}
#endif

#define M_EPSILON rb_float_new(2.2204460492503131e-16)
#define M_MIN     rb_float_new(2.2250738585072014e-308)
#define M_MAX     rb_float_new(1.7976931348623157e+308)

Version data entries

54 entries across 31 versions & 2 rubygems

Version Path
numo-narray-0.9.2.1 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.2.0 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.9 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.8 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.7 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.6 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.5 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.4 ext/numo/narray/numo/types/dcomplex.h
numo-narray-0.9.1.3 ext/numo/narray/numo/types/dcomplex.h
ruby-dnn-0.4.0 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h
ruby-dnn-0.4.0 lib/dnn/ext/rb_stb_image/numo/types/dcomplex.h
ruby-dnn-0.3.2 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h
ruby-dnn-0.3.2 lib/dnn/ext/image_io/numo/types/dcomplex.h
ruby-dnn-0.3.1 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h
ruby-dnn-0.3.1 lib/dnn/ext/image_io/numo/types/dcomplex.h
ruby-dnn-0.3.0 lib/dnn/ext/image_io/numo/types/dcomplex.h
ruby-dnn-0.3.0 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h
ruby-dnn-0.2.2 lib/dnn/ext/image_io/numo/types/dcomplex.h
ruby-dnn-0.2.2 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h
ruby-dnn-0.2.1 lib/dnn/ext/dataset_loader/numo/types/dcomplex.h