in reply to Permutation algorithm?
Here's my guess:@ControlMatrix = ( [1, 2, 0, 2], [0, 0, 2, 1] ) @perms = ( ([1, 0, 0, 0], [1, 1, 0, 0], [1, 0, 0, 1], [1, 1, 0, 1]) ([0, 0, 0, 1], [1, 1, 1, 1]) )
$index = 0; $pcount = 1; for ($names = 0; $names < @ControlNames.length; $names++) { for ($fields = 0; $fields < $ControlMatrix[$names].length; $fields++ +) { if (@ControlMatrix[$names][$fields] < 2 ) { for ($q = 0; $q < $pcount; $q++) { @perms[$names][$q][$fields] = @ControlMatrix[$names][$fields]; } } else { for ($q = 0; $q < $pcount; $q++) { @perms[$names][$q+$pcount] = @perms[names][$q]; $perms[$names][$q][$fields] = 0; $perms[$names][$q+$pcount][$fields] = 1; } $pcount *= 2; } } }
|
|---|