ruby-mpfi 0.0.4 → 0.0.5

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/.gemtest ADDED
File without changes
data/Manifest.txt CHANGED
@@ -30,9 +30,6 @@ ext/mpfi_matrix/mpfi/ruby_mpfr_matrix.h
30
30
  lib/mpfi/matrix.rb
31
31
  lib/mpfi/version.rb
32
32
  ruby-mpfi.gemspec
33
- script/console
34
- script/destroy
35
- script/generate
36
33
  spec/mpfi/generate_number_module.rb
37
34
  spec/mpfi/mpfi_alloc_spec.rb
38
35
  spec/mpfi/mpfi_diam_arithmetic_spec.rb
@@ -42,6 +39,7 @@ spec/mpfi/mpfi_math_functions_spec.rb
42
39
  spec/mpfi/mpfi_set_operation_spec.rb
43
40
  spec/mpfi/ruby-mpfi_spec.rb
44
41
  spec/mpfi/spec_helper.rb
42
+ spec/mpfi/string_spec.rb
45
43
  spec/mpfi_complex/spec_helper.rb
46
44
  spec/mpfi_matrix/generate_matrix_arguments.rb
47
45
  spec/mpfi_matrix/mpfi_matrix_alloc_spec.rb
@@ -54,5 +52,4 @@ spec/mpfi_matrix/mpfi_matrix_subdivision_spec.rb
54
52
  spec/mpfi_matrix/mpfi_square_matrix_spec.rb
55
53
  spec/mpfi_matrix/mpfi_vector_spec.rb
56
54
  spec/mpfi_matrix/spec_helper.rb
57
- spec/spec.opts
58
55
  tasks/extconf.rake
data/Rakefile CHANGED
@@ -1,27 +1,45 @@
1
- require 'rubygems'
2
- gem 'hoe', '>= 2.1.0'
3
- require 'hoe'
4
- require 'fileutils'
5
- require './lib/mpfi/version.rb'
6
-
7
- Hoe.plugin :newgem
8
- # Hoe.plugin :website
9
- # Hoe.plugin :cucumberfeatures
10
-
11
- # Generate all the Rake tasks
12
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
- $hoe = Hoe.spec 'ruby-mpfi' do
14
- self.developer 'Takayuki YAMAGUCHI', 'd@ytak.info'
15
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
- self.rubyforge_name = self.name # TODO this is default value
17
- self.extra_deps = [['ruby-mpfr','>= 0.0.4']]
18
- self.spec_extras[:extensions] = ["ext/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/extconf.rb"]
19
- self.extra_rdoc_files << 'README.rdoc'
20
- end
21
-
22
- require 'newgem/tasks'
23
- Dir['tasks/**/*.rake'].each { |t| load t }
24
-
25
- # TODO - want other tests/tasks run by default? Add them to the list
26
- # remove_task :default
27
- # task :default => [:spec, :features]
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/mpfi/version.rb'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'ruby-mpfi' do
14
+ self.developer 'Takayuki YAMAGUCHI', 'd@ytak.info'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ self.extra_deps = [['ruby-mpfr','>= 0.0.4']]
18
+ self.spec_extras[:extensions] = ["ext/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/extconf.rb"]
19
+ self.extra_rdoc_files << 'README.rdoc'
20
+ end
21
+
22
+ desc "Run 'make realclean' for extended libraries"
23
+ task "ext:realclean" do
24
+ Dir.glob("ext/**/Makefile").each do |path|
25
+ system("cd #{File.dirname(path)}; make realclean")
26
+ end
27
+ end
28
+
29
+ desc "Run 'make clean' for extended libraries"
30
+ task "ext:clean" do
31
+ Dir.glob("ext/**/Makefile").each do |path|
32
+ system("cd #{File.dirname(path)}; make clean")
33
+ end
34
+ end
35
+
36
+ desc "Run 'make realclean' for extended libraries"
37
+ task 'ext:make' do
38
+ Dir.glob("ext/**/extconf.rb").each do |path|
39
+ system("cd #{File.dirname(path)}; ruby extconf.rb && make")
40
+ end
41
+ end
42
+
43
+ # TODO - want other tests/tasks run by default? Add them to the list
44
+ # remove_task :default
45
+ # task :default => [:spec, :features]
data/ext/mpfi/extconf.rb CHANGED
@@ -1,5 +1,19 @@
1
1
  require 'mkmf'
