File: sf_debye.c

package info (click to toggle)
ruby-gsl 1.15.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,528 kB
  • ctags: 6,328
  • sloc: ansic: 62,164; ruby: 17,917; makefile: 18; sh: 15
file content (157 lines) | stat: -rw-r--r-- 4,751 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/*
  sf_debye.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; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#include "rb_gsl_sf.h"

static VALUE rb_gsl_sf_debye_1(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_1, x);
}

static VALUE rb_gsl_sf_debye_1_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_1_e, x);
}

static VALUE rb_gsl_sf_debye_2(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_2, x);
}

static VALUE rb_gsl_sf_debye_2_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_2_e, x);
}

static VALUE rb_gsl_sf_debye_3(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_3, x);
}

static VALUE rb_gsl_sf_debye_3_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_3_e, x);
}

static VALUE rb_gsl_sf_debye_4(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_4, x);
}

static VALUE rb_gsl_sf_debye_4_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_4_e, x);
}

static VALUE rb_gsl_sf_debye_n(int argc, VALUE *argv, VALUE obj)
{
  int n;
  VALUE x;
  switch (argc) {
  case 1:
    n = 1;
    x = argv[0];
    break;
  case 2:
    CHECK_FIXNUM(argv[0]);
    n = FIX2INT(argv[0]);
    x = argv[1];
    break;
  default:
    rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or 2)", argc);
    break;
  }
  switch (n) {
  case 1:
    return rb_gsl_sf_eval1(gsl_sf_debye_1, x);
    break;
  case 2:
    return rb_gsl_sf_eval1(gsl_sf_debye_2, x);
    break;
  case 3:
    return rb_gsl_sf_eval1(gsl_sf_debye_3, x);
    break;
  case 4:
    return rb_gsl_sf_eval1(gsl_sf_debye_4, x);
    break;
#ifdef GSL_1_8_LATER
  case 5:
    return rb_gsl_sf_eval1(gsl_sf_debye_5, x);
    break;
  case 6:
    return rb_gsl_sf_eval1(gsl_sf_debye_6, x);
    break;
#endif
  default:
    rb_raise(rb_eRuntimeError, "n must be 1, 2, 3, or 4");
    break;
  }
}

#ifdef GSL_1_8_LATER
static VALUE rb_gsl_sf_debye_5(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_5, x);
}

static VALUE rb_gsl_sf_debye_5_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_5_e, x);
}
static VALUE rb_gsl_sf_debye_6(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval1(gsl_sf_debye_6, x);
}

static VALUE rb_gsl_sf_debye_6_e(VALUE obj, VALUE x)
{
  return rb_gsl_sf_eval_e(gsl_sf_debye_6_e, x);
}

#endif

void Init_gsl_sf_debye(VALUE module)
{
  VALUE mgsl_sf_debye;
  rb_define_module_function(module, "debye_1",  rb_gsl_sf_debye_1, 1);
  rb_define_module_function(module, "debye_1_e",  rb_gsl_sf_debye_1_e, 1);
  rb_define_module_function(module, "debye_2",  rb_gsl_sf_debye_2, 1);
  rb_define_module_function(module, "debye_2_e",  rb_gsl_sf_debye_2_e, 1);
  rb_define_module_function(module, "debye_3",  rb_gsl_sf_debye_3, 1);
  rb_define_module_function(module, "debye_3_e",  rb_gsl_sf_debye_3_e, 1);
  rb_define_module_function(module, "debye_4",  rb_gsl_sf_debye_4, 1);
  rb_define_module_function(module, "debye_4_e",  rb_gsl_sf_debye_4_e, 1);
#ifdef GSL_1_8_LATER
  rb_define_module_function(module, "debye_5",  rb_gsl_sf_debye_5, 1);
  rb_define_module_function(module, "debye_5_e",  rb_gsl_sf_debye_5_e, 1);
  rb_define_module_function(module, "debye_6",  rb_gsl_sf_debye_6, 1);
  rb_define_module_function(module, "debye_6_e",  rb_gsl_sf_debye_6_e, 1);
#endif
  rb_define_module_function(module, "debye_n",  rb_gsl_sf_debye_n, -1);

  mgsl_sf_debye = rb_define_module_under(module, "Debye");
  rb_define_module_function(mgsl_sf_debye, "one",  rb_gsl_sf_debye_1, 1);
  rb_define_module_function(mgsl_sf_debye, "one_e",  rb_gsl_sf_debye_1_e, 1);
  rb_define_module_function(mgsl_sf_debye, "two",  rb_gsl_sf_debye_2, 1);
  rb_define_module_function(mgsl_sf_debye, "two_e",  rb_gsl_sf_debye_2_e, 1);
  rb_define_module_function(mgsl_sf_debye, "three",  rb_gsl_sf_debye_3, 1);
  rb_define_module_function(mgsl_sf_debye, "three_e",  rb_gsl_sf_debye_3_e, 1);
  rb_define_module_function(mgsl_sf_debye, "four",  rb_gsl_sf_debye_4, 1);
  rb_define_module_function(mgsl_sf_debye, "four_e",  rb_gsl_sf_debye_4_e, 1);
#ifdef GSL_1_8_LATER
  rb_define_module_function(mgsl_sf_debye, "five",  rb_gsl_sf_debye_5, 1);
  rb_define_module_function(mgsl_sf_debye, "five_e",  rb_gsl_sf_debye_5_e, 1);
  rb_define_module_function(mgsl_sf_debye, "six",  rb_gsl_sf_debye_6, 1);
  rb_define_module_function(mgsl_sf_debye, "six_e",  rb_gsl_sf_debye_6_e, 1);
#endif
  rb_define_module_function(mgsl_sf_debye, "n",  rb_gsl_sf_debye_n, -1);
}