Sunday, September 28, 2008

Gauss-Seidel Algorithm.

flag =1;

for(i=0; i < n;i++0)
{
x[i]=0;
t[i]=x[i];
}

while ( flag==1)
{
for(i=0;i < n;i++)
{

x[i]=b[i]/a[i][i] ;

for(j=0; j < n;j++)

{
if(i!=j)
x[i] - =(x[j]*a[i][j])/a[i][i];
else
continue;
}

}
for(i=0; i < n;i++)
{
if(x[i]-t[i] > =0.005)
{
flag==1;
t[i]=x[i];
}
else
flag==0;
}
}

No comments: