ruby-mpfi 0.0.5 → 0.0.6

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.
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ $hoe = Hoe.spec 'ruby-mpfi' do
14
14
  self.developer 'Takayuki YAMAGUCHI', 'd@ytak.info'
15
15
  self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
16
  self.rubyforge_name = self.name # TODO this is default value
17
- self.extra_deps = [['ruby-mpfr','>= 0.0.4']]
17
+ self.extra_deps = [['ruby-mpfr','>= 0.0.11']]
18
18
  self.spec_extras[:extensions] = ["ext/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/extconf.rb"]
19
19
  self.extra_rdoc_files << 'README.rdoc'
20
20
  end
data/ext/mpfi/ruby_mpfi.c CHANGED
@@ -15,7 +15,7 @@ void r_mpfi_set_function_state(int num)
15
15
  }
16
16
 
17
17
  /* Return state of last function of MPFI. */
18
- VALUE r_mpfr_get_function_state(VALUE self)
18
+ VALUE r_mpfi_get_function_state(VALUE self)
19
19
  {
20
20
  return rb_cv_get(r_mpfi_class, CLASS_VAL_FUNCTION_STATE);
21
21
  }
@@ -216,6 +216,57 @@ static VALUE r_mpfi_swap (VALUE self, VALUE other)
216
216
  return self;
217
217
  }
218
218
 
219
+ char *r_mpfi_dump_to_string(MPFI *ptr_s)
220
+ {
221
+ char *ret_str, *str_right, *str_left;
222
+ str_left = r_mpfr_dump_to_string(r_mpfi_left_ptr(ptr_s));
223
+ str_right = r_mpfr_dump_to_string(r_mpfi_right_ptr(ptr_s));
224
+ if(!mpfr_asprintf(&ret_str, "%s %s", str_left, str_right)) {
225
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
226
+ }
227
+ mpfr_free_str(str_left);
228
+ mpfr_free_str(str_right);
229
+ return ret_str;
230
+ }
231
+
232
+ static VALUE r_mpfi_marshal_dump(VALUE self)
233
+ {
234
+ MPFI *ptr_s;
235
+ r_mpfi_get_struct(ptr_s, self);
236
+ char *ret_str = r_mpfi_dump_to_string(ptr_s);
237
+ VALUE ret_val = rb_str_new2(ret_str);
238
+ mpfr_free_str(ret_str);
239
+ return ret_val;
240
+ }
241
+
242
+ void r_mpfi_load_string(MPFI *ptr_s, const char *dump)
243
+ {
244
+ int i;
245
+ char *left;
246
+ i = 0;
247
+ while (dump[i] != ' ') {
248
+ i++;
249
+ }
250
+ i++;
251
+ left = malloc(sizeof(char) * i);
252
+ strncpy(left, dump, i - 1);
253
+ left[i - 1] = '\0';
254
+ r_mpfr_load_string(r_mpfi_left_ptr(ptr_s), left);
255
+ free(left);
256
+ r_mpfr_load_string(r_mpfi_right_ptr(ptr_s), dump + i);
257
+ }
258
+
259
+ static VALUE r_mpfi_marshal_load(VALUE self, VALUE dump_string)
260
+ {
261
+ MPFI *ptr_s;
262
+ char *dump;
263
+ r_mpfi_get_struct(ptr_s, self);
264
+ Check_Type(dump_string, T_STRING);
265
+ dump = RSTRING_PTR(dump_string);
266
+ r_mpfi_load_string(ptr_s, dump);
267
+ return self;
268
+ }
269
+
219
270
  /* ------------------------------ allocation end ------------------------------ */
220
271
 
221
272
  /* ------------------------------ Rounding Modes and Precision Handling start ------------------------------*/
@@ -264,8 +315,11 @@ static VALUE r_mpfi_inspect(VALUE self)
264
315
  MPFI *ptr_s;
265
316
  r_mpfi_get_struct(ptr_s, self);
266
317
  char *ret_str;
