annotate DL/RLS-DLA/private/completeOps.m @ 60:ad36f80e2ccf

(none)
author idamnjanovic
date Tue, 15 Mar 2011 12:20:59 +0000
parents
children
rev   line source
idamnjanovic@60 1 function data = completeOps(data)
idamnjanovic@60 2
idamnjanovic@60 3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
idamnjanovic@60 4 % http://www.cs.ubc.ca/labs/scl/sparco
idamnjanovic@60 5 % $Id: completeOps.m 1040 2008-06-26 20:29:02Z ewout78 $
idamnjanovic@60 6
idamnjanovic@60 7 operators = {};
idamnjanovic@60 8 flagM = 0; if isfield(data,'M'), flagM = 1; end;
idamnjanovic@60 9 flagB = 0; if isfield(data,'B'), flagB = 1; end;
idamnjanovic@60 10
idamnjanovic@60 11 if (~flagM) && (~flagB)
idamnjanovic@60 12 error('At least one of the operators M or B has be to given.');
idamnjanovic@60 13 end
idamnjanovic@60 14
idamnjanovic@60 15 % Define measurement matrix if needed
idamnjanovic@60 16 if ~flagM
idamnjanovic@60 17 info = data.B([],0);
idamnjanovic@60 18 data.M = opDirac(info{1});
idamnjanovic@60 19 else
idamnjanovic@60 20 operators{end+1} = data.M;
idamnjanovic@60 21 end
idamnjanovic@60 22
idamnjanovic@60 23 % Define sparsity basis if needed
idamnjanovic@60 24 if ~flagB
idamnjanovic@60 25 info = data.M([],0);
idamnjanovic@60 26 data.B = opDirac(info{2});
idamnjanovic@60 27 else
idamnjanovic@60 28 operators{end+1} = data.B;
idamnjanovic@60 29 end
idamnjanovic@60 30
idamnjanovic@60 31 % Define operator A if needed
idamnjanovic@60 32 if ~isfield(data,'A')
idamnjanovic@60 33 if (length(operators) > 1)
idamnjanovic@60 34 data.A = opFoG(operators{:});
idamnjanovic@60 35 else
idamnjanovic@60 36 data.A = operators{1};
idamnjanovic@60 37 end
idamnjanovic@60 38 end
idamnjanovic@60 39
idamnjanovic@60 40 % Define empty solution if needed
idamnjanovic@60 41 if ~isfield(data,'x0')
idamnjanovic@60 42 data.x0 = [];
idamnjanovic@60 43 end
idamnjanovic@60 44
idamnjanovic@60 45 % Define the operator size and string
idamnjanovic@60 46 opInfo = data.A([],0);
idamnjanovic@60 47 data.sizeA = [opInfo{1},opInfo{2}];
idamnjanovic@60 48 opInfo = data.B([],0);
idamnjanovic@60 49 data.sizeB = [opInfo{1},opInfo{2}];
idamnjanovic@60 50 opInfo = data.M([],0);
idamnjanovic@60 51 data.sizeM = [opInfo{1},opInfo{2}];
idamnjanovic@60 52 data.op.strA = opToString(data.A);
idamnjanovic@60 53 data.op.strB = opToString(data.B);
idamnjanovic@60 54 data.op.strM = opToString(data.M);
idamnjanovic@60 55
idamnjanovic@60 56 % Get the size of the desired signal
idamnjanovic@60 57 if ~isfield(data,'signalSize')
idamnjanovic@60 58 if ~isfield(data,'signal')
idamnjanovic@60 59 error(['At least one of the fields signal ', ...
idamnjanovic@60 60 'or signalSize must be given.']);
idamnjanovic@60 61 end
idamnjanovic@60 62 data.signalSize = size(data.signal);
idamnjanovic@60 63 end
idamnjanovic@60 64
idamnjanovic@60 65 % Reconstruct signal from sparse coefficients
idamnjanovic@60 66 if ~isfield(data,'reconstruct')
idamnjanovic@60 67 data.reconstruct = @(x) reshape(data.B(x,1),data.signalSize);
idamnjanovic@60 68 end
idamnjanovic@60 69
idamnjanovic@60 70 % Reorder the fields (sort alphabetically)
idamnjanovic@60 71 m = fieldnames(data);
idamnjanovic@60 72 m = sort(m);
idamnjanovic@60 73 dataReorder = struct();
idamnjanovic@60 74 for i=1:length(m)
idamnjanovic@60 75 eval(sprintf('dataReorder.%s = data.%s;',m{i},m{i}));
idamnjanovic@60 76 end
idamnjanovic@60 77
idamnjanovic@60 78 data = dataReorder;