Hi All.I'm Very Very Glad To Join This Lovely Site & Speaking With You.
In This Term At My University I Have Numerical Methods & My Teacher Asks Me To Write 1 Program About Jacobi Iteration Method.I Have Write It But In Iteration Step I Have Problem & So I Want You Help Me To Improve This Or Write Another Iteration.Tnx All...
Here Its My Program :
#include<math.h>
#include<stdio.h>
#include<iostream>
using namespace std;
int sum(int n , int * pn)
{
int sum = 0;
for(int i = 0 ; i<n ; i++)
{sum = sum + pn[i];}
return sum;
}
double Power(double x , int n)
{
int i;
double pow = 1;
for(i = 0 ; i<n ; i++)
{
pow = pow * x ;
}
return pow ;
}
int main()
{
cout<<"Welcome To Robertoplusplus Jacobi Iterative Method Solver\n\n";
int n;
cout<<"Please Enter n:\n";
cin>>n;
cout<<"\n\n";
double ** A;
A = new double * [n];
A[0] = new double [n*n];
1 - write the code between the [code] tags because I don't understand anything
2 - don't use system("pause") - it will destroy your CPU
3 - what is the problem with the code? what doesn't work?
Tnq U For Notice This.I Retype My Program..My Problem Is In Iteration Step.I Have A Suitable Condition For While Case.
My While In Program Dosent Work Properly.
while(y==0)
{
for(int i = 0 ; i < n ; i++)
{
for(int j = 0 ; j < n ; j++)
{
seri[i] = 0;
if(!(j == i))
seri[i] = seri[i] + A[i][j]*x[j];
}
x[i] = (1./A[i][i])*(b[i]-seri[i]);;
}
for(int i = 0 ; i < n ; i++)
{cout<<"x["<<i<<"] = "<<x[i]<<endl<<endl;}
cout<<"For Continue Press 0 ; For Exit Press Any Number :\n\n";
cin>>y;
}
This is your loop. Try to run it in another new project and you'll see what's wrong. I didn't run it but I can say that this loop is working properly because your condition implies a variable that is manipulated in that loop so the condition can be false. Your problem is not in that loop.