267
- mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re'],%d>",
268
- NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s), r_mpfi_right_ptr(ptr_s), mpfi_get_prec(ptr_s));
318
+ if (!mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re'],%d>",
319
+ NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s),
320
+ r_mpfi_right_ptr(ptr_s), mpfi_get_prec(ptr_s))) {
321
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
322
+ }
269
323
  VALUE ret_val = rb_str_new2(ret_str);
270
324
  mpfr_free_str(ret_str);
271
325
  return ret_val;
@@ -277,8 +331,12 @@ static VALUE r_mpfi_to_str_ary(VALUE self)
277
331
  MPFI *ptr_self;
278
332
  r_mpfi_get_struct(ptr_self, self);
279
333
  char *ret_str1, *ret_str2;
280
- mpfr_asprintf(&ret_str1, "%.Re", r_mpfi_left_ptr(ptr_self));
281
- mpfr_asprintf(&ret_str2, "%.Re", r_mpfi_right_ptr(ptr_self));
334
+ if (!mpfr_asprintf(&ret_str1, "%.Re", r_mpfi_left_ptr(ptr_self))) {
335
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
336
+ }
337
+ if (!mpfr_asprintf(&ret_str2, "%.Re", r_mpfi_right_ptr(ptr_self))) {
338
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
339
+ }
282
340
  VALUE str1 = rb_str_new2(ret_str1), str2 = rb_str_new2(ret_str2);
283
341
  mpfr_free_str(ret_str1);
284
342
  mpfr_free_str(ret_str2);
@@ -292,8 +350,12 @@ static VALUE r_mpfi_to_strf_ary(VALUE self, VALUE format_str)
292
350
  r_mpfi_get_struct(ptr_self, self);
293
351
  char *format = StringValuePtr(format_str);
294
352
  char *ret_str1, *ret_str2;
295
- mpfr_asprintf(&ret_str1, format, r_mpfi_left_ptr(ptr_self));
296
- mpfr_asprintf(&ret_str2, format, r_mpfi_right_ptr(ptr_self));
353
+ if (!mpfr_asprintf(&ret_str1, format, r_mpfi_left_ptr(ptr_self))) {
354
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
355
+ }
356
+ if (!mpfr_asprintf(&ret_str2, format, r_mpfi_right_ptr(ptr_self))) {
357
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
358
+ }
297
359
  VALUE str1 = rb_str_new2(ret_str1), str2 = rb_str_new2(ret_str2);
298
360
  mpfr_free_str(ret_str1);
299
361
  mpfr_free_str(ret_str2);
@@ -1484,7 +1546,7 @@ void Init_mpfi()
1484
1546
 
1485
1547
  /* ------------------------------ function state start ------------------------------ */
1486
1548
  rb_define_class_variable(r_mpfi_class, CLASS_VAL_FUNCTION_STATE, INT2FIX(0));
1487
- rb_define_singleton_method(r_mpfi_class, "function_state", r_mpfr_get_function_state, 0);
1549
+ rb_define_singleton_method(r_mpfi_class, "function_state", r_mpfi_get_function_state, 0);
1488
1550
  /* ------------------------------ function state end ------------------------------ */
1489
1551
 
1490
1552
  /* ------------------------------ allocation start ------------------------------ */
@@ -1507,6 +1569,9 @@ void Init_mpfi()
1507
1569
  /* ------------------------------ string start ------------------------------ */
1508
1570
  rb_define_method(r_mpfi_class, "inspect", r_mpfi_inspect, 0);
1509
1571
 
1572
+ rb_define_method(r_mpfi_class, "marshal_dump", r_mpfi_marshal_dump, 0);
1573
+ rb_define_method(r_mpfi_class, "marshal_load", r_mpfi_marshal_load, 1);
1574
+
1510
1575
  rb_define_method(r_mpfi_class, "to_str_ary", r_mpfi_to_str_ary, 0);
1511
1576
  rb_define_method(r_mpfi_class, "to_strf_ary", r_mpfi_to_strf_ary, 1);
1512
1577
  /* ------------------------------ string end ------------------------------ */
data/ext/mpfi/ruby_mpfi.h CHANGED
@@ -34,6 +34,9 @@ void r_mpfi_set_robj(MPFI *ptr, VALUE obj);
34
34
  int r_mpfi_subdivision2(int num, MPFI *ret, mpfi_t x);
35
35
 
36
36
  void r_mpfi_set_function_state(int num);
37
- VALUE r_mpfr_get_function_state(VALUE self);
37
+ VALUE r_mpfi_get_function_state(VALUE self);
38
+
39
+ void r_mpfi_load_string(MPFI *ptr_s, const char *dump);
40
+ char *r_mpfi_dump_to_string(MPFI *ptr_s);
38
41
 
39
42
  #endif /* _RUBY_MPFI_H_ */
data/ext/mpfi/ruby_mpfr.h CHANGED
@@ -26,13 +26,19 @@ VALUE r_mpfr_class, r_mpfr_math;
26
26
  #define r_mpfr_check_non_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) > 0) rb_raise(rb_eArgError, "Not a non positive number."); }
27
27
 
28
28
  void r_mpfr_free(void *ptr);
29
+ VALUE r_mpfr_make_new_fr_obj(MPFR *ptr);
30
+ VALUE r_mpfr_make_new_fr_obj2(MPFR *ptr, int prec);
29
31
  VALUE r_mpfr_new_fr_obj(VALUE obj);
30
32
  void r_mpfr_set_robj(MPFR *ptr, VALUE obj, mp_rnd_t rnd);
33
+ VALUE r_mpfr_robj_to_mpfr(VALUE obj, int argc, VALUE *argv);
31
34
 
32
35
  mp_rnd_t r_mpfr_rnd_from_value(VALUE rnd);
33
36
  mp_rnd_t r_mpfr_rnd_from_optional_argument(int min, int max, int argc, VALUE *argv);
34
37
  mp_rnd_t r_mpfr_prec_from_optional_argument(int min, int max, int argc, VALUE *argv);
35
38
  void r_mpfr_get_rnd_prec_from_optional_arguments(mp_rnd_t *rnd, mp_prec_t *prec, int min, int max, int argc, VALUE *argv);
36
39
 
40
+ char *r_mpfr_dump_to_string(MPFR *ptr_s);
41
+ void r_mpfr_load_string(MPFR *ptr_s, const char *dump);
42
+
37
43
  #endif /* _RUBY_MPFR_H_ */
38
44
 
@@ -34,6 +34,9 @@ void r_mpfi_set_robj(MPFI *ptr, VALUE obj);
34
34
  int r_mpfi_subdivision2(int num, MPFI *ret, mpfi_t x);
35
35
 
36
36
  void r_mpfi_set_function_state(int num);
37
- VALUE r_mpfr_get_function_state(VALUE self);
37
+ VALUE r_mpfi_get_function_state(VALUE self);
38
+
39
+ void r_mpfi_load_string(MPFI *ptr_s, const char *dump);
40
+ char *r_mpfi_dump_to_string(MPFI *ptr_s);
38
41
 
39
42
  #endif /* _RUBY_MPFI_H_ */
@@ -132,9 +132,12 @@ static VALUE r_mpfi_complex_inspect(VALUE self){
132
132
  MPFIComplex *ptr_s;
133
133
  r_mpfi_get_complex_struct(ptr_s, self);
134
134
  char *ret_str;
135
- mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re', '%.Re %.Re'], [%d, %d]>",
136
- NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s->re), r_mpfi_right_ptr(ptr_s->re), r_mpfi_left_ptr(ptr_s->im), r_mpfi_right_ptr(ptr_s->im),
137
- mpfi_get_prec(ptr_s->re), mpfi_get_prec(ptr_s->im));
135
+ if (!mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re', '%.Re %.Re'], [%d, %d]>",
136
+ NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s->re),
137
+ r_mpfi_right_ptr(ptr_s->re), r_mpfi_left_ptr(ptr_s->im), r_mpfi_right_ptr(ptr_s->im),
138
+ mpfi_get_prec(ptr_s->re), mpfi_get_prec(ptr_s->im))) {
139
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
140
+ }
138
141
  VALUE ret_val = rb_str_new2(ret_str);
139
142
  mpfr_free_str(ret_str);
140
143
  return ret_val;
@@ -26,13 +26,19 @@ VALUE r_mpfr_class, r_mpfr_math;
26
26
  #define r_mpfr_check_non_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) > 0) rb_raise(rb_eArgError, "Not a non positive number."); }
27
27
 
28
28
  void r_mpfr_free(void *ptr);
29
+ VALUE r_mpfr_make_new_fr_obj(MPFR *ptr);
30
+ VALUE r_mpfr_make_new_fr_obj2(MPFR *ptr, int prec);
29
31
  VALUE r_mpfr_new_fr_obj(VALUE obj);
30
32
  void r_mpfr_set_robj(MPFR *ptr, VALUE obj, mp_rnd_t rnd);
33
+ VALUE r_mpfr_robj_to_mpfr(VALUE obj, int argc, VALUE *argv);
31
34
 
32
35
  mp_rnd_t r_mpfr_rnd_from_value(VALUE rnd);
33
36
  mp_rnd_t r_mpfr_rnd_from_optional_argument(int min, int max, int argc, VALUE *argv);
34
37
  mp_rnd_t r_mpfr_prec_from_optional_argument(int min, int max, int argc, VALUE *argv);
35
38
  void r_mpfr_get_rnd_prec_from_optional_arguments(mp_rnd_t *rnd, mp_prec_t *prec, int min, int max, int argc, VALUE *argv);
36
39
 
40
+ char *r_mpfr_dump_to_string(MPFR *ptr_s);
41
+ void r_mpfr_load_string(MPFR *ptr_s, const char *dump);
42
+
37
43
  #endif /* _RUBY_MPFR_H_ */
38
44
 
@@ -34,6 +34,9 @@ void r_mpfi_set_robj(MPFI *ptr, VALUE obj);
34
34
  int r_mpfi_subdivision2(int num, MPFI *ret, mpfi_t x);
35
35
 
36
36
  void r_mpfi_set_function_state(int num);
37
- VALUE r_mpfr_get_function_state(VALUE self);
37
+ VALUE r_mpfi_get_function_state(VALUE self);
38
+
39
+ void r_mpfi_load_string(MPFI *ptr_s, const char *dump);
40
+ char *r_mpfi_dump_to_string(MPFI *ptr_s);
38
41
 
39
42
  #endif /* _RUBY_MPFI_H_ */
@@ -208,7 +208,7 @@ static VALUE r_mpfi_col_vector_global_new(int argc, VALUE arg)
208
208
  {
209
209
  MPFIMatrix *ptr;
210
210
  VALUE val;
211
- r_mpfi_make_matrix_struct(val, ptr);
211
+ r_mpfi_make_col_vector_struct(val, ptr);
212
212
  r_mpfi_col_vector_set_initial_value(ptr, arg);
213
213
  return val;
214
214
  }
@@ -270,6 +270,48 @@ static VALUE r_mpfi_row_vector_initialize (VALUE self, VALUE arg){
270
270
  return Qtrue;
271
271
  }
272
272
 
