Mentions légales du service

Skip to content
Snippets Groups Projects
Commit dd2df41f authored by hhakim's avatar hhakim
Browse files

Fix matfaust.lazylinop.blkdiag for transpose/adjoint case and block offsets.

parent a4b9acdf
Branches
Tags
No related merge requests found
...@@ -29,18 +29,18 @@ function LB = blkdiag(varargin) ...@@ -29,18 +29,18 @@ function LB = blkdiag(varargin)
lAx = @(A, x) A * x; lAx = @(A, x) A * x;
lAHx = @(A, x) A' * x; lAHx = @(A, x) A' * x;
n = length(varargin); n = length(varargin);
offsets = zeros(n, 1); roffsets = zeros(n+1, 1);
nrows = 0; coffsets = zeros(n+1, 1);
for i=2:n+1 for i=2:n+1
offsets(i) = offsets(i-1) + size(varargin{i-1}, 2); roffsets(i) = roffsets(i-1) + size(varargin{i-1}, 2);
nrows = nrows + size(varargin{i-1}, 1); coffsets(i) = coffsets(i-1) + size(varargin{i-1}, 1);
end end
function P = matmat(x, lmul) function P = matmat(x, lmul, offsets)
P = []; P = [];
for i=1:n for i=1:n
A = varargin{i}; A = varargin{i};
P = [P ; lmul(A, x(offsets(i)+1: offsets(i+1), :))]; P = [P ; lmul(A, x(offsets(i)+1: offsets(i+1), :))];
end end
end end
LB = LazyLinearOperator([nrows, offsets(n+1)], 'matmat', @(x) matmat(x, lAx), 'rmatmat', @(x) matmat(x, lAHx)); LB = LazyLinearOperator([coffsets(n+1), roffsets(n+1)], 'matmat', @(x) matmat(x, lAx, roffsets), 'rmatmat', @(x) matmat(x, lAHx, coffsets));
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment