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 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') do |config|
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/'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{continued_fractions}
5
- s.version = "0.1.5"
5
+ s.version = "0.1.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jose Hales-Garcia"]
@@ -39,20 +39,21 @@ module ContinuedFractions
39
39
  end
40
40
 
41
41
  def calculate_convergents
42
- convs = ContinuedFractions.matrix(@limit+2,2,1)
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
- convs[i][0] = convs[i-1][0]*quotients[i-2]+convs[i-2][0]
47
- convs[i][1] = convs[i-1][1]*quotients[i-2]+convs[i-2][1]
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 matrix(n,m,fill=nil)
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 5
9
- version: 0.1.5
8
+ - 6
9
+ version: 0.1.6
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jose Hales-Garcia