continued_fractions 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -1
- data/continued_fractions.gemspec +1 -1
- data/lib/continued_fractions.rb +8 -9
- metadata +2 -2
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('continued_fractions', '0.1.
|
5
|
+
Echoe.new('continued_fractions', '0.1.11') do |config|
|
6
6
|
config.summary = 'Generate continued fractions.'
|
7
7
|
config.author = 'Jose Hales-Garcia'
|
8
8
|
config.url = 'http://bitbucket.org/jolohaga/continued_fractions/'
|
data/continued_fractions.gemspec
CHANGED
data/lib/continued_fractions.rb
CHANGED
@@ -13,10 +13,9 @@ module ContinuedFractions
|
|
13
13
|
attr_accessor :number, :quotients, :limit
|
14
14
|
attr_writer :convergents
|
15
15
|
|
16
|
-
# For a given number
|
16
|
+
# For a given number calculate its continued fraction quotients and convergents up to limit.
|
17
17
|
#
|
18
|
-
# The
|
19
|
-
# the second parameter to change the default.
|
18
|
+
# The limit is 5 by default. Pass an integer in the second parameter to change it.
|
20
19
|
#
|
21
20
|
# Example:
|
22
21
|
# cf = ContinuedFraction.new(Math::PI,10)
|
@@ -25,9 +24,9 @@ module ContinuedFractions
|
|
25
24
|
# @convergents=[[0, 1], [1, 0], [3, 1], [22, 7], [333, 106],
|
26
25
|
# [355, 113], [103993, 33102], [104348, 33215], [208341, 66317], [312689, 99532], [833719, 265381], [1146408, 364913]]>
|
27
26
|
#
|
28
|
-
def initialize(
|
29
|
-
@number =
|
30
|
-
@limit =
|
27
|
+
def initialize(number,limit=5)
|
28
|
+
@number = number
|
29
|
+
@limit = limit
|
31
30
|
@quotients = calculate_quotients
|
32
31
|
@convergents = calculate_convergents
|
33
32
|
end
|
@@ -76,11 +75,11 @@ module ContinuedFractions
|
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
79
|
-
class << self
|
80
|
-
def convergence_matrix(n,m,fill=nil)
|
78
|
+
class << self
|
79
|
+
def convergence_matrix(n,m,fill=nil) #:nodoc:
|
81
80
|
conv_mat = Array.new(n).map!{Array.new(m,fill)}
|
82
81
|
conv_mat[0][0],conv_mat[1][1] = 0,0
|
83
82
|
conv_mat
|
84
83
|
end
|
85
84
|
end
|
86
|
-
end
|
85
|
+
end
|