rubysl-bigdecimal 1.0.0 → 2.0.2
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.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/README.md +48 -17
- data/{lib/bigdecimal/bigdecimal_en.html → bigdecimal_en.html} +54 -58
- data/{lib/bigdecimal/bigdecimal_ja.html → bigdecimal_ja.html} +6 -6
- data/ext/rubysl/bigdecimal/bigdecimal.c +2234 -1120
- data/ext/rubysl/bigdecimal/bigdecimal.h +114 -57
- data/lib/bigdecimal/jacobian.rb +13 -11
- data/lib/bigdecimal/ludcmp.rb +24 -20
- data/lib/bigdecimal/math.rb +33 -62
- data/lib/bigdecimal/newton.rb +6 -5
- data/lib/bigdecimal/util.rb +87 -43
- data/lib/rubysl/bigdecimal/version.rb +1 -1
- data/rubysl-bigdecimal.gemspec +3 -1
- metadata +20 -23
- data/lib/bigdecimal/README +0 -60
- data/lib/bigdecimal/sample/linear.rb +0 -71
- data/lib/bigdecimal/sample/nlsolve.rb +0 -38
- data/lib/bigdecimal/sample/pi.rb +0 -20
@@ -1,38 +0,0 @@
|
|
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/lib/bigdecimal/sample/pi.rb
DELETED
@@ -1,20 +0,0 @@
|
|
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
|