Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.6K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

Changing the order of a list of matrices

Posted 3 years ago

I try to generate the possible permutations on a list of matrices as follows:

In[762]:= mats
Permutations[#,{3}]&/@mats
mats[[Ordering[#]]]&/@Permutations[Range[3]]

Out[762]= {{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{1/2, 3/2, 
   0}, {-(1/2), 3/2, 0}, {0, 1, 0}}, {{3/2, -(1/2), 0}, {3/2, 1/2, 
   0}, {1, 0, 0}}}

Out[763]= {{{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{0, 0, 1/2}, {0, 
    0, 1}, {0, 0, 1/2}}, {{0, 0, 1}, {0, 0, 1/2}, {0, 0, 1/2}}}, {{{1/
    2, 3/2, 0}, {-(1/2), 3/2, 0}, {0, 1, 0}}, {{1/2, 3/2, 0}, {0, 1, 
    0}, {-(1/2), 3/2, 0}}, {{-(1/2), 3/2, 0}, {1/2, 3/2, 0}, {0, 1, 
    0}}, {{-(1/2), 3/2, 0}, {0, 1, 0}, {1/2, 3/2, 0}}, {{0, 1, 0}, {1/
    2, 3/2, 0}, {-(1/2), 3/2, 0}}, {{0, 1, 0}, {-(1/2), 3/2, 0}, {1/2,
     3/2, 0}}}, {{{3/2, -(1/2), 0}, {3/2, 1/2, 0}, {1, 0, 0}}, {{3/
    2, -(1/2), 0}, {1, 0, 0}, {3/2, 1/2, 0}}, {{3/2, 1/2, 0}, {3/
    2, -(1/2), 0}, {1, 0, 0}}, {{3/2, 1/2, 0}, {1, 0, 0}, {3/
    2, -(1/2), 0}}, {{1, 0, 0}, {3/2, -(1/2), 0}, {3/2, 1/2, 0}}, {{1,
     0, 0}, {3/2, 1/2, 0}, {3/2, -(1/2), 0}}}}

Out[764]= {{{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{1/2, 3/2, 
    0}, {-(1/2), 3/2, 0}, {0, 1, 0}}, {{3/2, -(1/2), 0}, {3/2, 1/2, 
    0}, {1, 0, 0}}}, {{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{3/
    2, -(1/2), 0}, {3/2, 1/2, 0}, {1, 0, 0}}, {{1/2, 3/2, 0}, {-(1/2),
     3/2, 0}, {0, 1, 0}}}, {{{1/2, 3/2, 0}, {-(1/2), 3/2, 0}, {0, 1, 
    0}}, {{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{3/2, -(1/2), 0}, {3/
    2, 1/2, 0}, {1, 0, 0}}}, {{{3/2, -(1/2), 0}, {3/2, 1/2, 0}, {1, 0,
     0}}, {{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{1/2, 3/2, 
    0}, {-(1/2), 3/2, 0}, {0, 1, 0}}}, {{{1/2, 3/2, 0}, {-(1/2), 3/2, 
    0}, {0, 1, 0}}, {{3/2, -(1/2), 0}, {3/2, 1/2, 0}, {1, 0, 0}}, {{0,
     0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}}, {{{3/2, -(1/2), 0}, {3/2, 1/2,
     0}, {1, 0, 0}}, {{1/2, 3/2, 0}, {-(1/2), 3/2, 0}, {0, 1, 
    0}}, {{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}}}

As you can see, the above two methods give different results. I checked the related document, but still couldn't find the reason. Any tips will be appreciated.

Regards, Zhao

POSTED BY: Hongyi Zhao
Posted 3 years ago

A usage error caused this problem. The correct method is as follows:

In[55]:= m={{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{1/2, 3/2, 
   0}, {-(1/2), 3/2, 0}, {0, 1, 0}}, {{3/2, -(1/2), 0}, {3/2, 1/2, 
   0}, {1, 0, 0}}}
len=Length[m];
Permutations[m,{len}]//Sort;
m[[Ordering[#]]]&/@Permutations[Range[len]]//Sort;
%==%%

Out[55]= {{{0, 0, 1/2}, {0, 0, 1/2}, {0, 0, 1}}, {{1/2, 3/2, 
   0}, {-(1/2), 3/2, 0}, {0, 1, 0}}, {{3/2, -(1/2), 0}, {3/2, 1/2, 
   0}, {1, 0, 0}}}

Out[59]= True
POSTED BY: Hongyi Zhao
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard