continued_fractions 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/lib/continued_fractions/version.rb +1 -1
- data/lib/continued_fractions.rb +20 -12
- metadata +16 -3
- data/CHANGELOG.md +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3beec97175d427fec8bc5715efa6499a7c4e9705365b54ecac376b1a27c27636
|
4
|
+
data.tar.gz: 286cdeda5f5581953ff39c193926d9a94d4693d0757f25e4c580655aa371b9f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddbe0f9f64b4f7cce8bb461d8145b377e8256e130cb492b62039fa1e1cfd93b1fbbfde890b54512a962f887b9b3eb9bcfb8e60e9b7b90134505d65e6f02cbd7e
|
7
|
+
data.tar.gz: 539fb7194853af5edc6bbcdd7b25af6ce7899fcf329d19c4c691f1ff675f0049ce73fba269b05457a6868983c29187454e25e35cae2e9aadc062c93e10c7b389
|
data/LICENSE
CHANGED
data/lib/continued_fractions.rb
CHANGED
@@ -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)
|
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
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
-
|
157
|
-
|
158
|
-
|
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.
|
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:
|
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
|