Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALConstantsTest.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2011 Kipp Cannon
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20
21#include <stdio.h>
22#include <math.h>
23#include <lal/LALStdlib.h>
24#include <lal/LALConstants.h>
25
26#define MAX_FRACTIONAL_ERROR 1e-15
27
28static int compare_within_fraction(double a, double b, double max_fractional_difference)
29{
30 if(fabs(a - b) / fabs(a > b ? a : b) <= fabs(max_fractional_difference))
31 return 0;
32 return a > b ? +1 : -1;
33}
34
35
36#define REQUIRE_EQUAL(a, b) \
37 if(compare_within_fraction(a, b, MAX_FRACTIONAL_ERROR)) { \
38 fprintf(stderr, #a " != " #b " within %g (" #a " = %.17g, " #b " = %.17g)\n", MAX_FRACTIONAL_ERROR, a, b); \
39 return 1; \
40 }
41
42int main( void )
43{
44
45 REQUIRE_EQUAL(sqrt(2), LAL_SQRT2);
46 REQUIRE_EQUAL(1/sqrt(2), LAL_SQRT1_2);
56
58
62
65
66 return 0;
67}
#define REQUIRE_EQUAL(a, b)
static int compare_within_fraction(double a, double b, double max_fractional_difference)
int main(void)
#define LAL_2_SQRTPI
2/sqrt(pi)
Definition: LALConstants.h:185
#define LAL_LPL_SI
Planck length, m.
Definition: LALConstants.h:297
#define LAL_PI_2
pi/2
Definition: LALConstants.h:181
#define LAL_MPL_SI
Planck mass, kg.
Definition: LALConstants.h:290
#define LAL_EXPGAMMA
exp(gamma)
Definition: LALConstants.h:177
#define LAL_C_SI
Speed of light in vacuum, m s^-1.
Definition: LALConstants.h:198
#define LAL_TPL_SI
Planck time, s.
Definition: LALConstants.h:304
#define LAL_MSUN_SI
Nominal solar mass, kg.
Definition: LALConstants.h:578
#define LAL_180_PI
pi/180 is the number of radians in one degree
Definition: LALConstants.h:187
#define LAL_2_PI
2/pi is Buffon's constant
Definition: LALConstants.h:184
#define LAL_HBAR_SI
Reduced Planck constant, J s.
Definition: LALConstants.h:211
#define LAL_PI_180
180/pi is the number of degrees in one radian
Definition: LALConstants.h:186
#define LAL_PI
Archimedes's constant, pi.
Definition: LALConstants.h:179
#define LAL_1_PI
1/pi is the ratio of the volume of a regular octahedron to the volume of the circumscribed sphere
Definition: LALConstants.h:183
#define LAL_TWOPI
2*pi is circumference of a circle divided by its radius
Definition: LALConstants.h:180
#define LAL_MTSUN_SI
Geometrized nominal solar mass, s.
Definition: LALConstants.h:592
#define LAL_PI_4
pi/4 is the least positive solution to sin(x) = cos(x)
Definition: LALConstants.h:182
#define LAL_GAMMA
Euler-Mascheroni constant, gamma.
Definition: LALConstants.h:176
#define LAL_G_SI
Gravitational constant, N m^2 kg^-2.
Definition: LALConstants.h:258
#define LAL_SQRT2
Pythagoras's constant, sqrt(2)
Definition: LALConstants.h:174
#define LAL_MRSUN_SI
Geometrized nominal solar mass, m.
Definition: LALConstants.h:585
#define LAL_SQRT1_2
1/sqrt(2)
Definition: LALConstants.h:175
#define LAL_H_SI
Planck constant, J s.
Definition: LALConstants.h:199
static const INT4 a
Definition: Random.c:79