bigdecimal 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/sample/nlsolve.rb ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ #
4
+ # nlsolve.rb
5
+ # An example for solving nonlinear algebraic equation system.
6
+ #
7
+
8
+ require "bigdecimal"
9
+ require "bigdecimal/newton"
10
+ include Newton
11
+
12
+ class Function
13
+ def initialize()
14
+ @zero = BigDecimal::new("0.0")
15
+ @one = BigDecimal::new("1.0")
16
+ @two = BigDecimal::new("2.0")
17
+ @ten = BigDecimal::new("10.0")
18
+ @eps = BigDecimal::new("1.0e-16")
19
+ end
20
+ def zero;@zero;end
21
+ def one ;@one ;end
22
+ def two ;@two ;end
23
+ def ten ;@ten ;end
24
+ def eps ;@eps ;end
25
+ def values(x) # <= defines functions solved
26
+ f = []
27
+ f1 = x[0]*x[0] + x[1]*x[1] - @two # f1 = x**2 + y**2 - 2 => 0
28
+ f2 = x[0] - x[1] # f2 = x - y => 0
29
+ f <<= f1
30
+ f <<= f2
31
+ f
32
+ end
33
+ end
34
+ f = BigDecimal::limit(100)
35
+ f = Function.new
36
+ x = [f.zero,f.zero] # Initial values
37
+ n = nlsolve(f,x)
38
+ p x
data/sample/pi.rb ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/local/bin/ruby
2
+
3
+ #
4
+ # pi.rb
5
+ #
6
+ # Calculates 3.1415.... (the number of times that a circle's diameter
7
+ # will fit around the circle) using J. Machin's formula.
8
+ #
9
+
10
+ require "bigdecimal"
11
+ require "bigdecimal/math.rb"
12
+
13
+ include BigMath
14
+
15
+ if ARGV.size == 1
16
+ print "PI("+ARGV[0]+"):\n"
17
+ p PI(ARGV[0].to_i)
18
+ else
19
+ print "TRY: ruby pi.rb 1000 \n"
20
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bigdecimal
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kenta Murata
9
+ - Shigeo Kobayashi
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2011-07-30 00:00:00.000000000 Z
14
+ dependencies: []
15
+ description: This library provides arbitrary-precision decimal floating-point number
16
+ class.
17
+ email: mrkn@mrkn.jp
18
+ executables: []
19
+ extensions:
20
+ - extconf.rb
21
+ extra_rdoc_files: []
22
+ files:
23
+ - bigdecimal.gemspec
24
+ - bigdecimal.c
25
+ - bigdecimal.h
26
+ - README
27
+ - depend
28
+ - extconf.rb
29
+ - lib/bigdecimal/jacobian.rb
30
+ - lib/bigdecimal/ludcmp.rb
31
+ - lib/bigdecimal/math.rb
32
+ - lib/bigdecimal/newton.rb
33
+ - lib/bigdecimal/util.rb
34
+ - sample/linear.rb
35
+ - sample/nlsolve.rb
36
+ - sample/pi.rb
37
+ homepage: http://www.ruby-lang.org
38
+ licenses: []
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - .
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 1.8.15
58
+ signing_key:
59
+ specification_version: 3
60
+ summary: Arbitrary-precision decimal floating-point number library.
61
+ test_files: []