資源簡(jiǎn)介
雅克比迭代+高斯迭代+SOR迭代法Matlab程序,同時(shí)支持譜半徑計(jì)算,利于直接比較三種算法

代碼片段和文件信息
//?a.cpp?:?定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#include?“stdafx.h“
#include
#include
int?main()
{
double?a[10][10]?=?{
{?4?-1?0?0?0?0?0?0?0?0?}
{?-1?4?-1?0?0?0?0?0?0?0?}
{?0?-1?4?-1?0?0?0?0?0?0?}
{?0?0?-1?4?-1?0?0?0?0?0?}
{?0?0?0?-1?4?-1?0?0?0?0?}
{?0?0?0?0?-1?4?-1?0?0?0?}
{?0?0?0?0?0?-1?4?-1?0?0?}
{?0?0?0?0?0?0?-1?4?-1?0?}
{?0?0?0?0?0?0?0?-1?4?-1?}
{?0?0?0?0?0?0?0?0?-1?4?}
};
double?b[10]?=?{?75-13?2?6?-1214?-4?5?-?5?};
double?x0[10]?=?{?0?};
double?x[10]?=?{?0?};
int?n?=?50;//迭代次數(shù)?
double?zj?=?0;//存儲(chǔ)中間變量?
double?r;//存儲(chǔ)每一次的迭代誤差?
for?(int?i?=?0;?i {
for?(int?m?=?0;?m<10;?m++)
x0[m]?=?x[m];
for?(int?j?=?0;?j<10;?j++)
{
for?(int?l?=?0;?l<10;?l++)
zj?=?zj?+?a[j][l]?*?x0[l];
zj?=?zj?-?a[j][j]?*?x0[j];
x[j]?=?(b[j]?-?zj?)/?a[j][j];
zj?=?0;
}
}
printf(“\nx[]=\n“);
for?(int?i?=?0;?i<10;?i++)
printf(“\t%f\t\n\n“?x0[i]);
system(“pause“);
return?0;
}
?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----
?????文件????????1125??2017-04-02?16:47??c語(yǔ)言雅各比.cpp
?????文件?????????533??2017-04-02?21:34??gs.m
?????文件?????????533??2017-04-02?21:33??j.m
?????文件?????????622??2017-04-02?22:55??sor.m
評(píng)論
共有 條評(píng)論