Generate Matrices for Which the Sum is a Sparse Matrix

1 view (last 30 days)
Hi everyone,
I am trying to generate this matrix:
This matrix is the sum of p+1 matrices. To have a zero in some cell (i,j) of the matrix, there should be a zero in the same cell (i,j) and its transpose _(j,i)_for every Yk matrix. These matrices are calculated like this:
and like this:
The B's are randomly generated lower triangular matrices with entries 0, 0.5, and -0.5.
I would like to know how to constrain the Yk's to have 0's in some cells and their transposes.
I tried the code below but it's not working.
Any suggestion will be very appreciated.
function [Z, omega, tmat] = may195(n,p)
o = pi*2*(rand(1)-0.5);
F = zeros(n, n, p);
A = zeros(p*n, p*n);
check1 = 0;
while check1 == 0;
for s = 1:n;
for t = 1:n;
for i = 1:p;
M = randi(3,n,n);
M(M==1) = 0.5;
M(M==2) = 0;
M(M==3) = -0.5;
M = -triu(M)';
F(:,:,i) = M;
end
A(1:n,1:p*n) = reshape(F,[n,p*n]);
A(n+1:p*n, 1:(p-1)*n) = eye((p-1)*n);
while all(abs(eig(A))) < 1
U = eye(size(F,2));
p = size(F,3);
for l = 1:p;
U = U + F(:,:,l)' * F(:,:,l);
end
while U(s,t) == U(t,s) && U(s,t) == 0
Binit = eye(size(F,2));
Y = zeros(size(F,2));
Yp = zeros(size(F,2));
j = sqrt(-1);
for k = 1:p;
B = Binit;
B = B' * F(:,:,k);
for l = 1:(p-k);
B = B + F(:,:,l)' * F(:,:,k+l);
end
Yn = 2*B;
Ynn = exp(-j*k*o)*Yn;
Y = Y + Ynn;
Yt = Yn';
Ytt = exp(j*k*o)*Yt;
Yp = Yp + Ytt;
end
while B(s,t) == B(t,s) && B(s,t) == 0;
S = U + 0.5 * (Y + Yp);
if all(diag(S));
check1 = 1;
end
end
end
end
end
end
end
Z = S;
omega = o;
tmat = F;
end
  3 Comments
Matt J
Matt J on 19 May 2015
Edited: Matt J on 19 May 2015
I would like to know how to constrain the Yk's to have 0's in some cells and their transposes.
You need to explain what it is that you are allowed to control in imposing these constraints. If, for example, we take the simplified case p=0 where you have only the symmetric matrix Y0, you will make Y0(i,j) = 0 if and only if you can choose B0 so that B0(:,i) is orthogonal to B0(:,j).
Said Maanan
Said Maanan on 19 May 2015
@Jan Simon. I think the most relevant parts to my question are these:
for l = 1:p;
U = U + F(:,:,l)' * F(:,:,l);
end
and:
for l = 1:(p-k);
B = B + F(:,:,l)' * F(:,:,k+l);
end
I would like the resulting matrices (Y0 (U) and Yk (B)) to have at least one zero at the same cell (i,j) and its transpose (j,i) before going any further in the computation.

Sign in to comment.

Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!