111 lines
5.7 KiB
HTML
111 lines
5.7 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
|
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Description of qzswitch</title>
|
|
<meta name="keywords" content="qzswitch">
|
|
<meta name="description" content="from Chris Sims web site">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
|
<meta name="robots" content="index, follow">
|
|
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
|
</head>
|
|
<body>
|
|
<a name="_top"></a>
|
|
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > qzswitch.m</div>
|
|
|
|
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
|
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
|
|
|
<h1>qzswitch
|
|
</h1>
|
|
|
|
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
|
<div class="box"><strong>from Chris Sims web site</strong></div>
|
|
|
|
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
|
<div class="box"><strong>function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z) </strong></div>
|
|
|
|
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
|
<div class="fragment"><pre class="comment"> from Chris Sims web site
|
|
http://eco-072399b.princeton.edu/yftp/gensys/mfiles/QZSWITCH.M</pre></div>
|
|
|
|
<!-- crossreference -->
|
|
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
|
This function calls:
|
|
<ul style="list-style-image:url(../matlabicon.gif)">
|
|
</ul>
|
|
This function is called by:
|
|
<ul style="list-style-image:url(../matlabicon.gif)">
|
|
<li><a href="qzdiv.html" class="code" title="function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)">qzdiv</a> from Chris Sims web site</li></ul>
|
|
<!-- crossreference -->
|
|
|
|
|
|
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
|
<div class="fragment"><pre>0001 <span class="comment">% from Chris Sims web site</span>
|
|
0002 <span class="comment">% http://eco-072399b.princeton.edu/yftp/gensys/mfiles/QZSWITCH.M</span>
|
|
0003 <span class="comment">%</span>
|
|
0004
|
|
0005 <a name="_sub0" href="#_subfunctions" class="code">function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z)</a>
|
|
0006 <span class="comment">%function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z)</span>
|
|
0007 <span class="comment">%</span>
|
|
0008 <span class="comment">% Takes U.T. matrices A, B, orthonormal matrices Q,Z, interchanges</span>
|
|
0009 <span class="comment">% diagonal elements i and i+1 of both A and B, while maintaining</span>
|
|
0010 <span class="comment">% Q'AZ' and Q'BZ' unchanged. If diagonal elements of A and B</span>
|
|
0011 <span class="comment">% are zero at matching positions, the returned A will have zeros at both</span>
|
|
0012 <span class="comment">% positions on the diagonal. This is natural behavior if this routine is used</span>
|
|
0013 <span class="comment">% to drive all zeros on the diagonal of A to the lower right, but in this case</span>
|
|
0014 <span class="comment">% the qz transformation is not unique and it is not possible simply to switch</span>
|
|
0015 <span class="comment">% the positions of the diagonal elements of both A and B.</span>
|
|
0016 realsmall=sqrt(eps)*10;
|
|
0017 <span class="comment">%realsmall=1e-3;</span>
|
|
0018 a = A(i,i); d = B(i,i); b = A(i,i+1); e = B(i,i+1);
|
|
0019 c = A(i+1,i+1); f = B(i+1,i+1);
|
|
0020 <span class="comment">% A(i:i+1,i:i+1)=[a b; 0 c];</span>
|
|
0021 <span class="comment">% B(i:i+1,i:i+1)=[d e; 0 f];</span>
|
|
0022 <span class="keyword">if</span> (abs(c)<realsmall & abs(f)<realsmall)
|
|
0023 <span class="keyword">if</span> abs(a)<realsmall
|
|
0024 <span class="comment">% l.r. coincident 0's with u.l. of A=0; do nothing</span>
|
|
0025 <span class="keyword">return</span>
|
|
0026 <span class="keyword">else</span>
|
|
0027 <span class="comment">% l.r. coincident zeros; put 0 in u.l. of a</span>
|
|
0028 wz=[b; -a];
|
|
0029 wz=wz/sqrt(wz'*wz);
|
|
0030 wz=[wz [wz(2)';-wz(1)'] ];
|
|
0031 xy=eye(2);
|
|
0032 <span class="keyword">end</span>
|
|
0033 <span class="keyword">elseif</span> (abs(a)<realsmall & abs(d)<realsmall)
|
|
0034 <span class="keyword">if</span> abs(c)<realsmall
|
|
0035 <span class="comment">% u.l. coincident zeros with l.r. of A=0; do nothing</span>
|
|
0036 <span class="keyword">return</span>
|
|
0037 <span class="keyword">else</span>
|
|
0038 <span class="comment">% u.l. coincident zeros; put 0 in l.r. of A</span>
|
|
0039 wz=eye(2);
|
|
0040 xy=[c -b];
|
|
0041 xy=xy/sqrt(xy*xy');
|
|
0042 xy=[[xy(2)' -xy(1)'];xy];
|
|
0043 <span class="keyword">end</span>
|
|
0044 <span class="keyword">else</span>
|
|
0045 <span class="comment">% usual case</span>
|
|
0046 wz = [c*e-f*b, (c*d-f*a)'];
|
|
0047 xy = [(b*d-e*a)', (c*d-f*a)'];
|
|
0048 n = sqrt(wz*wz');
|
|
0049 m = sqrt(xy*xy');
|
|
0050 <span class="keyword">if</span> m<eps*100
|
|
0051 <span class="comment">% all elements of A and B proportional</span>
|
|
0052 <span class="keyword">return</span>
|
|
0053 <span class="keyword">end</span>
|
|
0054 wz = n\wz;
|
|
0055 xy = m\xy;
|
|
0056 wz = [wz; -wz(2)', wz(1)'];
|
|
0057 xy = [xy;-xy(2)', xy(1)'];
|
|
0058 <span class="keyword">end</span>
|
|
0059 A(i:i+1,:) = xy*A(i:i+1,:);
|
|
0060 B(i:i+1,:) = xy*B(i:i+1,:);
|
|
0061 A(:,i:i+1) = A(:,i:i+1)*wz;
|
|
0062 B(:,i:i+1) = B(:,i:i+1)*wz;
|
|
0063 Z(:,i:i+1) = Z(:,i:i+1)*wz;
|
|
0064 Q(i:i+1,:) = xy*Q(i:i+1,:);</pre></div>
|
|
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
|
</body>
|
|
</html> |