RE: Re: Cyclic permutations
- To: mathgroup at smc.vnet.net
- Subject: [mg79543] RE: [mg79534] Re: Cyclic permutations
- From: "King, Peter R" <peter.king at imperial.ac.uk>
- Date: Sun, 29 Jul 2007 00:04:45 -0400 (EDT)
- References: <200707280944.FAA00283@smc.vnet.net>
Many thanks to all for the useful help and suggestions. Fyi the version I used is Map[First, Union[Map[Sort[Table[RotateLeft[#, j], {j, Length[#]}]] &, z]]] (z being the list of permutations). I only (typically) have lists of the order a few hundred to 1000 permutations so efficiency isn't a huge issue. The above does the job perfectly well for me. A further related question. Ideally I am actually using character strings for the permutations So instead of {a,b,c,d} I have "abcd" and want to do the same thing (ie keep "abcd" and "acbd" but loose "bcda" or "cbda"). Currently I generate the strings through lists, but I don't need to and could work with strings directly. Obviously I can turn the string to a list and do the above (which is what I'm doing). It works but is inelegant (as I say efficiency isn't key). Is there a simpler way to do the same with strings? If what I am doing at present is best then I don't mind, as I say it works I'd just like to learn some more tricks for handling strings. Peter btw yes this is different from just keeping the odd or even permutations -----Original Message----- From: Bill Rowe [mailto:readnewsciv at sbcglobal.net] Sent: Sat 7/28/2007 10:44 AM To: mathgroup at smc.vnet.net Subject: [mg79543] [mg79534] Re: Cyclic permutations On 7/27/07 at 6:04 AM, drmajorbob at bigfoot.com (DrMajorBob) wrote: >Won't that SameTest equate a lot of permutations that aren't the >"same" in the OP's requested sense? >perms = Permutations[Range@4] Signature /@ perms Union[perms, >SameTest -> (SameQ @@ (Signature /@ {##}) &)] >{{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}, {1, 3, 4, 2}, {1, 4, 2, >3}, {1, 4, 3, 2}, {2, 1, 3, 4}, {2, 1, 4, 3}, {2, 3, 1, 4}, {2, 3, >4, 1}, {2, 4, 1, 3}, {2, 4, 3, 1}, {3, 1, 2, 4}, {3, 1, 4, 2}, {3, >2, 1, 4}, {3, 2, 4, 1}, {3, 4, 1, 2}, {3, 4, 2, 1}, {4, 1, 2, 3}, >{4, 1, 3, 2}, {4, 2, 1, 3}, {4, 2, 3, 1}, {4, 3, 1, 2}, {4, 3, 2, 1}} >{1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, 1, 1, -1, -1, >\ 1, 1, -1, -1, 1} >{{1, 2, 3, 4}, {1, 2, 4, 3}} >Only two distinct permutations exist (for ANY list) with that >SameTest. >I thought the OP wanted something like >Union[perms /. {a__, 1, b___} :> {1, b, a}] >{{1, 2, 3, 4}, {1, 2, 4, 3}, {1, 3, 2, 4}, {1, 3, 4, 2}, {1, 4, 2, >3}, {1, 4, 3, 2}} I think your assessment is correct. I had thought Signature returned different values for permutations that were not cyclic versions of each other. I see on looking at the documentation this isn't the case. Sorry for the confusion I perhaps caused. -- To reply via email subtract one hundred and four
- References:
- Re: Cyclic permutations
- From: Bill Rowe <readnewsciv@sbcglobal.net>
- Re: Cyclic permutations