## [77a22a]: frames / framemuleigs.m  Maximize  Restore  History

### 132 lines (113 with data), 3.4 kB

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131``` ```function [V,D]=framemuleigs(Fa,Fs,sym,varargin) %FRAMEMULEIGS Eigenpairs of frame multiplier % Usage: h=framemuleigs(Fa,Fs,sym,K); % h=framemuleigs(Fa,Fs,sym,K,...); % % Input parameters: % Fa : Frame analysis definition % Fs : Frame analysis definition % sym : symbol of Gabor multiplier % K : Number of eigenvectors to compute. % Output parameters: % V : Matrix containing eigenvectors. % D : Eigenvalues. % % `framemuleigs(Fa,Fs,sym,K)` computes the *K* largest eigenvalues and eigen- % vectors of the frame multiplier with symbol *c*, analysis frame *Fa* % and synthesis frame *Fs*. % % If *K* is empty, then all eigenvalues/pairs will be returned. % % `framemuleigs` takes the following parameters at the end of the line of input % arguments: % % 'tol',t Stop if relative residual error is less than the % specified tolerance. Default is 1e-9 % % 'maxit',n Do at most n iterations. % % 'iter' Call `eigs` to use an iterative algorithm. % % 'full' Call `eig` to solve the full problem. % % 'auto' Use the full method for small problems and the % iterative method for larger problems. This is the % default. % % 'crossover',c % Set the problem size for which the 'auto' method % switches. Default is 200. % % 'print' Display the progress. % % 'quiet' Don't print anything, this is the default. % % Examples: % --------- % % The following example calculates and plots the first eigenvector of the % Gabor multiplier given by the |batmask|_ function. Note that the mask % must be converted to a column vector to work with in this framework::: % % mask=batmask; % [Fa,Fs]=framepair('dgt','gauss','dual',10,40); % [V,D]=framemuleigs(Fa,Fs,mask(:)); % sgram(V(:,1),'dynrange',90); % % See also: framemul, framemulappr % Change this to 1 or 2 to see the iterative method in action. printopts=0; if nargin<2 error('%s: Too few input parameters.',upper(mfilename)); end; if nargout==2 doV=1; else doV=0; end; definput.keyvals.K=6; definput.keyvals.maxit=100; definput.keyvals.tol=1e-9; definput.keyvals.crossover=200; definput.flags.print={'quiet','print'}; definput.flags.method={'auto','iter','full'}; [flags,kv,K]=ltfatarghelper({'K'},definput,varargin); % Do the computation. For small problems a direct calculation is just as % fast. L=framelengthcoef(Fa,size(sym,1)); if (flags.do_iter) || (flags.do_auto && L>kv.crossover) if flags.do_print opts.disp=1; else opts.disp=0; end; opts.isreal = false; opts.maxit = kv.maxit; opts.tol = kv.tol; if doV [V,D] = eigs(@(x) frsyn(Fs,sym.*frana(Fa,x)),L,K,'LM',opts); else D = eigs(@(x) frsyn(Fs,sym.*frana(Fa,x)),L,K,'LM',opts); end; else % Compute the transform matrix. bigM=frsyn(F,diag(sym)*frana(F,eye(L))); if doV [V,D]=eig(bigM); else D=eig(bigM); end; end; % The output from eig and eigs is a diagonal matrix, so we must extract the % diagonal. D=diag(D); % Sort them in descending order [~,idx]=sort(abs(D),1,'descend'); D=D(idx(1:K)); if doV V=V(:,idx(1:K)); end; % Clean the eigenvalues, if we know that they are real-valued %if isreal(ga) && isreal(gs) && isreal(c) % D=real(D); %end; ```