Sha256: 3be7aee0767330639b40141b6e6119ea06644c41c4bd9c630773aca2db7ba3f6

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 KB

Contents

/*
  sf_power.c
  Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
    (C) Copyright 2001-2006 by Yoshiki Tsunesada

  Ruby/GSL is free software: you can redistribute it and/or modify it
  under the terms of the GNU General Public License.
  This library is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY.
*/

#include "rb_gsl_sf.h"

VALUE rb_gsl_complex_pow(int argc, VALUE *argv, VALUE obj);
static VALUE rb_gsl_sf_pow_int(VALUE obj, VALUE x, VALUE n)
{
  VALUE argv[2];
  if (COMPLEX_P(x) || VECTOR_COMPLEX_P(x) || MATRIX_COMPLEX_P(x)) {
    argv[0] = x;
    argv[1] = n;
    return rb_gsl_complex_pow(2, argv, obj);
  }
  return rb_gsl_sf_eval_double_int(gsl_sf_pow_int, x, n);
}

static VALUE rb_gsl_sf_pow_int_e(VALUE obj, VALUE x, VALUE n)
{
  gsl_sf_result *rslt = NULL;
  VALUE v;
  int status;
  Need_Float(x);
  CHECK_FIXNUM(n);
  v = Data_Make_Struct(cgsl_sf_result, gsl_sf_result, 0, free, rslt);
  status = gsl_sf_pow_int_e(NUM2DBL(x), FIX2INT(n), rslt);
  return v;
}

void Init_gsl_sf_power(VALUE module)
{
  VALUE mgsl_sf_pow;
  rb_define_module_function(module, "pow_int",  rb_gsl_sf_pow_int, 2);
  rb_define_module_function(module, "pow_int_e",  rb_gsl_sf_pow_int_e, 2);
  mgsl_sf_pow = rb_define_module_under(module, "Pow");
  rb_define_module_function(mgsl_sf_pow, "int",  rb_gsl_sf_pow_int, 2);
  rb_define_module_function(mgsl_sf_pow, "int_e",  rb_gsl_sf_pow_int_e, 2);
}

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
romanbsd-gsl-1.11.2.2 ext/sf_power.c
gsl-1.14.7 ext/sf_power.c
gsl-1.14.6 ext/sf_power.c
gsl-1.14.5 ext/sf_power.c
gsl-1.12.109 ext/sf_power.c
gsl-1.12.108 ext/sf_power.c