Skip to main content
12 events
when toggle format what by license comment
Mar 28, 2023 at 14:58 comment added IntroductionToProbability Thanks @Edmund, I was wondering about this and I'm glad OP got a solution
Mar 27, 2023 at 12:59 comment added Edmund @IntroductionToProbability Your solution does not have the same eigenvalues as the starting matrix. The "staying together" means the rows can change position and the numbers in a row change position within the row. Numbers should not leave their row, only be rearranged within it.
Nov 17, 2022 at 13:18 comment added Hauke Reddmann Edited. I hope it is clear now.
Nov 17, 2022 at 13:15 comment added IntroductionToProbability I'm sorry I can't help further without some examples or a definition of the vectors "staying together"
Nov 17, 2022 at 13:09 comment added Hauke Reddmann Here is an idea for an almost working poly-alg: 1.Sort all row vectors of mat element-wise. 2.Lump them together to a matrix mat2 and sort the cols by vector order alphanumeric. 3.Remember the permutation of step 2 (easy: patch 1...n to the end of the vectors before step 2 and extract perm afterwards). 4.Apply perm to both row and col of mat simultaneously: mat3=mat[perm[i],perm[j]]. Done. Unfortunately, with identical vectors occuring the algorithm still might fail.
Nov 17, 2022 at 13:06 comment added IntroductionToProbability @HaukeReddmann it is still not clear to me what you mean by stay together. Can you edit your question to include this constraint as well as give a concrete example?
Nov 17, 2022 at 13:02 comment added Hauke Reddmann Bad wording...The numbers of the vector stay "together". Obviously, this can't work with just sorting all numbers of the matrix - it's just a lucky accident that (0123),(0145),(0246) and (0356) stay together after sorting. OK, I reword it: if a matrix contains the vector (a1,a2,...) before, it must also contain this vector after sorting (in any order of the vector elements).
Nov 16, 2022 at 23:12 comment added IntroductionToProbability What do you mean by “the vectors stay in place”
Nov 16, 2022 at 14:18 history edited IntroductionToProbability CC BY-SA 4.0
improved formatting and made code more obvious
Nov 16, 2022 at 14:01 comment added IntroductionToProbability If the second example is {{0, 1, 2, 4}, {1, 0, 3, 5}, {2, 3, 0, 1}, {4, 5, 1, 0}} then it sorts to {{0, 1, 1, 2}, {1, 0, 3, 4}, {1, 3, 0, 5}, {2, 4, 5, 0}}. I will edit my answer to make the algorithm clearer
Nov 16, 2022 at 12:00 comment added Hauke Reddmann This is definitely correct (as a result), since the vectors stay in place, but how does it work exactly? And, even more relevant, does it work for the critical second example?
Nov 15, 2022 at 14:53 history answered IntroductionToProbability CC BY-SA 4.0