273
+ static VALUE r_mpfi_matrix_marshal_dump(VALUE self)
274
+ {
275
+ MPFIMatrix *ptr;
276
+ r_mpfi_get_matrix_struct(ptr, self);
277
+ int i;
278
+ char *tmp_str;
279
+ VALUE ret_ary;
280
+ ret_ary = rb_ary_new();
281
+ rb_ary_push(ret_ary, INT2FIX(ptr->row));
282
+ rb_ary_push(ret_ary, INT2FIX(ptr->column));
283
+
284
+ for (i = 0; i < ptr->size; i++) {
285
+ tmp_str = r_mpfi_dump_to_string(ptr->data + i);
286
+ rb_ary_push(ret_ary, rb_str_new2(tmp_str));
287
+ mpfr_free_str(tmp_str);
288
+ }
289
+
290
+ return ret_ary;
291
+ }
292
+
293
+ static VALUE r_mpfi_matrix_marshal_load(VALUE self, VALUE dump_ary)
294
+ {
295
+ MPFIMatrix *ptr;
296
+ r_mpfi_get_matrix_struct(ptr, self);
297
+
298
+ ptr->row = NUM2INT(rb_ary_entry(dump_ary, 0));
299
+ ptr->column = NUM2INT(rb_ary_entry(dump_ary, 1));
300
+ ptr->size = ptr->row * ptr->column;
301
+ ptr->data = ALLOC_N(MPFI, ptr->size);
302
+ int i;
303
+ char *dump;
304
+ VALUE dump_element;
305
+
306
+ for(i = 0; i < ptr->size; i++){
307
+ dump_element = rb_ary_entry(dump_ary, i + 2);
308
+ Check_Type(dump_element, T_STRING);
309
+ dump = RSTRING_PTR(dump_element);
310
+ r_mpfi_load_string(ptr->data + i, dump);
311
+ }
312
+ return self;
313
+ }
314
+
273
315
  /* Return size of data array which equals to column * row. */
