<Matlab-3:追赶法(Doolittle分解)工具箱

 1 function x=chase (d,e,f,b) 
 2 % ---------------------------------------------------------------
 3 %the method of chaase*******************************
 4 %  d, e, f,分别是是方程组的下对角,主对角,上对角的三条
 5 %  l,r, f分别是Doolittle分解的主和次对角线
 6 %    /1          0    ...             ...        0  0     \
 7 %    |l2               1  ...          ...       0  0     | 
 8 %  L=|0         l3              ...1                      |
 9 %    |                                                    |
10 %    |                                                    |
11 %    \                                   ln            1  /
12 %------------------------------------------------------------------
13 r(1)=e(1);y(1)=b(1);
14 for i=2:length(e)
15 l(i-1)=d(i-1)/r(i-1);r(i)=e(i)-l(i-1)*f(i-1);
16 y(i)=b(i)-l(i-1)*y(i-1);
17 end
18 x(length(e))=y(length(e))/r(length(e))
19 for j=length(e)-1:-1:1
20 x(j)=(y(j)-f(j)*x(j+1))/r(j)
21 end

 

posted @ 2017-03-05 17:11  胡冬冬  阅读(607)  评论(0编辑  收藏  举报