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.
@@ -5,15 +5,19 @@ typedef struct {
5
5
  double a;
6
6
  double b;
7
7
  size_t order;
8
- gsl_integration_glfixed_table *table;
8
+ int order_given;
9
+ VALUE table_value;
10
+ integration_glfixed_table_use table_use;
9
11
  double *result;
10
12
  } integration_glfixed_params;
11
13
 
12
14
  static VALUE integration_run_glfixed(VALUE data) {
13
15
  integration_glfixed_params *params = (integration_glfixed_params *)data;
14
16
 
15
- *(params->result) = gsl_integration_glfixed(params->function, params->a,
16
- params->b, params->table);
17
+ integration_glfixed_table_use_begin(params->table_value, &params->order,
18
+ params->order_given, &params->table_use);
19
+ *(params->result) = gsl_integration_glfixed(
20
+ params->function, params->a, params->b, params->table_use.table);
17
21
 
18
22
  return Qnil;
19
23
  }
@@ -22,7 +26,8 @@ static VALUE integration_run_glfixed_with_table(VALUE data) {
22
26
  integration_glfixed_params *params = (integration_glfixed_params *)data;
23
27
 
24
28
  return rb_ensure(integration_run_glfixed, data,
25
- integration_free_glfixed_table, (VALUE)params->table);
29
+ integration_glfixed_table_use_end,
30
+ (VALUE)&params->table_use);
26
31
  }
27
32
 