2
2
 
3
+ i = 0
4
+ while i < ARGV.size
5
+ case ARGV[i]
6
+ when '--ldflags'
7
+ if args = ARGV[i+1]
8
+ i += 1
9
+ $LDFLAGS += " #{args}"
10
+ end
11
+ else
12
+ raise "Invalid option: #{ARGV[i]}"
13
+ end
14
+ i += 1
15
+ end
16
+
3
17
  $CFLAGS += " -Wall"
4
18
 
5
19
  dir_config("mpfr")
data/ext/mpfi/ruby_mpfi.c CHANGED
@@ -39,16 +39,49 @@ VALUE r_mpfi_make_new_fi_obj(MPFI *ptr)
39
39
  return ret;
40
40
  }
41
41
 
42
- /* VALUE obj must have method to_s or to_str. */
43
- static void r_mpfi_set_from_object (MPFI *ptr, VALUE obj)
42
+ static void r_mpfi_set_interv_from_robjs (MPFI *ptr, VALUE a1, VALUE a2)
44
43
  {
44
+ if(RTEST(rb_funcall(__mpfr_class__, eqq, 1, a1)) && RTEST(rb_funcall(__mpfr_class__, eqq, 1, a2))){
45
+ MPFR *ptr_a1, *ptr_a2;
46
+ r_mpfr_get_struct(ptr_a1, a1);
47
+ r_mpfr_get_struct(ptr_a2, a2);
48
+ r_mpfi_set_function_state(mpfi_interv_fr(ptr, ptr_a1, ptr_a2));
49
+ }else if((TYPE(a1) == T_FIXNUM) && (TYPE(a2) == T_FIXNUM)){
50
+ r_mpfi_set_function_state(mpfi_interv_si(ptr, FIX2LONG(a1), FIX2LONG(a2)));
51
+ }else if((TYPE(a1) == T_FLOAT) && (TYPE(a2) == T_FLOAT)){
52
+ r_mpfi_set_function_state(mpfi_interv_d(ptr, NUM2DBL(a1), NUM2DBL(a2)));
53
+ }else{
54
+ MPFR *ptr_a1, *ptr_a2;
55
+ volatile VALUE tmp_a1 = r_mpfr_new_fr_obj(a1);
56
+ volatile VALUE tmp_a2 = r_mpfr_new_fr_obj(a2);
57
+ r_mpfr_get_struct(ptr_a1, tmp_a1);
58
+ r_mpfr_get_struct(ptr_a2, tmp_a2);
59
+ r_mpfi_set_function_state(mpfi_interv_fr(ptr, ptr_a1, ptr_a2));
60
+ }
61
+ }
62
+
63
+ static void r_mpfi_set_from_array (MPFI *ptr, VALUE obj)
64
+ {
65
+ if (RARRAY_LEN(obj) != 2) {
66
+ rb_raise(rb_eArgError, "Invalid size of array for MPFI initialization.");
67
+ }
68
+ r_mpfi_set_interv_from_robjs(ptr, rb_ary_entry(obj, 0), rb_ary_entry(obj, 1));
69
+ }
70
+
71
+ /* VALUE obj must have method to_s or to_str.
72
+ The formats of strings that we can use are "number" or "[number1, number2]"
73
+ (refer MPFI documents). */
74
+ static void r_mpfi_set_from_string (MPFI *ptr, VALUE obj)
75
+ {
76
+ char *str;
45
77
  if(RTEST(rb_funcall(rb_funcall(obj, class, 0), method_defined, 1, __sym_to_str__))){
46
- char *str = StringValuePtr(obj);
47
- mpfi_set_str(ptr, str, 10);
78
+ str = StringValuePtr(obj);
48
79
  }else if(RTEST(rb_funcall(rb_funcall(obj, class, 0), method_defined, 1, __sym_to_s__))){
49
80
  VALUE tmp = rb_funcall(obj, to_s, 0);
50
- char *str = StringValuePtr(tmp);
51
- mpfi_set_str(ptr, str, 10);
81
+ str = StringValuePtr(tmp);
82
+ }
83
+ if(mpfi_set_str(ptr, str, 10) != 0) {
84
+ rb_raise(rb_eArgError, "Invalid string format of MPFI initialization: \"%s\"", str);
52
85
  }
53
86
  }
