22 views (last 30 days)

Show older comments

I have a matrix W which is a block diagonal matrix with dimensions , and each of its two block diagonal is vector. I want to find the values of its enteries that minimze the difference between the following function:

Where: W is the required block diagonal matrix to be optimized, B is a matrix, H is a given matrix, and A is a matrix. A and B are calculated using the functions used in the attached code.

It tried this attached code, but I think it is now in infinte loop and I don't know what should I do?

while ((B*H)-(A*W)~=zeros(2,4))

w1=randn(1,2); % generate the first block diagonal vector with dimensions 1*2. The values of each entry of the block

% diagonal vector may be not the same.

w2=randn(1,2); % generate the second block diagonal vector with dimensions 1*2.

W=blkdiag(w1,w2); % bulid the block diagonal matrix that I want to optimize with dimmensions 2*4.

R=sqrtm(W*inv(inv(P)+(H'*inv(eye(2)+D)*H))*W'); % R is 2*2 matrix that will be used to calculate matrix A using LLL lattice

% reduction algorithm. The values of P (4*4 matrix), H (2*4 matrix) and D (2*2 matrix) are given. It's clear here that

% matrix R is a function of W.

A= LLL(R,3/4); % I use here LLL lattice reduction algorithm to obtain 2*2 matrix A which is function of R.

B=A'*W*P*H'*inv(eye(2)+D+H*P*H'); % B is 2*2 matrix which is function of A and W. The values of P (4*4 matrix),

% H (2*4 matrix) and D (2*2 matrix) are given.

end

Fabio Freschi
on 3 Mar 2020

If I understand correctly the problem can be recast to the following

A*W = B*H = F;

[a11 a12; a21 a22]*[w1 w2 0 0; 0 0 w3 w4] = [f11 f12 f13 f14; f21 f22 f23 f24];

If so, it is possible to write it in terms of another linear system

A0*w0 = f0;

[A 0 0 0; 0 A 0 0; 0 0 A 0; 0 0 0 A]*[w1 0 w2 0 0 w3 0 w4]' = [f11 f21 f12 f22 f13 f23 f14 f24];

Where A0 is 8x8, w0 is 8x1 and f is 8x1.

This is actually a over determined system, because some of the unknowns (at positions 2 4 5 and 7) are actually zeros, so we can delete the corresponding cols of A0, having a 8x4 matrix. This can be solved with backslash, which gives the linear least squares solution. I don't have the actual matrices, so I play with dummy values

% this is your matrix A

A = eye(2)+rand(2);

% this is the result of the product of your matrices B*H

F = rand(2,4);

% create the 8x8 system

A0 = blkdiag(A,A,A,A);

% create the rhs

f = F(:);

% remove the 2 4 5 7 cols from A0

A0(:,[2 4 5 7]) = [];

% now get the least squares solution

w = A0\f

% result with your notation w1 and w2

w1 = [W(1) W(2)];

w2 = [W(3) W(4)];

hope it helps

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

Start Hunting!