Sha256: 27087d79431ebd5802f04509f8b4afc3a6638ff922a05fc979dd96baf7dde45d

Contents?: true

Size: 515 Bytes

Versions: 1

Compression:

Stored size: 515 Bytes

Contents

#include "../kmat.h"

VALUE
kmm_MATH_exp2(VALUE self, VALUE x)
{
	return rb_float_new(exp2(NUM2DBL(x)));
}

VALUE
kmm_MATH_expm1(VALUE self, VALUE x)
{
	return rb_float_new(expm1(NUM2DBL(x)));
}

VALUE
kmm_MATH_log1p(VALUE self, VALUE x)
{
	return rb_float_new(log1p(NUM2DBL(x)));
}

VALUE
kmm_float_sign(VALUE self)
{
	const double x = NUM2DBL(self);
	if ( x == 0.0 ) {
		return INT2NUM(0);
	} else if ( x > 0.0 ) {
		return INT2NUM(1);
	} else if ( x < 0.0 ) {
		return INT2NUM(-1);
	} else {
		return self;
	}
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kmat-0.1.0 ext/kmat/arith/math.c