Thread Subject: ask for help expanding a matrix

Subject: ask for help expanding a matrix

From: Yaquan Xu

Date: 14 Mar, 2010 07:42:05

Message: 1 of 7

I have a question about matrix manipulation, I am not very familiar with matlab code and I am trying to expand a matrix by repeating the numbers.

Here is the example.

I have a 4 by 4 matrix as follow:

0 5 2 3
5 0 1 4
2 1 0 5
3 4 5 0

Now i try to expand this matrix to 8 by 8 matrix as follow:

0 0 5 0 2 0 3 0
0 0 0 5 0 2 0 3
5 0 0 0 1 0 4 0
0 5 0 0 0 1 0 4
2 0 1 0 0 0 5 0
0 2 0 1 0 0 0 5
3 0 4 0 5 0 0 0
0 3 0 4 0 5 0 0

Please help.Thanks in advance.

Subject: ask for help expanding a matrix

From: Bruno Luong

Date: 14 Mar, 2010 07:57:02

Message: 2 of 7

>> A=[0 5 2 3
5 0 1 4
2 1 0 5
3 4 5 0]

A =

     0 5 2 3
     5 0 1 4
     2 1 0 5
     3 4 5 0

>> kron(A,[1 0; 0 1])

ans =

     0 0 5 0 2 0 3 0
     0 0 0 5 0 2 0 3
     5 0 0 0 1 0 4 0
     0 5 0 0 0 1 0 4
     2 0 1 0 0 0 5 0
     0 2 0 1 0 0 0 5
     3 0 4 0 5 0 0 0
     0 3 0 4 0 5 0 0

% Bruno

Subject: ask for help expanding a matrix

From: Yaquan Xu

Date: 14 Mar, 2010 08:32:04

Message: 3 of 7

Thank you so much. It really solved my problem!

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hni4se$ot2$1@fred.mathworks.com>...
> >> A=[0 5 2 3
> 5 0 1 4
> 2 1 0 5
> 3 4 5 0]
>
> A =
>
> 0 5 2 3
> 5 0 1 4
> 2 1 0 5
> 3 4 5 0
>
> >> kron(A,[1 0; 0 1])
>
> ans =
>
> 0 0 5 0 2 0 3 0
> 0 0 0 5 0 2 0 3
> 5 0 0 0 1 0 4 0
> 0 5 0 0 0 1 0 4
> 2 0 1 0 0 0 5 0
> 0 2 0 1 0 0 0 5
> 3 0 4 0 5 0 0 0
> 0 3 0 4 0 5 0 0
>
> % Bruno

Subject: ask for help expanding a matrix

From: Matt J

Date: 14 Mar, 2010 12:58:02

Message: 4 of 7

"Yaquan Xu" <yaquanxu@gmail.com> wrote in message <hni6u4$pb2$1@fred.mathworks.com>...
> Thank you so much. It really solved my problem!

But you might want to explain a bit what you need this for.
It's important to point out that one rarely needs to explicitly expand a matrix using
kron(A,B), as you're doing. It's usually much more efficient to work with A and B separately, which is why I made this tool:

http://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-manipulation

Subject: ask for help expanding a matrix

From: Yaquan Xu

Date: 14 Mar, 2010 13:59:04

Message: 5 of 7

Thank you so much. It really solved my problem!

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <hni4se$ot2$1@fred.mathworks.com>...
> >> A=[0 5 2 3
> 5 0 1 4
> 2 1 0 5
> 3 4 5 0]
>
> A =
>
> 0 5 2 3
> 5 0 1 4
> 2 1 0 5
> 3 4 5 0
>
> >> kron(A,[1 0; 0 1])
>
> ans =
>
> 0 0 5 0 2 0 3 0
> 0 0 0 5 0 2 0 3
> 5 0 0 0 1 0 4 0
> 0 5 0 0 0 1 0 4
> 2 0 1 0 0 0 5 0
> 0 2 0 1 0 0 0 5
> 3 0 4 0 5 0 0 0
> 0 3 0 4 0 5 0 0
>
> % Bruno

Subject: ask for help expanding a matrix

From: Yaquan Xu

Date: 14 Mar, 2010 15:12:03

Message: 6 of 7

Matt,


Thank you very much for your software. I can use your tool to solve my case more efficient.

the expanded matrix is used to solve the clique partition problem in quadratic way. The first matrix is just a test sample for the weighted graph with 4 nodes ( actually it is not a good test sample since it is a clique already)

The size of expanded matrix is based on the number of cliques. assuming if there is two cliques in the graph, then we have 8 binary variables (Xij, 1 if node i assigned to clique j, 0 otherwise) and the expanded matrix goes to 8 by 8. If there is three cliques, then the matrix goes to 12 by 12, etc.




"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hnimgq$b8u$1@fred.mathworks.com>...
> "Yaquan Xu" <yaquanxu@gmail.com> wrote in message <hni6u4$pb2$1@fred.mathworks.com>...
> > Thank you so much. It really solved my problem!
>
> But you might want to explain a bit what you need this for.
> It's important to point out that one rarely needs to explicitly expand a matrix using
> kron(A,B), as you're doing. It's usually much more efficient to work with A and B separately, which is why I made this tool:
>
> http://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-manipulation

Subject: ask for help expanding a matrix

From: Yaquan Xu

Date: 14 Mar, 2010 15:14:06

Message: 7 of 7

Matt,


Thank you very much for your software. I can use your tool to solve my case more efficient.

the expanded matrix is used to solve the clique partition problem in quadratic way. The first matrix is just a test sample for the weighted graph with 4 nodes ( actually it is not a good test sample since it is a clique already)

The size of expanded matrix is based on the number of cliques. assuming if there is two cliques in the graph, then we have 8 binary variables (Xij, 1 if node i assigned to clique j, 0 otherwise) and the expanded matrix goes to 8 by 8. If there is three cliques, then the matrix goes to 12 by 12, etc.




"Matt J " <mattjacREMOVE@THISieee.spam> wrote in message <hnimgq$b8u$1@fred.mathworks.com>...
> "Yaquan Xu" <yaquanxu@gmail.com> wrote in message <hni6u4$pb2$1@fred.mathworks.com>...
> > Thank you so much. It really solved my problem!
>
> But you might want to explain a bit what you need this for.
> It's important to point out that one rarely needs to explicitly expand a matrix using
> kron(A,B), as you're doing. It's usually much more efficient to work with A and B separately, which is why I made this tool:
>
> http://www.mathworks.com/matlabcentral/fileexchange/25969-efficient-object-oriented-kronecker-product-manipulation

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
kronprod Matt J 14 Mar, 2010 09:20:38
rssFeed for this Thread

Contact us at files@mathworks.com