%Fastest descent method is realized by this function below
function y=FDM(A,b)
[row_num,column_num]=size(A);
length_b=length(b);
if row_num ~= column_num
disp('The number of rows of the coefficient matrix is not equal to its number of columns')
return
elseif row_num ~= length_b
disp('Please ensure the dimensions of the coefficient matrix is equal to the dimensions of inhomogeneous terms')
return
end
if row_num>2
for i=1:row_num-1
for j=i+1:num
if A(i,j)~=A(j,i)
disp('The coefficient matrix is not a symmetric matrix')
return
end
end
end
end
for i=1:length_b
Sequential_master=zeros(i);
for j=1:i
for k=1:i
Sequential_master(j,k)=A(j,k);
end
end
if abs(det(Sequential_master))<10^(-9)
disp('The coefficient matrix is not a positive-definite matrix')
return
else
continue
end
end
[r_b,c_b]=size(b);
if c_b>1
b=b';
end
x=zeros(row_num,1);
iterations=0;
while (A*x-b)'*(A*x-b)>10^(-9) || iterations>10^6
r=b-A*x;
alfa=(r'*r)/(r'*A*r);
x=x+alfa*r;
iterations=iterations+1;
end
txt=['Iterating ',num2str(iterations),' times'];
disp(txt)
y=x;
用最速下降法数值求解线性方程组
需积分: 0 124 浏览量
2023-04-16
16:10:44
上传
评论
收藏 683B ZIP 举报
呵呵哒?
- 粉丝: 0
- 资源: 7
最新资源
- 88-520告白(520气球).zip
- HTML+CSS+JS精品网页模板H126.rar
- n.cpp
- jdk-8u411-windows-x64下载安装可用
- vgg模型-图像分类算法对水果识别-不含数据集图片-含逐行注释和说明文档.zip
- KMP算法(Knuth-Morris-Pratt算法
- vgg模型-python语言pytorch框架训练识别化妆品分类-不含数据集图片-含逐行注释和说明文档.zip
- KMP算法(Knuth-Morris-Pratt算法
- shufflenet模型-基于人工智能的卷积网络训练识别狗的表情-不含数据集图片-含逐行注释和说明文档.zip
- EPIC Fantasy Town 1.0
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