00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00029 #include <iostream>
00030 #include <cmath>
00031 #include <stdexcept>
00032 #include <sys/time.h>
00033
00034 #include "arts.h"
00035 #include "array.h"
00036 #include "math_funcs.h"
00037 #include "matpackI.h"
00038 #include "logic.h"
00039
00040 extern const Numeric DEG2RAD;
00041 extern const Numeric PI;
00042
00043 void init_xy(float stepsize, int frequency,
00044 Matrix& Integrand, Vector& za_grid, Vector& aa_grid);
00045
00046 void init_x(int vsize, float stepsize, int frequency,
00047 Vector& Integrand, Vector& Theta);
00048
00049 Numeric AngIntegrate_trapezoid_original(MatrixView Integrand,
00050 ConstVectorView za_grid,
00051 ConstVectorView aa_grid);
00052
00053 Numeric AngIntegrate_trapezoid_opt(MatrixView Integrand,
00054 ConstVectorView za_grid,
00055 ConstVectorView aa_grid);
00056
00057 Numeric AngIntegrate_trapezoid_fixedstep(MatrixView Integrand,
00058 ConstVectorView za_grid,
00059 ConstVectorView aa_grid,
00060 Numeric stepsize);
00061
00062 Numeric AngIntegrate_trapezoid_fixedstep_opt(MatrixView Integrand,
00063 ConstVectorView za_grid,
00064 ConstVectorView aa_grid,
00065 Numeric stepsize);
00066
00067 Numeric AngIntegrate_trapezoid_fixedstep_opt2(MatrixView Integrand,
00068 ConstVectorView za_grid,
00069 ConstVectorView aa_grid,
00070 Numeric stepsize);
00071
00072 Numeric AngIntegrate_trapezoid_original(ConstVectorView Integrand,
00073 ConstVectorView za_grid);
00074
00075 Numeric AngIntegrate_trapezoid_fixedstep(ConstVectorView Integrand,
00076 ConstVectorView za_grid,
00077 Numeric stepsize);
00078
00079 Numeric test_xy(int z_size, int a_size,
00080 float stepsize, int frequency);
00081
00082 Numeric test_xy_opt(int z_size, int a_size,
00083 float stepsize, int frequency);
00084
00085 Numeric test_xy_fixedstep(int z_size, int a_size,
00086 float stepsize, int frequency);
00087
00088 Numeric test_xy_fixedstep_opt(int z_size, int a_size,
00089 float stepsize, int frequency);
00090
00091 Numeric test_xy_fixedstep_opt2(int z_size, int a_size,
00092 float stepsize, int frequency);
00093
00094 Numeric test_AngIntegrate_trapezoid_opti(int z_size, int a_size,
00095 float stepsize, int frequency);
00096
00097 Numeric test_x(int vsize,
00098 float stepsize,
00099 int frequency);
00100
00101 Numeric test_x_fixedstep(int vsize,
00102 int frequency);
00103
00104
00105 int main(int argc, char *argv[])
00106 {
00107 if (argc == 1)
00108 { cerr << argv[0] << " requires one parameter" << endl; exit (1); }
00109
00110 cout << "Uebergabewert von argv : " << argv[1] << endl;
00111
00112 int frequency = (int)strtol(argv[1], NULL, 10);
00113 cout << "Wert von frequency : " << frequency << endl;
00114
00115
00116
00117
00118
00119
00120 test_xy(181, 361, 1.0, frequency);
00121
00122
00123
00124
00125
00126
00127
00128 test_AngIntegrate_trapezoid_opti(181, 361, 1.0, frequency);
00129
00130 }
00131
00132
00134
00138 void init_x(int vsize, float stepsize, int frequency,
00139 Vector& Integrand, Vector& Theta)
00140 {
00141 cout << "----------------init_x---------------\n";
00142
00143
00144
00145
00146 for (int i = 0; i < Integrand.nelem(); i++)
00147 Integrand[i] = (float)i * stepsize;
00148
00149
00150 for (int i = 0; i < Theta.nelem(); i++)
00151 Theta[i] = (float)i * stepsize;
00152
00153 cout << "function Y = X" << endl
00154 << "vsize = " << vsize << endl
00155 << "stepsize = " << stepsize << endl
00156 << "frequency = " << frequency << endl
00157 << "Integrand: von " << Integrand[0] << " bis "
00158 << Integrand[Integrand.nelem() - 1] << endl
00159 << "Theta: von " << Theta[0] << " bis "
00160 << Theta[Theta.nelem() - 1] << endl;
00161 }
00162
00163
00165
00169 void init_xy(float stepsize, int frequency,
00170 Matrix& Integrand, Vector& za_grid, Vector& aa_grid)
00171 {
00172 cout << ">>>>>-----------init_xy---------------\n";
00173 Index n_za = za_grid.nelem();
00174 Index n_aa = aa_grid.nelem();
00175
00176
00177 for (Index i = 0; i < n_za; i++)
00178 for (Index j = 0; j < n_aa; j++)
00179 Integrand(i,j)=1;
00180
00181
00182 for (Index i = 0; i < n_za; i++)
00183 za_grid[i] = (float)i * stepsize;
00184
00185
00186 for (Index i = 0; i < n_aa; i++)
00187 aa_grid[i] = (float)i * stepsize;
00188
00189 cout << "function x^2 + y^2 + z^2 = 1" << endl
00190 << "n_za = " << n_za << endl
00191 << "n_aa = " << n_aa << endl
00192 << "stepsize = " << stepsize << endl
00193 << "frequency = " << frequency << endl
00194 << "Integrand(*,0): von " << Integrand(0,0) << " bis "
00195 << Integrand(n_za - 1, 0) << endl
00196 << "Integrand(0,*): von " << Integrand(0,0) << " bis "
00197 << Integrand(0, n_aa - 1) << endl
00198 << "za_grid (Theta): von " << za_grid[0] << " bis "
00199 << za_grid[za_grid.nelem() - 1] << endl
00200 << "aa_grid (Phi) : von " << aa_grid[0] << " bis "
00201 << aa_grid[aa_grid.nelem() - 1] << endl;
00202 cout << "---------------init_xy---------------<<<<<\n";
00203 }
00204
00205
00207
00218 Numeric AngIntegrate_trapezoid_original(MatrixView Integrand,
00219 ConstVectorView za_grid,
00220 ConstVectorView aa_grid)
00221 {
00222
00223 Index n = za_grid.nelem();
00224 Index m = aa_grid.nelem();
00225 Vector res1(n);
00226 assert (is_size(Integrand, n, m));
00227
00228 for (Index i = 0; i < n ; ++i)
00229 {
00230 res1[i] = 0.0;
00231
00232 for (Index j = 0; j < m - 1; ++j)
00233 {
00234 res1[i] += 0.5 * DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
00235 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[i] * DEG2RAD);
00236 }
00237 }
00238 Numeric res = 0.0;
00239 for (Index i = 0; i < n - 1; ++i)
00240 {
00241 res += 0.5 * DEG2RAD * (res1[i] + res1[i + 1]) *
00242 (za_grid[i + 1] - za_grid[i]);
00243 }
00244
00245
00246 return res;
00247 }
00249
00260 Numeric AngIntegrate_trapezoid_opt(MatrixView Integrand,
00261 ConstVectorView za_grid,
00262 ConstVectorView aa_grid)
00263 {
00264
00265 Index n = za_grid.nelem();
00266 Index m = aa_grid.nelem();
00267 Vector res1(n);
00268 assert (is_size(Integrand, n, m));
00269
00270 for (Index i = 0; i < n ; ++i)
00271 {
00272 res1[i] = 0.0;
00273
00274 for (Index j = 0; j < m - 1; ++j)
00275 {
00276 res1[i] += 0.5 * DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
00277 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[i] * DEG2RAD);
00278 }
00279 }
00280 Numeric res = 0.0;
00281 for (Index i = 0; i < n - 1; ++i)
00282 {
00283 res += 0.5 * DEG2RAD * (res1[i] + res1[i + 1]) *
00284 (za_grid[i + 1] - za_grid[i]);
00285 }
00286
00287
00288 return res;
00289 }
00290
00292
00304 Numeric AngIntegrate_trapezoid_fixedstep(MatrixView Integrand,
00305 ConstVectorView za_grid,
00306 ConstVectorView aa_grid,
00307 Numeric stepsize)
00308 {
00309 Index n = za_grid.nelem();
00310 Index m = aa_grid.nelem();
00311 Vector res1(n);
00312 assert (is_size(Integrand, n, m));
00313
00314 for (Index i = 0; i < n ; ++i)
00315 {
00316 res1[i] = 0.0;
00317
00318 for (Index j = 0; j < m - 1; ++j)
00319 {
00320 res1[i] += 0.5 * DEG2RAD * (Integrand(i, j) + Integrand(i, j + 1)) *
00321 stepsize * sin(za_grid[i] * DEG2RAD);
00322 }
00323 }
00324 Numeric res = 0.0;
00325 for (Index i = 0; i < n - 1; ++i)
00326 {
00327 res += 0.5 * DEG2RAD * (res1[i] + res1[i + 1]) * stepsize;
00328 }
00329
00330
00331 return res;
00332 }
00333
00335
00347 Numeric AngIntegrate_trapezoid_fixedstep_opt(MatrixView Integrand,
00348 ConstVectorView za_grid,
00349 ConstVectorView aa_grid,
00350 Numeric stepsize)
00351 {
00352 Index n = za_grid.nelem();
00353 Index m = aa_grid.nelem();
00354 Vector res1(n);
00355 assert (is_size(Integrand, n, m));
00356
00357 for (Index i = 0; i < n ; ++i)
00358 {
00359 res1[i] = 0.0;
00360
00361 res1[i] += Integrand(i, 0);
00362 for (Index j = 1; j < m - 1; j++)
00363 {
00364 res1[i] += Integrand(i, j) * 2;
00365 }
00366 res1[i] += Integrand(i, m-1);
00367 res1[i] *= 0.5 * DEG2RAD * stepsize * sin(za_grid[i] * DEG2RAD);
00368 }
00369 Numeric res = 0.0;
00370 res += res1[0];
00371 for (Index i = 1; i < n - 1; i++)
00372 {
00373 res += res1[i] * 2;
00374 }
00375 res += res1[n-1];
00376 res *= 0.5 * DEG2RAD * stepsize;
00377
00378
00379 return res;
00380 }
00381
00382
00384
00397 Numeric AngIntegrate_trapezoid_fixedstep_opt2(MatrixView Integrand,
00398 ConstVectorView za_grid,
00399 ConstVectorView aa_grid,
00400 Numeric stepsize)
00401 {
00402 Index n = za_grid.nelem();
00403 Index m = aa_grid.nelem();
00404 Vector res1(n);
00405 assert (is_size(Integrand, n, m));
00406
00407 Numeric temp = 0.0;
00408
00409 for (Index i = 0; i < n ; ++i)
00410 {
00411 temp = Integrand(i, 0);
00412 for (Index j = 1; j < m - 1; j++)
00413 {
00414 temp += Integrand(i, j) * 2;
00415 }
00416 temp += Integrand(i, m-1);
00417 temp *= 0.5 * DEG2RAD * stepsize * sin(za_grid[i] * DEG2RAD);
00418 res1[i] = temp;
00419 }
00420
00421 Numeric res = res1[0];
00422 for (Index i = 1; i < n - 1; i++)
00423 {
00424 res += res1[i] * 2;
00425 }
00426 res += res1[n-1];
00427 res *= 0.5 * DEG2RAD * stepsize;
00428
00429
00430 return res;
00431 }
00432
00433
00435
00438 Numeric AngIntegrate_trapezoid_original(ConstVectorView Integrand,
00439 ConstVectorView za_grid)
00440 {
00441
00442 Index n = za_grid.nelem();
00443 assert (is_size(Integrand, n));
00444
00445 Numeric res = 0.0;
00446 for (Index i = 0; i < n - 1; ++i)
00447 {
00448
00449 res += PI * DEG2RAD * (Integrand[i]* sin(za_grid[i] * DEG2RAD)
00450 + Integrand[i + 1] * sin(za_grid[i + 1] * DEG2RAD))
00451 * (za_grid[i + 1] - za_grid[i]);
00452 }
00453
00454
00455 return res;
00456 }
00457
00459
00462 Numeric AngIntegrate_trapezoid_fixedstep(ConstVectorView Integrand,
00463 ConstVectorView za_grid,
00464 Numeric stepsize)
00465 {
00466
00467 Index n = za_grid.nelem();
00468 assert (is_size(Integrand, n));
00469
00470 Numeric res = 0.0;
00471
00472 res += (Integrand[0] * sin(za_grid[0] * DEG2RAD));
00473 for (Index i = 1; i < n - 1 ; ++i)
00474 {
00475 res += (Integrand[i] * sin(za_grid[i] * DEG2RAD) * 2);
00476
00477 }
00478 res += ((Integrand[n-1] * sin(za_grid[n-1] * DEG2RAD)));
00479
00480
00481 res *= PI * DEG2RAD * stepsize;
00482
00483
00484 return res;
00485 }
00486
00487
00489
00500 Numeric test_xy(int z_size, int a_size,
00501 float stepsize, int frequency)
00502 {
00503 cout << ">>>>>-----------test_xy---------------\n";
00504 Matrix Integrand(z_size, a_size);
00505 Vector za_grid(z_size);
00506 Vector aa_grid(a_size);
00507
00508 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00509
00510 Numeric result = 0;
00511
00512 struct timeval start;
00513 struct timeval ende;
00514 gettimeofday(&start, NULL);
00515
00516
00517
00518 for (int i = 0; i < frequency; i++)
00519 result = AngIntegrate_trapezoid_original(Integrand, za_grid, aa_grid);
00520
00521 gettimeofday(&ende, NULL);
00522
00523 double error = result/(4*PI) - 1;
00524
00525 double diffs = (double)(ende.tv_sec - start.tv_sec)
00526 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00527 cout.precision(15);
00528 cout << "stepsize is : " << stepsize << endl
00529 << "z_size : " << z_size << endl
00530 << "a_size : " << a_size << endl
00531 << "1 is : " << result/(4*PI) << endl
00532 << "The result is : " << result << endl
00533 << "The error is : " << error*100 << " %\n"
00534 << "Number of loops: " << frequency << endl
00535 << "elapsed time : " << diffs << "s" << endl
00536 << "----------------test_xy----------<<<<<\n";
00537
00538 return result;
00539
00540 }
00541
00543
00554 Numeric test_xy_opt(int z_size, int a_size,
00555 float stepsize, int frequency)
00556 {
00557 cout << ">>>>>-----------test_xy_opt---------------\n";
00558 Matrix Integrand(z_size, a_size);
00559 Vector za_grid(z_size);
00560 Vector aa_grid(a_size);
00561
00562 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00563
00564 Numeric result = 0;
00565
00566 struct timeval start;
00567 struct timeval ende;
00568 gettimeofday(&start, NULL);
00569
00570
00571
00572 for (int i = 0; i < frequency; i++)
00573 result = AngIntegrate_trapezoid_opt(Integrand, za_grid, aa_grid);
00574
00575 gettimeofday(&ende, NULL);
00576
00577 double error = result/(4*PI) - 1;
00578
00579 double diffs = (double)(ende.tv_sec - start.tv_sec)
00580 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00581 cout.precision(15);
00582 cout << "stepsize is : " << stepsize << endl
00583 << "z_size : " << z_size << endl
00584 << "a_size : " << a_size << endl
00585 << "1 is : " << result/(4*PI) << endl
00586 << "The result is : " << result << endl
00587 << "The error is : " << error*100 << " %\n"
00588 << "Number of loops: " << frequency << endl
00589 << "elapsed time : " << diffs << "s" << endl
00590 << "----------------test_xy_opt----------<<<<<\n";
00591
00592 return result;
00593
00594 }
00595
00597
00608 Numeric test_xy_fixedstep(int z_size, int a_size,
00609 float stepsize, int frequency)
00610 {
00611 cout << ">>>>>-----------test_xy_fixedstep---------------\n";
00612 Matrix Integrand(z_size, a_size);
00613 Vector za_grid(z_size);
00614 Vector aa_grid(a_size);
00615
00616 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00617
00618 Numeric result = 0;
00619
00620 struct timeval start;
00621 struct timeval ende;
00622 gettimeofday(&start, NULL);
00623
00624
00625
00626 for (int i = 0; i < frequency; i++)
00627 result = AngIntegrate_trapezoid_fixedstep(Integrand, za_grid, aa_grid, stepsize);
00628
00629 gettimeofday(&ende, NULL);
00630
00631 double error = result/(4*PI) - 1;
00632
00633 double diffs = (double)(ende.tv_sec - start.tv_sec)
00634 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00635 cout.precision(15);
00636 cout << diffs << endl;
00637 cout << "stepsize is : " << stepsize << endl
00638 << "z_size : " << z_size << endl
00639 << "a_size : " << a_size << endl
00640 << "1 is : " << result/(4*PI) << endl
00641 << "The result is : " << result << endl
00642 << "The error is : " << error*100 << " %\n"
00643 << "Number of loops: " << frequency << endl
00644 << "elapsed time : " << diffs << "s" << endl
00645 << "----------------test_xy_fixedstep----------<<<<<\n";
00646
00647 return result;
00648
00649 }
00650
00652
00663 Numeric test_xy_fixedstep_opt(int z_size, int a_size,
00664 float stepsize, int frequency)
00665 {
00666 cout << ">>>>>-----------test_xy_fixedstep_opt---------------\n";
00667 Matrix Integrand(z_size, a_size);
00668 Vector za_grid(z_size);
00669 Vector aa_grid(a_size);
00670
00671 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00672
00673 Numeric result = 0;
00674
00675 struct timeval start;
00676 struct timeval ende;
00677 gettimeofday(&start, NULL);
00678
00679
00680
00681 for (int i = 0; i < frequency; i++)
00682 result = AngIntegrate_trapezoid_fixedstep_opt(Integrand, za_grid, aa_grid, stepsize);
00683
00684 gettimeofday(&ende, NULL);
00685
00686 double error = result/(4*PI) - 1;
00687
00688 double diffs = (double)(ende.tv_sec - start.tv_sec)
00689 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00690 cout.precision(15);
00691 cout << diffs << endl;
00692 cout << "stepsize is : " << stepsize << endl
00693 << "z_size : " << z_size << endl
00694 << "a_size : " << a_size << endl
00695 << "1 is : " << result/(4*PI) << endl
00696 << "The result is : " << result << endl
00697 << "The error is : " << error*100 << " %\n"
00698 << "Number of loops: " << frequency << endl
00699 << "elapsed time : " << diffs << "s" << endl
00700 << "----------------test_xy_fixedstep_opt----------<<<<<\n";
00701
00702 return result;
00703 }
00704
00705
00707
00718 Numeric test_xy_fixedstep_opt2(int z_size, int a_size,
00719 float stepsize, int frequency)
00720 {
00721 cout << ">>>>>-----------test_xy_fixedstep_opt2---------------\n";
00722 Matrix Integrand(z_size, a_size);
00723 Vector za_grid(z_size);
00724 Vector aa_grid(a_size);
00725
00726 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00727
00728 Numeric result = 0;
00729
00730 struct timeval start;
00731 struct timeval ende;
00732 gettimeofday(&start, NULL);
00733
00734
00735
00736 for (int i = 0; i < frequency; i++)
00737 result = AngIntegrate_trapezoid_fixedstep_opt2(Integrand, za_grid, aa_grid, stepsize);
00738
00739 gettimeofday(&ende, NULL);
00740
00741 double error = result/(4*PI) - 1;
00742
00743 double diffs = (double)(ende.tv_sec - start.tv_sec)
00744 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00745 cout.precision(15);
00746 cout << diffs << endl;
00747 cout << "stepsize is : " << stepsize << endl
00748 << "z_size : " << z_size << endl
00749 << "a_size : " << a_size << endl
00750 << "1 is : " << result/(4*PI) << endl
00751 << "The result is : " << result << endl
00752 << "The error is : " << error*100 << " %\n"
00753 << "Number of loops: " << frequency << endl
00754 << "elapsed time : " << diffs << "s" << endl
00755 << "----------------test_xy_fixedstep_opt2----------<<<<<\n";
00756
00757 return result;
00758 }
00759
00761
00774 Numeric test_AngIntegrate_trapezoid_opti(int z_size, int a_size,
00775 float stepsize, int frequency)
00776 {
00777 cout << ">>>>>-----------test_AngIntegrate_trapezoid_opti---------------\n";
00778 Matrix Integrand(z_size, a_size);
00779 Vector za_grid(z_size);
00780 Vector aa_grid(a_size);
00781
00782 Vector grid_stepsize(2);
00783
00784 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
00785
00786 grid_stepsize[0] = za_grid[1] - za_grid[0];
00787 grid_stepsize[1] = aa_grid[1] - aa_grid[0];
00788
00789
00790
00791
00792
00793
00794
00795 Numeric result = 0;
00796
00797 struct timeval start;
00798 struct timeval ende;
00799 gettimeofday(&start, NULL);
00800
00801
00802
00803 for (int i = 0; i < frequency; i++)
00804 result = AngIntegrate_trapezoid_opti(Integrand, za_grid, aa_grid, grid_stepsize);
00805
00806 gettimeofday(&ende, NULL);
00807
00808 double error = result/(4*PI) - 1;
00809
00810 double diffs = (double)(ende.tv_sec - start.tv_sec)
00811 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00812 cout.precision(15);
00813 cout << diffs << endl;
00814 cout << "stepsize is : " << stepsize << endl
00815 << "z_size : " << z_size << endl
00816 << "a_size : " << a_size << endl
00817 << "1 is : " << result/(4*PI) << endl
00818 << "The result is : " << result << endl
00819 << "The error is : " << error*100 << " %\n"
00820 << "Number of loops: " << frequency << endl
00821 << "elapsed time : " << diffs << "s" << endl
00822 << "----------------test_AngIntegrate_trapezoid_opti----------<<<<<\n";
00823
00824 return result;
00825 }
00826
00827
00828
00830
00840 Numeric test_x(int vsize,
00841 float stepsize,
00842 int frequency)
00843 {
00844 cout << ">>>>>-----------test_x---------------\n";
00845 Vector Integrand(vsize);
00846 Vector Theta(vsize);
00847
00848 init_x(vsize, stepsize, frequency, Integrand, Theta);
00849
00850 Numeric result = 0;
00851
00852 struct timeval start;
00853 struct timeval ende;
00854 gettimeofday(&start, NULL);
00855 cout << "Sekunden : " << start.tv_sec << endl
00856 << "Milisekunden: " << start.tv_usec << endl;
00857
00858 for (int i = 0; i < frequency; i++)
00859 result = AngIntegrate_trapezoid_original(Integrand, Theta);
00860
00861 gettimeofday(&ende, NULL);
00862
00863
00864 result = result / (2*180);
00865
00866 double error = result/PI - 1;
00867
00868
00869
00870 double diffs = (double)(ende.tv_sec - start.tv_sec)
00871 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00872 cout.precision(15);
00873 cout << diffs << endl;
00874 cout << "stepsize is : " << stepsize << endl
00875 << "number of steps: " << vsize << endl
00876 << "1 is : " << PI/PI << endl
00877 << "The result is : " << result/PI << endl
00878 << "The error is : " << error*100 << "%\n"
00879 << "Number of loops: " << frequency << endl
00880 << "elapsed time : " << diffs << "s" << endl
00881 << "---------------test_x-----------<<<<<\n";
00882
00883 return result;
00884
00885 }
00887
00896 Numeric test_x_fixedstep(int vsize,
00897 int frequency)
00898 {
00899 cout << ">>>>>-----------test_x_fixedstep---------------\n";
00900 cout.precision(12);
00901 Vector Integrand(vsize);
00902 Vector Theta(vsize);
00903
00904 double stepsize;
00905 stepsize = 180.0 / (vsize - 1);
00906 cout << "Neue berechnete Stepsize: " << stepsize << endl;
00907
00908 for (int i = 0; i < Integrand.nelem(); i++)
00909 Integrand[i] = i * stepsize;
00910
00911
00912 for (int i = 0; i < Theta.nelem(); i++)
00913 Theta[i] = i * stepsize;
00914
00915
00916 cout << "Integrand: von " << Integrand[0] << " bis "
00917 << Integrand[Integrand.nelem() - 1] << endl
00918 << "Theta: von " << Theta[0] << " bis "
00919 << Theta[Theta.nelem() - 1] << endl;
00920
00921 Numeric result = 0;
00922
00923 struct timeval start;
00924 struct timeval ende;
00925 gettimeofday(&start, NULL);
00926 cout << "Sekunden : " << start.tv_sec << endl
00927 << "Milisekunden: " << start.tv_usec << endl;
00928
00929 for (int i = 0; i < frequency; i++)
00930 result = AngIntegrate_trapezoid_fixedstep(Integrand, Theta, stepsize);
00931
00932 gettimeofday(&ende, NULL);
00933
00934
00935 result = result / (2*180);
00936
00937 double error = result/PI - 1;
00938
00939
00940
00941 double diffs = (double)(ende.tv_sec - start.tv_sec)
00942 + (double)(ende.tv_usec - start.tv_usec)/1000000.0;
00943 cout.precision(15);
00944 cout << diffs << endl;
00945 cout << "stepsize is : " << stepsize << endl
00946 << "number of steps: " << vsize << endl
00947 << "1 is : " << PI/PI << endl
00948 << "The result is : " << result/PI << endl
00949 << "The error is : " << error*100 << "%\n"
00950 << "Number of loops: " << frequency << endl
00951 << "elapsed time : " << diffs << "s" << endl
00952 << "---------------test_x_fixedstep----------<<<<<\n";
00953
00954 return result;
00955
00956 }