From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: organized scrambling of matrix
Date: Mon, 19 Apr 2010 10:34:06 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <hqhbiu$ej6$>
References: <hqh74e$2ml$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1271673246 14950 (19 Apr 2010 10:34:06 GMT)
NNTP-Posting-Date: Mon, 19 Apr 2010 10:34:06 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:627801

"Juliette Salexa" <> wrote in message <hqh74e$2ml$>...
> Hi all,
> I was wondering if there's a cleaner way to get:
> K=vertcat(kron(U,conj(U)),
>               kron(flipud(U),conj(U)),
>               kron(U,flipud(conj(U))),
>               kron(flipud(U),flipud(conj(U))));
> where U is a column vector.
> Of course, I could save conj(U)=A, and flipud(U)=B, and flipud(conj(U))=C,
> but it would still involve 4 kroneker products, even though it looks like there's a lot of symmetry and repetition in the command.
> It would be neat to see if there's a clean alternative,
> Cheers!
  Yes, it does seem a shame to do four times as many multiplications as are really necessary.  Try this:

 K = kron(U,conj(U)); % First block
 K = vertcat(K,reshape(flipud(reshape(K,[],length(U))),[],1)); % Add 2nd block
 K = vertcat(K,flipud(K)); % Add 3rd & 4th blocks

I don't know that this could be considered "cleaner", but it does have only one 'kron' operation.  The last step by itself would probably save some execution time but I am not sure of the middle step with its two reshapes.

Roger Stafford