continued_fractions 1.8.2 → 1.8.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc3cc4f4da6b42a3c0ef5cf2824484521259c8166aa17d27647daeff911039da
4
- data.tar.gz: 63349536f6492a66972004b7a65db93db0c63c1835d4652a74ff9198a738e711
3
+ metadata.gz: 3beec97175d427fec8bc5715efa6499a7c4e9705365b54ecac376b1a27c27636
4
+ data.tar.gz: 286cdeda5f5581953ff39c193926d9a94d4693d0757f25e4c580655aa371b9f3
5
5
  SHA512:
6
- metadata.gz: fb01d65d0952130b356d90c20d6ee980fe16001f6973a45e1c4e3a798e4246e544e813954d6eb8a633eaf8c4723fa01da6a3692a7114cf6af7d93bb0f3445baf
7
- data.tar.gz: e99077dfdd3897a341c04eb8d73fe0c455b5ddd6fbf2139472d02259dc79d4c589f3c90845bd5d1aaacfba09e7a11906729d28651a212e19567dc3e14a27186f
6
+ metadata.gz: ddbe0f9f64b4f7cce8bb461d8145b377e8256e130cb492b62039fa1e1cfd93b1fbbfde890b54512a962f887b9b3eb9bcfb8e60e9b7b90134505d65e6f02cbd7e
7
+ data.tar.gz: 539fb7194853af5edc6bbcdd7b25af6ce7899fcf329d19c4c691f1ff675f0049ce73fba269b05457a6868983c29187454e25e35cae2e9aadc062c93e10c7b389
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  == License:
2
2
 
3
- Copyright (c) 2019 Jose Hales-Garcia
3
+ Copyright (c) 2021 Jose Hales-Garcia
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
@@ -1,3 +1,3 @@
1
1
  module ContinuedFractions
2
- VERSION = "1.8.2"
2
+ VERSION = "1.8.3"
3
3
  end
@@ -3,7 +3,7 @@
3
3
  # Generates quotients and convergents for a given number
4
4
  #
5
5
  # Author:: Jose Hales-Garcia (mailto:jolohaga@me.com)
6
- # Copyright:: Copyright (c) 2015 Jose Hales-Garcia
6
+ # Copyright:: Copyright (c) 2021 Jose Hales-Garcia
7
7
  #
8
8
  #
9
9
  class ContinuedFraction
@@ -142,19 +142,27 @@ class ContinuedFraction
142
142
  end
143
143
 
144
144
  def calculate_convergents #:nodoc:
145
- convs = convergence_matrix(quotients.length+2,2,1)
146
- nth ||= convs.length
147
- 2.upto(quotients.length+1) do |i|
148
- i_minus1,i_minus2 = i-1,i-2
149
- convs[i][0] = convs[i_minus1][0]*quotients[i_minus2]+convs[i_minus2][0]
150
- convs[i][1] = convs[i_minus1][1]*quotients[i_minus2]+convs[i_minus2][1]
151
- end
152
- convs[2...nth+2]
145
+ nth = nil
146
+ convergence_matrix(quotients.length+2,2,1).tap do |convs|
147
+ nth ||= convs.length
148
+ 2.upto(quotients.length+1) do |i|
149
+ i_minus1,i_minus2 = i-1,i-2
150
+ convs[i][0] = convs[i_minus1][0]*quotients[i_minus2]+convs[i_minus2][0]
151
+ convs[i][1] = convs[i_minus1][1]*quotients[i_minus2]+convs[i_minus2][1]
152
+ end
153
+ end[2...nth+2]
153
154
  end
154
155
 
155
156
  def convergence_matrix(n,m,fill=nil) #:nodoc:
156
- conv_mat = Array.new(n).map!{Array.new(m,fill)}
157
- conv_mat[0][0],conv_mat[1][1] = 0,0
158
- conv_mat
157
+ Array.new(n).map!{Array.new(m,fill)}.tap do |conv_mat|
158
+ conv_mat[0][0],conv_mat[1][1] = 0,0
159
+ end
159
160
  end
160
161
  end
162
+
163
+ # @return [ContinuedFraction] new instance
164
+ # @see ContinuedFraction#initialize
165
+ #
166
+ def ContinuedFraction(number,limit=5)
167
+ ContinuedFraction.new(number,limit=5)
168
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: continued_fractions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Hales-Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-13 00:00:00.000000000 Z
11
+ date: 2021-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.1'
27
41
  description: Class for working with continued fractions
28
42
  email: jolohaga@me.com
29
43
  executables: []
@@ -33,7 +47,6 @@ extra_rdoc_files:
33
47
  - README.md
34
48
  - lib/continued_fractions.rb
35
49
  files:
36
- - CHANGELOG.md
37
50
  - LICENSE
38
51
  - README.md
39
52
  - lib/continued_fractions.rb
data/CHANGELOG.md DELETED
@@ -1,23 +0,0 @@
1
- 1.8.2 - Make gemspec data dynamic
2
-
3
- 1.8.1 - Include Github repo in gemspec
4
-
5
- 1.8.0 - Add comparison
6
-
7
- 1.7.0 - Accept Float and Rational as well as Integer in operators
8
-
9
- 1.6.1 - Remove dependency on Echoe
10
-
11
- v1.6.0 Handle rational numbers, finite continued fractions
12
-
13
- v1.5.0 Remove ContinuedFractions module; Move its methods into ContinuedFraction class
14
-
15
- v1.4.0 Eliminate need to invoke "include ContinuedFractions"
16
-
17
- v1.3.0 Add binary operators: + - * /
18
-
19
- v1.2.0 Change parameter signature of ContinuedFraction#convergents_as_rationals
20
-
21
- v1.1.0 Change public class representation of convergents from an array of Rationals to an array of arrays.
22
-
23
- v0.1.0 Initial release