Graphics Programs Reference
In-Depth Information
sturmSeq
Given the diagonals c and d of A
=
[ c
\
d
\
c ], and the valueof
λ
,thisfunctionreturns
the Sturm sequence P 0 (
λ
)
,
P 1 (
λ
)
,...,
P n (
λ
). Note that P n (
λ
)
= |
A
λ
I
|
.
functionp=sturmSeq(c,d,lambda)
% Returns Sturm sequence p associated with
%thetridiagonalmatrixA=[c\d\c]andlambda.
%USAGE:p=sturmSeq(c,d,lambda).
%Notethat
|
A - lambda*I
|
= p(n).
n = length(d) + 1;
p = ones(n,1);
p(2) = d(1) - lambda;
fori=2:n-1
p(i+1) = (d(i) - lambda)*p(i) - (c(i-1)ˆ2 )*p(i-1);
end
count eVals
Thisfunction counts the number of sign changes in the Sturm sequence and returns
the number of eigenvalues of the matrix A
=
[ c
\
d
\
c ]that aresmaller than
λ
.
function num
eVals(c,d,lambda)
% Counts eigenvalues smaller than lambda of matrix
%A=[c\d\c].UsestheSturmsequence.
% USAGE: num
_
eVals = count
_
_
eVals = count
_
eVals(c,d,lambda).
p = sturmSeq(c,d,lambda);
n = length(p);
oldSign = 1; num
_
eVals = 0;
fori=2:n
pSign = sign(p(i));
if pSign == 0; pSign = -oldSign; end
if pSign*oldSign < 0
num
_
eVals = num
_
eVals + 1;
end
oldSign = pSign;
end
Search WWH ::




Custom Search