50 int vsize,
float stepsize,
int frequency,
Vector& Integrand,
Vector& Theta);
82 Numeric test_xy(
int z_size,
int a_size,
float stepsize,
int frequency);
110 int main(
int argc,
char* argv[]) {
112 cerr << argv[0] <<
" requires one parameter" << endl;
116 cout <<
"Uebergabewert von argv : " << argv[1] << endl;
118 int frequency = (int)strtol(argv[1], NULL, 10);
119 cout <<
"Wert von frequency : " << frequency << endl;
126 test_xy(181, 361, 1.0, frequency);
148 cout <<
"----------------init_x---------------\n";
153 for (
int i = 0;
i < Integrand.
nelem();
i++)
154 Integrand[
i] = (
float)
i * stepsize;
157 for (
int i = 0;
i < Theta.
nelem();
i++) Theta[
i] = (
float)
i * stepsize;
159 cout <<
"function Y = X" << endl
160 <<
"vsize = " << vsize << endl
161 <<
"stepsize = " << stepsize << endl
162 <<
"frequency = " << frequency << endl
163 <<
"Integrand: von " << Integrand[0] <<
" bis " 164 << Integrand[Integrand.
nelem() - 1] << endl
165 <<
"Theta: von " << Theta[0] <<
" bis " << Theta[Theta.
nelem() - 1]
179 cout <<
">>>>>-----------init_xy---------------\n";
185 for (
Index j = 0; j < n_aa; j++) Integrand(
i, j) = 1;
188 for (
Index i = 0;
i < n_za;
i++) za_grid[
i] = (
float)
i * stepsize;
191 for (
Index i = 0;
i < n_aa;
i++) aa_grid[
i] = (
float)
i * stepsize;
193 cout <<
"function x^2 + y^2 + z^2 = 1" << endl
194 <<
"n_za = " << n_za << endl
195 <<
"n_aa = " << n_aa << endl
196 <<
"stepsize = " << stepsize << endl
197 <<
"frequency = " << frequency << endl
198 <<
"Integrand(*,0): von " << Integrand(0, 0) <<
" bis " 199 << Integrand(n_za - 1, 0) << endl
200 <<
"Integrand(0,*): von " << Integrand(0, 0) <<
" bis " 201 << Integrand(0, n_aa - 1) << endl
202 <<
"za_grid (Theta): von " << za_grid[0] <<
" bis " 203 << za_grid[za_grid.
nelem() - 1] << endl
204 <<
"aa_grid (Phi) : von " << aa_grid[0] <<
" bis " 205 << aa_grid[aa_grid.
nelem() - 1] << endl;
206 cout <<
"---------------init_xy---------------<<<<<\n";
227 assert(
is_size(Integrand, n, m));
232 for (
Index j = 0; j < m - 1; ++j) {
233 res1[
i] += 0.5 *
DEG2RAD * (Integrand(
i, j) + Integrand(
i, j + 1)) *
234 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[
i] *
DEG2RAD);
240 0.5 *
DEG2RAD * (res1[
i] + res1[
i + 1]) * (za_grid[
i + 1] - za_grid[
i]);
264 assert(
is_size(Integrand, n, m));
269 for (
Index j = 0; j < m - 1; ++j) {
270 res1[
i] += 0.5 *
DEG2RAD * (Integrand(
i, j) + Integrand(
i, j + 1)) *
271 (aa_grid[j + 1] - aa_grid[j]) * sin(za_grid[
i] *
DEG2RAD);
277 0.5 *
DEG2RAD * (res1[
i] + res1[
i + 1]) * (za_grid[
i + 1] - za_grid[
i]);
304 assert(
is_size(Integrand, n, m));
309 for (
Index j = 0; j < m - 1; ++j) {
310 res1[
i] += 0.5 *
DEG2RAD * (Integrand(
i, j) + Integrand(
i, j + 1)) *
311 stepsize * sin(za_grid[
i] *
DEG2RAD);
316 res += 0.5 *
DEG2RAD * (res1[
i] + res1[
i + 1]) * stepsize;
343 assert(
is_size(Integrand, n, m));
348 res1[
i] += Integrand(
i, 0);
349 for (
Index j = 1; j < m - 1; j++) {
350 res1[
i] += Integrand(
i, j) * 2;
352 res1[
i] += Integrand(
i, m - 1);
361 res *= 0.5 *
DEG2RAD * stepsize;
388 assert(
is_size(Integrand, n, m));
393 temp = Integrand(
i, 0);
394 for (
Index j = 1; j < m - 1; j++) {
395 temp += Integrand(
i, j) * 2;
397 temp += Integrand(
i, m - 1);
407 res *= 0.5 *
DEG2RAD * stepsize;
426 (Integrand[
i] * sin(za_grid[
i] *
DEG2RAD) +
427 Integrand[
i + 1] * sin(za_grid[
i + 1] * DEG2RAD)) *
428 (za_grid[
i + 1] - za_grid[
i]);
447 res += (Integrand[0] * sin(za_grid[0] *
DEG2RAD));
449 res += (Integrand[
i] * sin(za_grid[
i] * DEG2RAD) * 2);
452 res += ((Integrand[n - 1] * sin(za_grid[n - 1] * DEG2RAD)));
455 res *=
PI * DEG2RAD * stepsize;
474 cout <<
">>>>>-----------test_xy---------------\n";
475 Matrix Integrand(z_size, a_size);
479 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
483 struct timeval start;
485 gettimeofday(&start, NULL);
489 for (
int i = 0;
i < frequency;
i++)
492 gettimeofday(&ende, NULL);
494 double error = result / (4 *
PI) - 1;
496 double diffs = (double)(ende.tv_sec - start.tv_sec) +
497 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
499 cout <<
"stepsize is : " << stepsize << endl
500 <<
"z_size : " << z_size << endl
501 <<
"a_size : " << a_size << endl
502 <<
"1 is : " << result / (4 *
PI) << endl
503 <<
"The result is : " << result << endl
504 <<
"The error is : " << error * 100 <<
" %\n" 505 <<
"Number of loops: " << frequency << endl
506 <<
"elapsed time : " << diffs <<
"s" << endl
507 <<
"----------------test_xy----------<<<<<\n";
525 cout <<
">>>>>-----------test_xy_opt---------------\n";
526 Matrix Integrand(z_size, a_size);
530 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
534 struct timeval start;
536 gettimeofday(&start, NULL);
540 for (
int i = 0;
i < frequency;
i++)
543 gettimeofday(&ende, NULL);
545 double error = result / (4 *
PI) - 1;
547 double diffs = (double)(ende.tv_sec - start.tv_sec) +
548 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
550 cout <<
"stepsize is : " << stepsize << endl
551 <<
"z_size : " << z_size << endl
552 <<
"a_size : " << a_size << endl
553 <<
"1 is : " << result / (4 *
PI) << endl
554 <<
"The result is : " << result << endl
555 <<
"The error is : " << error * 100 <<
" %\n" 556 <<
"Number of loops: " << frequency << endl
557 <<
"elapsed time : " << diffs <<
"s" << endl
558 <<
"----------------test_xy_opt----------<<<<<\n";
579 cout <<
">>>>>-----------test_xy_fixedstep---------------\n";
580 Matrix Integrand(z_size, a_size);
584 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
588 struct timeval start;
590 gettimeofday(&start, NULL);
594 for (
int i = 0;
i < frequency;
i++)
598 gettimeofday(&ende, NULL);
600 double error = result / (4 *
PI) - 1;
602 double diffs = (double)(ende.tv_sec - start.tv_sec) +
603 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
605 cout << diffs << endl;
606 cout <<
"stepsize is : " << stepsize << endl
607 <<
"z_size : " << z_size << endl
608 <<
"a_size : " << a_size << endl
609 <<
"1 is : " << result / (4 *
PI) << endl
610 <<
"The result is : " << result << endl
611 <<
"The error is : " << error * 100 <<
" %\n" 612 <<
"Number of loops: " << frequency << endl
613 <<
"elapsed time : " << diffs <<
"s" << endl
614 <<
"----------------test_xy_fixedstep----------<<<<<\n";
635 cout <<
">>>>>-----------test_xy_fixedstep_opt---------------\n";
636 Matrix Integrand(z_size, a_size);
640 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
644 struct timeval start;
646 gettimeofday(&start, NULL);
650 for (
int i = 0;
i < frequency;
i++)
652 Integrand, za_grid, aa_grid, stepsize);
654 gettimeofday(&ende, NULL);
656 double error = result / (4 *
PI) - 1;
658 double diffs = (double)(ende.tv_sec - start.tv_sec) +
659 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
661 cout << diffs << endl;
662 cout <<
"stepsize is : " << stepsize << endl
663 <<
"z_size : " << z_size << endl
664 <<
"a_size : " << a_size << endl
665 <<
"1 is : " << result / (4 *
PI) << endl
666 <<
"The result is : " << result << endl
667 <<
"The error is : " << error * 100 <<
" %\n" 668 <<
"Number of loops: " << frequency << endl
669 <<
"elapsed time : " << diffs <<
"s" << endl
670 <<
"----------------test_xy_fixedstep_opt----------<<<<<\n";
691 cout <<
">>>>>-----------test_xy_fixedstep_opt2---------------\n";
692 Matrix Integrand(z_size, a_size);
696 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
700 struct timeval start;
702 gettimeofday(&start, NULL);
706 for (
int i = 0;
i < frequency;
i++)
708 Integrand, za_grid, aa_grid, stepsize);
710 gettimeofday(&ende, NULL);
712 double error = result / (4 *
PI) - 1;
714 double diffs = (double)(ende.tv_sec - start.tv_sec) +
715 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
717 cout << diffs << endl;
718 cout <<
"stepsize is : " << stepsize << endl
719 <<
"z_size : " << z_size << endl
720 <<
"a_size : " << a_size << endl
721 <<
"1 is : " << result / (4 *
PI) << endl
722 <<
"The result is : " << result << endl
723 <<
"The error is : " << error * 100 <<
" %\n" 724 <<
"Number of loops: " << frequency << endl
725 <<
"elapsed time : " << diffs <<
"s" << endl
726 <<
"----------------test_xy_fixedstep_opt2----------<<<<<\n";
749 cout <<
">>>>>-----------test_AngIntegrate_trapezoid_opti---------------\n";
750 Matrix Integrand(z_size, a_size);
756 init_xy(stepsize, frequency, Integrand, za_grid, aa_grid);
758 grid_stepsize[0] = za_grid[1] - za_grid[0];
759 grid_stepsize[1] = aa_grid[1] - aa_grid[0];
769 struct timeval start;
771 gettimeofday(&start, NULL);
775 for (
int i = 0;
i < frequency;
i++)
779 gettimeofday(&ende, NULL);
781 double error = result / (4 *
PI) - 1;
783 double diffs = (double)(ende.tv_sec - start.tv_sec) +
784 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
786 cout << diffs << endl;
787 cout <<
"stepsize is : " << stepsize << endl
788 <<
"z_size : " << z_size << endl
789 <<
"a_size : " << a_size << endl
790 <<
"1 is : " << result / (4 *
PI) << endl
791 <<
"The result is : " << result << endl
792 <<
"The error is : " << error * 100 <<
" %\n" 793 <<
"Number of loops: " << frequency << endl
794 <<
"elapsed time : " << diffs <<
"s" << endl
795 <<
"----------------test_AngIntegrate_trapezoid_opti----------<<<<<\n";
812 cout <<
">>>>>-----------test_x---------------\n";
816 init_x(vsize, stepsize, frequency, Integrand, Theta);
820 struct timeval start;
822 gettimeofday(&start, NULL);
823 cout <<
"Sekunden : " << start.tv_sec << endl
824 <<
"Milisekunden: " << start.tv_usec << endl;
826 for (
int i = 0;
i < frequency;
i++)
829 gettimeofday(&ende, NULL);
832 result = result / (2 * 180);
834 double error = result /
PI - 1;
836 double diffs = (double)(ende.tv_sec - start.tv_sec) +
837 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
839 cout << diffs << endl;
840 cout <<
"stepsize is : " << stepsize << endl
841 <<
"number of steps: " << vsize << endl
842 <<
"1 is : " <<
PI /
PI << endl
843 <<
"The result is : " << result /
PI << endl
844 <<
"The error is : " << error * 100 <<
"%\n" 845 <<
"Number of loops: " << frequency << endl
846 <<
"elapsed time : " << diffs <<
"s" << endl
847 <<
"---------------test_x-----------<<<<<\n";
862 cout <<
">>>>>-----------test_x_fixedstep---------------\n";
871 cout <<
"Neue berechnete Stepsize: " << stepsize << endl;
873 for (
int i = 0;
i < Integrand.
nelem();
i++) Integrand[
i] =
i * stepsize;
876 for (
int i = 0;
i < Theta.
nelem();
i++) Theta[
i] =
i * stepsize;
878 cout <<
"Integrand: von " << Integrand[0] <<
" bis " 879 << Integrand[Integrand.
nelem() - 1] << endl
880 <<
"Theta: von " << Theta[0] <<
" bis " << Theta[Theta.
nelem() - 1]
885 struct timeval start;
887 gettimeofday(&start, NULL);
888 cout <<
"Sekunden : " << start.tv_sec << endl
889 <<
"Milisekunden: " << start.tv_usec << endl;
891 for (
int i = 0;
i < frequency;
i++)
894 gettimeofday(&ende, NULL);
897 result = result / (2 * 180);
899 double error = result /
PI - 1;
901 double diffs = (double)(ende.tv_sec - start.tv_sec) +
902 (double)(ende.tv_usec - start.tv_usec) / 1000000.0;
904 cout << diffs << endl;
905 cout <<
"stepsize is : " << stepsize << endl
906 <<
"number of steps: " << vsize << endl
907 <<
"1 is : " <<
PI /
PI << endl
908 <<
"The result is : " << result /
PI << endl
909 <<
"The error is : " << error * 100 <<
"%\n" 910 <<
"Number of loops: " << frequency << endl
911 <<
"elapsed time : " << diffs <<
"s" << endl
912 <<
"---------------test_x_fixedstep----------<<<<<\n";
INDEX Index
The type to use for all integer numbers and indices.
Numeric AngIntegrate_trapezoid_opti(ConstMatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, ConstVectorView grid_stepsize)
AngIntegrate_trapezoid_opti.
void init_x(int vsize, float stepsize, int frequency, Vector &Integrand, Vector &Theta)
init_x
Numeric AngIntegrate_trapezoid_fixedstep(MatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, Numeric stepsize)
AngIntegrate_trapezoid_fixedstep.
Numeric test_x(int vsize, float stepsize, int frequency)
test_x
void init_xy(float stepsize, int frequency, Matrix &Integrand, Vector &za_grid, Vector &aa_grid)
init_xy
Index nelem() const
Returns the number of elements.
This file contains the definition of Array.
The global header file for ARTS.
Numeric test_xy_fixedstep_opt2(int z_size, int a_size, float stepsize, int frequency)
test_xy_fixedstep_opt2
Numeric test_x_fixedstep(int vsize, int frequency)
test_x_fixedstep
Numeric test_xy(int z_size, int a_size, float stepsize, int frequency)
test_xy
Numeric AngIntegrate_trapezoid_original(MatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid_original.
Numeric AngIntegrate_trapezoid_fixedstep_opt2(MatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, Numeric stepsize)
AngIntegrate_trapezoid_fixedstep_opt2.
NUMERIC Numeric
The type to use for all floating point numbers.
Implementation of Matrix, Vector, and such stuff.
Header file for logic.cc.
Numeric AngIntegrate_trapezoid_opt(MatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid)
AngIntegrate_trapezoid_opt.
Numeric test_xy_opt(int z_size, int a_size, float stepsize, int frequency)
test_xy_opt
A constant view of a Vector.
Numeric test_AngIntegrate_trapezoid_opti(int z_size, int a_size, float stepsize, int frequency)
test_AngIntegrate_trapezoid_opti
Numeric test_xy_fixedstep_opt(int z_size, int a_size, float stepsize, int frequency)
test_xy_fixedstep_opt
bool is_size(ConstVectorView x, const Index &n)
Verifies that the size of x is l.
Numeric test_xy_fixedstep(int z_size, int a_size, float stepsize, int frequency)
test_xy_fixedstep
Numeric AngIntegrate_trapezoid_fixedstep_opt(MatrixView Integrand, ConstVectorView za_grid, ConstVectorView aa_grid, Numeric stepsize)
AngIntegrate_trapezoid_fixedstep_opt.
int main(int argc, char *argv[])