|
13 | 13 | """ |
14 | 14 | ) |
15 | 15 |
|
16 | | -# A number of examples from Implementing Discrete Mathematics by |
17 | | -# Steven Skiena and |
18 | | -# A number of examples from Computation Discrete Mathematics by |
19 | | -# Sriram Pemmaraju and Steven Skiena. |
| 16 | +# A number of examples from: |
| 17 | +# * Implementing Discrete Mathematics by Steven Skiena and |
| 18 | +# * Computation Discrete Mathematics by Sriram Pemmaraju and Steven Skiena. |
20 | 19 |
|
21 | 20 | # Page numbers below come from the first book |
22 | 21 |
|
23 | | - |
24 | 22 | def test_combinatorica_permutations_1_1(): |
25 | 23 |
|
26 | 24 | for str_expr, str_expected, message in ( |
@@ -241,6 +239,38 @@ def test_combinatorica_permutations_1_2(): |
241 | 239 | "{90, 90}", |
242 | 240 | "StirlingSecond 1.2.4, Page 24", |
243 | 241 | ), |
| 242 | + ( |
| 243 | + "SignaturePermutation[{1,3,2,4,5,6,7,8}]", |
| 244 | + "-1", |
| 245 | + "SignaturePermutation 1.2.5, Page 25", |
| 246 | + ), |
| 247 | + ( |
| 248 | + "SignaturePermutation[p] == SignaturePermutation[InversePermutation[p]]", |
| 249 | + "True", |
| 250 | + "A particular permutation has the same sign as its inverse 1.2.5, Page 25", |
| 251 | + ), |
| 252 | + ( |
| 253 | + "PermutationGroupQ[ Select [ Permutations[Range[4]], (SignaturePermutation[#]==1)&] ]", |
| 254 | + "True", |
| 255 | + "All permutations have the same sign as their inverse 1.2.5, Page 25", |
| 256 | + ), |
| 257 | + ( |
| 258 | + "Polya[Table[RotateRight[Range[8],i], {i, 8}], m]", |
| 259 | + "(4 m + 2 m ^ 2 + m ^ 4 + m ^ 8) / 8", |
| 260 | + "Polya counting resulting in polynomial 1.2.6, Page 25", |
| 261 | + ), |
| 262 | + # MapAt not finished which is probably causing Poly to fail here... |
| 263 | + # ( |
| 264 | + # "Polya[Automorphisms[Cycle[8]], m]", |
| 265 | + # "(4 m + 2 m ^ 2 + m ^ 4 + m ^ 8) / 8", |
| 266 | + # "Polya counting resulting in polynomial 1.2.6, Page 26", |
| 267 | + # ), |
| 268 | + ( |
| 269 | + "Factor[(4 m + 2 m^2 + 5m^4 + 4m^5 + m^8)/16]", |
| 270 | + "m (1 + m) (4 - 2 m + 2 m ^ 2 + 3 m ^ 3 + m ^ 4 - m ^ 5 + m ^ 6) / 16", |
| 271 | + "Factor example in Polya polynomial 1.2.6, Page 26", |
| 272 | + ), |
| 273 | + |
244 | 274 | ): |
245 | 275 | check_evaluation(str_expr, str_expected, message) |
246 | 276 |
|
|
0 commit comments