-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAlternatingGroup.class.st
More file actions
71 lines (60 loc) · 1.8 KB
/
Copy pathAlternatingGroup.class.st
File metadata and controls
71 lines (60 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"
The alternating group Alt(X) of even permutations on the elements of a set X (which we call 'space'). This is a subgroup of Sym(X) (see SymmetricGroup).
"
Class {
#name : #AlternatingGroup,
#superclass : #PermutationGroup,
#category : #'Mathematics-Groups-Permutations'
}
{ #category : #examples }
AlternatingGroup class >> example1 [
"The group of even permutations on the set of 3 elements {1,2,3}."
^ AlternatingGroup new: 3
]
{ #category : #examples }
AlternatingGroup class >> example2 [
"The group of even permutations on the set {a,b,c}."
^ AlternatingGroup on: #(a b c).
]
{ #category : #'instance creation' }
AlternatingGroup class >> new: anInteger [
^ self new ambient: (SymmetricGroup new: anInteger)
]
{ #category : #'instance creation' }
AlternatingGroup class >> on: aCollection [
^ self new ambient: (SymmetricGroup on: aCollection)
]
{ #category : #random }
AlternatingGroup >> atRandom: aRandom bits: bitSize [
| S answer |
S := self ambient.
[(answer := S atRandom: aRandom bits: bitSize) even] whileFalse.
^ answer
]
{ #category : #private }
AlternatingGroup >> computeGenerators [
| X |
X := self space asArray.
^ (1 to: self degree - 2) collect: [:i| self ambient cycle: {X at: i. X at: i+1. X at: i+2}]
]
{ #category : #testing }
AlternatingGroup >> contains: aPermutation [
"Answer true if the receiver contains the given element of its ambient."
^ aPermutation even
]
{ #category : #enumerating }
AlternatingGroup >> do: aBlock [
self ambient do: [:each| each even ifTrue: [aBlock value: each]]
]
{ #category : #testing }
AlternatingGroup >> isSimple [
^ self degree >= 5
]
{ #category : #printing }
AlternatingGroup >> printOn: aStream [
aStream nextPutAll: 'Alt('; print: self space; nextPut: $)
]
{ #category : #accessing }
AlternatingGroup >> size [
^ self degree factorial / 2
]