numo-gsl-integration 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,120 @@
1
+ #include "integration_internal.h"
2
+
3
+ #include <float.h>
4
+ #include <math.h>
5
+
6
+ static VALUE integration_cQAWFTable;
7
+
8
+ static double integration_qawf_cycle_length(double omega) {
9
+ double absolute_omega = fabs(omega);
10
+ double length =
11
+ (2.0 * (floor(absolute_omega) / absolute_omega) + 1.0 / absolute_omega) *
12
+ M_PI;
13
+
14
+ if (!isfinite(length) || length <= 0.0) {
15
+ rb_raise(rb_eArgError, "omega produces a non-finite cycle length");
16
+ }
17
+
18
+ return length;
19
+ }
20
+
21
+ static int integration_qawf_table_double_equal(double left, double right) {
22
+ double scale = fmax(fabs(left), fabs(right));
23
+
24
+ return fabs(left - right) <= DBL_EPSILON * fmax(1.0, scale) * 4.0;
25
+ }
26
+
27
+ static VALUE integration_qawf_table_initialize(int argc, VALUE *argv,
28
+ VALUE self) {
29
+ VALUE options;
30
+ VALUE omega_value;
31
+ VALUE sine_value;
32
+ VALUE levels_value;
33
+ VALUE qawo_options;
34
+ VALUE super_argv[1];
35
+ ID keywords[] = {rb_intern("omega"), rb_intern("sine"), rb_intern("levels")};
36
+ VALUE keyword_values[3];
37
+ double omega;
38
+ int sine;
39
+
40
+ rb_scan_args(argc, argv, "0:", &options);
41
+ if (NIL_P(options)) {
42
+ rb_raise(rb_eArgError, "missing keywords: :omega, :sine, :levels");
43
+ }
44
+ rb_get_kwargs(options, keywords, 3, 0, keyword_values);
45
+ omega_value = keyword_values[0];
46
+ sine_value = keyword_values[1];
47
+ levels_value = keyword_values[2];
48
+
49
+ if (!rb_obj_is_kind_of(omega_value, rb_cNumeric)) {
50
+ rb_raise(rb_eTypeError, "omega must be Numeric");
51
+ }
52
+ if (!RB_INTEGER_TYPE_P(sine_value)) {
53
+ rb_raise(rb_eTypeError, "sine must be an Integer");
54
+ }
55
+ if (!RB_INTEGER_TYPE_P(levels_value)) {
56
+ rb_raise(rb_eTypeError, "levels must be an Integer");
57
+ }
58
+
59
+ omega = NUM2DBL(omega_value);
60
+ sine = NUM2INT(sine_value);
61
+ if (!isfinite(omega) || omega == 0.0) {
62
+ rb_raise(rb_eArgError, "omega must be finite and nonzero");
63
+ }
64
+ if (sine != GSL_INTEG_SINE && sine != GSL_INTEG_COSINE) {
65
+ rb_raise(rb_eArgError, "sine must be SINE or COSINE");
66
+ }
67
+ if (RTEST(rb_funcall(levels_value, rb_intern("<="), 1, INT2FIX(0)))) {
68
+ rb_raise(rb_eArgError, "levels must be positive");
69
+ }
70
+
71
+ qawo_options = rb_hash_new();
72
+ rb_hash_aset(qawo_options, ID2SYM(rb_intern("omega")), omega_value);
73
+ rb_hash_aset(qawo_options, ID2SYM(rb_intern("length")),
74
+ DBL2NUM(integration_qawf_cycle_length(omega)));
75
+ rb_hash_aset(qawo_options, ID2SYM(rb_intern("sine")), sine_value);
76
+ rb_hash_aset(qawo_options, ID2SYM(rb_intern("levels")), levels_value);
77
+ super_argv[0] = qawo_options;
78
+
79
+ return rb_call_super_kw(1, super_argv, RB_PASS_KEYWORDS);
80
+ }
81
+
82
+ void integration_qawf_table_use_begin(VALUE table_value, double omega,
83
+ enum gsl_integration_qawo_enum sine,
84
+ size_t levels,
85
+ integration_qawo_table_use *use) {
86
+ double length = omega == 0.0 ? 1.0 : integration_qawf_cycle_length(omega);
87
+
88
+ if (table_value != Qundef) {
89
+ double table_omega;
90
+ enum gsl_integration_qawo_enum table_sine;
91
+
92
+ if (!rb_obj_is_kind_of(table_value, integration_cQAWFTable)) {
93
+ rb_raise(rb_eTypeError,
94
+ "table must be a Numo::GSL::Integration::QAWFTable");
95
+ }
96
+
97
+ table_omega = NUM2DBL(rb_funcall(table_value, rb_intern("omega"), 0));
98
+ table_sine = (enum gsl_integration_qawo_enum)NUM2INT(
99
+ rb_funcall(table_value, rb_intern("sine"), 0));
100
+ if (!integration_qawf_table_double_equal(table_omega, omega)) {
101
+ rb_raise(rb_eArgError, "omega does not match QAWF table");
102
+ }
103
+ if (table_sine != sine) {
104
+ rb_raise(rb_eArgError, "sine does not match QAWF table");
105
+ }
106
+ }
107
+
108
+ integration_qawo_table_use_begin(table_value, omega, length, sine, levels,
109
+ use);
110
+ }
111
+
112
+ void integration_qawf_table_init(VALUE integration_module) {
113
+ VALUE qawo_table_class =
114
+ rb_const_get(integration_module, rb_intern("QAWOTable"));
115
+
116
+ integration_cQAWFTable =
117
+ rb_define_class_under(integration_module, "QAWFTable", qawo_table_class);
118
+ rb_define_method(integration_cQAWFTable, "initialize",
119
+ integration_qawf_table_initialize, -1);
120
+ }
@@ -118,6 +118,9 @@ static VALUE integration_qawo_table_initialize(int argc, VALUE *argv,
118
118
  levels = NUM2SIZET(levels_value);
119
119
  TypedData_Get_Struct(self, integration_qawo_table,
120
120
  &integration_qawo_table_type, table);
121
+ if (table->table != NULL) {
122
+ rb_raise(rb_eRuntimeError, "table is already initialized");
123
+ }
121
124
  table->omega = omega;
122
125
  table->length = length;
123
126
  table->sine = (enum gsl_integration_qawo_enum)sine;
@@ -6,7 +6,10 @@ typedef struct {
6
6
  double b;
7
7
  double epsabs;
8
8
  double epsrel;
9
- gsl_integration_romberg_workspace *workspace;
9
+ size_t limit;
10
+ int limit_given;
11
+ VALUE workspace_value;
12
+ integration_romberg_workspace_use workspace_use;
10
13
  double *result;
11
14
  size_t *evaluations;
12
15
  } integration_romberg_params;
@@ -14,9 +17,12 @@ typedef struct {
14
17
  static VALUE integration_run_romberg(VALUE data) {
15
18
  integration_romberg_params *params = (integration_romberg_params *)data;
16
19
 
17
- (void)gsl_integration_romberg(params->function, params->a, params->b,
18
- params->epsabs, params->epsrel, params->result,
19
- params->evaluations, params->workspace);
20
+ integration_romberg_workspace_use_begin(params->workspace_value,
21
+ &params->limit, params->limit_given,
22
+ &params->workspace_use);
23
+ (void)gsl_integration_romberg(
24
+ params->function, params->a, params->b, params->epsabs, params->epsrel,
25
+ params->result, params->evaluations, params->workspace_use.workspace);
20
26
 
21
27
  return Qnil;
22
28
  }
@@ -25,22 +31,28 @@ static VALUE integration_run_romberg_with_workspace(VALUE data) {
25
31
  integration_romberg_params *params = (integration_romberg_params *)data;
26
32
 
27
33
  return rb_ensure(integration_run_romberg, data,
28
- integration_free_romberg_workspace,
29
- (VALUE)params->workspace);
34
+ integration_romberg_workspace_use_end,
35
+ (VALUE)&params->workspace_use);
30
36
  }
31
37
 
32
38
  VALUE integration_romberg(int argc, VALUE *argv, VALUE self) {
33
39
  VALUE a;
34
40
  VALUE b;
35
41
  VALUE options;
36
- integration_options parsed_options;
42
+ VALUE epsabs_value = Qundef;
43
+ VALUE epsrel_value = Qundef;
44
+ VALUE limit_value = Qundef;
45
+ VALUE workspace_value = Qundef;
46
+ ID keywords[] = {rb_intern("epsabs"), rb_intern("epsrel"), rb_intern("limit"),
47
+ rb_intern("workspace")};
48
+ VALUE keyword_values[4];
37
49
  double epsabs;
38
50
  double epsrel;
39
- size_t limit;
40
- gsl_integration_romberg_workspace *workspace;
51
+ size_t limit = 20;
52
+ int limit_given;
41
53
  gsl_function function;
42
54
  integration_callback_params params;
43
- integration_romberg_params romberg_params;
55
+ integration_romberg_params romberg_params = {0};
44
56
  double result;
45
57
  size_t evaluations;
46
58
  int state = 0;
@@ -48,23 +60,38 @@ VALUE integration_romberg(int argc, VALUE *argv, VALUE self) {
48
60
  (void)self;
49
61
 
50
62
  rb_scan_args(argc, argv, "2:", &a, &b, &options);
51
-
52
- integration_options_parse(options, &parsed_options, 0.0, 1e-8, 20);
53
-
54
- epsabs = parsed_options.epsabs;
55
- epsrel = parsed_options.epsrel;
56
- limit = parsed_options.limit;
63
+ if (!NIL_P(options)) {
64
+ rb_get_kwargs(options, keywords, 0, 4, keyword_values);
65
+ epsabs_value = keyword_values[0];
66
+ epsrel_value = keyword_values[1];
67
+ limit_value = keyword_values[2];
68
+ workspace_value = keyword_values[3];
69
+ }
70
+
71
+ epsabs = epsabs_value == Qundef ? 0.0 : NUM2DBL(epsabs_value);
72
+ epsrel = epsrel_value == Qundef ? 1e-8 : NUM2DBL(epsrel_value);
73
+ limit_given = limit_value != Qundef;
74
+ if (limit_given) {
75
+ if (!RB_INTEGER_TYPE_P(limit_value)) {
76
+ rb_raise(rb_eTypeError, "limit must be an Integer");
77
+ }
78
+ if (RTEST(rb_funcall(limit_value, rb_intern("<"), 1, INT2FIX(1))) ||
79
+ RTEST(rb_funcall(limit_value, rb_intern(">"), 1, INT2FIX(30)))) {
80
+ rb_raise(rb_eArgError, "limit must be between 1 and 30");
81
+ }
82
+ limit = NUM2SIZET(limit_value);
83
+ }
57
84
 
58
85
  integration_function_init(&function, &params);
59
86
 
60
- workspace = gsl_integration_romberg_alloc(limit);
61
-
62
87
  romberg_params.function = &function;
63
88
  romberg_params.a = NUM2DBL(a);
64
89
  romberg_params.b = NUM2DBL(b);
65
90
  romberg_params.epsabs = epsabs;
66
91
  romberg_params.epsrel = epsrel;
67
- romberg_params.workspace = workspace;
92
+ romberg_params.limit = limit;
93
+ romberg_params.limit_given = limit_given;
94
+ romberg_params.workspace_value = workspace_value;
68
95
  romberg_params.result = &result;
69
96
  romberg_params.evaluations = &evaluations;
70
97
 
@@ -73,6 +100,7 @@ VALUE integration_romberg(int argc, VALUE *argv, VALUE self) {
73
100
 
74
101
  RB_GC_GUARD(params.block);
75
102
  RB_GC_GUARD(params.exception);
103
+ RB_GC_GUARD(workspace_value);
76
104
 
77
105
  integration_finish_callback(&params, state);
78
106
 
@@ -0,0 +1,215 @@
1
+ #include "integration_internal.h"
2
+
3
+ static VALUE integration_cRombergWorkspace;
4
+
5
+ static void integration_romberg_workspace_free(void *data) {
6
+ integration_romberg_workspace *workspace = data;
7
+
8
+ if (workspace->workspace != NULL) {
9
+ gsl_integration_romberg_free(workspace->workspace);
10
+ }
11
+
12
+ xfree(workspace);
13
+ }
14
+
15
+ static size_t integration_romberg_workspace_memsize(const void *data) {
16
+ return data == NULL ? 0 : sizeof(integration_romberg_workspace);
17
+ }
18
+
19
+ static const rb_data_type_t integration_romberg_workspace_type = {
20
+ .wrap_struct_name = "Numo::GSL::Integration::RombergWorkspace",
21
+ .function =
22
+ {
23
+ .dmark = NULL,
24
+ .dfree = integration_romberg_workspace_free,
25
+ .dsize = integration_romberg_workspace_memsize,
26
+ },
27
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
28
+ };
29
+
30
+ static VALUE integration_romberg_workspace_allocate(VALUE klass) {
31
+ integration_romberg_workspace *workspace;
32
+ VALUE object =
33
+ TypedData_Make_Struct(klass, integration_romberg_workspace,
34
+ &integration_romberg_workspace_type, workspace);
35
+
36
+ workspace->workspace = NULL;
37
+ workspace->limit = 0;
38
+ workspace->busy = 0;
39
+
40
+ return object;
41
+ }
42
+
43
+ static VALUE integration_romberg_workspace_initialize(int argc, VALUE *argv,
44
+ VALUE self) {
45
+ VALUE options;
46
+ VALUE limit_value;
47
+ ID keywords[] = {rb_intern("limit")};
48
+ VALUE keyword_values[1];
49
+ size_t limit;
50
+ gsl_integration_romberg_workspace *native_workspace;
51
+ integration_romberg_workspace *workspace;
52
+
53
+ rb_scan_args(argc, argv, "0:", &options);
54
+ if (NIL_P(options)) {
55
+ rb_raise(rb_eArgError, "missing keyword: :limit");
56
+ }
57
+
58
+ rb_get_kwargs(options, keywords, 1, 0, keyword_values);
59
+ limit_value = keyword_values[0];
60
+ if (!RB_INTEGER_TYPE_P(limit_value)) {
61
+ rb_raise(rb_eTypeError, "limit must be an Integer");
62
+ }
63
+ if (RTEST(rb_funcall(limit_value, rb_intern("<"), 1, INT2FIX(1))) ||
64
+ RTEST(rb_funcall(limit_value, rb_intern(">"), 1, INT2FIX(30)))) {
65
+ rb_raise(rb_eArgError, "limit must be between 1 and 30");
66
+ }
67
+
68
+ TypedData_Get_Struct(self, integration_romberg_workspace,
69
+ &integration_romberg_workspace_type, workspace);
70
+ if (workspace->workspace != NULL) {
71
+ rb_raise(rb_eRuntimeError, "workspace is already initialized");
72
+ }
73
+
74
+ limit = NUM2SIZET(limit_value);
75
+ native_workspace = gsl_integration_romberg_alloc(limit);
76
+ if (native_workspace == NULL) {
77
+ rb_memerror();
78
+ }
79
+
80
+ workspace->workspace = native_workspace;
81
+ workspace->limit = limit;
82
+
83
+ return self;
84
+ }
85
+
86
+ static VALUE integration_romberg_workspace_limit(VALUE self) {
87
+ integration_romberg_workspace *workspace;
88
+
89
+ TypedData_Get_Struct(self, integration_romberg_workspace,
90
+ &integration_romberg_workspace_type, workspace);
91
+
92
+ return SIZET2NUM(workspace->limit);
93
+ }
94
+
95
+ static VALUE integration_romberg_workspace_closed_p(VALUE self) {
96
+ integration_romberg_workspace *workspace;
97
+
98
+ TypedData_Get_Struct(self, integration_romberg_workspace,
99
+ &integration_romberg_workspace_type, workspace);
100
+
101
+ return workspace->workspace == NULL ? Qtrue : Qfalse;
102
+ }
103
+
104
+ static VALUE integration_romberg_workspace_close(VALUE self) {
105
+ integration_romberg_workspace *workspace;
106
+
107
+ TypedData_Get_Struct(self, integration_romberg_workspace,
108
+ &integration_romberg_workspace_type, workspace);
109
+ if (workspace->busy) {
110
+ rb_raise(rb_eRuntimeError, "workspace is already in use");
111
+ }
112
+ if (workspace->workspace != NULL) {
113
+ gsl_integration_romberg_free(workspace->workspace);
114
+ workspace->workspace = NULL;
115
+ }
116
+
117
+ return Qnil;
118
+ }
119
+
120
+ static VALUE integration_romberg_workspace_yield(VALUE workspace) {
121
+ return rb_yield(workspace);
122
+ }
123
+
124
+ static VALUE integration_romberg_workspace_open(int argc, VALUE *argv,
125
+ VALUE klass) {
126
+ VALUE workspace;
127
+
128
+ workspace =
129
+ rb_funcallv_kw(klass, rb_intern("new"), argc, argv, RB_PASS_KEYWORDS);
130
+
131
+ return rb_ensure(integration_romberg_workspace_yield, workspace,
132
+ integration_romberg_workspace_close, workspace);
133
+ }
134
+
135
+ static integration_romberg_workspace *
136
+ integration_romberg_workspace_get(VALUE workspace_value) {
137
+ integration_romberg_workspace *workspace;
138
+
139
+ if (!rb_obj_is_kind_of(workspace_value, integration_cRombergWorkspace)) {
140
+ rb_raise(rb_eTypeError,
141
+ "workspace must be a Numo::GSL::Integration::RombergWorkspace");
142
+ }
143
+
144
+ TypedData_Get_Struct(workspace_value, integration_romberg_workspace,
145
+ &integration_romberg_workspace_type, workspace);
146
+ if (workspace->workspace == NULL) {
147
+ rb_raise(rb_eRuntimeError, "workspace is closed");
148
+ }
149
+ if (workspace->busy) {
150
+ rb_raise(rb_eRuntimeError, "workspace is already in use");
151
+ }
152
+
153
+ return workspace;
154
+ }
155
+
156
+ void integration_romberg_workspace_use_begin(
157
+ VALUE workspace_value, size_t *limit, int limit_given,
158
+ integration_romberg_workspace_use *use) {
159
+ integration_romberg_workspace *workspace;
160
+
161
+ use->workspace = NULL;
162
+ use->owner = NULL;
163
+ if (workspace_value == Qundef) {
164
+ use->workspace = gsl_integration_romberg_alloc(*limit);
165
+ if (use->workspace == NULL) {
166
+ rb_memerror();
167
+ }
168
+ return;
169
+ }
170
+
171
+ workspace = integration_romberg_workspace_get(workspace_value);
172
+ if (limit_given && *limit != workspace->limit) {
173
+ rb_raise(rb_eArgError, "limit must match workspace capacity");
174
+ }
175
+ if (!limit_given) {
176
+ *limit = workspace->limit;
177
+ }
178
+
179
+ workspace->busy = 1;
180
+ use->workspace = workspace->workspace;
181
+ use->owner = workspace;
182
+ }
183
+
184
+ VALUE integration_romberg_workspace_use_end(VALUE data) {
185
+ integration_romberg_workspace_use *use =
186
+ (integration_romberg_workspace_use *)data;
187
+
188
+ if (use->owner != NULL) {
189
+ use->owner->busy = 0;
190
+ } else if (use->workspace != NULL) {
191
+ gsl_integration_romberg_free(use->workspace);
192
+ }
193
+
194
+ use->workspace = NULL;
195
+ use->owner = NULL;
196
+
197
+ return Qnil;
198
+ }
199
+
200
+ void integration_romberg_workspace_init(VALUE integration_module) {
201
+ integration_cRombergWorkspace =
202
+ rb_define_class_under(integration_module, "RombergWorkspace", rb_cObject);
203
+ rb_define_alloc_func(integration_cRombergWorkspace,
204
+ integration_romberg_workspace_allocate);
205
+ rb_define_method(integration_cRombergWorkspace, "initialize",
206
+ integration_romberg_workspace_initialize, -1);
207
+ rb_define_method(integration_cRombergWorkspace, "limit",
208
+ integration_romberg_workspace_limit, 0);
209
+ rb_define_method(integration_cRombergWorkspace, "closed?",
210
+ integration_romberg_workspace_closed_p, 0);
211
+ rb_define_method(integration_cRombergWorkspace, "close",
212
+ integration_romberg_workspace_close, 0);
213
+ rb_define_singleton_method(integration_cRombergWorkspace, "open",
214
+ integration_romberg_workspace_open, -1);
215
+ }
@@ -121,9 +121,35 @@ static VALUE integration_workspace_open(int argc, VALUE *argv, VALUE klass) {
121
121
  integration_workspace_close, workspace);
122
122
  }
123
123
 
124
- void integration_workspace_use_begin(VALUE workspace_value, size_t *limit,
125
- int limit_given,
126
- integration_workspace_use *use) {
124
+ static integration_workspace *integration_workspace_get(VALUE workspace_value,
125
+ const char *name) {
126
+ integration_workspace *workspace;
127
+
128
+ if (!rb_obj_is_kind_of(workspace_value, integration_cWorkspace)) {
129
+ rb_raise(rb_eTypeError, "%s must be a Numo::GSL::Integration::Workspace",
130
+ name);
131
+ }
132
+
133
+ TypedData_Get_Struct(workspace_value, integration_workspace,
134
+ &integration_workspace_type, workspace);
135
+ if (workspace->workspace == NULL) {
136
+ rb_raise(rb_eRuntimeError, "%s is closed", name);
137
+ }
138
+ if (workspace->busy) {
139
+ rb_raise(rb_eRuntimeError, "%s is already in use", name);
140
+ }
141
+
142
+ return workspace;
143
+ }
144
+
145
+ size_t integration_workspace_capacity(VALUE workspace_value, const char *name) {
146
+ return integration_workspace_get(workspace_value, name)->limit;
147
+ }
148
+
149
+ void integration_workspace_use_begin_named(VALUE workspace_value, size_t *limit,
150
+ int limit_given,
151
+ integration_workspace_use *use,
152
+ const char *name) {
127
153
  integration_workspace *workspace;
128
154
 
129
155
  use->workspace = NULL;
@@ -137,21 +163,9 @@ void integration_workspace_use_begin(VALUE workspace_value, size_t *limit,
137
163
  return;
138
164
  }
139
165
 
140
- if (!rb_obj_is_kind_of(workspace_value, integration_cWorkspace)) {
141
- rb_raise(rb_eTypeError,
142
- "workspace must be a Numo::GSL::Integration::Workspace");
143
- }
144
-
145
- TypedData_Get_Struct(workspace_value, integration_workspace,
146
- &integration_workspace_type, workspace);
147
- if (workspace->workspace == NULL) {
148
- rb_raise(rb_eRuntimeError, "workspace is closed");
149
- }
150
- if (workspace->busy) {
151
- rb_raise(rb_eRuntimeError, "workspace is already in use");
152
- }
166
+ workspace = integration_workspace_get(workspace_value, name);
153
167
  if (limit_given && *limit > workspace->limit) {
154
- rb_raise(rb_eArgError, "limit exceeds workspace capacity");
168
+ rb_raise(rb_eArgError, "limit exceeds %s capacity", name);
155
169
  }
156
170
  if (!limit_given) {
157
171
  *limit = workspace->limit;
@@ -162,6 +176,13 @@ void integration_workspace_use_begin(VALUE workspace_value, size_t *limit,
162
176
  use->owner = workspace;
163
177
  }
164
178
 
179
+ void integration_workspace_use_begin(VALUE workspace_value, size_t *limit,
180
+ int limit_given,
181
+ integration_workspace_use *use) {
182
+ integration_workspace_use_begin_named(workspace_value, limit, limit_given,
183
+ use, "workspace");
184
+ }
185
+
165
186
  VALUE integration_workspace_use_end(VALUE data) {
166
187
  integration_workspace_use *use = (integration_workspace_use *)data;
167
188
 
@@ -3,7 +3,7 @@
3
3
  module Numo
4
4
  module GSL
5
5
  module Integration
6
- VERSION = "0.5.0"
6
+ VERSION = "0.7.0"
7
7
  end
8
8
  end
9
9
  end
@@ -17,6 +17,27 @@ module Numo
17
17
  def close: () -> nil
18
18
  def closed?: () -> bool
19
19
  end
20
+ class CQUADWorkspace
21
+ def self.open: [T] (limit: Integer) { (CQUADWorkspace) -> T } -> T
22
+ def initialize: (limit: Integer) -> void
23
+ def limit: () -> Integer
24
+ def close: () -> nil
25
+ def closed?: () -> bool
26
+ end
27
+ class RombergWorkspace
28
+ def self.open: [T] (limit: Integer) { (RombergWorkspace) -> T } -> T
29
+ def initialize: (limit: Integer) -> void
30
+ def limit: () -> Integer
31
+ def close: () -> nil
32
+ def closed?: () -> bool
33
+ end
34
+ class GLFixedTable
35
+ def self.open: [T] (order: Integer) { (GLFixedTable) -> T } -> T
36
+ def initialize: (order: Integer) -> void
37
+ def order: () -> Integer
38
+ def close: () -> nil
39
+ def closed?: () -> bool
40
+ end
20
41
  class QAWOTable
21
42
  def self.open: [T] (
22
43
  omega: Numeric,
@@ -37,6 +58,18 @@ module Numo
37
58
  def close: () -> nil
38
59
  def closed?: () -> bool
39
60
  end
61
+ class QAWFTable < QAWOTable
62
+ def self.open: [T] (
63
+ omega: Numeric,
64
+ sine: Integer,
65
+ levels: Integer
66
+ ) { (QAWFTable) -> T } -> T
67
+ def initialize: (
68
+ omega: Numeric,
69
+ sine: Integer,
70
+ levels: Integer
71
+ ) -> void
72
+ end
40
73
  class QAWSTable
41
74
  def self.open: [T] (
42
75
  alpha: Numeric,
@@ -145,26 +178,32 @@ module Numo
145
178
  Numeric omega,
146
179
  Integer sine,
147
180
  ?epsabs: Numeric,
148
- ?limit: Integer
181
+ ?limit: Integer,
182
+ ?workspace: Workspace,
183
+ ?cycle_workspace: Workspace,
184
+ ?table: QAWFTable
149
185
  ) { (Float) -> Numeric } -> [Float, Float]
150
186
  def self.cquad: (
151
187
  Numeric a,
152
188
  Numeric b,
153
189
  ?epsabs: Numeric,
154
190
  ?epsrel: Numeric,
155
- ?limit: Integer
191
+ ?limit: Integer,
192
+ ?workspace: CQUADWorkspace
156
193
  ) { (Float) -> Numeric } -> [Float, Float, Integer]
157
194
  def self.romberg: (
158
195
  Numeric a,
159
196
  Numeric b,
160
197
  ?epsabs: Numeric,
161
198
  ?epsrel: Numeric,
162
- ?limit: Integer
199
+ ?limit: Integer,
200
+ ?workspace: RombergWorkspace
163
201
  ) { (Float) -> Numeric } -> [Float, Integer]
164
202
  def self.glfixed: (
165
203
  Numeric a,
166
204
  Numeric b,
167
- ?order: Integer
205
+ ?order: Integer,
206
+ ?table: GLFixedTable
168
207
  ) { (Float) -> Numeric } -> Float
169
208
  def self.fixed: (
170
209
  (:legendre | :chebyshev | :chebyshev2 | :gegenbauer | :jacobi | :laguerre | :hermite | :exponential | :rational) type,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: numo-gsl-integration
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro SATOH
@@ -26,9 +26,11 @@ files:
26
26
  - docs/routines.md
27
27
  - ext/numo/gsl/integration/callback.c
28
28
  - ext/numo/gsl/integration/cquad.c
29
+ - ext/numo/gsl/integration/cquad_workspace.c
29
30
  - ext/numo/gsl/integration/extconf.rb
30
31
  - ext/numo/gsl/integration/fixed.c
31
32
  - ext/numo/gsl/integration/glfixed.c
33
+ - ext/numo/gsl/integration/glfixed_table.c
32
34
  - ext/numo/gsl/integration/integration.c
33
35
  - ext/numo/gsl/integration/integration_internal.h
34
36
  - ext/numo/gsl/integration/lebedev.c
@@ -41,6 +43,7 @@ files:
41
43
  - ext/numo/gsl/integration/qags.c
42
44
  - ext/numo/gsl/integration/qawc.c
43
45
  - ext/numo/gsl/integration/qawf.c
46
+ - ext/numo/gsl/integration/qawf_table.c
44
47
  - ext/numo/gsl/integration/qawo.c
45
48
  - ext/numo/gsl/integration/qawo_table.c
46
49
  - ext/numo/gsl/integration/qaws.c
@@ -48,6 +51,7 @@ files:
48
51
  - ext/numo/gsl/integration/qng.c
49
52
  - ext/numo/gsl/integration/resources.c
50
53
  - ext/numo/gsl/integration/romberg.c
54
+ - ext/numo/gsl/integration/romberg_workspace.c
51
55
  - ext/numo/gsl/integration/workspace.c
52
56
  - lib/numo/gsl/integration.rb
53
57
  - lib/numo/gsl/integration/version.rb