Re: Algorithm to determine matrix similarity
- From: jeroen.wieland@xxxxxxxxxxxxxx
- Date: Mon, 19 Jan 2009 15:48:17 -0800 (PST)
On 19 Jan, 23:17, Rainer Rosenthal <r.rosent...@xxxxxx> wrote:
quasi wrote:
But let me ask -- how do you arrive at A' and B'?
Oops, my first idea was, to let you see my Maple code.
But then I had to admit: it was gone somewhere in the
Bit-Nirwana. Then I thought it would be easy to
program the lines again. And then ... I wasn't sure
any more whether I had programmed it ever. I remember
that for my matrices M1 and M2 (see below) I had been
lucky to find a correspondence establishing their
equivalence. After that I was told the sorting trick
and thought: "how ingenious!" I could have sworn that I
had tested the trick, just for fun, but obviously I
did not :-(
I will have to think again, but in the meantime I will
show you my 16x16 matrices M1 and M2 as well as
my correspondence K:{1..16}->{1..16} which satisfies
M1[i,j] = M2[K[i],K[j]] for all i and j.
It took me quite a while and I felt like Sherlock Holmes
having found
K = [2,3,13,8,4,9,7,11,6,1,12,10,5,14,15,16], i.e.
n 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
---------------------------------------------------
K[n] 2 3 13 8 4 9 7 11 6 1 12 10 5 14 15 16
My matrices M1 and M2 were:
M1 := Matrix([[4,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3]
,[1,4,2,2,3,3,1,1,2,2,3,1,1,2,3,3]
,[1,2,4,3,2,3,1,2,1,3,2,2,3,1,1,1]
,[1,2,3,4,3,2,2,1,3,1,2,3,2,1,3,3]
,[1,3,2,3,4,2,2,3,1,2,1,1,3,3,2,2]
,[1,3,3,2,2,4,3,2,2,1,1,3,1,3,1,1]
,[2,1,1,2,2,3,4,3,3,1,1,2,3,2,3,3]
,[2,1,2,1,3,2,3,4,1,3,1,3,2,2,1,1]
,[2,2,1,3,1,2,3,1,4,1,3,2,1,3,2,2]
,[2,2,3,1,2,1,1,3,1,4,3,1,2,3,3,3]
,[2,3,2,2,1,1,1,1,3,3,4,3,3,1,2,2]
,[3,1,2,3,1,3,2,3,2,1,3,4,2,1,1,1]
,[3,1,3,2,3,1,3,2,1,2,3,2,4,1,2,2]
,[3,2,1,1,3,3,2,2,3,3,1,1,1,4,2,2]
,[3,3,1,3,2,1,3,1,2,3,2,1,2,2,4,0]
,[3,3,1,3,2,1,3,1,2,3,2,1,2,2,0,4]
]);
M2 := Matrix([[4,2,2,2,2,1,1,1,1,1,3,3,3,3,3,3]
,[2,4,1,1,3,2,2,1,1,3,2,2,1,3,3,3]
,[2,1,4,3,1,2,1,2,3,1,1,3,2,2,3,3]
,[2,1,3,4,3,1,2,3,2,1,3,1,2,3,2,2]
,[2,3,1,3,4,1,3,2,1,2,2,3,3,1,2,2]
,[1,2,2,1,1,4,3,3,2,2,1,3,1,3,2,2]
,[1,2,1,2,3,3,4,2,3,2,3,1,1,2,3,3]
,[1,1,2,3,2,3,2,4,2,3,1,2,3,1,3,3]
,[1,1,3,2,1,2,3,2,4,3,2,1,3,3,1,1]
,[1,3,1,1,2,2,2,3,3,4,3,3,2,1,1,1]
,[3,2,1,3,2,1,3,1,2,3,4,1,2,2,1,1]
,[3,2,3,1,3,3,1,2,1,3,1,4,2,1,2,2]
,[3,1,2,2,3,1,1,3,3,2,2,2,4,1,1,1]
,[3,3,2,3,1,3,2,1,3,1,2,1,1,4,2,2]
,[3,3,3,2,2,2,3,3,1,1,1,2,1,2,4,0]
,[3,3,3,2,2,2,3,3,1,1,1,2,1,2,0,4]
]);
I'd like to say where these matrices stem from. Any
two different people among the 16 people at a party are
in exactly one of the three relationships 1, 2 or 3,
except for one pair in a different relationship 0.
Both matrices depict such a situation, using entry 4 for
the identity relation. The interesting thing and motivation
for finding these matrices: they are completely "intransitive"
in the following sense: whenever a and b are in the same
relation r as b and c, then a and c are *not* in this same
relation r. (Problem Matx#329-part 4 in de.rec.denksport).
Example: In M1 we have M1[1,2]=1 and M1[2,7]=1; so it is not
allowed to have M1[1,7]=1. And indeed: M1[1,7]=2.
(It is possible to find a 17x17 matrix with this property,
but 17 is the largest dimension for that.)
Cheers and thanks for your critical remarks. Sorry to the OP,
who liked the sorting idea as well as I did. But I fear he
will get into the same troubles as I did some minutes ago,
trying to "rewrite" my code :-(
Cheers,
Rainer Rosenthal
r.rosent...@xxxxxx
Well, I thought I understood your proposed algorithm and implemented
the following to find the matrix A' (defined in a post above) from A
as follows:
- Define a total order < on the matrices by lexicographical ordering
- done=false;
while (!done)
{
done=true;
for (i=0;i<N-1;i++)
{
At=exchangecolumns(exchangerows(A,i,i+1),i,i+1);
if (At<A)
{
A=At;
done=false;
}
}
}
This is a rather crude variaty of bubblesort. It does find quite a few
equivalence relationships. But in light of the discussion below, I now
am uncertain whether this algorithm always converges to a unique A'
for all matrices in the equivalence class. Will continue to test. If
it works, I intend to optimise the sort algorithm.
.
- Follow-Ups:
- Re: Algorithm to determine matrix similarity
- From: Mariano Suárez-Alvarez
- Re: Algorithm to determine matrix similarity
- From: Rainer Rosenthal
- Re: Algorithm to determine matrix similarity
- References:
- Algorithm to determine matrix similarity
- From: jeroen . wieland
- Re: Algorithm to determine matrix similarity
- From: Rainer Rosenthal
- Re: Algorithm to determine matrix similarity
- From: quasi
- Re: Algorithm to determine matrix similarity
- From: Rainer Rosenthal
- Re: Algorithm to determine matrix similarity
- From: quasi
- Re: Algorithm to determine matrix similarity
- From: Rainer Rosenthal
- Algorithm to determine matrix similarity
- Prev by Date: Re: Circular functions
- Next by Date: Re: what is this type of equals sign?
- Previous by thread: Re: Algorithm to determine matrix similarity
- Next by thread: Re: Algorithm to determine matrix similarity
- Index(es):
Relevant Pages
|