迭代法求解AX=B方程组
请问这个程序为什么能运行,啥结果也没有
double Jacobi(double **a, double **g, double *x1,double *x0)//雅克比迭代法
{
double sum,err=0.0;
x0=(double *)malloc(sizeof(double )*n7);
x1=(double *)malloc(sizeof(double )*n7);
for(i=0;i<=(n+1)*(n+1);++i)
{
x0[i]=0.0;
x1[i]=0.0;
}
for (k=0;k<maxn;k++)//k为迭代次数
{
max_error=0.0;
for (i=0;i<=(n+1)*(n+1)-1;i++)
{
sum=0.0;
for (j=0;j<=(n+1)*(n+1)-1;j++)
{
if(j!=i)
sum+=a[i][j]*x0[j];
}
x1[i]=(b[i]-sum)/a[i][i];
}
for(i=0;i<=(n+1)*(n+1)-1;i++)
{
err=fabs(x1[i]-x0[i]);//绝对误差
if(err>max_error)
max_error=err;
x0[i]=x1[i];
}
if (err<pow(10,-7))
break;
}
printf("经过%d次雅克比迭代得到以下解向量\n", k+1);
}