silicium 0.0.14 → 0.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +4 -0
- data/.gitignore +13 -11
- data/.rakeTasks +8 -0
- data/.travis.yml +17 -3
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile +8 -4
- data/LICENSE.txt +21 -21
- data/Makefile +269 -0
- data/README.md +588 -44
- data/Rakefile +17 -10
- data/bin/console +14 -14
- data/bin/setup +8 -8
- data/docs/Object.html +117 -0
- data/docs/README_md.html +142 -0
- data/docs/Silicium/Combinatorics.html +270 -0
- data/docs/Silicium/Dice/Polyhedron.html +315 -0
- data/docs/Silicium/Dice/PolyhedronSet.html +321 -0
- data/docs/Silicium/Dice.html +99 -0
- data/docs/Silicium/Error.html +106 -0
- data/docs/Silicium/Geometry/Line2dCanon.html +243 -0
- data/docs/Silicium/Geometry/VariablesOrderException.html +106 -0
- data/docs/Silicium/Geometry.html +940 -0
- data/docs/Silicium/GraphVisualizer.html +226 -0
- data/docs/Silicium/Graphs/GraphError.html +106 -0
- data/docs/Silicium/Graphs/OrientedGraph.html +901 -0
- data/docs/Silicium/Graphs/UnorientedGraph.html +237 -0
- data/docs/Silicium/Graphs.html +374 -0
- data/docs/Silicium/IntegralDoesntExistError.html +106 -0
- data/docs/Silicium/NumericalIntegration.html +521 -0
- data/docs/Silicium/Optimization.html +629 -0
- data/docs/Silicium/Plotter/Image.html +297 -0
- data/docs/Silicium/Plotter.html +186 -0
- data/docs/Silicium.html +101 -0
- data/docs/created.rid +9 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +619 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +134 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +697 -0
- data/lib/algebra.rb +452 -0
- data/lib/algebra_diff.rb +258 -0
- data/lib/geometry/figure.rb +62 -0
- data/lib/geometry.rb +290 -0
- data/lib/geometry3d.rb +270 -0
- data/lib/graph/dfs.rb +41 -0
- data/lib/graph/kruskal.rb +36 -0
- data/lib/graph/scc.rb +97 -0
- data/lib/graph.rb +350 -0
- data/lib/graph_visualizer.rb +286 -0
- data/lib/ml_algorithms.rb +181 -0
- data/lib/numerical_integration.rb +184 -0
- data/lib/optimization.rb +208 -0
- data/lib/plotter.rb +258 -0
- data/lib/polynomial_division.rb +132 -0
- data/lib/polynomial_interpolation.rb +94 -0
- data/lib/regression.rb +120 -0
- data/lib/silicium/adding.rb +37 -0
- data/lib/silicium/conversions.rb +23 -0
- data/lib/silicium/multi.rb +82 -0
- data/lib/silicium/sparse.rb +76 -0
- data/lib/silicium/sugar.rb +37 -0
- data/lib/silicium/trans.rb +26 -0
- data/lib/silicium/version.rb +3 -3
- data/lib/silicium.rb +29 -6
- data/lib/theory_of_probability.rb +240 -0
- data/lib/topological_sort.rb +50 -0
- data/oriented_graph.png +0 -0
- data/plot.png +0 -0
- data/silicium.gemspec +4 -3
- metadata +122 -12
data/Rakefile
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
-
require "bundler/gem_tasks"
|
2
|
-
require "rake/testtask"
|
3
|
-
|
4
|
-
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs << "test"
|
6
|
-
t.libs << "lib"
|
7
|
-
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
-
end
|
9
|
-
|
10
|
-
task :default => :test
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :test
|
11
|
+
|
12
|
+
require 'rdoc/task'
|
13
|
+
|
14
|
+
RDoc::Task.new do |rdoc|
|
15
|
+
rdoc.rdoc_files.include("README.md", "lib /*.rb")
|
16
|
+
rdoc.rdoc_dir = 'docs'
|
17
|
+
end
|
data/bin/console
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "silicium"
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require "pry"
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require "irb"
|
14
|
-
IRB.start(__FILE__)
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "silicium"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
set -euo pipefail
|
3
|
-
IFS=$'\n\t'
|
4
|
-
set -vx
|
5
|
-
|
6
|
-
bundle install
|
7
|
-
|
8
|
-
# Do any other automated setup that you need to do here
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -euo pipefail
|
3
|
+
IFS=$'\n\t'
|
4
|
+
set -vx
|
5
|
+
|
6
|
+
bundle install
|
7
|
+
|
8
|
+
# Do any other automated setup that you need to do here
|
data/docs/Object.html
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>class Object - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="class">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="./index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
<div id="parent-class-section" class="nav-section">
|
63
|
+
<h3>Parent</h3>
|
64
|
+
|
65
|
+
|
66
|
+
<p class="link">BasicObject
|
67
|
+
|
68
|
+
</div>
|
69
|
+
|
70
|
+
<div id="includes-section" class="nav-section">
|
71
|
+
<h3>Included Modules</h3>
|
72
|
+
|
73
|
+
<ul class="link-list">
|
74
|
+
|
75
|
+
|
76
|
+
<li><a class="include" href="Silicium/Plotter.html">Silicium::Plotter</a>
|
77
|
+
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
</div>
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
</nav>
|
86
|
+
|
87
|
+
<main role="main" aria-labelledby="class-Object">
|
88
|
+
<h1 id="class-Object" class="class">
|
89
|
+
class Object
|
90
|
+
</h1>
|
91
|
+
|
92
|
+
<section class="description">
|
93
|
+
|
94
|
+
</section>
|
95
|
+
|
96
|
+
|
97
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
</section>
|
108
|
+
|
109
|
+
</main>
|
110
|
+
|
111
|
+
|
112
|
+
<footer id="validator-badges" role="contentinfo">
|
113
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
114
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
115
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
116
|
+
</footer>
|
117
|
+
|
data/docs/README_md.html
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>README - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="file">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="./index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
<div class="nav-section">
|
60
|
+
<h3>Table of Contents</h3>
|
61
|
+
|
62
|
+
<ul class="link-list" role="directory">
|
63
|
+
<li><a href="#label-Silicium">Silicium</a>
|
64
|
+
<li><a href="#label-Installation">Installation</a>
|
65
|
+
<li><a href="#label-Usage">Usage</a>
|
66
|
+
<li><a href="#label-Development">Development</a>
|
67
|
+
<li><a href="#label-Contributing">Contributing</a>
|
68
|
+
<li><a href="#label-License">License</a>
|
69
|
+
<li><a href="#label-Code+of+Conduct">Code of Conduct</a>
|
70
|
+
</ul>
|
71
|
+
</div>
|
72
|
+
|
73
|
+
|
74
|
+
<div id="project-metadata">
|
75
|
+
<div id="fileindex-section" class="nav-section">
|
76
|
+
<h3>Pages</h3>
|
77
|
+
|
78
|
+
<ul class="link-list">
|
79
|
+
|
80
|
+
<li><a href="./README_md.html">README</a>
|
81
|
+
|
82
|
+
</ul>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
</nav>
|
87
|
+
|
88
|
+
<main role="main" aria-label="Page README.md">
|
89
|
+
|
90
|
+
<p><a href="https://badge.fury.io/rb/silicium"><img src="https://badge.fury.io/rb/silicium.svg"></a> <a href="https://travis-ci.org/mmcs-ruby/silicium"><img src="https://travis-ci.org/mmcs-ruby/silicium.svg?branch=master"></a> <a href="https://codeclimate.com/github/mmcs-ruby/silicium/maintainability"><img src="https://api.codeclimate.com/v1/badges/b0ec4b3029f90d4273a1/maintainability"></a> <a href="https://codeclimate.com/github/mmcs-ruby/silicium/test_coverage"><img src="https://api.codeclimate.com/v1/badges/b0ec4b3029f90d4273a1/test_coverage"></a></p>
|
91
|
+
|
92
|
+
<h1 id="label-Silicium"><a href="Silicium.html"><code>Silicium</code></a><span><a href="#label-Silicium">¶</a> <a href="#top">↑</a></span></h1>
|
93
|
+
|
94
|
+
<p>Ruby Math Library written as exercise by MMCS students.</p>
|
95
|
+
|
96
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
97
|
+
|
98
|
+
<p>Add this line to your application's Gemfile:</p>
|
99
|
+
|
100
|
+
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-string">'silicium'</span>
|
101
|
+
</pre>
|
102
|
+
|
103
|
+
<p>And then execute:</p>
|
104
|
+
|
105
|
+
<pre>$ bundle</pre>
|
106
|
+
|
107
|
+
<p>Or install it yourself as:</p>
|
108
|
+
|
109
|
+
<pre>$ gem install silicium</pre>
|
110
|
+
|
111
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
112
|
+
|
113
|
+
<p>TODO: Write usage instructions here</p>
|
114
|
+
|
115
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
116
|
+
|
117
|
+
<p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake test</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
|
118
|
+
|
119
|
+
<p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and tags, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
|
120
|
+
|
121
|
+
<h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">¶</a> <a href="#top">↑</a></span></h2>
|
122
|
+
|
123
|
+
<p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/mmcs-ruby/silicium">github.com/mmcs-ruby/silicium</a>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="http://contributor-covenant.org">Contributor Covenant</a> code of conduct.</p>
|
124
|
+
|
125
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
126
|
+
|
127
|
+
<p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
|
128
|
+
|
129
|
+
<h2 id="label-Code+of+Conduct">Code of Conduct<span><a href="#label-Code+of+Conduct">¶</a> <a href="#top">↑</a></span></h2>
|
130
|
+
|
131
|
+
<p>Everyone interacting in the <a href="Silicium.html"><code>Silicium</code></a> project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the {code of conduct}[https://github.com/[USERNAME]/silicium/blob/master/CODE_OF_CONDUCT.md].</p>
|
132
|
+
|
133
|
+
</main>
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
<footer id="validator-badges" role="contentinfo">
|
138
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
139
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
140
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
141
|
+
</footer>
|
142
|
+
|
@@ -0,0 +1,270 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>module Silicium::Combinatorics - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "../";
|
11
|
+
var index_rel_prefix = "../";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="../js/navigation.js" defer></script>
|
15
|
+
<script src="../js/search.js" defer></script>
|
16
|
+
<script src="../js/search_index.js" defer></script>
|
17
|
+
<script src="../js/searcher.js" defer></script>
|
18
|
+
<script src="../js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="../css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="../css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
<body id="top" role="document" class="module">
|
27
|
+
<nav role="navigation">
|
28
|
+
<div id="project-navigation">
|
29
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
30
|
+
<h2>
|
31
|
+
<a href="../index.html" rel="home">Home</a>
|
32
|
+
</h2>
|
33
|
+
|
34
|
+
<div id="table-of-contents-navigation">
|
35
|
+
<a href="../table_of_contents.html#pages">Pages</a>
|
36
|
+
<a href="../table_of_contents.html#classes">Classes</a>
|
37
|
+
<a href="../table_of_contents.html#methods">Methods</a>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
42
|
+
<form action="#" method="get" accept-charset="utf-8">
|
43
|
+
<div id="search-field-wrapper">
|
44
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
45
|
+
aria-autocomplete="list" aria-controls="search-results"
|
46
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
47
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
48
|
+
</div>
|
49
|
+
|
50
|
+
<ul id="search-results" aria-label="Search Results"
|
51
|
+
aria-busy="false" aria-expanded="false"
|
52
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
53
|
+
</form>
|
54
|
+
</div>
|
55
|
+
|
56
|
+
</div>
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<!-- Method Quickref -->
|
66
|
+
<div id="method-list-section" class="nav-section">
|
67
|
+
<h3>Methods</h3>
|
68
|
+
|
69
|
+
<ul class="link-list" role="directory">
|
70
|
+
|
71
|
+
<li ><a href="#method-i-arrangement">#arrangement</a>
|
72
|
+
|
73
|
+
<li ><a href="#method-i-combination">#combination</a>
|
74
|
+
|
75
|
+
<li ><a href="#method-i-fact">#fact</a>
|
76
|
+
|
77
|
+
<li ><a href="#method-i-factorial">#factorial</a>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
</div>
|
81
|
+
|
82
|
+
</div>
|
83
|
+
</nav>
|
84
|
+
|
85
|
+
<main role="main" aria-labelledby="module-Silicium::Combinatorics">
|
86
|
+
<h1 id="module-Silicium::Combinatorics" class="module">
|
87
|
+
module Silicium::Combinatorics
|
88
|
+
</h1>
|
89
|
+
|
90
|
+
<section class="description">
|
91
|
+
|
92
|
+
</section>
|
93
|
+
|
94
|
+
|
95
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<section id="public-instance-5Buntitled-5D-method-details" class="method-section">
|
106
|
+
<header>
|
107
|
+
<h3>Public Instance Methods</h3>
|
108
|
+
</header>
|
109
|
+
|
110
|
+
|
111
|
+
<div id="method-i-arrangement" class="method-detail ">
|
112
|
+
|
113
|
+
<div class="method-heading">
|
114
|
+
<span class="method-name">arrangement</span><span
|
115
|
+
class="method-args">(n, k)</span>
|
116
|
+
|
117
|
+
<span class="method-click-advice">click to toggle source</span>
|
118
|
+
|
119
|
+
</div>
|
120
|
+
|
121
|
+
|
122
|
+
<div class="method-description">
|
123
|
+
|
124
|
+
<p>Function A(n,k)</p>
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
<div class="method-source-code" id="arrangement-source">
|
130
|
+
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 38</span>
|
131
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">arrangement</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
132
|
+
<span class="ruby-identifier">f</span> = <span class="ruby-identifier">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
133
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">k</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">k</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
134
|
+
<span class="ruby-value">-1</span>
|
135
|
+
<span class="ruby-keyword">else</span>
|
136
|
+
<span class="ruby-identifier">f</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">/</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">1</span>]
|
137
|
+
<span class="ruby-keyword">end</span>
|
138
|
+
<span class="ruby-keyword">end</span></pre>
|
139
|
+
</div>
|
140
|
+
|
141
|
+
</div>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
</div>
|
147
|
+
|
148
|
+
|
149
|
+
<div id="method-i-combination" class="method-detail ">
|
150
|
+
|
151
|
+
<div class="method-heading">
|
152
|
+
<span class="method-name">combination</span><span
|
153
|
+
class="method-args">(n, k)</span>
|
154
|
+
|
155
|
+
<span class="method-click-advice">click to toggle source</span>
|
156
|
+
|
157
|
+
</div>
|
158
|
+
|
159
|
+
|
160
|
+
<div class="method-description">
|
161
|
+
|
162
|
+
<p>Function C(n,k)</p>
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
<div class="method-source-code" id="combination-source">
|
168
|
+
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 27</span>
|
169
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">combination</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
170
|
+
<span class="ruby-identifier">f</span> = <span class="ruby-identifier">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
171
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator"><</span> <span class="ruby-identifier">k</span> <span class="ruby-keyword">or</span> <span class="ruby-identifier">k</span> <span class="ruby-operator"><=</span> <span class="ruby-value">0</span>
|
172
|
+
<span class="ruby-value">-1</span>
|
173
|
+
<span class="ruby-keyword">else</span>
|
174
|
+
<span class="ruby-identifier">f</span>[<span class="ruby-value">0</span>] <span class="ruby-operator">/</span> (<span class="ruby-identifier">f</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">*</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">1</span>])
|
175
|
+
<span class="ruby-keyword">end</span>
|
176
|
+
<span class="ruby-keyword">end</span></pre>
|
177
|
+
</div>
|
178
|
+
|
179
|
+
</div>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
</div>
|
185
|
+
|
186
|
+
|
187
|
+
<div id="method-i-fact" class="method-detail ">
|
188
|
+
|
189
|
+
<div class="method-heading">
|
190
|
+
<span class="method-name">fact</span><span
|
191
|
+
class="method-args">(n, k)</span>
|
192
|
+
|
193
|
+
<span class="method-click-advice">click to toggle source</span>
|
194
|
+
|
195
|
+
</div>
|
196
|
+
|
197
|
+
|
198
|
+
<div class="method-description">
|
199
|
+
|
200
|
+
<p>Factorial for counting 3 parameters in one run</p>
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
<div class="method-source-code" id="fact-source">
|
206
|
+
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 17</span>
|
207
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">fact</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>)
|
208
|
+
<span class="ruby-identifier">res</span> = [<span class="ruby-value">1</span>,<span class="ruby-value">1</span>,<span class="ruby-value">1</span>]
|
209
|
+
<span class="ruby-keyword">if</span> <span class="ruby-identifier">n</span> <span class="ruby-operator">></span> <span class="ruby-value">1</span>
|
210
|
+
<span class="ruby-identifier">fact_n_greater_1</span>(<span class="ruby-identifier">n</span>, <span class="ruby-identifier">k</span>, <span class="ruby-identifier">res</span>)
|
211
|
+
<span class="ruby-keyword">end</span>
|
212
|
+
<span class="ruby-identifier">res</span>
|
213
|
+
<span class="ruby-keyword">end</span></pre>
|
214
|
+
</div>
|
215
|
+
|
216
|
+
</div>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
</div>
|
222
|
+
|
223
|
+
|
224
|
+
<div id="method-i-factorial" class="method-detail ">
|
225
|
+
|
226
|
+
<div class="method-heading">
|
227
|
+
<span class="method-name">factorial</span><span
|
228
|
+
class="method-args">(n)</span>
|
229
|
+
|
230
|
+
<span class="method-click-advice">click to toggle source</span>
|
231
|
+
|
232
|
+
</div>
|
233
|
+
|
234
|
+
|
235
|
+
<div class="method-description">
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
<div class="method-source-code" id="factorial-source">
|
243
|
+
<pre><span class="ruby-comment"># File lib/theory_of_probability.rb, line 10</span>
|
244
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">factorial</span>(<span class="ruby-identifier">n</span>)
|
245
|
+
<span class="ruby-identifier">res</span> = (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">n</span>).<span class="ruby-identifier">inject</span>(<span class="ruby-value">:*</span>) <span class="ruby-operator">||</span> <span class="ruby-value">1</span>
|
246
|
+
<span class="ruby-identifier">res</span>
|
247
|
+
<span class="ruby-keyword">end</span></pre>
|
248
|
+
</div>
|
249
|
+
|
250
|
+
</div>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</div>
|
256
|
+
|
257
|
+
|
258
|
+
</section>
|
259
|
+
|
260
|
+
</section>
|
261
|
+
|
262
|
+
</main>
|
263
|
+
|
264
|
+
|
265
|
+
<footer id="validator-badges" role="contentinfo">
|
266
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
267
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.2.0.
|
268
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
269
|
+
</footer>
|
270
|
+
|