/*
  gsl.c
  Ruby/GSL: Ruby extension library for GSL (GNU Scientific Library)
    (C) Copyright 2001-2004 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.h"
#include "gsl/gsl_machine.h"

VALUE mgsl;
ID rb_gsl_id_beg, rb_gsl_id_end, rb_gsl_id_excl;

static void rb_gsl_define_global_const();
static void rb_gsl_define_const(VALUE module);

void Init_rb_gsl()
{
  mgsl = rb_define_module("GSL");

  rb_gsl_define_global_const();

  Init_gsl_error();

  Init_gsl_math();
  Init_gsl_complex();

  Init_gsl_array();

  Init_gsl_blas();

  Init_gsl_sort();

  Init_gsl_poly();  /* this must be called after the Vector class defined */

  Init_gsl_sf();

  Init_gsl_linalg();
  Init_gsl_linalg_complex();
  Init_gsl_eigen();

  Init_gsl_fft();
  Init_gsl_function();
  Init_gsl_integration();

  Init_gsl_rng();
  Init_gsl_qrng();
  Init_gsl_ran();
  Init_gsl_stats();

  Init_gsl_histogram();
  Init_gsl_histogram2d();
  Init_gsl_ntuple();
  Init_gsl_monte();
  Init_gsl_siman();

  Init_gsl_odeiv();
  Init_gsl_interp();
  Init_gsl_diff();

  Init_gsl_cheb();
  Init_gsl_sum();
  Init_gsl_dht();

  Init_gsl_root();
  Init_gsl_multiroot();
  Init_gsl_min();
  Init_gsl_multimin();
  Init_gsl_fit();
  Init_gsl_multifit();

  Init_gsl_const();

  Init_gsl_ieee();

#ifdef HAVE_NARRAY_H
  Init_gsl_narray();
#endif

#ifdef HAVE_WAVELET_H
  Init_wavelet();
#endif

  rb_gsl_define_const(mgsl);
}

static void rb_gsl_define_global_const()
{
  rb_gsl_id_beg   = rb_intern("begin");
  rb_gsl_id_end   = rb_intern("end");
  rb_gsl_id_excl   = rb_intern("excl");
}

static void rb_gsl_define_const(VALUE module)
{

  rb_define_const(module, "PREC_DOUBLE", INT2FIX(GSL_PREC_DOUBLE));
  rb_define_const(module, "PREC_SINGLE", INT2FIX(GSL_PREC_SINGLE));
  rb_define_const(module, "PREC_APPROX", INT2FIX(GSL_PREC_APPROX));
#ifdef GSL_VERSION
  rb_define_const(module, "VERSION", rb_str_new2(GSL_VERSION));
#endif
#ifdef RUBY_GSL_VERSION
  rb_define_const(module, "RUBY_GSL_VERSION", rb_str_new2(RUBY_GSL_VERSION));
  rb_define_const(module, "RB_GSL_VERSION", rb_str_new2(RUBY_GSL_VERSION));
#endif

  rb_define_const(module, "DBL_EPSILON", rb_float_new(GSL_DBL_EPSILON));
  rb_define_const(module, "MACH_EPS", rb_float_new(GSL_MACH_EPS));
  rb_define_const(module, "SQRT_DBL_EPSILON", rb_float_new(GSL_SQRT_DBL_EPSILON));
  rb_define_const(module, "ROOT3_DBL_EPSILON", rb_float_new(GSL_ROOT3_DBL_EPSILON));
  rb_define_const(module, "ROOT4_DBL_EPSILON", rb_float_new(GSL_ROOT4_DBL_EPSILON));
  rb_define_const(module, "ROOT5_DBL_EPSILON", rb_float_new(GSL_ROOT5_DBL_EPSILON));
  rb_define_const(module, "ROOT6_DBL_EPSILON", rb_float_new(GSL_ROOT6_DBL_EPSILON));
  rb_define_const(module, "LOG_DBL_EPSILON", rb_float_new(GSL_LOG_DBL_EPSILON));

}

