1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
int main(){
const int Lambda = 4;
const int N = 10;
const int N_iter = 202;
vector <vector <long double> >r;
r.push_back(vector<long double> (1, 1));
long double result;
long double old_result;
int k = N;
//initialize the vector r
for (int i = 0; i<N+1; i++)
{
get_r(r, i, i, N);
}
// double check that r(k, k) is defined
get_r(r, k, k, N);
old_result = alpha(k, N, Lambda)*innerloop(r, N, k);
k++;
get_r(r, k, k, N);
result = old_result + alpha(k, N, Lambda)*innerloop(r, N, k);
while(k<N_iter){
k++; // update k
old_result = result;
get_r(r, k, k, N); // ensure that r(k, k)is defined
result = result+ alpha(k, N, Lambda)*innerloop(r,N, k); //update result
}
cout << k << endl;
cout << result<< "\t " << old_result << endl;
return 0;
}
|