Graphics Programs Reference
In-Depth Information
fori=1:maxIter
xOld = x; % Save current x
x = LUsol3(c,d,e,x); % Solve A*x = xOld
xMag=sqrt(dot(x,x));x=x/xMag; %Normalizex
xSign = sign(dot(xOld,x));
% Detect sign change of x
x = x*xSign;
% Check for convergence
if sqrt(dot(xOld - x,xOld - x)) < tol
eVal = s + xSign/xMag; eVec = x;
return
end
end
error('Too many iterations')
EXAMPLE 9.13
Compute the 10th smallest eigenvalue of the matrix A given in Example 9.12.
Solution The following program extracts the m th eigenvalueof A by the inverse
powermethodwith eigenvalueshifting:
Example 9.13 (Eigenvals. of tridiagonal matrix)
format short e
m=10
n=100;
d = ones(n,1)*2; c = -ones(n-1,1);
r = eValBrackets(c,d,m);
s =(r(m) + r(m+1))/2;
[eVal,eVec] = invPower3(c,d,s);
mth
_
eigenvalue = eVal
The result is
>>m=
10
_
mth
eigenvalue =
9.5974e-002
EXAMPLE 9.14
Compute the three smallest eigenvalues and the corresponding eigenvectors of the
matrix A in Example 9.5.
Search WWH ::




Custom Search