54
87
 
@@ -70,8 +103,11 @@ void r_mpfi_set_robj(MPFI *ptr, VALUE obj)
70
103
  case T_FIXNUM:
71
104
  mpfi_set_si(ptr, FIX2LONG(obj));
72
105
  break;
106
+ case T_ARRAY:
107
+ r_mpfi_set_from_array(ptr, obj);
108
+ break;
73
109
  default:
74
- r_mpfi_set_from_object(ptr, obj);
110
+ r_mpfi_set_from_string(ptr, obj);
75
111
  break;
76
112
  }
77
113
  }
@@ -126,7 +162,11 @@ static VALUE r_mpfi_global_new(int argc, VALUE *argv, VALUE self)
126
162
  return val;
127
163
  }
128
164
 
129
- /* Two optional arguments are acceptable. First argument is value and second is precision. */
165
+ /* Two optional arguments are acceptable.
166
+ The first argument means value of number,
167
+ which is MPFR, Float, Fixnum, String, and Array having two elements.
168
+ The string must be "number" or "[number1, number2]" (refer MPFI documents).
169
+ The second one is precision and its class is Fixnum. */
130
170
  static VALUE r_mpfi_initialize(int argc, VALUE *argv, VALUE self)
131
171
  {
132
172
  MPFI *ptr;
@@ -225,7 +265,7 @@ static VALUE r_mpfi_inspect(VALUE self)
225
265
  r_mpfi_get_struct(ptr_s, self);
226
266
  char *ret_str;
227
267
  mpfr_asprintf(&ret_str, "#<MPFI:%lx,['%.Re %.Re'],%d>",
228
- NUM2LONG(rb_funcall(self, object_id, 0)), r_mpfi_left_ptr(ptr_s), r_mpfi_right_ptr(ptr_s), mpfi_get_prec(ptr_s));
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));
229
269
  VALUE ret_val = rb_str_new2(ret_str);
230
270
  mpfr_free_str(ret_str);
231
271
  return ret_val;
@@ -810,25 +850,8 @@ static VALUE r_mpfi_interv (VALUE self, VALUE a1, VALUE a2)
810
850
  {
811
851
  MPFI *ptr_self;
812
852
  r_mpfi_get_struct(ptr_self, self);
813
-
814
- if(RTEST(rb_funcall(__mpfr_class__, eqq, 1, a1)) && RTEST(rb_funcall(__mpfr_class__, eqq, 1, a2))){
815
- MPFR *ptr_a1, *ptr_a2;
816
- r_mpfr_get_struct(ptr_a1, a1);
817
- r_mpfr_get_struct(ptr_a2, a2);
818
- r_mpfi_set_function_state(mpfi_interv_fr(ptr_self, ptr_a1, ptr_a2));
819
- }else if((TYPE(a1) == T_FIXNUM) && (TYPE(a2) == T_FIXNUM)){
820
- r_mpfi_set_function_state(mpfi_interv_si(ptr_self, FIX2LONG(a1), FIX2LONG(a2)));
821
- }else if((TYPE(a1) == T_FLOAT) && (TYPE(a2) == T_FLOAT)){
822
- r_mpfi_set_function_state(mpfi_interv_d(ptr_self, NUM2DBL(a1), NUM2DBL(a2)));
823
- }else{
824
- MPFR *ptr_a1, *ptr_a2;
825
- volatile VALUE tmp_a1 = r_mpfr_new_fr_obj(a1);
826
- r_mpfr_get_struct(ptr_a1, tmp_a1);
827
- volatile VALUE tmp_a2 = r_mpfr_new_fr_obj(a2);
828
- r_mpfr_get_struct(ptr_a2, tmp_a2);
829
- r_mpfi_set_function_state(mpfi_interv_fr(ptr_self, ptr_a1, ptr_a2));
830
- }
831
- return self;
853
+ r_mpfi_set_interv_from_robjs(ptr_self, a1, a2);
854
+ return self;
832
855
  }
833
856
 
834
857
  /* Return new MPFI of which endpoints are the same as p1 and p2. */
@@ -837,29 +860,7 @@ static VALUE r_mpfi_interval (int argc, VALUE *argv, VALUE self)
837
860
  VALUE val_ret;
838
861
  MPFI *ptr_ret;
