數值分析GaussSeidel迭代
function [X,Number_of_iteration] = GaussSeidel_iteration(A,B,P,delta,max1)
% Input - A is an N x N nonsingular matrix
% - B is an N x 1 matrix
% - P is an N x 1 matrix: the initial guess
% - delta is the tolerance for P
% - max1 is the maximum number of iterations
% Output - X is an N x 1 matrix: the GaussSeidel approximation to the
% - solution of the AX = B
N = length(B);
count = 0;
for k = 1 : max1
for j = 1 : N
if j == 1
X(1) = (B(1) - (A(1,(2:N)) * P(2:N))) / A(1,1);
elseif j == N
X(N) = (B(N) - (A(N,(1:N-1)) * X(1:N-1)')) / A(N,N);
else
%X contains the kth approxiamation and P the (k-1)st
X(j) = (B(j) - A (j,1:j-1) * X(1,j-1)' - A(j,(j+1:N)) * P(j+1 : N))/A(j,j);
end
end
count = count + 1;
err = abs(norm(X'-P));
reletive_err = err/(norm(X)+eps);
P = X';
if(err < delta) || (reletive_err < delta)
break
end
end
X = X';
Number_of_iteration = count;
相關文章
- 數值分析Jacobian迭代
- 迭代閾值分割演算法演算法
- 【機器學習】數值分析02——任意方程求根機器學習
- 【機器學習】數值分析01——緒論及誤差分析機器學習
- 數值分析1 - 誤差概念介紹
- 做數值就是做體驗! RPG遊戲關卡數值設計思路分析遊戲
- Bailian2732 求自然常數e的近似值(精確到n)【迭代】AI
- 更改 Excel 迭代公式的次數Excel公式
- 數值分析Python實現系列—— 一、拉格朗日插值法Python
- 從JVM底層原理分析數值交換那些事JVM
- Python迭代器:捕獲Generator的返回值Python
- Go 陷阱之 for 迴圈迭代變數Go變數
- oracle中的數值資料儲存格式分析(ZT)Oracle
- 掙值分析
- 用分析函式分析每行裡面列值重複的列的最大個數函式
- 二值影象分析:案例實戰(文字分離+硬幣計數)
- js數值精度JS
- oracle數值精度Oracle
- 對遞迴和迭代的效率的思考和分析遞迴
- Altair SimSolid快速設計迭代的結構分析AISolid
- ConcurrentModificationException,iterator迭代問題[原始碼分析]Exception原始碼
- 全價值鏈賦能,數字化助力營銷價值全力釋放 | 愛分析報告
- 數值變數交換常用方法變數
- 二值影象分析之輪廓分析
- 掙值分析-PythonPython
- 數字展廳建設所具備的應用價值分析
- 數值分析:最小二乘與嶺迴歸(Pytorch實現)PyTorch
- 數值計算 插值與擬合
- js迭代器實現斐波那契數列JS
- TypeScript 數值型別TypeScript型別
- mysql相同數值排序MySql排序
- Octave 數值計算
- ORACLE USER 變數值Oracle變數
- 求插值係數
- c# 方法引數_值引數C#
- 遊戲數值乾貨:RPG戰鬥數值開源示範遊戲
- 金融BI分析的價值
- 網格缺陷檢測(二值化閾值分析)