274
316
  static VALUE r_mpfi_matrix_size (VALUE self){
275
317
  MPFIMatrix *ptr_self;
@@ -373,8 +415,10 @@ static VALUE r_mpfi_matrix_str_ary_for_inspect(VALUE self){
373
415
  VALUE ret_val[ptr_self->size];
374
416
  int i;
375
417
  for (i = 0; i < ptr_self->size; i++) {
376
- mpfr_asprintf(&tmp_str, "%.Re %.Re",
377
- r_mpfi_left_ptr((ptr_self->data + i)), r_mpfi_right_ptr(ptr_self->data + i));
418
+ if(!mpfr_asprintf(&tmp_str, "%.Re %.Re",
419
+ r_mpfi_left_ptr((ptr_self->data + i)), r_mpfi_right_ptr(ptr_self->data + i))) {
420
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
421
+ }
378
422
  ret_val[i] = rb_str_new2(tmp_str);
379
423
  mpfr_free_str(tmp_str);
380
424
  }
@@ -393,8 +437,10 @@ static VALUE r_mpfi_matrix_str_ary_for_inspect2(VALUE self){
393
437
  }
394
438
  for (i = 0; i < ptr_self->size; i += ptr_self->row) {
395
439
  for (j = 0; j < ptr_self->row; j++) {
396
- mpfr_asprintf(&tmp_str, "%.Re %.Re",
397
- r_mpfi_left_ptr((ptr_self->data + i + j)), r_mpfi_right_ptr(ptr_self->data + i + j));
440
+ if(!mpfr_asprintf(&tmp_str, "%.Re %.Re",
441
+ r_mpfi_left_ptr((ptr_self->data + i + j)), r_mpfi_right_ptr(ptr_self->data + i + j))) {
442
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
443
+ }
398
444
  rb_ary_push(ary[j], rb_str_new2(tmp_str));
399
445
  mpfr_free_str(tmp_str);
400
446
  }
@@ -413,8 +459,12 @@ static VALUE r_mpfi_matrix_to_str_ary(VALUE self){
413
459
  }
414
460
  for (i = 0; i < ptr_self->size; i += ptr_self->row) {
415
461
  for (j = 0; j < ptr_self->row; j++) {
416
- mpfr_asprintf(&tmp_str1, "%.Re", r_mpfi_left_ptr((ptr_self->data + i + j)));
417
- mpfr_asprintf(&tmp_str2, "%.Re", r_mpfi_right_ptr(ptr_self->data + i + j));
462
+ if (!mpfr_asprintf(&tmp_str1, "%.Re", r_mpfi_left_ptr((ptr_self->data + i + j)))) {
463
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
464
+ }
465
+ if (!mpfr_asprintf(&tmp_str2, "%.Re", r_mpfi_right_ptr(ptr_self->data + i + j))) {
466
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
467
+ }
418
468
  rb_ary_push(ary[j], rb_ary_new3(2, rb_str_new2(tmp_str1), rb_str_new2(tmp_str2)));
419
469
  mpfr_free_str(tmp_str1);
420
470
  mpfr_free_str(tmp_str2);
@@ -435,8 +485,12 @@ static VALUE r_mpfi_matrix_to_strf_ary(VALUE self, VALUE format_str){
435
485
  }
436
486
  for (i = 0; i < ptr_self->size; i += ptr_self->row) {
437
487
  for (j = 0; j < ptr_self->row; j++) {
438
- mpfr_asprintf(&tmp_str1, format, r_mpfi_left_ptr((ptr_self->data + i + j)));
439
- mpfr_asprintf(&tmp_str2, format, r_mpfi_right_ptr(ptr_self->data + i + j));
488
+ if(!mpfr_asprintf(&tmp_str1, format, r_mpfi_left_ptr((ptr_self->data + i + j)))) {
489
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
490
+ }
491
+ if(!mpfr_asprintf(&tmp_str2, format, r_mpfi_right_ptr(ptr_self->data + i + j))) {
492
+ rb_raise(rb_eFatal, "Can not allocate a string by mpfr_asprintf.");
493
+ }
440
494
  rb_ary_push(ary[j], rb_ary_new3(2, rb_str_new2(tmp_str1), rb_str_new2(tmp_str2)));
441
495
  mpfr_free_str(tmp_str1);
442
496
  mpfr_free_str(tmp_str2);
@@ -1151,6 +1205,9 @@ void Init_matrix(){
1151
1205
  rb_define_private_method(r_mpfi_matrix, "initialize", r_mpfi_matrix_initialize, -1);
1152
1206
  rb_define_private_method(r_mpfi_matrix, "initialize_copy", r_mpfi_matrix_initialize_copy, 1);
1153
1207
 
1208
+ rb_define_method(r_mpfi_matrix, "marshal_dump", r_mpfi_matrix_marshal_dump, 0);
1209
+ rb_define_method(r_mpfi_matrix, "marshal_load", r_mpfi_matrix_marshal_load, 1);
1210
+
1154
1211
  rb_define_singleton_method(tmp_r_mpfi_class, "SquareMatrix", r_mpfi_square_matrix_global_new, 1);
1155
1212
  rb_define_alloc_func(r_mpfi_square_matrix, r_mpfi_square_matrix_alloc);
1156
1213
  rb_define_private_method(r_mpfi_square_matrix, "initialize", r_mpfi_square_matrix_initialize, 1);
@@ -1228,9 +1285,6 @@ void Init_matrix(){
1228
1285
  /* Initialization of MPFI::Vector module */
1229
1286
  r_mpfi_vector_module = rb_define_module_under(tmp_r_mpfi_class, "Vector");
1230
1287
 
1231
- rb_include_module(r_mpfi_col_vector, r_mpfi_vector_module);
1232
- rb_include_module(r_mpfi_row_vector, r_mpfi_vector_module);
1233
-
1234
1288
  rb_define_method(r_mpfi_vector_module, "[]=", r_mpfi_vector_set_element, 2);
1235
1289
  rb_define_method(r_mpfi_vector_module, "[]", r_mpfi_vector_element, 1);
1236
1290
  rb_define_method(r_mpfi_vector_module, "each_element", r_mpfi_vector_each_element, 0);
@@ -1256,6 +1310,8 @@ void Init_matrix(){
1256
1310
 
1257
1311
  rb_define_method(r_mpfr_matrix, "to_fi_matrix", r_mpfr_matrix_to_fi_matrix, 0);
1258
1312
 
1313
+ rb_include_module(r_mpfi_col_vector, r_mpfi_vector_module);
1314
+ rb_include_module(r_mpfi_row_vector, r_mpfi_vector_module);
1259
1315
 
1260
1316
  eqq = rb_intern("===");
1261
1317
  __mpfr_matrix_class__ = rb_eval_string("MPFR::Matrix");
@@ -26,13 +26,19 @@ VALUE r_mpfr_class, r_mpfr_math;
26
26
  #define r_mpfr_check_non_positive_number(c_val) { if(mpfr_number_p(c_val) == 0 && mpfr_sgn(c_val) > 0) rb_raise(rb_eArgError, "Not a non positive number."); }
27
27
 
28
28
  void r_mpfr_free(void *ptr);
29
+ VALUE r_mpfr_make_new_fr_obj(MPFR *ptr);
30
+ VALUE r_mpfr_make_new_fr_obj2(MPFR *ptr, int prec);
29
31
  VALUE r_mpfr_new_fr_obj(VALUE obj);
30
32
  void r_mpfr_set_robj(MPFR *ptr, VALUE obj, mp_rnd_t rnd);
33
+ VALUE r_mpfr_robj_to_mpfr(VALUE obj, int argc, VALUE *argv);
31
34
 
32
35
  mp_rnd_t r_mpfr_rnd_from_value(VALUE rnd);
33
36
  mp_rnd_t r_mpfr_rnd_from_optional_argument(int min, int max, int argc, VALUE *argv);
34
37
  mp_rnd_t r_mpfr_prec_from_optional_argument(int min, int max, int argc, VALUE *argv);
35
38
  void r_mpfr_get_rnd_prec_from_optional_arguments(mp_rnd_t *rnd, mp_prec_t *prec, int min, int max, int argc, VALUE *argv);
36
39
 
40
+ char *r_mpfr_dump_to_string(MPFR *ptr_s);
41
+ void r_mpfr_load_string(MPFR *ptr_s, const char *dump);
42
+
37
43
  #endif /* _RUBY_MPFR_H_ */
38
44
 
data/lib/mpfi/version.rb CHANGED
@@ -1 +1 @@
1
- RUBY_MPFI_VERSION = '0.0.5'
1
+ RUBY_MPFI_VERSION = '0.0.6'
@@ -1,5 +1,19 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper.rb'
2
2
 
3
+ describe MPFI::ColumnVector, "when creating MPFI::ColumnVector method" do
4
+ it "should return MPFI::ColumnVector" do
5
+ MPFI::ColumnVector([1, 2]).should be_an_instance_of MPFI::ColumnVector
6
+ MPFI::ColumnVector(3).should be_an_instance_of MPFI::ColumnVector
7
+ end
8
+ end
9
+
10
+ describe MPFI::RowVector, "when creating MPFI::RowVector method" do
11
+ it "should return MPFI::ColumnVector" do
12
+ MPFI::RowVector([1, 2]).should be_an_instance_of MPFI::RowVector
13
+ MPFI::ColumnVector(3).should be_an_instance_of MPFI::ColumnVector
14
+ end
15
+ end
16
+
3
17
  describe MPFI::ColumnVector, "when dividing to some parts" do
4
18
  before(:all) do
5
19
  MPFR.set_default_prec(128)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ruby-mpfi
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.5
5
+ version: 0.0.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Takayuki YAMAGUCHI
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-02-16 00:00:00 +09:00
13
+ date: 2011-02-26 00:00:00 +09:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -21,7 +21,7 @@ dependencies:
21
21
  requirements:
22
22
  - - ">="
23
23
  - !ruby/object:Gem::Version
24
- version: 0.0.4
24
+ version: 0.0.11
25
25
  type: :runtime
26
26
  version_requirements: *id001
27
27
  - !ruby/object:Gem::Dependency