839
862
  r_mpfi_make_struct_init2(val_ret, ptr_ret, r_mpfr_prec_from_optional_argument(2, 3, argc, argv));
840
-
841
- if(RTEST(rb_funcall(__mpfr_class__, eqq, 1, argv[0])) && RTEST(rb_funcall(__mpfr_class__, eqq, 1, argv[1]))){
842
- MPFR *ptr_a0, *ptr_a1;
843
- r_mpfr_get_struct(ptr_a0, argv[0]);
844
- r_mpfr_get_struct(ptr_a1, argv[1]);
845
- r_mpfi_set_function_state(mpfi_interv_fr(ptr_ret, ptr_a0, ptr_a1));
846
- }else if((TYPE(argv[0]) == T_FIXNUM) && (TYPE(argv[1]) == T_FIXNUM)){
847
- r_mpfi_set_function_state(mpfi_interv_si(ptr_ret, FIX2LONG(argv[0]), FIX2LONG(argv[1])));
848
- }else if((TYPE(argv[0]) == T_FLOAT) && (TYPE(argv[1]) == T_FLOAT)){
849
- r_mpfi_set_function_state(mpfi_interv_d(ptr_ret, NUM2DBL(argv[0]), NUM2DBL(argv[1])));
850
- }else{
851
- /* printf("r_mpfi_interval [start]\n"); */
852
- MPFR *ptr_a0, *ptr_a1;
853
- volatile VALUE tmp1 = r_mpfr_new_fr_obj(argv[0]), tmp2 = r_mpfr_new_fr_obj(argv[1]);
854
- r_mpfr_get_struct(ptr_a0, tmp1);
855
- r_mpfr_get_struct(ptr_a1, tmp2);
856
- /* volatile VALUE tmp_argv0 = r_mpfr_new_fr_obj(argv[0]);
857
- r_mpfr_get_struct(ptr_a0, tmp_argv0); */
858
- /* volatile VALUE tmp_argv1 = r_mpfr_new_fr_obj(argv[1]);
859
- r_mpfr_get_struct(ptr_a1, tmp_argv1); */
860
- r_mpfi_set_function_state(mpfi_interv_fr(ptr_ret, ptr_a0, ptr_a1));
861
- /* printf("r_mpfi_interval [end]\n"); */
862
- }
863
+ r_mpfi_set_interv_from_robjs(ptr_ret, argv[0], argv[1]);
863
864
  return val_ret;
864
865
  }
865
866
 
@@ -1,5 +1,19 @@
1
1
  require 'mkmf'
2
2
 
3
+ i = 0
4
+ while i < ARGV.size
5
+ case ARGV[i]
6
+ when '--ldflags'
7
+ if args = ARGV[i+1]
8
+ i += 1
9
+ $LDFLAGS += " #{args}"
10
+ end
11
+ else
12
+ raise "Invalid option: #{ARGV[i]}"
13
+ end
14
+ i += 1
15
+ end
16
+
3
17
  $CFLAGS += " -Wall"
4
18
 
5
19
  dir_config("mpfr")
@@ -1,5 +1,19 @@
1
1
  require 'mkmf'
2
2
 
3
+ i = 0
4
+ while i < ARGV.size
5
+ case ARGV[i]
6
+ when '--ldflags'
7
+ if args = ARGV[i+1]
8
+ i += 1
9
+ $LDFLAGS += " #{args}"
10
+ end
11
+ else
12
+ raise "Invalid option: #{ARGV[i]}"
13
+ end
14
+ i += 1
15
+ end
16
+
3
17
  dir_config('mpfr')
4
18
  dir_config('mpfi')
5
19
  dir_config('gmp')
data/lib/mpfi/version.rb CHANGED
@@ -1 +1 @@
1
- RUBY_MPFI_VERSION = '0.0.4'
1
+ RUBY_MPFI_VERSION = '0.0.5'
data/ruby-mpfi.gemspec CHANGED
@@ -2,37 +2,37 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ruby-mpfi}
5
- s.version = "0.0.3"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Takayuki YAMAGUCHI"]
9
- s.date = %q{2009-12-19}
10
- s.description = %q{FIX (describe your package)}
9
+ s.date = %q{2011-02-15}
10
+ s.description = %q{ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/]
11
+ which is the library of the interval arithmetic with multiprecision.}
11
12
  s.email = ["d@ytak.info"]
