本程序可以用雅可比迭代法,塞德尔迭代法,逐次超松弛法求解线性方程组 已经在visual studio2005中调试通过!
已经在visual studio2005中调试通过!
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;
#define kk 50 //定义最大方程元数
int n,i,c,j,ll,hh,gg,mm;
double A[kk][kk],x[kk][kk],b[kk],y[kk],a[kk],z[kk],m,nn,d,e=1,w,fff ;
void main()
{
cout<<" **********************************************************************"<<endl;
cout<<" ***本程序可以用雅可比迭代法,塞德尔迭代法,逐次超松弛法求解线性方程组***"<<endl;
cout<<" ***************************制作人###*****************************"<<endl;
cout<<" ***********************说明:方程最多个数为50**************************"<<endl;
cout<<" **********************************************************************"<<endl;
//*********************************数据的输入********************************
/*bb:*/cout<<"输入的方程元数"<<endl;
cin>>n;
cout<<"请输入方程系数矩阵:"<<endl;
for(i=0;i<n;i++)
for(j=0;j<n;j++)
cin>>A[i][j];
cout<<"请输入右边向量:"<<endl;
for(i=0;i<n;i++)
cin>>b[i];
cout<<"输入你想要的迭代精度(建议1e-5以上)!"<<endl;
cin>>fff;
cout<<"输入最大迭代次数(建议300次以上)!"<<endl;
cin>>mm;
////*******************************判断是否对角占优*************************
// for(i=0;i<n;i++)
// {
// for(j=0;j<n;j++)
// {
// nn=0;
// if(i==j)
// {
// d=fabs(A[i][i]);
// }
// else
// nn=nn+fabs(A[i][j]);
// }
// if(nn>d)
// {
// cout<<"该方程不对角占优,迭代不收敛"<<endl;
// cout<<"是否继续?是(0),否(1)"<<endl;
// cin>>hh;
// if(hh!=1)
// goto bb;
// else exit(1);
// }
// }
//********************************计算出迭代矩阵*************************
for(i=0;i<n;i++)
{
b[i]=b[i]/A[i][i];
for(j=0;j<n;j++)
{
if(i==j)
{
x[i][i]=0;
}
else
{
x[i][j]=-A[i][j]/A[i][i];
}
}
}
//*******************************输出迭代矩阵*****************************
cout<<"计算出迭代矩阵为:"<<endl;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
cout<<x[i][j]<<" ";
cout<<b[i]<<" ";
cout<<endl;
}
//****************************迭代方法的选择*****************************
cout<<"请你选择迭代方法!"<<endl;
cout<<endl;
cout<<endl;
cout<<"选用雅可比迭代法,请输入(1)!"<<endl;
cout<<endl;
cout<<endl;
cout<<"选用塞德尔迭代法,请输入(2)!"<<endl;
cout<<endl;
cout<<endl;
cout<<"选用逐次超松弛法,请输入(3)!"<<endl;
cout<<endl;
cout<<endl;
cin>>ll;
//*****************************赋迭代初值***********************************
cout<<"输入迭代初值"<<endl;
for(i=0;i<n;i++)
cin>>y[i];
int f=1;
switch(ll)
{
case 1:goto cc;
break;
case 2:goto aa;
break;
case 3:goto dd;
}
//***************************雅可比迭代法************************************
cc:cout<<" ";
fo
2.2 Fixed-Point Iteration (1) Introduction A fixed point for a given function g is a number p for which g(p)=p. Root-finding problem: f(p)=...
SEI 软件工程研究所 Xidian University Software School RUP -- Iteration Iteration vs. Disciplines SEI 软件工程研究所 Xidian University Software School RUP -- ...
The main advantage of division by functional iteration is...更多>>A class of high performance division algorithms is functional iteration. Division by ...
4.2 Fixed-Point Iteration_理学_高等教育_教育专区。合工大数值分析中英文课件4.2 Fixed-Point Iteration 4.2.1 Basic Concepts 4.2.2 Convergence Analysis ...
Graeffe iteration was the choice algorithm for solving univariate polynomials in the XIX-th and early XX-th century. In this paper, a new variation of...
Power Iteration Clustering_IT/计算机_专业资料。Power Iteration Clustering Speaker: Xiaofei Di 2010.10.11 Outline ? ? ? ? ? Authors Abstract Backg...
KRYLOV SUBSPACE ITERATION Presented by: Nab Raj Roshyara Master and Ph.D. Student Supervisors: Prof. Dr. Peter Benner, Department of Mathematics, TU ...
Suppose that we approximate the n by n matrix A, of the linear system Ax = b, by the simpler matrix K, then the above sketched iteration process ...
tester10 迭代次数:2 次 场景设臵(一):Sequential+Each Iteration 执行结果: VuGen 中:1 个用户 第一次迭代(Iteration)取值为 tester1 第二次迭代(Iteration)...
The most fundamental and easy to code by a combinator are (simple) iteration and primitive-recursion. Some other schemes that are more general in terms ...
热门文档