How can I find the state matrix representation?

55 Views Asked by At

I have been trapped in where I go wrong. The problem is as follows:

Consider the list E of 16 matrices $\mathbb{E}_{(i,j)}$ for $(i,j)\in\{1,2,3,4\}$ where the $(i,j)$'th place equals $1$ and is zero elsewhere. (ie. standard basis for $4\times 4$ matrices)

Let $L=cc^T$, where $c=[2,-1,0,-1]^T$. (Note L is symmetric) Find and state the matrix representation of the 2D convolution:

$C_L=(X\star_2L)_{(p,q)} = \sum^m_{i=1}\sum^n_{j=1}x_{j,k}~l_{(p-i(\text{mod}~ m)+1,~(q-j(\text{mod}~ m)+1)}~~,~~(p,q)\in\{1,2,3,4\}$

with regards to basis $\mathbb{E}$, ie. find $A:=_E[C_L]_E$. Using Matlab is recommended.

My Matlab code is extremely messy, but is as follows:

ct = c'
L = c*ct
% Our E basis
E11 = [1 0 0 0;0 0 0 0;0 0 0 0;0 0 0 0];E12 = [0 1 0 0;0 0 0 0;0 0 0 0;0 0 0 0];
E13 = [0 0 1 0;0 0 0 0;0 0 0 0;0 0 0 0];E14 = [0 0 0 1;0 0 0 0;0 0 0 0;0 0 0 0];
E21 = [0 0 0 0;1 0 0 0;0 0 0 0;0 0 0 0];E22 = [0 0 0 0;0 1 0 0;0 0 0 0;0 0 0 0];
E23 = [0 0 0 0;0 0 1 0;0 0 0 0;0 0 0 0];E24 = [0 0 0 0;0 0 0 1;0 0 0 0;0 0 0 0];
E31 = [0 0 0 0;0 0 0 0;1 0 0 0;0 0 0 0];E32 = [0 0 0 0;0 0 0 0;0 1 0 0;0 0 0 0];
E33 = [0 0 0 0;0 0 0 0;0 0 1 0;0 0 0 0];E34 = [0 0 0 0;0 0 0 0;0 0 0 1;0 0 0 0];
E41 = [0 0 0 0;0 0 0 0;0 0 0 0;1 0 0 0];E42 = [0 0 0 0;0 0 0 0;0 0 0 0;0 1 0 0];
E43 = [0 0 0 0;0 0 0 0;0 0 0 0;0 0 1 0];E44 = [0 0 0 0;0 0 0 0;0 0 0 0;0 0 0 1];

% Now we pass E through our CL for E(i,j) yielding 4x4 matrices each time
m=4;
n=4;
temp11 = 0;temp12 = 0;temp13 = 0;temp14 = 0;
temp21 = 0;temp22 = 0;temp23 = 0;temp24 = 0;
temp31 = 0;temp32 = 0;temp33 = 0;temp34 = 0;
temp41 = 0;temp42 = 0;temp43 = 0;temp44 = 0;
for p=1:4
    for q=1:4
        for j=1:m       % row
            for k=1:n   % column
                temp11 = temp11 + E11(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp12 = temp12 + E12(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp13 = temp13 + E13(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp14 = temp14 + E14(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp21 = temp21 + E21(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp22 = temp22 + E22(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp23 = temp23 + E23(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp24 = temp24 + E24(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp31 = temp31 + E31(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp32 = temp32 + E32(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp33 = temp33 + E33(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp34 = temp34 + E34(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp41 = temp41 + E41(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp42 = temp42 + E42(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp43 = temp43 + E43(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
                temp44 = temp44 + E44(j,k) * L(mod(p-j,m)+1, mod(q-k,n)+1);
               
            end
        end
        E11conv2L(p,q) = temp11;E12conv2L(p,q) = temp12;E13conv2L(p,q) = temp13;
        E14conv2L(p,q) = temp14;E21conv2L(p,q) = temp21;E22conv2L(p,q) = temp22;
        E23conv2L(p,q) = temp23;E24conv2L(p,q) = temp24;E31conv2L(p,q) = temp31;
        E32conv2L(p,q) = temp32;E33conv2L(p,q) = temp33;E34conv2L(p,q) = temp34;
        E41conv2L(p,q) = temp41;E42conv2L(p,q) = temp42;E43conv2L(p,q) = temp43;
        E44conv2L(p,q) = temp44;
    end
end
        
E11conv2L
E12conv2L;E13conv2L;E14conv2L;
E21conv2L;E22conv2L;E23conv2L;E24conv2L;
E31conv2L;E32conv2L;E33conv2L;E34conv2L;
E41conv2L;E42conv2L;E43conv2L;E44conv2L;
% Now, we need to get it represented in the E basis, thus we make 16x1
% column vectors and make A = [E11conv2L | E12conv2L | ... | E44conv2L], 
% a 16x16 matrix

A = [reshape(E11conv2L',[],1) reshape(E12conv2L',[],1) reshape(E13conv2L',[],1) ...
     reshape(E14conv2L',[],1) reshape(E21conv2L',[],1) reshape(E22conv2L',[],1) ...
     reshape(E23conv2L',[],1) reshape(E24conv2L',[],1) reshape(E31conv2L',[],1) ...
     reshape(E32conv2L',[],1) reshape(E33conv2L',[],1) reshape(E34conv2L',[],1) ...
     reshape(E41conv2L',[],1) reshape(E42conv2L',[],1) reshape(E43conv2L',[],1) reshape(E44conv2L',[],1)]

Now, the problem is that A is not a symmetric matrix, which it supposedly should be due to L? I have no clue why my calculations are wrong. My thoughts are pinned in the comments of the code. Where did I go wrong?

1

There are 1 best solutions below

2
On BEST ANSWER

I will assume that the standard basis is, in your context, defined to go in the order $\mathcal E = (E_{11},E_{12},\dots,E_{43},E_{44})$. I also assume that $x_{jk}$ should be $x_{ij}$ in your definition of the convolution map. With that said, you might find the following hints to be helpful.

  • For a $4 \times 4$ matrix $X$, the coordinate vector $[X]_{\mathcal E}$ of $X$ relative to the basis $\mathcal E$ can be found with the Matlab command reshape(X.',[],1).

  • Conversely, given a coordinate-vector $v$ with 16 entries, the corresponding matrix is given by the result of reshape(v,4,4).'.

  • The columns of the matrix $A$ are given by $$ [C_L(X_{11})]_{\mathcal E},[C_L(X_{12})]_{\mathcal E}\dots, [C_L(X_{43})]_{\mathcal E}, [C_L(X_{44})]_{\mathcal E}. $$

  • The following script generates all of the elements of $\mathcal E$ in the correct order.

script:

for i = 1:4
    for j = 1:4
        E = zeros(4,4);
        E(i,j) = 1;
        disp(E)
    end
end
  • Note that $C_L(E_{ij})_{(p,q)} = l_{(p-i\bmod 4+1,q-j\bmod 4+1)} = c_{p-i\bmod 4+1} \cdot c_{p-j\bmod 4+1}$.

A quick script to get the answer:

c=[2;-1;0;-1];
L = c*c.';
A = zeros(16,16);
col = 1;
for i = 1:4
    for j = 1:4
        temp = circshift(L,i-1);
        temp = circshift(temp,j-1,2);
        A(:,col) = reshape(temp.',[],1);
        col = col + 1;
    end
end