@@ -57,20 +57,20 @@ PMPermutation class >> fromCycles: aCollectionofCollections [
57
57
]
58
58
59
59
{ #category : #accessing }
60
- PMPermutation class >> generator: arrayOfPermutations [
61
- |f max generators |
62
- max: = (arrayOfPermutations collect: [:g |g size])max.
63
- generators: = arrayOfPermutations collect: [:g | g extendTo: max].
64
- f: = PMFixpoint
65
- block: [ :s | |aSet |
66
- aSet: = Set newFrom: s.
67
- s do: [:p |s do: [:q |
68
- aSet add: (p permute: q)]].
69
- aSet]
70
- value: generators.
71
- f verbose: false .
72
- ^ f evaluate asArray.
60
+ PMPermutation class >> generator: arrayOfPermutations [
73
61
62
+ | f max generators |
63
+ max := (arrayOfPermutations collect: [ :g | g size ]) max.
64
+ generators := arrayOfPermutations collect: [ :g | g extendTo: max ].
65
+ f := PMFixpoint
66
+ block: [ :s |
67
+ | aSet |
68
+ aSet := Set newFrom: s.
69
+ s do: [ :p | s do: [ :q | aSet add: (p permute: q) ] ].
70
+ aSet ]
71
+ value: generators.
72
+ f verbose: false .
73
+ ^ f evaluate asArray
74
74
]
75
75
76
76
{ #category : #' instance creation' }
@@ -87,19 +87,28 @@ uses super withAll: since this way a primitive can be used, which is generally m
87
87
88
88
{ #category : #' instance creation' }
89
89
PMPermutation class >> ordering: aCollection [
90
- " use #newFrom: for an unreduced Permutation! but then most things won't work before you call #reduce.
90
+ " use #newFrom: for an unreduced Permutation! but then most things won't work before you call #reduce.
91
91
aCollection must consist of elements that can be sorted via #<="
92
- ^ ( super withAll: aCollection ) reduce
92
+
93
+ ^ (super withAll: aCollection) reduce
93
94
]
94
95
95
96
{ #category : #accessing }
96
97
PMPermutation class >> randomGenerator [
97
- ^ RandomGenerator ifNil: [ RandomGenerator := Random new ]
98
+
99
+ ^ RandomGenerator ifNil: [ RandomGenerator := Random new ]
100
+ ]
101
+
102
+ { #category : #accessing }
103
+ PMPermutation class >> randomGenerator: aGenerator [
104
+
105
+ ^ RandomGenerator := aGenerator
98
106
]
99
107
100
108
{ #category : #' instance creation' }
101
109
PMPermutation class >> randomPermutation: size [
102
- ^ self ordering: (self randomGenerator next: size)
110
+
111
+ ^ self newFrom: ((1 to: size) asArray shuffleBy: self randomGenerator)
103
112
]
104
113
105
114
{ #category : #' instance creation' }
0 commit comments