12
13
  s.extensions = ["ext/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/extconf.rb"]
13
14
  s.extra_rdoc_files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc"]
14
- s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "ext/mpfi/extconf.rb", "ext/mpfi/func_mpfi_extention.c", "ext/mpfi/func_mpfi_extention.h", "ext/mpfi/ruby_mpfi.c", "ext/mpfi/ruby_mpfi.h", "ext/mpfi/ruby_mpfr.h", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/func_mpfi_extention.h", "ext/mpfi_complex/mpfi/func_ruby_mpfi_complex.c", "ext/mpfi_complex/mpfi/func_ruby_mpfi_complex.h", "ext/mpfi_complex/mpfi/ruby_mpfi.h", "ext/mpfi_complex/mpfi/ruby_mpfi_complex.c", "ext/mpfi_complex/mpfi/ruby_mpfi_complex.h", "ext/mpfi_complex/mpfi/ruby_mpfr.h", "ext/mpfi_matrix/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/func_mpfi_extention.h", "ext/mpfi_matrix/mpfi/func_mpfi_matrix.c", "ext/mpfi_matrix/mpfi/func_mpfi_matrix.h", "ext/mpfi_matrix/mpfi/func_mpfr_matrix.h", "ext/mpfi_matrix/mpfi/ruby_mpfi.h", "ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c", "ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.h", "ext/mpfi_matrix/mpfi/ruby_mpfr.h", "ext/mpfi_matrix/mpfi/ruby_mpfr_matrix.h", "lib/mpfi/matrix.rb", "lib/mpfi/version.rb", "ruby-mpfi.gemspec", "script/console", "script/destroy", "script/generate", "spec/mpfi/generate_number_module.rb", "spec/mpfi/mpfi_alloc_spec.rb", "spec/mpfi/mpfi_diam_arithmetic_spec.rb", "spec/mpfi/mpfi_interval_arithmetic_spec.rb", "spec/mpfi/mpfi_interval_functions_spec.rb", "spec/mpfi/mpfi_math_functions_spec.rb", "spec/mpfi/mpfi_set_operation_spec.rb", "spec/mpfi/ruby-mpfi_spec.rb", "spec/mpfi/spec_helper.rb", "spec/mpfi_complex/spec_helper.rb", "spec/mpfi_matrix/generate_matrix_arguments.rb", "spec/mpfi_matrix/mpfi_matrix_alloc_spec.rb", "spec/mpfi_matrix/mpfi_matrix_arithmetic_spec.rb", "spec/mpfi_matrix/mpfi_matrix_interval_func_spec.rb", "spec/mpfi_matrix/mpfi_matrix_set_element_spec.rb", "spec/mpfi_matrix/mpfi_matrix_set_operation_spec.rb", "spec/mpfi_matrix/mpfi_matrix_string_spec.rb", "spec/mpfi_matrix/mpfi_matrix_subdivision_spec.rb", "spec/mpfi_matrix/mpfi_square_matrix_spec.rb", "spec/mpfi_matrix/mpfi_vector_spec.rb", "spec/mpfi_matrix/spec_helper.rb", "spec/spec.opts", "tasks/extconf.rake"]
15
+ s.files = ["History.txt", "Manifest.txt", "PostInstall.txt", "README.rdoc", "Rakefile", "ext/mpfi/extconf.rb", "ext/mpfi/func_mpfi_extention.c", "ext/mpfi/func_mpfi_extention.h", "ext/mpfi/ruby_mpfi.c", "ext/mpfi/ruby_mpfi.h", "ext/mpfi/ruby_mpfr.h", "ext/mpfi_complex/mpfi/extconf.rb", "ext/mpfi_complex/mpfi/func_mpfi_extention.h", "ext/mpfi_complex/mpfi/func_ruby_mpfi_complex.c", "ext/mpfi_complex/mpfi/func_ruby_mpfi_complex.h", "ext/mpfi_complex/mpfi/ruby_mpfi.h", "ext/mpfi_complex/mpfi/ruby_mpfi_complex.c", "ext/mpfi_complex/mpfi/ruby_mpfi_complex.h", "ext/mpfi_complex/mpfi/ruby_mpfr.h", "ext/mpfi_matrix/mpfi/extconf.rb", "ext/mpfi_matrix/mpfi/func_mpfi_extention.h", "ext/mpfi_matrix/mpfi/func_mpfi_matrix.c", "ext/mpfi_matrix/mpfi/func_mpfi_matrix.h", "ext/mpfi_matrix/mpfi/func_mpfr_matrix.h", "ext/mpfi_matrix/mpfi/ruby_mpfi.h", "ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c", "ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.h", "ext/mpfi_matrix/mpfi/ruby_mpfr.h", "ext/mpfi_matrix/mpfi/ruby_mpfr_matrix.h", "lib/mpfi/matrix.rb", "lib/mpfi/version.rb", "ruby-mpfi.gemspec", "spec/mpfi/generate_number_module.rb", "spec/mpfi/mpfi_alloc_spec.rb", "spec/mpfi/mpfi_diam_arithmetic_spec.rb", "spec/mpfi/mpfi_interval_arithmetic_spec.rb", "spec/mpfi/mpfi_interval_functions_spec.rb", "spec/mpfi/mpfi_math_functions_spec.rb", "spec/mpfi/mpfi_set_operation_spec.rb", "spec/mpfi/ruby-mpfi_spec.rb", "spec/mpfi/spec_helper.rb", "spec/mpfi/string_spec.rb", "spec/mpfi_complex/spec_helper.rb", "spec/mpfi_matrix/generate_matrix_arguments.rb", "spec/mpfi_matrix/mpfi_matrix_alloc_spec.rb", "spec/mpfi_matrix/mpfi_matrix_arithmetic_spec.rb", "spec/mpfi_matrix/mpfi_matrix_interval_func_spec.rb", "spec/mpfi_matrix/mpfi_matrix_set_element_spec.rb", "spec/mpfi_matrix/mpfi_matrix_set_operation_spec.rb", "spec/mpfi_matrix/mpfi_matrix_string_spec.rb", "spec/mpfi_matrix/mpfi_matrix_subdivision_spec.rb", "spec/mpfi_matrix/mpfi_square_matrix_spec.rb", "spec/mpfi_matrix/mpfi_vector_spec.rb", "spec/mpfi_matrix/spec_helper.rb", "tasks/extconf.rake", ".gemtest"]
15
16
  s.homepage = %q{http://rubyforge.org/projects/ruby-mpfr/}
16
17
  s.post_install_message = %q{PostInstall.txt}
17
18
  s.rdoc_options = ["--main", "README.rdoc"]
18
- s.require_paths = ["lib", "ext"]
19
+ s.require_paths = ["lib"]
19
20
  s.rubyforge_project = %q{ruby-mpfi}
20
- s.rubygems_version = %q{1.3.5}
21
- s.summary = %q{FIX (describe your package)}
21
+ s.rubygems_version = %q{1.5.2}
22
+ s.summary = %q{ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/] which is the library of the interval arithmetic with multiprecision.}
22
23
 
23
24
  if s.respond_to? :specification_version then
24
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
25
  s.specification_version = 3
26
26
 
27
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
28
  s.add_runtime_dependency(%q<ruby-mpfr>, [">= 0.0.4"])
29
- s.add_development_dependency(%q<hoe>, [">= 2.4.0"])
29
+ s.add_development_dependency(%q<hoe>, [">= 2.9.1"])
30
30
  else
31
31
  s.add_dependency(%q<ruby-mpfr>, [">= 0.0.4"])
32
- s.add_dependency(%q<hoe>, [">= 2.4.0"])
32
+ s.add_dependency(%q<hoe>, [">= 2.9.1"])
33
33
  end
34
34
  else
35
35
  s.add_dependency(%q<ruby-mpfr>, [">= 0.0.4"])
36
- s.add_dependency(%q<hoe>, [">= 2.4.0"])
36
+ s.add_dependency(%q<hoe>, [">= 2.9.1"])
37
37
  end
38
38
  end
@@ -1,8 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
1
+ require_relative 'spec_helper'
6
2
 
7
3
  describe MPFI, "when initializing MPFI instance" do
8
4
  before(:all) do
@@ -53,3 +49,46 @@ describe MPFI, "when initializing MPFI instance by method interval" do
53
49
 
54
50
  end
55
51
 
