fibonacci 0.1.8 → 0.1.9
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 +5 -5
- data/LICENSE +15 -0
- data/README.markdown +87 -0
- data/Rakefile +27 -0
- data/ext/fibonacci/extconf.rb +1 -1
- data/ext/fibonacci/fibonacci.c +1 -1
- data/fibonacci.gemspec +32 -0
- data/lib/fibonacci/version.rb +1 -1
- data/lib/fibonacci.rb +6 -1
- data/test/fibonacci_test.rb +2 -1
- data/test/test_helper.rb +15 -0
- metadata +45 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 92d83c1000268723f80d5fdd0567d04963c2c9553854f7f33bec822a49cf8a26
|
|
4
|
+
data.tar.gz: ff9284bf3844d92b0febcba8b21ea148f22bc84c2c3e21af47475d5e56c48d86
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89c1528d25301f494f457b7a0ef1e20db05bf214b49bb0328f3bee4f1a429f9f7ae37144960ac241563f786443a3bbaed18de59599c14d5b12d5d2d4c27916fd
|
|
7
|
+
data.tar.gz: f3dfc2f46a1250257b2fae4f8951bb7c013f3b341cbcd3325849a869c5b13ef3f71e9a78aa44f6c417ab65f40b6451806d5da531ff51ee9120a9ab20b4765b7c
|
data/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License (ISC)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011, NagaChaitanya Vellanki <me@chaitanyavellanki.com>
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
data/README.markdown
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Fibonacci is a Ruby gem written as a C-extension for exploring the Fibonacci series.
|
|
2
|
+
===============================================================================
|
|
3
|
+
|
|
4
|
+
-------------------------------------------------------------------------------
|
|
5
|
+
Installation:
|
|
6
|
+
-------------------------------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
gem install fibonacci
|
|
9
|
+
|
|
10
|
+
If you download the source and want to build locally:
|
|
11
|
+
|
|
12
|
+
bundle install
|
|
13
|
+
bundle exec rake test
|
|
14
|
+
|
|
15
|
+
This will generate the extension Makefile, compile the native extension, and run the tests.
|
|
16
|
+
|
|
17
|
+
If you want to build the extension manually:
|
|
18
|
+
|
|
19
|
+
cd ext/fibonacci
|
|
20
|
+
ruby extconf.rb
|
|
21
|
+
make
|
|
22
|
+
|
|
23
|
+
-------------------------------------------------------------------------------
|
|
24
|
+
Testing:
|
|
25
|
+
-------------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
From the project root:
|
|
28
|
+
|
|
29
|
+
bundle install
|
|
30
|
+
bundle exec rake test
|
|
31
|
+
|
|
32
|
+
This is the recommended path for cloned source.
|
|
33
|
+
|
|
34
|
+
-------------------------------------------------------------------------------
|
|
35
|
+
Usage:
|
|
36
|
+
-------------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
irb(main):001:0> require 'fibonacci'
|
|
39
|
+
#=> true
|
|
40
|
+
|
|
41
|
+
irb(main):002:0> fib = Fibonacci.new
|
|
42
|
+
#=> #<Fibonacci:0x000000025cf218>
|
|
43
|
+
|
|
44
|
+
fib.print(n) will print the first n terms of the series
|
|
45
|
+
|
|
46
|
+
irb(main):003:0> fib.print(5)
|
|
47
|
+
#=> 0
|
|
48
|
+
1
|
|
49
|
+
1
|
|
50
|
+
2
|
|
51
|
+
3
|
|
52
|
+
|
|
53
|
+
fib[n] will return the nth term of the series, the nth term is computed
|
|
54
|
+
iteratively
|
|
55
|
+
|
|
56
|
+
irb(main):004:0> fib[1000]
|
|
57
|
+
#=> 43466557686937456435688527675040625802564660517371780402481729089536555417949051890403879840079255169295922593080322634775209689623239873322471161642996440906533187938298969649928516003704476137795166849228875
|
|
58
|
+
|
|
59
|
+
fib.matrix(n) will return the nth power of matrix(http://en.wikipedia.org/wiki/Fibonacci_number#Matrix_form)
|
|
60
|
+
|
|
61
|
+
irb(main):013:0> fib.matrix(100)
|
|
62
|
+
#=> [[573147844013817084101, 354224848179261915075], [354224848179261915075, 218922995834555169026]]
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
fib.terms(n) will return an array of first n terms of the series
|
|
66
|
+
|
|
67
|
+
irb(main):005:0> fib.terms(5)
|
|
68
|
+
#=> [0, 1, 1, 2, 3]
|
|
69
|
+
|
|
70
|
+
fib.num_digits(n) will return the number of digits in the nth term of series
|
|
71
|
+
(http://en.wikipedia.org/wiki/Fibonacci_number#Computation_by_rounding)
|
|
72
|
+
|
|
73
|
+
irb(main):007:0> fib.num_digits(1000)
|
|
74
|
+
#=> 209
|
|
75
|
+
|
|
76
|
+
irb(main):006:0> fib[1000].to_s.length
|
|
77
|
+
#=> 209
|
|
78
|
+
|
|
79
|
+
fib.fast_val(n) will return the nth term of the series, the nth term is
|
|
80
|
+
computed as the product of the Lucas numbers,
|
|
81
|
+
|
|
82
|
+
ref: Daisuke Takahashi, A fast algorithm for computing large Fibonacci
|
|
83
|
+
numbers, Information Processing Letters, Volume 75, Issue 6, 30 November
|
|
84
|
+
2000, Pages 243-246, ISSN 0020-0190, 10.1016/S0020-0190(00)00112-5.
|
|
85
|
+
|
|
86
|
+
irb(main):004:0> fib.fast_val(10000)
|
|
87
|
+
#=> 33644764876431783266621612005107543310302148460680063906564769974680081442166662368155595513633734025582065332680836159373734790483865268263040892463056431887354544369559827491606602099884183933864652731300088830269235673613135117579297437854413752130520504347701602264758318906527890855154366159582987279682987510631200575428783453215515103870818298969791613127856265033195487140214287532698187962046936097879900350962302291026368131493195275630227837628441540360584402572114334961180023091208287046088923962328835461505776583271252546093591128203925285393434620904245248929403901706233888991085841065183173360437470737908552631764325733993712871937587746897479926305837065742830161637408969178426378624212835258112820516370298089332099905707920064367426202389783111470054074998459250360633560933883831923386783056136435351892133279732908133732642652633989763922723407882928177953580570993691049175470808931841056146322338217465637321248226383092103297701648054726243842374862411453093812206564914032751086643394517512161526545361333111314042436854805106765843493523836959653428071768775328348234345557366719731392746273629108210679280784718035329131176778924659089938635459327894523777674406192240337638674004021330343297496902028328145933418826817683893072003634795623117103101291953169794607632737589253530772552375943788434504067715555779056450443016640119462580972216729758615026968443146952034614932291105970676243268515992834709891284706740862008587135016260312071903172086094081298321581077282076353186624611278245537208532365305775956430072517744315051539600905168603220349163222640885248852433158051534849622434848299380905070483482449327453732624567755879089187190803662058009594743150052402532709746995318770724376825907419939632265984147498193609285223945039707165443156421328157688908058783183404917434556270520223564846495196112460268313970975069382648706613264507665074611512677522748621598642530711298441182622661057163515069260029861704945425047491378115154139941550671256271197133252763631939606902895650288268608362241082050562430701794976171121233066073310059947366875
|
data/Rakefile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
require "rbconfig"
|
|
4
|
+
|
|
5
|
+
EXT_DIR = File.expand_path("ext/fibonacci", __dir__)
|
|
6
|
+
EXT_NAME = "fibonacci_ext"
|
|
7
|
+
EXT_FILE = File.join(EXT_DIR, "#{EXT_NAME}.#{RbConfig::CONFIG['DLEXT']}")
|
|
8
|
+
|
|
9
|
+
file EXT_FILE => File.join(EXT_DIR, "extconf.rb") do
|
|
10
|
+
Dir.chdir(EXT_DIR) do
|
|
11
|
+
sh RbConfig.ruby, "extconf.rb"
|
|
12
|
+
sh "make"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task compile_extension: EXT_FILE
|
|
17
|
+
|
|
18
|
+
Rake::TestTask.new do |t|
|
|
19
|
+
t.libs << "lib"
|
|
20
|
+
t.libs << EXT_DIR
|
|
21
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
22
|
+
t.verbose = true
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
task test: :compile_extension
|
|
26
|
+
|
|
27
|
+
task default: :test
|
data/ext/fibonacci/extconf.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
require 'mkmf'
|
|
2
|
-
create_makefile('
|
|
2
|
+
create_makefile('fibonacci_ext')
|
data/ext/fibonacci/fibonacci.c
CHANGED
data/fibonacci.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "fibonacci/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "fibonacci"
|
|
7
|
+
s.version = VERSION
|
|
8
|
+
s.authors = ["NagaChaitanya Vellanki"]
|
|
9
|
+
s.email = ["nagachaitanya.vellanki.com"]
|
|
10
|
+
s.homepage = "http://github.com/chaitanyav/fibonacci"
|
|
11
|
+
s.summary = %q{Fibonacci}
|
|
12
|
+
s.description = %q{A Ruby gem for exploring Fibonacci series}
|
|
13
|
+
s.license = "MIT"
|
|
14
|
+
s.required_ruby_version = ">= 2.7"
|
|
15
|
+
|
|
16
|
+
s.rubyforge_project = "fibonacci"
|
|
17
|
+
|
|
18
|
+
s.files = Dir.glob('lib/**/*') + Dir.glob('ext/**/*.{c,h,rb}') + %w[README.markdown LICENSE Rakefile fibonacci.gemspec]
|
|
19
|
+
s.extensions = ['ext/fibonacci/extconf.rb']
|
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
22
|
+
s.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
s.metadata = {
|
|
25
|
+
"homepage_uri" => s.homepage,
|
|
26
|
+
"source_code_uri" => "https://github.com/chaitanyav/fibonacci",
|
|
27
|
+
"changelog_uri" => "https://github.com/chaitanyav/fibonacci/releases"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
s.add_development_dependency "rake", ">= 13.0"
|
|
31
|
+
s.add_development_dependency "minitest", ">= 5.0"
|
|
32
|
+
end
|
data/lib/fibonacci/version.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "0.1.
|
|
1
|
+
VERSION = "0.1.9"
|
data/lib/fibonacci.rb
CHANGED
data/test/fibonacci_test.rb
CHANGED
data/test/test_helper.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "bundler/setup"
|
|
2
|
+
require "rbconfig"
|
|
3
|
+
|
|
4
|
+
EXT_DIR = File.expand_path("../ext/fibonacci", __dir__)
|
|
5
|
+
EXT_NAME = "fibonacci_ext"
|
|
6
|
+
EXT_FILE = File.join(EXT_DIR, "#{EXT_NAME}.#{RbConfig::CONFIG['DLEXT']}")
|
|
7
|
+
|
|
8
|
+
unless File.exist?(EXT_FILE)
|
|
9
|
+
Dir.chdir(EXT_DIR) do
|
|
10
|
+
system(RbConfig.ruby, "extconf.rb") or raise "Failed to generate Makefile for the extension"
|
|
11
|
+
system("make") or raise "Failed to build the extension"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$LOAD_PATH.unshift(EXT_DIR) unless $LOAD_PATH.include?(EXT_DIR)
|
metadata
CHANGED
|
@@ -1,15 +1,42 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fibonacci
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- NagaChaitanya Vellanki
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: rake
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '13.0'
|
|
19
|
+
type: :development
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '13.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: minitest
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '5.0'
|
|
13
40
|
description: A Ruby gem for exploring Fibonacci series
|
|
14
41
|
email:
|
|
15
42
|
- nagachaitanya.vellanki.com
|
|
@@ -18,15 +45,23 @@ extensions:
|
|
|
18
45
|
- ext/fibonacci/extconf.rb
|
|
19
46
|
extra_rdoc_files: []
|
|
20
47
|
files:
|
|
48
|
+
- LICENSE
|
|
49
|
+
- README.markdown
|
|
50
|
+
- Rakefile
|
|
21
51
|
- ext/fibonacci/extconf.rb
|
|
22
52
|
- ext/fibonacci/fibonacci.c
|
|
53
|
+
- fibonacci.gemspec
|
|
23
54
|
- lib/fibonacci.rb
|
|
24
55
|
- lib/fibonacci/version.rb
|
|
25
56
|
- test/fibonacci_test.rb
|
|
57
|
+
- test/test_helper.rb
|
|
26
58
|
homepage: http://github.com/chaitanyav/fibonacci
|
|
27
|
-
licenses:
|
|
28
|
-
|
|
29
|
-
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata:
|
|
62
|
+
homepage_uri: http://github.com/chaitanyav/fibonacci
|
|
63
|
+
source_code_uri: https://github.com/chaitanyav/fibonacci
|
|
64
|
+
changelog_uri: https://github.com/chaitanyav/fibonacci/releases
|
|
30
65
|
rdoc_options: []
|
|
31
66
|
require_paths:
|
|
32
67
|
- lib
|
|
@@ -34,17 +69,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
34
69
|
requirements:
|
|
35
70
|
- - ">="
|
|
36
71
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: '
|
|
72
|
+
version: '2.7'
|
|
38
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
39
74
|
requirements:
|
|
40
75
|
- - ">="
|
|
41
76
|
- !ruby/object:Gem::Version
|
|
42
77
|
version: '0'
|
|
43
78
|
requirements: []
|
|
44
|
-
|
|
45
|
-
rubygems_version: 2.4.5
|
|
46
|
-
signing_key:
|
|
79
|
+
rubygems_version: 4.0.10
|
|
47
80
|
specification_version: 4
|
|
48
81
|
summary: Fibonacci
|
|
49
82
|
test_files:
|
|
50
83
|
- test/fibonacci_test.rb
|
|
84
|
+
- test/test_helper.rb
|