28
33
  VALUE integration_glfixed(int argc, VALUE *argv, VALUE self) {
@@ -30,35 +35,34 @@ VALUE integration_glfixed(int argc, VALUE *argv, VALUE self) {
30
35
  VALUE b;
31
36
  VALUE options;
32
37
  VALUE order_value = Qundef;
33
- ID keywords[] = {rb_intern("order")};
34
- VALUE keyword_values[1];
35
- size_t order;
38
+ VALUE table_value = Qundef;
39
+ ID keywords[] = {rb_intern("order"), rb_intern("table")};
40
+ VALUE keyword_values[2];
41
+ size_t order = 10;
42
+ int order_given;
36
43
  gsl_function function;
37
44
  integration_callback_params params;
38
- integration_glfixed_params glfixed_params;
45
+ integration_glfixed_params glfixed_params = {0};
39
46
  double result;
40
47
  int state = 0;
41
48
 
42
49
  (void)self;
43
50
 
44
51
  rb_scan_args(argc, argv, "2:", &a, &b, &options);
45
-
46
52
  if (!NIL_P(options)) {
47
- rb_get_kwargs(options, keywords, 0, 1, keyword_values);
53
+ rb_get_kwargs(options, keywords, 0, 2, keyword_values);
48
54
  order_value = keyword_values[0];
55
+ table_value = keyword_values[1];
49
56
  }
50
57
 
51
- if (order_value == Qundef) {
52
- order = 10;
53
- } else {
58
+ order_given = order_value != Qundef;
59
+ if (order_given) {
54
60
  if (!RB_INTEGER_TYPE_P(order_value)) {
55
61
  rb_raise(rb_eTypeError, "order must be an Integer");
56
62
  }
57
-
58
63
  if (RTEST(rb_funcall(order_value, rb_intern("<="), 1, INT2FIX(0)))) {
59
64
  rb_raise(rb_eArgError, "order must be positive");
60
65
  }
61
-
62
66
  order = NUM2SIZET(order_value);
63
67
  }
64
68
 
@@ -68,9 +72,8 @@ VALUE integration_glfixed(int argc, VALUE *argv, VALUE self) {
68
72
  glfixed_params.a = NUM2DBL(a);
69
73
  glfixed_params.b = NUM2DBL(b);
70
74
  glfixed_params.order = order;
71
-
72
- glfixed_params.table = gsl_integration_glfixed_table_alloc(order);
73
-
75
+ glfixed_params.order_given = order_given;
76
+ glfixed_params.table_value = table_value;
74
77
  glfixed_params.result = &result;
75
78
 
76
79
  rb_protect(integration_run_glfixed_with_table, (VALUE)&glfixed_params,
@@ -78,6 +81,7 @@ VALUE integration_glfixed(int argc, VALUE *argv, VALUE self) {
78
81
 
79
82
  RB_GC_GUARD(params.block);
80
83
  RB_GC_GUARD(params.exception);
84
+ RB_GC_GUARD(table_value);
81
85
 
82
86
  integration_finish_callback(&params, state);
83
87
 
@@ -0,0 +1,211 @@
1
+ #include "integration_internal.h"
2
+
3
+ static VALUE integration_cGLFixedTable;
4
+
5
+ static void integration_glfixed_table_free(void *data) {
6
+ integration_glfixed_table *table = data;
7
+
8
+ if (table->table != NULL) {
9
+ gsl_integration_glfixed_table_free(table->table);
10
+ }
11
+
12
+ xfree(table);
13
+ }
14
+
15
+ static size_t integration_glfixed_table_memsize(const void *data) {
16
+ return data == NULL ? 0 : sizeof(integration_glfixed_table);
17
+ }
18
+
19
+ static const rb_data_type_t integration_glfixed_table_type = {
20
+ .wrap_struct_name = "Numo::GSL::Integration::GLFixedTable",
21
+ .function =
22
+ {
23
+ .dmark = NULL,
24
+ .dfree = integration_glfixed_table_free,
25
+ .dsize = integration_glfixed_table_memsize,
26
+ },
27
+ .flags = RUBY_TYPED_FREE_IMMEDIATELY,
28
+ };
29
+
30
+ static VALUE integration_glfixed_table_allocate(VALUE klass) {
31
+ integration_glfixed_table *table;
32
+ VALUE object = TypedData_Make_Struct(klass, integration_glfixed_table,
33
+ &integration_glfixed_table_type, table);
34
+
35
+ table->table = NULL;
36
+ table->order = 0;
37
+ table->busy = 0;
38
+
39
+ return object;
40
+ }
41
+
42
+ static VALUE integration_glfixed_table_initialize(int argc, VALUE *argv,
43
+ VALUE self) {
44
+ VALUE options;
45
+ VALUE order_value;
46
+ ID keywords[] = {rb_intern("order")};
47
+ VALUE keyword_values[1];
48
+ size_t order;
49
+ gsl_integration_glfixed_table *native_table;
50
+ integration_glfixed_table *table;
51
+
52
+ rb_scan_args(argc, argv, "0:", &options);
53
+ if (NIL_P(options)) {
54
+ rb_raise(rb_eArgError, "missing keyword: :order");
55
+ }
56
+
57
+ rb_get_kwargs(options, keywords, 1, 0, keyword_values);
58
+ order_value = keyword_values[0];
59
+ if (!RB_INTEGER_TYPE_P(order_value)) {
60
+ rb_raise(rb_eTypeError, "order must be an Integer");
61
+ }
62
+ if (RTEST(rb_funcall(order_value, rb_intern("<="), 1, INT2FIX(0)))) {
63
+ rb_raise(rb_eArgError, "order must be positive");
64
+ }
65
+
66
+ TypedData_Get_Struct(self, integration_glfixed_table,
67
+ &integration_glfixed_table_type, table);
68
+ if (table->table != NULL) {
69
+ rb_raise(rb_eRuntimeError, "table is already initialized");
70
+ }
71
+
72
+ order = NUM2SIZET(order_value);
73
+ native_table = gsl_integration_glfixed_table_alloc(order);
74
+ if (native_table == NULL) {
75
+ rb_memerror();
76
+ }
77
+
78
+ table->table = native_table;
79
+ table->order = order;
80
+
81
+ return self;
82
+ }
83
+
84
+ static VALUE integration_glfixed_table_order(VALUE self) {
85
+ integration_glfixed_table *table;
86
+
87
+ TypedData_Get_Struct(self, integration_glfixed_table,
88
+ &integration_glfixed_table_type, table);
89
+
90
+ return SIZET2NUM(table->order);
91
+ }
92
+
93
+ static VALUE integration_glfixed_table_closed_p(VALUE self) {
94
+ integration_glfixed_table *table;
95
+
96
+ TypedData_Get_Struct(self, integration_glfixed_table,
97
+ &integration_glfixed_table_type, table);
98
+
99
+ return table->table == NULL ? Qtrue : Qfalse;
100
+ }
101
+
102
+ static VALUE integration_glfixed_table_close(VALUE self) {
103
+ integration_glfixed_table *table;
104
+
105
+ TypedData_Get_Struct(self, integration_glfixed_table,
106
+ &integration_glfixed_table_type, table);
107
+ if (table->busy) {
108
+ rb_raise(rb_eRuntimeError, "table is already in use");
109
+ }
110
+ if (table->table != NULL) {
111
+ gsl_integration_glfixed_table_free(table->table);
112
+ table->table = NULL;
113
+ }
114
+
115
+ return Qnil;
116
+ }
117
+
118
+ static VALUE integration_glfixed_table_yield(VALUE table) {
119
+ return rb_yield(table);
120
+ }
121
+
122
+ static VALUE integration_glfixed_table_open(int argc, VALUE *argv,
123
+ VALUE klass) {
124
+ VALUE table;
125
+
126
+ table = rb_funcallv_kw(klass, rb_intern("new"), argc, argv, RB_PASS_KEYWORDS);
127
+
128
+ return rb_ensure(integration_glfixed_table_yield, table,
129
+ integration_glfixed_table_close, table);
130
+ }
131
+
132
+ static integration_glfixed_table *
133
+ integration_glfixed_table_get(VALUE table_value) {
134
+ integration_glfixed_table *table;
135
+
136
+ if (!rb_obj_is_kind_of(table_value, integration_cGLFixedTable)) {
137
+ rb_raise(rb_eTypeError,
138
+ "table must be a Numo::GSL::Integration::GLFixedTable");
139
+ }
140
+
141
+ TypedData_Get_Struct(table_value, integration_glfixed_table,
142
+ &integration_glfixed_table_type, table);
143
+ if (table->table == NULL) {
144
+ rb_raise(rb_eRuntimeError, "table is closed");
145
+ }
146
+ if (table->busy) {
147
+ rb_raise(rb_eRuntimeError, "table is already in use");
148
+ }
149
+
150
+ return table;
151
+ }
152
+
153
+ void integration_glfixed_table_use_begin(VALUE table_value, size_t *order,
154
+ int order_given,
155
+ integration_glfixed_table_use *use) {
156
+ integration_glfixed_table *table;
157
+
158
+ use->table = NULL;
159
+ use->owner = NULL;
160
+ if (table_value == Qundef) {
161
+ use->table = gsl_integration_glfixed_table_alloc(*order);
162
+ if (use->table == NULL) {
163
+ rb_memerror();
164
+ }
165
+ return;
166
+ }
167
+
168
+ table = integration_glfixed_table_get(table_value);
169
+ if (order_given && *order != table->order) {
170
+ rb_raise(rb_eArgError, "order does not match GLFixed table");
171
+ }
172
+ if (!order_given) {
173
+ *order = table->order;
174
+ }
175
+
176
+ table->busy = 1;
177
+ use->table = table->table;
178
+ use->owner = table;
179
+ }
180
+
181
+ VALUE integration_glfixed_table_use_end(VALUE data) {
182
+ integration_glfixed_table_use *use = (integration_glfixed_table_use *)data;
183
+
184
+ if (use->owner != NULL) {
185
+ use->owner->busy = 0;
186
+ } else if (use->table != NULL) {
187
+ gsl_integration_glfixed_table_free(use->table);
188
+ }
189
+
190
+ use->table = NULL;
191
+ use->owner = NULL;
192
+
193
+ return Qnil;
194
+ }
195
+
196
+ void integration_glfixed_table_init(VALUE integration_module) {
197
+ integration_cGLFixedTable =
198
+ rb_define_class_under(integration_module, "GLFixedTable", rb_cObject);
199
+ rb_define_alloc_func(integration_cGLFixedTable,
200
+ integration_glfixed_table_allocate);
201
+ rb_define_method(integration_cGLFixedTable, "initialize",
202
+ integration_glfixed_table_initialize, -1);
203
+ rb_define_method(integration_cGLFixedTable, "order",
204
+ integration_glfixed_table_order, 0);
205
+ rb_define_method(integration_cGLFixedTable, "closed?",
206
+ integration_glfixed_table_closed_p, 0);
207
+ rb_define_method(integration_cGLFixedTable, "close",
208
+ integration_glfixed_table_close, 0);
209
+ rb_define_singleton_method(integration_cGLFixedTable, "open",
210
+ integration_glfixed_table_open, -1);
211
+ }
@@ -18,9 +18,18 @@ void Init_integration(void) {
18
18
  mGSL = rb_define_module_under(mNumo, "GSL");
19
19
  mIntegration = rb_define_module_under(mGSL, "Integration");
20
20
  numo_eGslError = rb_define_class_under(mGSL, "GslError", rb_eStandardError);
21
+
21
22
  gsl_set_error_handler(&integration_gsl_error_handler);
23
+
22
24
  integration_workspace_init(mIntegration);
25
+
26
+ integration_cquad_workspace_init(mIntegration);
27
+
28
+ integration_romberg_workspace_init(mIntegration);
29
+
30
+ integration_glfixed_table_init(mIntegration);
23
31
  integration_qawo_table_init(mIntegration);
32
+ integration_qawf_table_init(mIntegration);
24
33
  integration_qaws_table_init(mIntegration);
25
34
  integration_fixed_init();
26
35
 
@@ -32,11 +32,58 @@ typedef struct {
32
32
  } integration_workspace_use;
33
33
 
34
34
  void integration_workspace_init(VALUE integration_module);
35
+ size_t integration_workspace_capacity(VALUE workspace_value, const char *name);
36
+ void integration_workspace_use_begin_named(VALUE workspace_value, size_t *limit,
37
+ int limit_given,
38
+ integration_workspace_use *use,
39
+ const char *name);
35
40
  void integration_workspace_use_begin(VALUE workspace_value, size_t *limit,
36
41
  int limit_given,
37
42
  integration_workspace_use *use);
38
43
  VALUE integration_workspace_use_end(VALUE data);
39
44
 
45
+ typedef struct {
46
+ gsl_integration_cquad_workspace *workspace;
47
+ size_t limit;
48
+ int busy;
49
+ } integration_cquad_workspace;
50
+ typedef struct {
51
+ gsl_integration_cquad_workspace *workspace;
52
+ integration_cquad_workspace *owner;
53
+ } integration_cquad_workspace_use;
54
+ void integration_cquad_workspace_init(VALUE integration_module);
55
+ void integration_cquad_workspace_use_begin(
56
+ VALUE workspace_value, size_t *limit, int limit_given,
57
+ integration_cquad_workspace_use *use);
58
+ VALUE integration_cquad_workspace_use_end(VALUE data);
59
+ typedef struct {
60
+ gsl_integration_romberg_workspace *workspace;
61
+ size_t limit;
62
+ int busy;
63
+ } integration_romberg_workspace;
64
+ typedef struct {
65
+ gsl_integration_romberg_workspace *workspace;
66
+ integration_romberg_workspace *owner;
67
+ } integration_romberg_workspace_use;
68
+ void integration_romberg_workspace_init(VALUE integration_module);
69
+ void integration_romberg_workspace_use_begin(
70
+ VALUE workspace_value, size_t *limit, int limit_given,
71
+ integration_romberg_workspace_use *use);
72
+ VALUE integration_romberg_workspace_use_end(VALUE data);
73
+ typedef struct {
74
+ gsl_integration_glfixed_table *table;
75
+ size_t order;
76
+ int busy;
77
+ } integration_glfixed_table;
78
+ typedef struct {
79
+ gsl_integration_glfixed_table *table;
80
+ integration_glfixed_table *owner;
81
+ } integration_glfixed_table_use;
82
+ void integration_glfixed_table_init(VALUE integration_module);
83
+ void integration_glfixed_table_use_begin(VALUE table_value, size_t *order,
84
+ int order_given,
85
+ integration_glfixed_table_use *use);
86
+ VALUE integration_glfixed_table_use_end(VALUE data);
40
87
  typedef struct {
41
88
  gsl_integration_qawo_table *table;
42
89
  double omega;
@@ -58,6 +105,11 @@ void integration_qawo_table_use_begin(VALUE table_value, double omega,
58
105
  size_t levels,
59
106
  integration_qawo_table_use *use);
60
107
  VALUE integration_qawo_table_use_end(VALUE data);
108
+ void integration_qawf_table_init(VALUE integration_module);
109
+ void integration_qawf_table_use_begin(VALUE table_value, double omega,
110
+ enum gsl_integration_qawo_enum sine,
111
+ size_t levels,
112
+ integration_qawo_table_use *use);
61
113
 
62
114
  typedef struct {
63
115
  gsl_integration_qaws_table *table;
@@ -8,9 +8,14 @@ typedef struct {
8
8
  enum gsl_integration_qawo_enum sine;
9
9
  double epsabs;
10
10
  size_t limit;
11
- gsl_integration_workspace *workspace;
12
- gsl_integration_workspace *cycle_workspace;
13
- gsl_integration_qawo_table *table;
11
+ VALUE workspace_value;
12
+ VALUE cycle_workspace_value;
13
+ VALUE table_value;
14
+ integration_workspace_use workspace_use;
15
+ integration_workspace_use cycle_workspace_use;
16
+ integration_qawo_table_use table_use;
17
+ size_t cycle_workspace_native_limit;
18
+ int cycle_workspace_limit_changed;
14
19
  double *result;
15
20
  double *error;
16
21
  } integration_qawf_params;
@@ -18,17 +23,16 @@ typedef struct {
18
23
  static VALUE integration_free_qawf_resources(VALUE data) {
19
24
  integration_qawf_params *params = (integration_qawf_params *)data;
20
25
 
21
- if (params->table != NULL) {
22
- gsl_integration_qawo_table_free(params->table);
23
- }
26
+ integration_qawo_table_use_end((VALUE)&params->table_use);
24
27
 
25
- if (params->cycle_workspace != NULL) {
26
- gsl_integration_workspace_free(params->cycle_workspace);
28
+ if (params->cycle_workspace_limit_changed) {
29
+ params->cycle_workspace_use.workspace->limit =
30
+ params->cycle_workspace_native_limit;
31
+ params->cycle_workspace_limit_changed = 0;
27
32
  }
28
33
 
29
- if (params->workspace != NULL) {
30
- gsl_integration_workspace_free(params->workspace);
31
- }
34
+ integration_workspace_use_end((VALUE)&params->cycle_workspace_use);
35
+ integration_workspace_use_end((VALUE)&params->workspace_use);
32
36
 
33
37
  return Qnil;
34
38
  }
@@ -36,15 +40,25 @@ static VALUE integration_free_qawf_resources(VALUE data) {
36
40
  static VALUE integration_run_qawf(VALUE data) {
37
41
  integration_qawf_params *params = (integration_qawf_params *)data;
38
42
 
39
- params->table = gsl_integration_qawo_table_alloc(params->omega, 1.0,
40
- params->sine, params->limit);
41
- params->workspace = gsl_integration_workspace_alloc(params->limit);
42
- params->cycle_workspace = gsl_integration_workspace_alloc(params->limit);
43
+ integration_workspace_use_begin(params->workspace_value, &params->limit, 1,
44
+ &params->workspace_use);
45
+ integration_workspace_use_begin_named(
46
+ params->cycle_workspace_value, &params->limit, 1,
47
+ &params->cycle_workspace_use, "cycle_workspace");
48
+
49
+ params->cycle_workspace_native_limit =
50
+ params->cycle_workspace_use.workspace->limit;
51
+ params->cycle_workspace_use.workspace->limit = params->limit;
52
+ params->cycle_workspace_limit_changed = 1;
43
53
 
44
- (void)gsl_integration_qawf(params->function, params->a, params->epsabs,
45
- params->limit, params->workspace,
46
- params->cycle_workspace, params->table,
47
- params->result, params->error);
54
+ integration_qawf_table_use_begin(params->table_value, params->omega,
55
+ params->sine, params->limit,
56
+ &params->table_use);
57
+
58
+ (void)gsl_integration_qawf(
59
+ params->function, params->a, params->epsabs, params->limit,
60
+ params->workspace_use.workspace, params->cycle_workspace_use.workspace,
61
+ params->table_use.table, params->result, params->error);
48
62
 
49
63
  return Qnil;
50
64
  }
@@ -61,13 +75,23 @@ VALUE integration_qawf(int argc, VALUE *argv, VALUE self) {
61
75
  VALUE options;
62
76
  VALUE epsabs_value = Qundef;
63
77
  VALUE limit_value = Qundef;
64
- ID keywords[] = {rb_intern("epsabs"), rb_intern("limit")};
65
- VALUE keyword_values[2];
78
+ VALUE workspace_value = Qundef;
79
+ VALUE cycle_workspace_value = Qundef;
80
+ VALUE table_value = Qundef;
81
+ ID keywords[] = {rb_intern("epsabs"), rb_intern("limit"),
82
+ rb_intern("workspace"), rb_intern("cycle_workspace"),
83
+ rb_intern("table")};
84
+ VALUE keyword_values[5];
66
85
  double epsabs;
67
- size_t limit;
86
+ size_t limit = 1000;
87
+ size_t workspace_capacity = 0;
88
+ size_t cycle_workspace_capacity = 0;
89
+ int limit_given;
90
+ int workspace_given;
91
+ int cycle_workspace_given;
68
92
  gsl_function function;
69
93
  integration_callback_params params;
70
- integration_qawf_params qawf_params;
94
+ integration_qawf_params qawf_params = {0};
71
95
  double result;
72
96
  double error;
73
97
  int state = 0;
@@ -77,25 +101,74 @@ VALUE integration_qawf(int argc, VALUE *argv, VALUE self) {
77
101
  rb_scan_args(argc, argv, "3:", &a, &omega, &sine, &options);
78
102
 
79
103
  if (!NIL_P(options)) {
80
- rb_get_kwargs(options, keywords, 0, 2, keyword_values);
104
+ rb_get_kwargs(options, keywords, 0, 5, keyword_values);
81
105
  epsabs_value = keyword_values[0];
82
106
  limit_value = keyword_values[1];
107
+ workspace_value = keyword_values[2];
108
+ cycle_workspace_value = keyword_values[3];
109
+ table_value = keyword_values[4];
83
110
  }
84
111
 
112
+ qawf_params.a = NUM2DBL(a);
113
+ qawf_params.omega = NUM2DBL(omega);
114
+ if (!RB_INTEGER_TYPE_P(sine)) {
115
+ rb_raise(rb_eTypeError, "sine must be an Integer");
116
+ }
117
+ qawf_params.sine = (enum gsl_integration_qawo_enum)NUM2INT(sine);
118
+ if (qawf_params.sine != GSL_INTEG_SINE &&
119
+ qawf_params.sine != GSL_INTEG_COSINE) {
120
+ rb_raise(rb_eArgError, "sine must be SINE or COSINE");
121
+ }
85
122
  epsabs = epsabs_value == Qundef ? 1e-10 : NUM2DBL(epsabs_value);
86
- limit = limit_value == Qundef ? 1000 : NUM2SIZET(limit_value);
123
+ limit_given = limit_value != Qundef;
124
+ if (limit_given) {
125
+ limit = NUM2SIZET(limit_value);
126
+ }
127
+
128
+ workspace_given = workspace_value != Qundef;
129
+ cycle_workspace_given = cycle_workspace_value != Qundef;
130
+
131
+ if (workspace_given) {
132
+ workspace_capacity =
133
+ integration_workspace_capacity(workspace_value, "workspace");
134
+ }
135
+ if (cycle_workspace_given) {
136
+ cycle_workspace_capacity = integration_workspace_capacity(
137
+ cycle_workspace_value, "cycle_workspace");
138
+ }
139
+ if (workspace_given && cycle_workspace_given &&
140
+ workspace_value == cycle_workspace_value) {
141
+ rb_raise(rb_eArgError,
142
+ "workspace and cycle_workspace must be different objects");
143
+ }
144
+
145
+ if (!limit_given) {
146
+ if (workspace_given && cycle_workspace_given) {
147
+ limit = workspace_capacity < cycle_workspace_capacity
148
+ ? workspace_capacity
149
+ : cycle_workspace_capacity;
150
+ } else if (workspace_given) {
151
+ limit = workspace_capacity;
152
+ } else if (cycle_workspace_given) {
153
+ limit = cycle_workspace_capacity;
154
+ }
155
+ }
156
+
157
+ if (workspace_given && limit > workspace_capacity) {
158
+ rb_raise(rb_eArgError, "limit exceeds workspace capacity");
159
+ }
160
+ if (cycle_workspace_given && limit > cycle_workspace_capacity) {
161
+ rb_raise(rb_eArgError, "limit exceeds cycle_workspace capacity");
162
+ }
87
163
 
88
164
  integration_function_init(&function, &params);
89
165
 
90
166
  qawf_params.function = &function;
91
- qawf_params.a = NUM2DBL(a);
92
- qawf_params.omega = NUM2DBL(omega);
93
- qawf_params.sine = (enum gsl_integration_qawo_enum)NUM2INT(sine);
94
167
  qawf_params.epsabs = epsabs;
95
168
  qawf_params.limit = limit;
96
- qawf_params.workspace = NULL;
97
- qawf_params.cycle_workspace = NULL;
98
- qawf_params.table = NULL;
169
+ qawf_params.workspace_value = workspace_value;
170
+ qawf_params.cycle_workspace_value = cycle_workspace_value;
171
+ qawf_params.table_value = table_value;
99
172
  qawf_params.result = &result;
100
173
  qawf_params.error = &error;
101
174
 
@@ -103,6 +176,9 @@ VALUE integration_qawf(int argc, VALUE *argv, VALUE self) {
103
176
 
104
177
  RB_GC_GUARD(params.block);
105
178
  RB_GC_GUARD(params.exception);
179
+ RB_GC_GUARD(workspace_value);
180
+ RB_GC_GUARD(cycle_workspace_value);
181
+ RB_GC_GUARD(table_value);
106
182
 
107
183
  integration_finish_callback(&params, state);
108
184