Athena++/Atmosphere
Planetary Atmosphere Simulator
core.h
Go to the documentation of this file.
1 #ifndef CORE_H_
2 #define CORE_H_
3 #include <math.h>
4 
5 struct float_triplet {
6  double x, y, z;
7 };
8 
9 inline double sqr(double x) {
10  return x*x;
11 }
12 inline double cub(double x) {
13  return x*x*x;
14 }
15 inline double min(double x1, double x2, double x3) {
16  return fmin(x1, fmin(x2, x3));
17 }
18 inline double max(double x1, double x2, double x3) {
19  return fmax(x1, fmax(x2, x3));
20 }
21 inline double allmax(double *a, int n) {
22  double v = a[0];
23  for (int i = 1; i < n; ++i)
24  if (v < a[i]) v = a[i];
25  return v;
26 }
27 inline double allmin(double *a, int n) {
28  double v = a[0];
29  for (int i = 1; i < n; ++i)
30  if (v > a[i]) v = a[i];
31  return v;
32 }
33 inline int sign(double x) {
34  return x < 0. ? -1 : 1;
35 }
36 
37 int fcmp(double x1, double x2);
38 
39 
40 // unit conversion
41 
42 inline double rad2deg(double phi) { return phi*180./M_PI; }
43 inline double deg2rad(double phi) { return phi*M_PI/180.; }
44 
45 inline double km2m(double x) { return x*1.E3; }
46 inline double m2km(double x) { return x/1.E3; }
47 
48 inline double day2sec(double x) { return x*86400.; }
49 inline double sec2day(double x) { return x/86400.; }
50 
51 inline double au2m(double x) { return x*1.495978707E11; }
52 inline double m2au(double x) { return x/1.495978707E11; }
53 
54 #endif
int sign(double x)
Definition: core.h:33
double m2km(double x)
Definition: core.h:46
double deg2rad(double phi)
Definition: core.h:43
double sqr(double x)
Definition: core.h:9
double day2sec(double x)
Definition: core.h:48
double km2m(double x)
Definition: core.h:45
double min(double x1, double x2, double x3)
Definition: core.h:15
double max(double x1, double x2, double x3)
Definition: core.h:18
int fcmp(double x1, double x2)
Definition: fcmp.c:34
double au2m(double x)
Definition: core.h:51
double cub(double x)
Definition: core.h:12
double allmin(double *a, int n)
Definition: core.h:27
double allmax(double *a, int n)
Definition: core.h:21
double m2au(double x)
Definition: core.h:52
double sec2day(double x)
Definition: core.h:49
double rad2deg(double phi)
Definition: core.h:42
double y
Definition: core.h:6
double z
Definition: core.h:6
double x
Definition: core.h:6