ARTS  2.4.0(git:4fb77825)
test_legendre.cc
Go to the documentation of this file.
1 /* Copyright (C) 2003-2012 Oliver Lemke <olemke@core-dump.info>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16  USA. */
17 
18 #include "arts.h"
19 
20 #if HAVE_UNISTD_H
21 #include <sys/types.h>
22 #include <unistd.h>
23 #endif
24 #ifdef _POSIX_VERSION
25 #include <sys/times.h>
26 #endif
27 #include "exceptions.h"
28 #include "legendre.h"
29 
30 void test_gsl_int() {
31  Vector x, w;
32 
33  std::cout << gsl_integration_glfixed_table_alloc(x, w, 20) << std::endl;
34  std::cout << x << std::endl;
35  std::cout << w << std::endl << std::endl;
36 }
37 
38 int main(int argc, char *argv[]) {
39  Index l, m;
40  Numeric x;
41 
42  if (argc != 4) {
43  cerr << "Usage: " << argv[0] << " l m x" << endl;
44  exit(1);
45  }
46 
47  l = atoi(argv[1]);
48  m = atoi(argv[2]);
49  x = strtod(argv[3], NULL);
50 
51  try {
52  cout << "l = " << l << " m = " << m << " x = " << x << endl;
53  cout << "Pml = " << legendre_poly(l, m, x) << endl;
54  cout << "dPml = " << legendre_poly_deriv(l, m, x) << endl;
55  cout << "Norm Pml = " << legendre_poly_norm_schmidt(l, m, x) << endl;
56  cout << "Norm dPml = " << legendre_poly_norm_schmidt_deriv(l, m, x) << endl;
57  } catch (const std::runtime_error &e) {
58  cerr << e.what();
59  }
60 
61  /* struct tms cput_start, cput_end;
62  const Index n = 1000000;
63  Index clktck;
64  Vector v2 (n), r2 (n);
65 
66  cout << endl << "Timing ("
67  << n << " loops):" << endl;
68 
69  for (Index i = 0; i < n; i++)
70  {
71  v2[i] = -1.0 + Numeric (i) / n * 2.0;
72  }
73 
74  if ((clktck = sysconf (_SC_CLK_TCK)) < 0)
75  throw runtime_error ("Timer error: Unable to determine CPU clock ticks");
76 
77  if (times (&cput_start) == -1)
78  throw runtime_error ("Timer error: Unable to get current CPU time");
79 
80  for (Index i = 0; i < n; i++)
81  r2[i] = legendre_poly (l, m, v2[i]);
82 
83  if (times (&cput_end) == -1)
84  throw runtime_error ("Timer error: Unable to get current CPU time");
85 
86  cout << "CPU time: " << setprecision (2)
87  << ((cput_end.tms_stime - cput_start.tms_stime)
88  + (cput_end.tms_utime - cput_start.tms_utime))
89  / (Numeric)clktck << " s" << endl;
90 */
91 
92  return (0);
93 }
main
int main(int argc, char *argv[])
Definition: test_legendre.cc:38
exceptions.h
The declarations of all the exception classes.
w
Complex w(Complex z) noexcept
The Faddeeva function.
Definition: linefunctions.cc:42
legendre.h
Contains the code to calculate Legendre polynomials.
gsl_integration_glfixed_table_alloc
bool gsl_integration_glfixed_table_alloc(Vector &x, Vector &w, Index n)
gsl_integration_glfixed_table_alloc
Definition: legendre.cc:2685
legendre_poly_norm_schmidt
Numeric legendre_poly_norm_schmidt(Index l, Index m, Numeric x)
legendre_poly_norm_schmidt
Definition: legendre.cc:122
legendre_poly_norm_schmidt_deriv
Numeric legendre_poly_norm_schmidt_deriv(Index l, Index m, Numeric x)
legendre_poly_norm_schmidt_deriv
Definition: legendre.cc:216
test_gsl_int
void test_gsl_int()
Definition: test_legendre.cc:30
legendre_poly_deriv
Numeric legendre_poly_deriv(Index l, Index m, Numeric x)
legendre_poly_deriv
Definition: legendre.cc:151
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
legendre_poly
Numeric legendre_poly(Index l, Index m, Numeric x)
legendre_poly
Definition: legendre.cc:58
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Vector
The Vector class.
Definition: matpackI.h:860
arts.h
The global header file for ARTS.