dgoldhirsch-cs 0.0.1 → 0.0.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.
- data/README.rdoc +5 -5
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -15,7 +15,7 @@ M**k contains the (k + 1)'th Fibonacci number. This is very fast if the Matrix.
|
|
15
15
|
is optimized to use successive squaring rather than individual multiplications. Ruby's
|
16
16
|
implementation of Matrix.** does exactly this, fortunately.
|
17
17
|
|
18
|
-
[
|
18
|
+
[Simple addition] This is a simple loop that computes F(n) by adding F(0) + F(1) + ... + F(n - 1).
|
19
19
|
For n < 5000, this seems to perform about as well as the matrix exponentiation. But, thereafter
|
20
20
|
it is MUCH slower (at least, in the benchmarks we performed).
|
21
21
|
|
@@ -25,12 +25,12 @@ The algorithms are available in two forms. The basic form is a module method:
|
|
25
25
|
|
26
26
|
require 'rubygems'
|
27
27
|
require 'cs'
|
28
|
-
y = CS::fibonacci(6) # returns F(6) which is 8 = 5 + 3, using
|
28
|
+
y = CS::fibonacci(6) # returns F(6) which is 8 = 5 + 3, using matrix algorithm by default
|
29
29
|
|
30
30
|
An optional parameter selects the algorithm to be used. By default, the matrix
|
31
31
|
exponentiation algorithm is used. However, you can choose one or the other as follows:
|
32
32
|
|
33
|
-
y_more_slowly = CS::fibonacci(6, CS::
|
33
|
+
y_more_slowly = CS::fibonacci(6, CS::ADDITION)
|
34
34
|
|
35
35
|
As a convenience, the method is also available as an instance mixin for the class Integer:
|
36
36
|
|
@@ -41,8 +41,8 @@ As a convenience, the method is also available as an instance mixin for the clas
|
|
41
41
|
|
42
42
|
== Obtaining the gem from github
|
43
43
|
|
44
|
-
gem sources -a http://gems.github.com
|
45
|
-
gem install dgoldhirsch-cs
|
44
|
+
gem sources -a http://gems.github.com
|
45
|
+
gem install dgoldhirsch-cs
|
46
46
|
|
47
47
|
== Extensions to Standard Library
|
48
48
|
|