@@ -57,20 +57,20 @@ PMPermutation class >> fromCycles: aCollectionofCollections [
5757]
5858
5959{ #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 [
7361
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
7474]
7575
7676{ #category : #' instance creation' }
@@ -87,19 +87,28 @@ uses super withAll: since this way a primitive can be used, which is generally m
8787
8888{ #category : #' instance creation' }
8989PMPermutation 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.
9191aCollection must consist of elements that can be sorted via #<="
92- ^ ( super withAll: aCollection ) reduce
92+
93+ ^ (super withAll: aCollection) reduce
9394]
9495
9596{ #category : #accessing }
9697PMPermutation 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
98106]
99107
100108{ #category : #' instance creation' }
101109PMPermutation class >> randomPermutation: size [
102- ^ self ordering: (self randomGenerator next: size)
110+
111+ ^ self newFrom: ((1 to: size) asArray shuffleBy: self randomGenerator)
103112]
104113
105114{ #category : #' instance creation' }
0 commit comments