Graphics Programs Reference
In-Depth Information
-0.7414
-0.0502
0.5949
-0.1497
Convergence was achievedwith 4 iterations.Without the eigenvalueshift 26 iter-
ations wouldbe required.
EXAMPLE 9.6
Unlike Jacobi diagonalization, the inverse powermethod lends itself to eigenvalue
problemsofbandedmatrices.Write aprogram thatcomputes the smallest buckling
load of the beam described in Example 9.3, making full use of the banded forms.Run
the programwith 100 interiornodes ( n
=
100).
Solution The function invPower5 listedbelowreturns the smallest eigenvalue and
the corresponding eigenvector of Ax
Bx , where A is apentadiagonal matrix and
B is a sparse matrix (in this problemit istridiagonal). The matrix A is input by its
diagonals d , e and f as was done in Art.2.4 in conjunctionwith the LU decomposition.
The algorithm for invPower5 does not use B directly, butcalls the function func(v)
thatsupplies the product Bv
= λ
.
Eigenvalueshifting is not used.
function [eVal,eVec] = invPower5(func,d,e,f)
% Finds smallest eigenvalue of A*x = lambda*B*x by
% the inverse power method.
% USAGE: [eVal,eVec] = invPower5(func,d,e,f)
% Matrix A must be pentadiagonal and stored in form
% A = [f\e\d\e\f].
% func = handle of function that returns B*v.
n = length(d);
[d,e,f] = LUdec5(d,e,f); % Decompose A
x = rand(n,1); % Seed x with random numbers
xMag=sqrt(dot(x,x));x=x/xMag;%Normalizex
fori=1:50
xOld = x;
% Save current x
x = LUsol5(d,e,f,feval(func,x));
% Solve [A]
{
x
}
=[B]
{
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)) < 1.0e-6
Search WWH ::




Custom Search