ARTS  2.2.66
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 "legendre.h"
28 #include "exceptions.h"
29 
30 int
31 main (int argc, char *argv[])
32 {
33  Index l, m;
34  Numeric x;
35 
36  if (argc != 4)
37  {
38  cerr << "Usage: " << argv[0] << " l m x" << endl;
39  exit (1);
40  }
41 
42  l = atoi (argv[1]);
43  m = atoi (argv[2]);
44  x = strtod (argv[3], NULL);
45 
46  try
47  {
48  cout << "l = " << l << " m = " << m << " x = " << x << endl;
49  cout << "Pml = " << legendre_poly (l, m, x) << endl;
50  cout << "dPml = " << legendre_poly_deriv (l, m, x) << endl;
51  cout << "Norm Pml = " << legendre_poly_norm_schmidt (l, m, x) << endl;
52  cout << "Norm dPml = " << legendre_poly_norm_schmidt_deriv (l, m, x) << endl;
53  }
54  catch (runtime_error e)
55  {
56  cerr << e.what ();
57  }
58 
59 /* struct tms cput_start, cput_end;
60  const Index n = 1000000;
61  Index clktck;
62  Vector v2 (n), r2 (n);
63 
64  cout << endl << "Timing ("
65  << n << " loops):" << endl;
66 
67  for (Index i = 0; i < n; i++)
68  {
69  v2[i] = -1.0 + Numeric (i) / n * 2.0;
70  }
71 
72  if ((clktck = sysconf (_SC_CLK_TCK)) < 0)
73  throw runtime_error ("Timer error: Unable to determine CPU clock ticks");
74 
75  if (times (&cput_start) == -1)
76  throw runtime_error ("Timer error: Unable to get current CPU time");
77 
78  for (Index i = 0; i < n; i++)
79  r2[i] = legendre_poly (l, m, v2[i]);
80 
81  if (times (&cput_end) == -1)
82  throw runtime_error ("Timer error: Unable to get current CPU time");
83 
84  cout << "CPU time: " << setprecision (2)
85  << ((cput_end.tms_stime - cput_start.tms_stime)
86  + (cput_end.tms_utime - cput_start.tms_utime))
87  / (Numeric)clktck << " s" << endl;
88 */
89 
90  return (0);
91 }
92 
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
Numeric legendre_poly_norm_schmidt_deriv(Index l, Index m, Numeric x)
legendre_poly_norm_schmidt_deriv
Definition: legendre.cc:257
Contains the code to calculate Legendre polynomials.
Numeric legendre_poly_norm_schmidt(Index l, Index m, Numeric x)
legendre_poly_norm_schmidt
Definition: legendre.cc:137
The global header file for ARTS.
The declarations of all the exception classes.
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:29
Numeric legendre_poly_deriv(Index l, Index m, Numeric x)
legendre_poly_deriv
Definition: legendre.cc:173
int main(int argc, char *argv[])
Numeric legendre_poly(Index l, Index m, Numeric x)
legendre_poly
Definition: legendre.cc:66