52
+ describe MPFI, "when setting value from some objects" do
53
+ before(:all) do
54
+ MPFR.set_default_prec(128)
55
+ MPFR.set_error_of_test(MPFR('1e-12'))
56
+ end
57
+
58
+ it "should create an MPFI object from a string" do
59
+ n = MPFI("[1.2, 1.3]")
60
+ n.left.check_error(1.2).should be_true
61
+ n.right.check_error(1.3).should be_true
62
+ end
63
+
64
+ it "should create an MPFI object from an integer" do
65
+ n = MPFI(8)
66
+ n.left.check_error(8).should be_true
67
+ n.right.check_error(8).should be_true
68
+ end
69
+
70
+ it "should create an MPFI object from an array of float numbers" do
71
+ n = MPFI([-1.3, -0.5])
72
+ n.left.check_error(-1.3)
73
+ n.right.check_error(-0.5)
74
+ end
75
+
76
+ it "should create an MPFI object from an array of MPFR numbers" do
77
+ n = MPFI([MPFR(-1.0), MPFR(-0.5)])
78
+ n.left.check_error(-1.0)
79
+ n.right.check_error(-0.5)
80
+ end
81
+
82
+ it "should create an MPFI object from an array of strings" do
83
+ n = MPFI(['3.8', '4.9'])
84
+ n.left.check_error(3.8)
85
+ n.right.check_error(4.9)
86
+ end
87
+
88
+ it "should create an MPFI object from an array of some objects" do
89
+ n = MPFI([MPFR(1.2), '4.9'])
90
+ n.left.check_error(1.2)
91
+ n.right.check_error(4.9)
92
+ end
93
+
94
+ end
@@ -1,8 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
1
+ require_relative 'spec_helper'
6
2
 
7
3
  describe MPFI, "when puting arithmetic operation" do
8
4
  before(:all) do
@@ -1,8 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
1
+ require_relative 'spec_helper'
6
2
 
7
3
  #
8
4
  # To test method +, -, / and *, we calculate these operator for MPFR and MPFI
@@ -1,8 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
1
+ require_relative 'spec_helper'
6
2
 
7
3
  #
8
4
  # The following is test for interval functions and endpoints.
@@ -1,9 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
6
-
1
+ require_relative 'spec_helper'
7
2
 
8
3
  describe MPFI, "when calculating mathematical functions" do
9
4
  it "should not raise error" do
@@ -1,8 +1,4 @@
1
- require 'rubygems'
2
- require 'spec'
3
- require 'mpfr'
4
- require 'mpfi'
5
- require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
1
+ require_relative 'spec_helper'
6
2
 
7
3
  describe MPFI, "when checking inclusive relations" do
8
4
  before(:all) do
@@ -1,10 +1,15 @@
1
1
  begin
2
- require 'spec'
2
+ require 'rspec'
3
3
  rescue LoadError
4
4
  require 'rubygems' unless ENV['NO_RUBYGEMS']
5
5
  gem 'rspec'
6
- require 'spec'
6
+ require 'rspec'
7
7
  end
8
8
 
9
9
  $:.unshift(File.dirname(__FILE__) + '/../lib')
10
- require 'mpfi'
10
+
11
+ require 'pp'
12
+ require 'mpfr'
13
+ require 'mpfr/rspec'
14
+ require_relative '../../ext/mpfi/mpfi.so'
15
+ require "#{File.dirname(File.expand_path(__FILE__))}/generate_number_module.rb"
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ describe MPFI, "when converting to string" do
4
+ it "should return string created by inspect" do
5
+ s = MPFI(['1.2', '1.3']).inspect
6
+ s.should be_an_instance_of String
7
+ end
8
+
9
+ it "should return an array of strings" do
10
+ a = MPFI(['1.2', '1.3']).to_str_ary
11
+ a.should be_an_instance_of Array
12
+ a.size.should == 2
13
+ end
14
+ end
@@ -1,9 +1,9 @@
1
1
  begin
2
- require 'spec'
2
+ require 'rspec'
3
3
  rescue LoadError
4
4
  require 'rubygems' unless ENV['NO_RUBYGEMS']
5
5
  gem 'rspec'
6
- require 'spec'
6
+ require 'rspec'
7
7
  end
8
8
 
9
9
  $:.unshift(File.dirname(__FILE__) + '/../lib')
@@ -1,9 +1,9 @@
1
1
  begin
