continued_fractions 0.1.5 → 0.1.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/History.txt +5 -0
- data/Rakefile +1 -1
- data/continued_fractions.gemspec +1 -1
- data/lib/continued_fractions.rb +8 -7
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
=== 0.1.6 / 2010-03-15
|
2
|
+
|
3
|
+
* Refactored code generating matrix that holds convergences. Renamed the method convergence_matrix.
|
4
|
+
* In calculate_convergences, refactored multiple occurances of i-1 and i-2, assigning the values to variables at the top of the iterations.
|
5
|
+
|
1
6
|
=== 0.1.5 / 2010-03-15
|
2
7
|
|
3
8
|
* Minor changes to README
|
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.6') do |config|
|
6
6
|
config.description = '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
@@ -39,20 +39,21 @@ module ContinuedFractions
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def calculate_convergents
|
42
|
-
convs = ContinuedFractions.
|
43
|
-
convs[0][0] = 0
|
44
|
-
convs[1][1] = 0
|
42
|
+
convs = ContinuedFractions.convergence_matrix(@limit+2,2,1)
|
45
43
|
2.upto(@limit+1) do |i|
|
46
|
-
|
47
|
-
convs[i][
|
44
|
+
i_1,i_2 = i-1,i-2
|
45
|
+
convs[i][0] = convs[i_1][0]*quotients[i_2]+convs[i_2][0]
|
46
|
+
convs[i][1] = convs[i_1][1]*quotients[i_2]+convs[i_2][1]
|
48
47
|
end
|
49
48
|
convs
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
53
52
|
class << self # :nodoc:
|
54
|
-
def
|
55
|
-
Array.new(n).map!{Array.new(m,fill)}
|
53
|
+
def convergence_matrix(n,m,fill=nil)
|
54
|
+
conv_mat = Array.new(n).map!{Array.new(m,fill)}
|
55
|
+
conv_mat[0][0],conv_mat[1][1] = 0,0
|
56
|
+
conv_mat
|
56
57
|
end
|
57
58
|
end
|
58
59
|
end
|