正在加载图片...
83 Jacobi Gauss-Seidel Iterative Methods Algorithm: Jacobi iterative Method Solve ax=b given an initial approximation x(o Input: the number of equations and unknowns n; the matrix entries a[[; the entries bl l; the initial approximation nn l. tolerance TOL maximum number ofiteratiop 迭代过程中,A的元麦 Output: approximate solution Step 1 set k=1; Ⅺ(不改变,故 a bit wasteful, Step 2 whi steps 3-6 a≠0 sn’tit? 必须等w完全计算 好了才能计算x,因此aG 需要两组向量存储。 Impute xk * Step4If‖X-X0|l X-XO, TOL then Output (XI D; STOP: /* successful Step 5 For i=1,.,n Set X0[sXI /update X0*/ Step 6 Set k ++ Step 7 Output(Maximum number of iterations exceeded); STOP. / unsuccessful *§3 Jacobi & Gauss-Seidel Iterative Methods Algorithm: Jacobi Iterative Method Solve given an initial approximation . Input: the number of equations and unknowns n; the matrix entries a[ ][ ]; the entries b[ ]; the initial approximation X0[ ]; tolerance TOL; maximum number of iterations Nmax. Output: approximate solution X[ ] or a message of failure. Step 1 Set k = 1; Step 2 While ( k  Nmax) do steps 3-6 Step 3 For i = 1, …, n Set ; /* compute xk */ Step 4 If then Output (X[ ]); STOP; /* successful */ Step 5 For i = 1, …, n Set X 0[ ] = X [ ]; /* update X0 */ Step 6 Set k ++; Step 7 Output (Maximum number of iterations exceeded); STOP. /* unsuccessful */ Ax b   = (0) x  ii n j j i i ij j i a b a X X  =  − = 1 ( 0 ) X X Xi X i TOL i n − = −     || 0 || max | 0 | 1 What if aii = 0? 迭代过程中,A的元素 不改变,故可以事先调整好A 使得 aii  0,否则 A不可逆。 必须等X(k)完全计算 好了才能计算X(k+1),因此 需要两组向量存储。 A bit wasteful, isn’t it?
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有