algebra 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +53 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +28 -0
- data/LICENSE.txt +21 -0
- data/README-ja.txt +60 -0
- data/README.md +61 -0
- data/Rakefile +43 -0
- data/algebra.gemspec +33 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc-ja/README-ja.html +69 -0
- data/doc-ja/README-ja.rd +60 -0
- data/doc-ja/README.html +0 -0
- data/doc-ja/README.rd +0 -0
- data/doc-ja/algebra-ja.html +66 -0
- data/doc-ja/algebra-ja.rd +60 -0
- data/doc-ja/algebraic-equation-ja.html +36 -0
- data/doc-ja/algebraic-equation-ja.rd +26 -0
- data/doc-ja/algebraic-extension-field-ja.html +122 -0
- data/doc-ja/algebraic-extension-field-ja.rd +118 -0
- data/doc-ja/algebraic-parser-ja.html +87 -0
- data/doc-ja/algebraic-parser-ja.rd +95 -0
- data/doc-ja/changes.html +161 -0
- data/doc-ja/changes.rd +119 -0
- data/doc-ja/elementary-divisor-ja.html +56 -0
- data/doc-ja/elementary-divisor-ja.rd +45 -0
- data/doc-ja/euclidian-ring-ja.html +78 -0
- data/doc-ja/euclidian-ring-ja.rd +69 -0
- data/doc-ja/finite-group-ja.html +285 -0
- data/doc-ja/finite-group-ja.rd +276 -0
- data/doc-ja/finite-map-ja.html +224 -0
- data/doc-ja/finite-map-ja.rd +227 -0
- data/doc-ja/finite-set-ja.html +393 -0
- data/doc-ja/finite-set-ja.rd +408 -0
- data/doc-ja/index-ja.html +113 -0
- data/doc-ja/index-ja.rd +112 -0
- data/doc-ja/jordan-form-ja.html +106 -0
- data/doc-ja/jordan-form-ja.rd +99 -0
- data/doc-ja/localized-ring-ja.html +121 -0
- data/doc-ja/localized-ring-ja.rd +131 -0
- data/doc-ja/m-polynomial-ja.html +542 -0
- data/doc-ja/m-polynomial-ja.rd +596 -0
- data/doc-ja/matrix-algebra-ja.html +686 -0
- data/doc-ja/matrix-algebra-ja.rd +727 -0
- data/doc-ja/matrix-algebra-triplet-ja.html +124 -0
- data/doc-ja/matrix-algebra-triplet-ja.rd +129 -0
- data/doc-ja/permutation-group-ja.html +159 -0
- data/doc-ja/permutation-group-ja.rd +151 -0
- data/doc-ja/polynomial-converter-ja.html +64 -0
- data/doc-ja/polynomial-converter-ja.rd +54 -0
- data/doc-ja/polynomial-ja.html +446 -0
- data/doc-ja/polynomial-ja.rd +473 -0
- data/doc-ja/residue-class-ring-ja.html +112 -0
- data/doc-ja/residue-class-ring-ja.rd +113 -0
- data/doc-ja/sample-algebraic-equation01.rb.v.rd +11 -0
- data/doc-ja/sample-algebraic-equation02.rb.v.rd +11 -0
- data/doc-ja/sample-algebraic-root01.rb.v.rd +20 -0
- data/doc-ja/sample-algebraicfield01.rb.v.rd +26 -0
- data/doc-ja/sample-algebraicfield02.rb.v.rd +15 -0
- data/doc-ja/sample-cayleyhamilton01.rb.v.rd +14 -0
- data/doc-ja/sample-diagonalization01.rb.v.rd +48 -0
- data/doc-ja/sample-divmod01.rb.v.rd +17 -0
- data/doc-ja/sample-elementary-divisor01.rb.v.rd +48 -0
- data/doc-ja/sample-factorize01.rb.v.rd +11 -0
- data/doc-ja/sample-factorize02.rb.v.rd +13 -0
- data/doc-ja/sample-factorize03.rb.v.rd +14 -0
- data/doc-ja/sample-factorize04.rb.v.rd +14 -0
- data/doc-ja/sample-factorize05.rb.v.rd +53 -0
- data/doc-ja/sample-galois-group01.rb.v.rd +27 -0
- data/doc-ja/sample-gaussian-elimination01.rb.v.rd +19 -0
- data/doc-ja/sample-geometry01.rb.v.rd +33 -0
- data/doc-ja/sample-geometry02.rb.v.rd +34 -0
- data/doc-ja/sample-geometry03.rb.v.rd +45 -0
- data/doc-ja/sample-geometry04.rb.v.rd +33 -0
- data/doc-ja/sample-geometry07.rb.v.rd +62 -0
- data/doc-ja/sample-groebner01.rb.v.rd +13 -0
- data/doc-ja/sample-groebner02.rb.v.rd +18 -0
- data/doc-ja/sample-groebner03.rb.v.rd +19 -0
- data/doc-ja/sample-group01.rb.v.rd +21 -0
- data/doc-ja/sample-jordan-form01.rb.v.rd +56 -0
- data/doc-ja/sample-jordanform01.rb.v.rd +55 -0
- data/doc-ja/sample-lagrange-multiplier01.rb.v.rd +35 -0
- data/doc-ja/sample-m-factorize01.rb.v.rd +15 -0
- data/doc-ja/sample-m-factorize02.rb.v.rd +12 -0
- data/doc-ja/sample-m-polynomial01.rb.v.rd +10 -0
- data/doc-ja/sample-map01.rb.v.rd +9 -0
- data/doc-ja/sample-polynomial01.rb.v.rd +9 -0
- data/doc-ja/sample-polynomial02.rb.v.rd +11 -0
- data/doc-ja/sample-primefield01.rb.v.rd +13 -0
- data/doc-ja/sample-quotientfield01.rb.v.rd +11 -0
- data/doc-ja/sample-quotientfield02.rb.v.rd +18 -0
- data/doc-ja/sample-quotientfield03.rb.v.rd +16 -0
- data/doc-ja/sample-quotientfield04.rb.v.rd +16 -0
- data/doc-ja/sample-set01.rb.v.rd +18 -0
- data/doc-ja/sample-splitting-field01.rb.v.rd +19 -0
- data/doc-ja/samples-ja.html +885 -0
- data/doc-ja/samples-ja.rd +221 -0
- data/doc-ja/style.css +85 -0
- data/doc-ja/todo.html +20 -0
- data/doc-ja/todo.rd +9 -0
- data/lib/algebra.rb +36 -0
- data/lib/algebra/algebraic-equation.rb +56 -0
- data/lib/algebra/algebraic-extension-field.rb +135 -0
- data/lib/algebra/algebraic-parser.rb +160 -0
- data/lib/algebra/algebraic-system.rb +224 -0
- data/lib/algebra/annihilate.rb +52 -0
- data/lib/algebra/array-supplement.rb +53 -0
- data/lib/algebra/auto-require.rb +84 -0
- data/lib/algebra/chinese-rem-th.rb +135 -0
- data/lib/algebra/combinatorial.rb +145 -0
- data/lib/algebra/elementary-divisor.rb +193 -0
- data/lib/algebra/euclidian-ring.rb +161 -0
- data/lib/algebra/factors.rb +305 -0
- data/lib/algebra/finite-group.rb +374 -0
- data/lib/algebra/finite-map.rb +201 -0
- data/lib/algebra/finite-set.rb +456 -0
- data/lib/algebra/galois-group.rb +129 -0
- data/lib/algebra/gaussian-elimination.rb +385 -0
- data/lib/algebra/groebner-basis-coeff.rb +228 -0
- data/lib/algebra/groebner-basis.rb +197 -0
- data/lib/algebra/import-module-single-thread.rb +86 -0
- data/lib/algebra/import-module.rb +491 -0
- data/lib/algebra/jordan-form.rb +114 -0
- data/lib/algebra/linear-algebra.rb +143 -0
- data/lib/algebra/localized-ring.rb +294 -0
- data/lib/algebra/m-index.rb +282 -0
- data/lib/algebra/m-polynomial-factor-int.rb +186 -0
- data/lib/algebra/m-polynomial-factor-zp.rb +114 -0
- data/lib/algebra/m-polynomial-factor.rb +315 -0
- data/lib/algebra/m-polynomial-gcd.rb +40 -0
- data/lib/algebra/m-polynomial.rb +875 -0
- data/lib/algebra/matrix-algebra-triplet.rb +292 -0
- data/lib/algebra/matrix-algebra.rb +929 -0
- data/lib/algebra/numeric-supplement.rb +123 -0
- data/lib/algebra/permutation-group.rb +257 -0
- data/lib/algebra/polynomial-converter.rb +193 -0
- data/lib/algebra/polynomial-factor-alg.rb +148 -0
- data/lib/algebra/polynomial-factor-int.rb +252 -0
- data/lib/algebra/polynomial-factor-zp.rb +165 -0
- data/lib/algebra/polynomial-factor.rb +140 -0
- data/lib/algebra/polynomial.rb +592 -0
- data/lib/algebra/powers.rb +31 -0
- data/lib/algebra/prime-gen.rb +32 -0
- data/lib/algebra/rational.rb +81 -0
- data/lib/algebra/residue-class-ring.rb +219 -0
- data/lib/algebra/sets-system.rb +43 -0
- data/lib/algebra/splitting-field.rb +103 -0
- data/lib/algebra/version.rb +3 -0
- data/sample/Makefile +10 -0
- data/sample/do-testscripts.rb +100 -0
- data/sample/sample-algebraic-equation01.rb +6 -0
- data/sample/sample-algebraic-equation02.rb +6 -0
- data/sample/sample-algebraic-root01.rb +15 -0
- data/sample/sample-algebraicfield01.rb +21 -0
- data/sample/sample-algebraicfield02.rb +10 -0
- data/sample/sample-cayleyhamilton01.rb +9 -0
- data/sample/sample-diagonalization01.rb +43 -0
- data/sample/sample-divmod01.rb +12 -0
- data/sample/sample-elementary-divisor01.rb +43 -0
- data/sample/sample-factorize01.rb +6 -0
- data/sample/sample-factorize02.rb +8 -0
- data/sample/sample-factorize03.rb +9 -0
- data/sample/sample-factorize04.rb +9 -0
- data/sample/sample-factorize05.rb +48 -0
- data/sample/sample-galois-group01.rb +22 -0
- data/sample/sample-gaussian-elimination01.rb +14 -0
- data/sample/sample-geometry01.rb +28 -0
- data/sample/sample-geometry02.rb +29 -0
- data/sample/sample-geometry03.rb +40 -0
- data/sample/sample-geometry04.rb +28 -0
- data/sample/sample-geometry07.rb +58 -0
- data/sample/sample-groebner01.rb +8 -0
- data/sample/sample-groebner02.rb +13 -0
- data/sample/sample-groebner03.rb +14 -0
- data/sample/sample-group01.rb +16 -0
- data/sample/sample-jordan-form01.rb +51 -0
- data/sample/sample-lagrange-multiplier01.rb +30 -0
- data/sample/sample-m-factorize01.rb +10 -0
- data/sample/sample-m-factorize02.rb +7 -0
- data/sample/sample-m-polynomial01.rb +5 -0
- data/sample/sample-map01.rb +4 -0
- data/sample/sample-polynomial01.rb +4 -0
- data/sample/sample-polynomial02.rb +6 -0
- data/sample/sample-primefield01.rb +8 -0
- data/sample/sample-quotientfield01.rb +6 -0
- data/sample/sample-quotientfield02.rb +13 -0
- data/sample/sample-quotientfield03.rb +11 -0
- data/sample/sample-quotientfield04.rb +11 -0
- data/sample/sample-set01.rb +13 -0
- data/sample/sample-splitting-field01.rb +14 -0
- data/sample/test-00-cayley-hamilton.rb +76 -0
- data/sample/test-00-groebner-basis.rb +274 -0
- data/sample/test-00-polynomial-factor-alg.rb +89 -0
- data/sample/test-00.list +4 -0
- data/sample/time-trial.rb +65 -0
- metadata +373 -0
@@ -0,0 +1,408 @@
|
|
1
|
+
########################################################################
|
2
|
+
# #
|
3
|
+
# finite-set.rb #
|
4
|
+
# #
|
5
|
+
########################################################################
|
6
|
+
=begin
|
7
|
+
[((<index-ja|URL:index-ja.html>))]
|
8
|
+
[((<finite-map-ja|URL:finite-map-ja.html>))]
|
9
|
+
((<Algebra::Set>))
|
10
|
+
/
|
11
|
+
((<Enumerable>))
|
12
|
+
|
13
|
+
= Algebra::Set
|
14
|
+
((*集合のクラス*))
|
15
|
+
|
16
|
+
集合を表現するクラスです。2つの集合 ((|s|)), ((|t|)) に関して、
|
17
|
+
((|s|)) が ((|t|)) に含まれる事は ((<all?>)) を使って、
|
18
|
+
|
19
|
+
s.all?{|x| t.member?(x)}
|
20
|
+
|
21
|
+
で表現されます。
|
22
|
+
|
23
|
+
== ファイル名:
|
24
|
+
* ((|finite-set.rb|))
|
25
|
+
|
26
|
+
== スーパークラス:
|
27
|
+
* ((|Object|))
|
28
|
+
|
29
|
+
== インクルードしているモジュール:
|
30
|
+
|
31
|
+
* ((|Enumerable|))
|
32
|
+
|
33
|
+
== クラスメソッド:
|
34
|
+
|
35
|
+
--- ::[]([obj0, [obj1, [obj2, ...]]])
|
36
|
+
引数の列から ((|Set|)) オブジェクトを生成します。
|
37
|
+
|
38
|
+
例: 全て {"a", [1, 2], 0} を生成する。
|
39
|
+
require "finite-set"
|
40
|
+
p Algebra::Set[0, "a", [1, 2]]
|
41
|
+
p Algebra::Set.new(0, "a", [1, 2])
|
42
|
+
p Algebra::Set.new_a([0, "a", [1, 2]])
|
43
|
+
p Algebra::Set.new_h({0=>true, "a"=>true, [1, 2]=>true})
|
44
|
+
|
45
|
+
--- ::new([obj0, [obj1, [obj2, ...]]])
|
46
|
+
引数の列から ((|Set|)) オブジェクトを生成します。
|
47
|
+
|
48
|
+
--- ::new_a(a)
|
49
|
+
配列 ((|a|)) から ((|Set|)) オブジェクトを生成します。
|
50
|
+
|
51
|
+
--- ::new_h(h)
|
52
|
+
((|Hash|)) から ((|Set|)) オブジェクトを生成します。
|
53
|
+
|
54
|
+
--- self.empty_set
|
55
|
+
空集合を生成する。
|
56
|
+
|
57
|
+
--- ::phi
|
58
|
+
--- ::null
|
59
|
+
((<::empty_set>)) のエイリアスです。
|
60
|
+
|
61
|
+
|
62
|
+
--- ::singleton(x)
|
63
|
+
((|x|)) 一元のみで構成される集合を生成します。
|
64
|
+
|
65
|
+
== メソッド:
|
66
|
+
|
67
|
+
--- empty_set
|
68
|
+
空集合を生成する。
|
69
|
+
|
70
|
+
--- phi
|
71
|
+
--- null
|
72
|
+
((<empty_set>)) のエイリアスです。
|
73
|
+
|
74
|
+
--- empty?
|
75
|
+
空集合であるとき真を返します。
|
76
|
+
|
77
|
+
--- phi?
|
78
|
+
--- empty_set?
|
79
|
+
--- null?
|
80
|
+
((<empty?>)) のエイリアスです。
|
81
|
+
|
82
|
+
--- singleton(x)
|
83
|
+
((|x|)) 一元のみで構成される集合を生成します。
|
84
|
+
|
85
|
+
--- singleton?
|
86
|
+
一元のみで構成される集合であるとき真を返します。
|
87
|
+
|
88
|
+
--- size
|
89
|
+
集合の大きさを返します。
|
90
|
+
|
91
|
+
--- each
|
92
|
+
集合の各要素に関して繰り返します。繰り返しの順番は不定です。
|
93
|
+
|
94
|
+
例:
|
95
|
+
require "finite-set"
|
96
|
+
include Algebra
|
97
|
+
Set[0, 1, 2].each do |x|
|
98
|
+
p x #=> 1, 0, 2
|
99
|
+
end
|
100
|
+
|
101
|
+
--- separate
|
102
|
+
集合の各要素をブロックパラメータに渡し、ブロックの値を真にする
|
103
|
+
もので構成される集合を返します。
|
104
|
+
|
105
|
+
例:
|
106
|
+
require "finite-set"
|
107
|
+
include Algebra
|
108
|
+
p Set[0, 1, 2, 3].separate{|x| x % 2 == 0} #=> {2, 0}
|
109
|
+
|
110
|
+
--- select_s
|
111
|
+
--- find_all_s
|
112
|
+
((<separate>)) のエイリアスです。
|
113
|
+
|
114
|
+
--- map_s
|
115
|
+
集合の各要素をブロックパラメータに渡し、ブロックの値によって
|
116
|
+
構成される集合を返します。
|
117
|
+
|
118
|
+
例:
|
119
|
+
require "finite-set"
|
120
|
+
include Algebra
|
121
|
+
p Set[0, 1, 2, 3].map_s{|x| x % 2 + 1} #=> {2, 1}
|
122
|
+
|
123
|
+
--- pick
|
124
|
+
集合の要素から一つ選んで値とします。どの要素が選ばれるかは
|
125
|
+
不定です。空集合に対しては ((|nil|)) を返します。
|
126
|
+
|
127
|
+
--- shift
|
128
|
+
集合の要素から一つ選んで取り出し値とします。どの要素が選ばれる
|
129
|
+
かは不定です。
|
130
|
+
|
131
|
+
例:
|
132
|
+
require "finite-set"
|
133
|
+
include Algebra
|
134
|
+
s = Set[0, 1, 2, 3]
|
135
|
+
p s.shift #=> 2
|
136
|
+
p s #=> {0, 1, 3}
|
137
|
+
|
138
|
+
--- dup
|
139
|
+
集合の複製を返します。(内部の Hash の複製によります。)
|
140
|
+
|
141
|
+
--- append!(x)
|
142
|
+
集合に要素 ((|x|)) を付け加えます。返り値は ((|self|)) です。
|
143
|
+
|
144
|
+
--- push
|
145
|
+
--- <<
|
146
|
+
((|append!|)) のエイリアスです。
|
147
|
+
|
148
|
+
--- append(x)
|
149
|
+
集合に要素 ((|x|)) を付け加えた複製を返します。
|
150
|
+
|
151
|
+
--- concat(other)
|
152
|
+
集合に別の集合 ((|other|)) の要素を付け加えます。
|
153
|
+
(((|+|)) の破壊版です。)
|
154
|
+
|
155
|
+
--- rehash
|
156
|
+
内部の ((|Hash|)) オブジェクトを ((|rehash|)) します。
|
157
|
+
|
158
|
+
--- eql?(other)
|
159
|
+
集合 ((|other|)) と等しいとき、真を返します。
|
160
|
+
(({ self >= other and self <= other})) と同値です。
|
161
|
+
|
162
|
+
--- ==
|
163
|
+
((<eql?>)) のエイリアスです。
|
164
|
+
|
165
|
+
--- hash
|
166
|
+
自身が ((|Hash|)) あるいは ((|Set|)) の要素となるときに利用される
|
167
|
+
ハッシュ値関数です。
|
168
|
+
|
169
|
+
--- include?(x)
|
170
|
+
集合が ((|x|)) を要素としているとき、真を返します。
|
171
|
+
|
172
|
+
--- member?
|
173
|
+
--- has?
|
174
|
+
--- contains?
|
175
|
+
((<include?>)) のエイリアスです。
|
176
|
+
|
177
|
+
--- superset?(other)
|
178
|
+
集合が他の集合 ((|other|)) を包含するとき真を返します。
|
179
|
+
(({other.all{|x| member?(x)}})) と同値です。
|
180
|
+
|
181
|
+
--- >=
|
182
|
+
--- incl?
|
183
|
+
(({superset?})) のエイリアスです。
|
184
|
+
|
185
|
+
--- subset?(other)
|
186
|
+
集合が他の集合 ((|other|)) の部分集合であるとき真を返します。
|
187
|
+
(({self.all{|x| other.member?(x)}})) と同値です。
|
188
|
+
|
189
|
+
--- <=
|
190
|
+
--- part_of?
|
191
|
+
((|subset?|)) のエイリアスです。
|
192
|
+
|
193
|
+
--- <(other)
|
194
|
+
((|self|)) が ((|other|)) の真部分集合の時真を返します。
|
195
|
+
|
196
|
+
--- >(other)
|
197
|
+
((|self|)) が ((|other|)) を真に含む時真を返します。
|
198
|
+
|
199
|
+
--- union([other])
|
200
|
+
((|self|)) と ((|other|)) の合併集合を返します。
|
201
|
+
((|other|)) が省略された場合、自身を集合の集合とみなし、全ての
|
202
|
+
要素の合併を返します。
|
203
|
+
|
204
|
+
例:
|
205
|
+
require "finite-set"
|
206
|
+
include Algebra
|
207
|
+
p Set[0, 2, 4].cup Set[1, 3] #=> {0, 1, 2, 3, 4}
|
208
|
+
s = Set[*(0...15).to_a]
|
209
|
+
s2 = s.separate{|x| x % 2 == 0}
|
210
|
+
s3 = s.separate{|x| x % 3 == 0}
|
211
|
+
s5 = s.separate{|x| x % 5 == 0}
|
212
|
+
p Set[s2, s3, s5].union #=> {1, 7, 11, 13}
|
213
|
+
|
214
|
+
--- |
|
215
|
+
--- +
|
216
|
+
--- cup
|
217
|
+
((|union|)) のエイリアスです。
|
218
|
+
|
219
|
+
--- intersection([other])
|
220
|
+
((|self|)) と ((|other|)) の交わりの集合を返します。
|
221
|
+
((|other|)) が省略された場合、自身を集合の集合とみなし、全ての
|
222
|
+
要素の共通部分を返します。
|
223
|
+
|
224
|
+
例:
|
225
|
+
require "finite-set"
|
226
|
+
include Algebra
|
227
|
+
p Set[0, 2, 4].cap(Set[4, 2, 0]) #=> {0, 2, 4}
|
228
|
+
s = Set[*(0..30).to_a]
|
229
|
+
s2 = s.separate{|x| x % 2 == 0}
|
230
|
+
s3 = s.separate{|x| x % 3 == 0}
|
231
|
+
s5 = s.separate{|x| x % 5 == 0}
|
232
|
+
p Set[s2, s3, s5].cap #=> {0, 30}
|
233
|
+
|
234
|
+
--- &
|
235
|
+
--- cap
|
236
|
+
((|intersection|)) のエイリアスです。
|
237
|
+
|
238
|
+
|
239
|
+
--- difference(other)
|
240
|
+
((|self|)) から ((|other|)) に含まれる要素を取り除いたものを返します。
|
241
|
+
|
242
|
+
--- -
|
243
|
+
((|difference|)) のエイリアスです。
|
244
|
+
|
245
|
+
|
246
|
+
--- each_pair
|
247
|
+
集合から異なる2つの要素を取り出して、ブロックパラメータに
|
248
|
+
代入して繰り返します。
|
249
|
+
|
250
|
+
例:
|
251
|
+
require "finite-set"
|
252
|
+
include Algebra
|
253
|
+
s = Set.phi
|
254
|
+
Set[0, 1, 2].each_pair do |x, y|
|
255
|
+
s.push [x, y]
|
256
|
+
end
|
257
|
+
p s == Set[[0, 1], [0, 2], [1, 2]] #=> true
|
258
|
+
|
259
|
+
--- each_member(n)
|
260
|
+
集合から異なる ((|n|)) 個の要素を取り出して、ブロックパラメータに
|
261
|
+
代入して繰り返します。
|
262
|
+
|
263
|
+
例:
|
264
|
+
require "finite-set"
|
265
|
+
include Algebra
|
266
|
+
s = Set.phi
|
267
|
+
Set[0, 1, 2].each_member(2) do |x, y|
|
268
|
+
s.push [x, y]
|
269
|
+
end
|
270
|
+
p s == Set[[0, 1], [0, 2], [1, 2]] #=> true
|
271
|
+
|
272
|
+
--- each_subset
|
273
|
+
集合の全ての部分集合をブロックパラメータに代入して繰り返します。
|
274
|
+
|
275
|
+
例:
|
276
|
+
require "finite-set"
|
277
|
+
include Algebra
|
278
|
+
s = Set.phi
|
279
|
+
Set[0, 1, 2].each_subset do |t|
|
280
|
+
s.append! t
|
281
|
+
end
|
282
|
+
p s.size = 2**3 #=> true
|
283
|
+
|
284
|
+
--- each_non_trivial_subset
|
285
|
+
集合の空集合でない真部分集合をブロックパラメータに代入して繰り返します。
|
286
|
+
|
287
|
+
--- power_set
|
288
|
+
集合の全ての部分集合の集合を返します。
|
289
|
+
|
290
|
+
--- each_product(other)
|
291
|
+
((|self|)) と ((|other|)) の全ての要素 ((|x|)), ((|y|)) に
|
292
|
+
ついて、繰り返します。
|
293
|
+
|
294
|
+
例:
|
295
|
+
require "finite-set"
|
296
|
+
include Algebra
|
297
|
+
Set[0, 1].each_prodct(Set[0, 1]) do |x, y|
|
298
|
+
p [x, y] #=> [0,0], [0,1], [1,0], [1,1]
|
299
|
+
end
|
300
|
+
|
301
|
+
--- product(other)
|
302
|
+
((|self|)) と ((|other|)) の積集合を返します。積集合の各元
|
303
|
+
は配列 (({[x, y]})) です。ブロックが与えられた時は、ブロック
|
304
|
+
を評価した値で構成される集合を返します。
|
305
|
+
|
306
|
+
例:
|
307
|
+
require "finite-set"
|
308
|
+
include Algebra
|
309
|
+
p Set[0, 1].product(Set[0, 1]) #=> {[0,0], [0,1], [1,0], [1,1]}
|
310
|
+
p Set[0, 1].product(Set[0, 1]){|x, y| x + 2*y} #=> {0, 1, 2, 3]
|
311
|
+
|
312
|
+
--- *
|
313
|
+
((<product>)) のエイリアスです。
|
314
|
+
|
315
|
+
--- equiv_class([equiv])
|
316
|
+
集合を同値関係で割った商集合を返します。同値関係の与え方は次の3通りあります。
|
317
|
+
|
318
|
+
(1) ブロックの評価値を真にする同値関係
|
319
|
+
require "finite-set"
|
320
|
+
include Algebra
|
321
|
+
s = Set[0, 1, 2, 3, 4, 5]
|
322
|
+
p s.equiv_class{|a, b| (a - b) % 3 == 0} #=> {{0, 3}, {1, 4}, {2, 5}}
|
323
|
+
(2) 引数に与えられたオブジェクトに対するメソッド ((|call(x, y)|))
|
324
|
+
の真偽値による同値関係
|
325
|
+
require "finite-set"
|
326
|
+
include Algebra
|
327
|
+
o = Object.new
|
328
|
+
def o.call(x, y)
|
329
|
+
(x - y) % 3 == 0
|
330
|
+
end
|
331
|
+
s = Set[0, 1, 2, 3, 4, 5]
|
332
|
+
p s.equiv_class(o) #=> {{0, 3}, {1, 4}, {2, 5}}
|
333
|
+
(3) 引数に与えられた ((|Symbol|)) に応じたメソッドによる同値関係
|
334
|
+
require "finite-set"
|
335
|
+
include Algebra
|
336
|
+
s = Set[0, 1, 2, 3, 4, 5]
|
337
|
+
def q(x, y)
|
338
|
+
(x - y) % 3 == 0
|
339
|
+
end
|
340
|
+
p s.equiv_class(:q) #=> {{0, 3}, {1, 4}, {2, 5}}
|
341
|
+
|
342
|
+
--- /
|
343
|
+
((<equiv_class>)) のエイリアスです。
|
344
|
+
|
345
|
+
--- to_a
|
346
|
+
集合を配列にして返します。要素の並びの順は不定です。
|
347
|
+
|
348
|
+
--- to_ary
|
349
|
+
((<to_a>)) のエイリアスです。
|
350
|
+
|
351
|
+
--- sort
|
352
|
+
((<to_a>)) の値をソートして返します。
|
353
|
+
|
354
|
+
--- power(other)
|
355
|
+
((|other|)) から ((|self|)) への写像全ての集合を返します。
|
356
|
+
写像は ((<Map|URL:finite-map-ja.html>)) の元として表現されます。
|
357
|
+
|
358
|
+
例:
|
359
|
+
require "finite-map"
|
360
|
+
include Algebra
|
361
|
+
a = Set[0, 1, 2, 3]
|
362
|
+
b = Set[0, 1, 2]
|
363
|
+
s =
|
364
|
+
p( (a ** b).size ) #=> 4 ** 3 = 64
|
365
|
+
p b.surjections(a).size #=> S(3, 4) = 36
|
366
|
+
p a.injections(b).size #=> 4P3 = 24
|
367
|
+
|
368
|
+
--- **
|
369
|
+
((<power>)) のエイリアスです。
|
370
|
+
|
371
|
+
--- identity_map
|
372
|
+
自分への恒等写像を返します。
|
373
|
+
|
374
|
+
--- surjections(other)
|
375
|
+
((|other|)) から ((|self|)) への全射全ての集合を返します。
|
376
|
+
|
377
|
+
#--- injections0(other)
|
378
|
+
|
379
|
+
--- injections(other)
|
380
|
+
((|other|)) から ((|self|)) への単射全ての集合を返します。
|
381
|
+
|
382
|
+
|
383
|
+
--- bijections(other)
|
384
|
+
((|other|)) から ((|self|)) への全単射全ての集合を返します。
|
385
|
+
|
386
|
+
|
387
|
+
#--- monotonic_series #what is this?
|
388
|
+
|
389
|
+
= Enumerable
|
390
|
+
|
391
|
+
== ファイル名:
|
392
|
+
* ((|finite-set.rb|))
|
393
|
+
|
394
|
+
== メソッド:
|
395
|
+
|
396
|
+
--- any?
|
397
|
+
ブロックを真にする要素があるとき、真を返します。
|
398
|
+
((|Enumerable#find|)) の別名です。(built-in of ruby-1.8)
|
399
|
+
|
400
|
+
--- all?
|
401
|
+
全ての要素についてブロックが真であるとき、真を返します。
|
402
|
+
|
403
|
+
!any?{|x| !yield(x)}
|
404
|
+
|
405
|
+
と定義されています。(built-in of ruby-1.8)
|
406
|
+
|
407
|
+
=end
|
408
|
+
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
8
|
+
<title>doc-ja/index-ja.rd</title>
|
9
|
+
<link href="style.css" type="text/css" rel="stylesheet" />
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<p>[<a href="README-ja.html">README-ja</a>] [<a href="../doc/index.html">English</a>]</p>
|
13
|
+
<h1><a name="label-0" id="label-0">代数パッケージ</a></h1><!-- RDLabel: "代数パッケージ" -->
|
14
|
+
<pre>Version: 0.72 (2006.09.16)
|
15
|
+
Author: 原 信一郎 (sinara@blade.nagaokaut.ac.jp)
|
16
|
+
|
17
|
+
これは1変数あるいは多変数の多項式を計算するためのライブラリです。</pre>
|
18
|
+
<h2><a name="label-1" id="label-1">0. 最初の一歩</a></h2><!-- RDLabel: "0. 最初の一歩" -->
|
19
|
+
<p>最も簡単な利用法は require "algebra" として、計算を始めることです。</p>
|
20
|
+
<pre>require "algebra"
|
21
|
+
x = Polynomial(Integer, "x").var
|
22
|
+
puts( (x+1)**7 )
|
23
|
+
#=> x^7 + 7x^6 + 21x^5 + 35x^4 + 35x^3 + 21x^2 + 7x + 1
|
24
|
+
puts( (x**7 + 7*x**6 + 21*x**5 + 35*x**4 + 35*x**3 + 21*x**2 + 7*x + 1).factorize )
|
25
|
+
#=> (x + 1)^7</pre>
|
26
|
+
<h2><a name="label-2" id="label-2">1. 例題</a></h2><!-- RDLabel: "1. 例題" -->
|
27
|
+
<ul>
|
28
|
+
<li><a href="samples-ja.html">Samples</a></li>
|
29
|
+
</ul>
|
30
|
+
<h2><a name="label-3" id="label-3">2. 主なクラス・モジュール</a></h2><!-- RDLabel: "2. 主なクラス・モジュール" -->
|
31
|
+
<ul>
|
32
|
+
<li><a href="algebra-ja.html">Algebra</a> (代数モジュール)
|
33
|
+
<ul>
|
34
|
+
<li><a href="polynomial-ja.html">Algebra::Polynomial</a> (1変数多項式環クラス)</li>
|
35
|
+
<li><a href="euclidian-ring-ja.html">Algebra::EuclidianRing</a> (ユークリッド環モジュール)</li>
|
36
|
+
<li><a href="m-polynomial-ja.html">Algebra::MPolynomial</a> (多変数多項式環クラス)</li>
|
37
|
+
<li><a href="residue-class-ring-ja.html">Algebra::ResidueClassRing</a> (剰余環クラス)</li>
|
38
|
+
<li><a href="algebraic-extension-field-ja.html">Algebra::AlgebraicExtensionField</a> (代数拡大体クラス)</li>
|
39
|
+
<li><a href="localized-ring-ja.html">Algebra::LocalizedRing</a> (局所化環クラス)</li>
|
40
|
+
<li><a href="matrix-algebra-ja.html">Algebra::MatrixAlgebra</a> (行列代数クラス)</li>
|
41
|
+
<li><a href="algebraic-parser-ja.html">Algebra::AlgebraicParser</a> (代数式を表す文字列の評価クラス)</li>
|
42
|
+
<li><a href="finite-set-ja.html">Algebra::Set</a> (集合のクラス)</li>
|
43
|
+
<li><a href="finite-map-ja.html">Algebra::Map</a> (写像のクラス)</li>
|
44
|
+
<li><a href="finite-group-ja.html">Algebra::Group</a> (群のクラス)</li>
|
45
|
+
<li><a href="permutation-group-ja.html">Algebra::PermutationGroup</a> (置換群のクラス)</li>
|
46
|
+
</ul></li>
|
47
|
+
</ul>
|
48
|
+
<h2><a name="label-4" id="label-4">3. その他</a></h2><!-- RDLabel: "3. その他" -->
|
49
|
+
<ul>
|
50
|
+
<li><a href="elementary-divisor-ja.html">Algebra::ElementaryDivisor</a> (単因子モジュール)</li>
|
51
|
+
<li><a href="jordan-form-ja.html">Algebra::JordanForm</a> (ジョルダン行列クラス)</li>
|
52
|
+
<li><a href="matrix-algebra-triplet-ja.html">Algebra::MatrixAlgebraTriplet</a> (3つ組行列のクラス)</li>
|
53
|
+
<li><a href="algebraic-equation-ja.html">代数方程式ハンドルユーティリティー</a></li>
|
54
|
+
<li><a href="polynomial-converter-ja.html">多項式環相互変換ユーティリティー</a></li>
|
55
|
+
</ul>
|
56
|
+
<h2><a name="label-5" id="label-5">4. パッケージ内容</a></h2><!-- RDLabel: "4. パッケージ内容" -->
|
57
|
+
<h3><a name="label-6" id="label-6">総合</a></h3><!-- RDLabel: "総合" -->
|
58
|
+
<pre>algebra.rb Algebra ライブラリ一般利用ファイル</pre>
|
59
|
+
<h3><a name="label-7" id="label-7">一変数関係</a></h3><!-- RDLabel: "一変数関係" -->
|
60
|
+
<pre>polynomial.rb 1変数多項式環のクラス
|
61
|
+
euclidian-ring.rb ユークリッド整域ユティリティー(G.C.D.の計算)
|
62
|
+
polynomial-factor.rb 1変数多項式因数分解ライブラリ
|
63
|
+
polynomial-factor-int.rb 整数係数版
|
64
|
+
polynomial-factor-zp.rb Zp係数版
|
65
|
+
polynomial-factor-alg.rb 代数的数係数版</pre>
|
66
|
+
<h3><a name="label-8" id="label-8">多変数関係</a></h3><!-- RDLabel: "多変数関係" -->
|
67
|
+
<pre>m-polynomial.rb 多変数多項式環のクラス
|
68
|
+
m-index.rb m-polynomial.rb の下請け
|
69
|
+
m-polynomial-factor.rb 1変数多項式因数分解ライブラリ
|
70
|
+
m-polynomial-factor-int.rb 整数係数版
|
71
|
+
m-polynomial-factor-zp.rb Zp係数版
|
72
|
+
groebner-basis.rb グレブナ基底の計算モジュール
|
73
|
+
groebner-basis-coeff.rb 除算の計算モジュール</pre>
|
74
|
+
<h3><a name="label-9" id="label-9">代数全般</a></h3><!-- RDLabel: "代数全般" -->
|
75
|
+
<pre>localized-ring.rb 商体作成ライブラリ
|
76
|
+
matrix-algebra.rb 行列代数のクラス
|
77
|
+
elementary-divisor.rb 単因子操作モジュール
|
78
|
+
matrix-algebra.triplete.rb 3つ組行列クラス
|
79
|
+
jordan-form.rb ジョルダン行列クラス
|
80
|
+
residue-class-ring.rb 多項式環の剰余環
|
81
|
+
algebraic-extention-field.rb 代数拡大体
|
82
|
+
splitting-field.rb 多項式の最小分解体
|
83
|
+
galois-group.rb Galois 群
|
84
|
+
linear-algebra.rb 線形代数ライブラリ
|
85
|
+
algebraic-equation.rb 代数方程式ライブラリ</pre>
|
86
|
+
<h3><a name="label-10" id="label-10">基礎部分</a></h3><!-- RDLabel: "基礎部分" -->
|
87
|
+
<pre>finite-set.rb 集合のクラス
|
88
|
+
finite-map.rb 写像のクラス
|
89
|
+
finite-group.rb 群のクラス
|
90
|
+
permutation-group.rb 置換群のクラス</pre>
|
91
|
+
<h3><a name="label-11" id="label-11">共通部分</a></h3><!-- RDLabel: "共通部分" -->
|
92
|
+
<pre>prime-gen.rb 素数生成クラス
|
93
|
+
numeric-supplement.rb Numeric の補完
|
94
|
+
polynomial-converter.rb 多項式環相互変換ユーティリティー
|
95
|
+
algebra-system.rb 代数系の共通仕様
|
96
|
+
algebraic-parser.rb 多元環の式の文字列表現を評価するモジュール</pre>
|
97
|
+
<h3><a name="label-12" id="label-12">その他</a></h3><!-- RDLabel: "その他" -->
|
98
|
+
<pre>array-supplement.rb Array の補完
|
99
|
+
doc-ja/ マニュアル日本語版(RD, HTML, TXT)
|
100
|
+
doc/ マニュアル英語版(RD, HTML, TXT)
|
101
|
+
sample/ サンプルコード
|
102
|
+
work/ (開発作業場所)</pre>
|
103
|
+
<h2><a name="label-13" id="label-13">5. ToDo</a></h2><!-- RDLabel: "5. ToDo" -->
|
104
|
+
<ul>
|
105
|
+
<li><a href="todo.html">todo.html</a></li>
|
106
|
+
</ul>
|
107
|
+
<h2><a name="label-14" id="label-14">6. Changes</a></h2><!-- RDLabel: "6. Changes" -->
|
108
|
+
<ul>
|
109
|
+
<li><a href="changes.html">changes.html</a></li>
|
110
|
+
</ul>
|
111
|
+
|
112
|
+
</body>
|
113
|
+
</html>
|