2
- require 'spec'
2
+ require 'rspec'
3
3
  rescue LoadError
4
4
  require 'rubygems' unless ENV['NO_RUBYGEMS']
5
5
  gem 'rspec'
6
- require 'spec'
6
+ require 'rspec'
7
7
  end
8
8
 
9
9
  $:.unshift(File.dirname(__FILE__) + '/../../lib')
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mpfi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ prerelease:
5
+ version: 0.0.5
5
6
  platform: ruby
6
7
  authors:
7
8
  - Takayuki YAMAGUCHI
@@ -9,49 +10,31 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2010-02-06 00:00:00 +09:00
13
+ date: 2011-02-16 00:00:00 +09:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: ruby-mpfr
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
20
21
  requirements:
21
22
  - - ">="
22
23
  - !ruby/object:Gem::Version
23
24
  version: 0.0.4
24
- version:
25
- - !ruby/object:Gem::Dependency
26
- name: rubyforge
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: 2.0.3
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: gemcutter
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: 0.3.0
44
- version:
25
+ type: :runtime
26
+ version_requirements: *id001
45
27
  - !ruby/object:Gem::Dependency
46
28
  name: hoe
47
- type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
50
32
  requirements:
51
33
  - - ">="
52
34
  - !ruby/object:Gem::Version
53
- version: 2.5.0
54
- version:
35
+ version: 2.9.1
36
+ type: :development
37
+ version_requirements: *id002
55
38
  description: |-
56
39
  ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/]
57
40
  which is the library of the interval arithmetic with multiprecision.
@@ -101,9 +84,6 @@ files:
101
84
  - lib/mpfi/matrix.rb
102
85
  - lib/mpfi/version.rb
103
86
  - ruby-mpfi.gemspec
104
- - script/console
105
- - script/destroy
106
- - script/generate
107
87
  - spec/mpfi/generate_number_module.rb
108
88
  - spec/mpfi/mpfi_alloc_spec.rb
109
89
  - spec/mpfi/mpfi_diam_arithmetic_spec.rb
@@ -113,6 +93,7 @@ files:
113
93
  - spec/mpfi/mpfi_set_operation_spec.rb
114
94
  - spec/mpfi/ruby-mpfi_spec.rb
115
95
  - spec/mpfi/spec_helper.rb
96
+ - spec/mpfi/string_spec.rb
116
97
  - spec/mpfi_complex/spec_helper.rb
117
98
  - spec/mpfi_matrix/generate_matrix_arguments.rb
118
99
  - spec/mpfi_matrix/mpfi_matrix_alloc_spec.rb
@@ -125,8 +106,8 @@ files:
125
106
  - spec/mpfi_matrix/mpfi_square_matrix_spec.rb
126
107
  - spec/mpfi_matrix/mpfi_vector_spec.rb
127
108
  - spec/mpfi_matrix/spec_helper.rb
128
- - spec/spec.opts
129
109
  - tasks/extconf.rake
110
+ - .gemtest
130
111
  has_rdoc: true
131
112
  homepage: http://rubyforge.org/projects/ruby-mpfr/
132
113
  licenses: []
@@ -137,23 +118,22 @@ rdoc_options:
137
118
  - README.rdoc
138
119
  require_paths:
139
120
  - lib
140
- - ext
141
121
  required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
142
123
  requirements:
143
124
  - - ">="
144
125
  - !ruby/object:Gem::Version
145
126
  version: "0"
146
- version:
147
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
+ none: false
148
129
  requirements:
149
130
  - - ">="
150
131
  - !ruby/object:Gem::Version
151
132
  version: "0"
152
- version:
153
133
  requirements: []
154
134
 
155
135
  rubyforge_project: ruby-mpfi
156
- rubygems_version: 1.3.5
136
+ rubygems_version: 1.5.2
157
137
  signing_key:
158
138
  specification_version: 3
159
139
  summary: ruby-mpfi is an extended C library to use MPFI[http://gforge.inria.fr/projects/mpfi/] which is the library of the interval arithmetic with multiprecision.
data/script/console DELETED
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/ruby-mpfi.rb'}"
9
- puts "Loading ruby-mpfi gem"
10
- exec "#{irb} #{libs} --simple-prompt"
data/script/destroy DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
data/spec/spec.opts DELETED
@@ -1 +0,0 @@
1
- --colour