annotate util/sparco utils/completeOps.m @ 82:138f7f0fdcdf

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