diff options
| author | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
|---|---|---|
| committer | Jakob Kaivo <jkk@ung.org> | 2020-08-16 14:00:51 -0400 |
| commit | 896e28812c51b9ffdf3efc00c7d7ef699e380a58 (patch) | |
| tree | aaa25e093fb4a2ac4c57609e1f745e5ac0734ca8 /src/math | |
| parent | 0b0d1fe1d4fbf8560577d81e5af0549683eac8ba (diff) | |
formatting
Diffstat (limited to 'src/math')
| -rw-r--r-- | src/math/HUGE_VAL.c | 1 | ||||
| -rw-r--r-- | src/math/_tgmath.h | 8 | ||||
| -rw-r--r-- | src/math/acos.c | 7 | ||||
| -rw-r--r-- | src/math/asin.c | 5 | ||||
| -rw-r--r-- | src/math/atan.c | 7 | ||||
| -rw-r--r-- | src/math/atan2.c | 14 | ||||
| -rw-r--r-- | src/math/ceil.c | 5 | ||||
| -rw-r--r-- | src/math/cos.c | 7 | ||||
| -rw-r--r-- | src/math/cosh.c | 5 | ||||
| -rw-r--r-- | src/math/exp.c | 5 | ||||
| -rw-r--r-- | src/math/fabs.c | 5 | ||||
| -rw-r--r-- | src/math/floor.c | 5 | ||||
| -rw-r--r-- | src/math/fmod.c | 7 | ||||
| -rw-r--r-- | src/math/frexp.c | 5 | ||||
| -rw-r--r-- | src/math/ldexp.c | 5 | ||||
| -rw-r--r-- | src/math/log.c | 7 | ||||
| -rw-r--r-- | src/math/log10.c | 7 | ||||
| -rw-r--r-- | src/math/modf.c | 5 | ||||
| -rw-r--r-- | src/math/pow.c | 7 | ||||
| -rw-r--r-- | src/math/sin.c | 7 | ||||
| -rw-r--r-- | src/math/sinh.c | 5 | ||||
| -rw-r--r-- | src/math/sqrt.c | 5 | ||||
| -rw-r--r-- | src/math/tan.c | 7 | ||||
| -rw-r--r-- | src/math/tanh.c | 5 |
24 files changed, 61 insertions, 85 deletions
diff --git a/src/math/HUGE_VAL.c b/src/math/HUGE_VAL.c index f72afacf..04d6da01 100644 --- a/src/math/HUGE_VAL.c +++ b/src/math/HUGE_VAL.c @@ -1,4 +1,3 @@ -#include <math.h> #define HUGE_VAL (1.0) /* TODO: massive positive double */ /** a huge value **/ diff --git a/src/math/_tgmath.h b/src/math/_tgmath.h index 8cd7871b..0d6c9551 100644 --- a/src/math/_tgmath.h +++ b/src/math/_tgmath.h @@ -68,4 +68,12 @@ #define copysign(_x, _y) (_x < 0 ? -_y : _y) #endif +#ifndef M_PI +#include "M_PI.c" +#endif + +#ifndef M_PI_2 +#include "M_PI_2.c" +#endif + #endif diff --git a/src/math/acos.c b/src/math/acos.c index 9a356100..2d391fe2 100644 --- a/src/math/acos.c +++ b/src/math/acos.c @@ -1,10 +1,11 @@ # define TGSOURCE "acos.c" +#include <errno.h> +#include <fenv.h> #include <math.h> -#include "fenv.h" -#include "errno.h" #include "_tgmath.h" /** arc cosine **/ + TYPE TGFN(acos)(TYPE x) { if (TGFN(fabs)(x) > 1) { @@ -36,7 +37,5 @@ the range [-1, +1]. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/asin.c b/src/math/asin.c index a94338f5..5a6ca259 100644 --- a/src/math/asin.c +++ b/src/math/asin.c @@ -1,9 +1,10 @@ # define TGSOURCE "asin.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** arc sine **/ + TYPE TGFN(asin)(TYPE x) { if (TGFN(fabs)(x) > 1.0) { @@ -33,7 +34,5 @@ the range [-1, +1]. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/atan.c b/src/math/atan.c index 6d9eee63..267670d3 100644 --- a/src/math/atan.c +++ b/src/math/atan.c @@ -1,11 +1,10 @@ # define TGSOURCE "atan.c" +#include <errno.h> #include <math.h> -#include "errno.h" #include "_tgmath.h" -#include "M_PI_2.c" - /** arc tangent **/ + TYPE TGFN(atan)(TYPE x) { int MAXLOOPS = 10; @@ -50,7 +49,5 @@ compute the principal value of the arc tangent of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/atan2.c b/src/math/atan2.c index 38ba944e..8d7c1260 100644 --- a/src/math/atan2.c +++ b/src/math/atan2.c @@ -1,17 +1,11 @@ # define TGSOURCE "atan2.c" +#include <errno.h> #include <math.h> -#include "_tgmath.h" -#include "errno.h" #include "_assert.h" - -#include "M_PI.c" -#include "M_PI_2.c" - -#ifndef copysign -#define copysign(_x, _y) _x -#endif +#include "_tgmath.h" /** arc tangent **/ + TYPE TGFN(atan2)(TYPE y, TYPE x) { int classy = fpclassify(y); @@ -88,7 +82,5 @@ the correct quadrant. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/ceil.c b/src/math/ceil.c index d90ba15f..34a93fe3 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -1,9 +1,10 @@ # define TGSOURCE "ceil.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** round up to nearest integer **/ + TYPE TGFN(ceil)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ than ARGUMENT(x), returning it as the same floating-point type as ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/cos.c b/src/math/cos.c index 86a1c995..437428c8 100644 --- a/src/math/cos.c +++ b/src/math/cos.c @@ -1,10 +1,11 @@ # define TGSOURCE "cos.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "fenv.h" -#include "errno.h" /** cosine **/ + TYPE TGFN(cos)(TYPE x) { int MAXLOOPS = 10; @@ -51,8 +52,6 @@ compute cosine of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/cosh.c b/src/math/cosh.c index 0f981e36..735c8cd4 100644 --- a/src/math/cosh.c +++ b/src/math/cosh.c @@ -1,9 +1,10 @@ # define TGSOURCE "cosh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic cosine **/ + TYPE TGFN(cosh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the hyperbolic cosine of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/exp.c b/src/math/exp.c index 412697b2..4b25da63 100644 --- a/src/math/exp.c +++ b/src/math/exp.c @@ -1,9 +1,10 @@ # define TGSOURCE "exp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** exponential function **/ + TYPE TGFN(exp)(TYPE x) { int MAXLOOPS = 10; @@ -44,7 +45,5 @@ compute the exponential function of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/fabs.c b/src/math/fabs.c index 5fc42750..5ee54286 100644 --- a/src/math/fabs.c +++ b/src/math/fabs.c @@ -1,9 +1,10 @@ # define TGSOURCE "fabs.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** absolute value **/ + TYPE TGFN(fabs)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the absolute value of a floating-point number ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/floor.c b/src/math/floor.c index 41350fe8..e2d2093a 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -1,9 +1,10 @@ # define TGSOURCE "floor.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** round down to nearest integer **/ + TYPE TGFN(floor)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ than ARGUMENT(x), returning it as the same floating-point type as ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/fmod.c b/src/math/fmod.c index 4370830f..3d31f55b 100644 --- a/src/math/fmod.c +++ b/src/math/fmod.c @@ -1,10 +1,11 @@ # define TGSOURCE "fmod.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** floating-point remainder **/ + TYPE TGFN(fmod)(TYPE x, TYPE y) { int classx = fpclassify(x); @@ -46,7 +47,5 @@ FIXME: I am not sure I understand this. IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) IMPLEMENTATION(Whether ARGUMENT(y) being LITERAL(0) results in a domain error or THIS() returning LITERAL(0)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/frexp.c b/src/math/frexp.c index b60dadc5..04579dff 100644 --- a/src/math/frexp.c +++ b/src/math/frexp.c @@ -1,9 +1,10 @@ # define TGSOURCE "frexp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** extract mantissa and exponent **/ + TYPE TGFN(frexp)(TYPE value, int *exp) { switch (fpclassify(value)) { @@ -40,7 +41,5 @@ Multiplying the normalized fraction by 2 to the power ARGUMENT(*exp). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/ldexp.c b/src/math/ldexp.c index 33e2f381..c56fe405 100644 --- a/src/math/ldexp.c +++ b/src/math/ldexp.c @@ -1,9 +1,10 @@ # define TGSOURCE "ldexp.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** multiply by a power of 2 **/ + TYPE TGFN(ldexp)(TYPE x, int exp) { switch (fpclassify(x)) { @@ -34,7 +35,5 @@ by 2 raised to the power ARGUMENT(exp). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/log.c b/src/math/log.c index abc29e4e..cb08aa98 100644 --- a/src/math/log.c +++ b/src/math/log.c @@ -1,10 +1,11 @@ # define TGSOURCE "log.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** natural logarithm **/ + TYPE TGFN(log)(TYPE x) { switch (fpclassify(x)) { @@ -41,7 +42,5 @@ compute the natural logarithm of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/log10.c b/src/math/log10.c index e504df44..922bfceb 100644 --- a/src/math/log10.c +++ b/src/math/log10.c @@ -1,10 +1,11 @@ # define TGSOURCE "log10.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** base-10 logarithm **/ + TYPE TGFN(log10)(TYPE x) { switch (fpclassify(x)) { @@ -41,7 +42,5 @@ compute the base-ten logarithm of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/modf.c b/src/math/modf.c index 63db6094..a9331317 100644 --- a/src/math/modf.c +++ b/src/math/modf.c @@ -1,9 +1,10 @@ # define TGSOURCE "modf.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** decompose floating-point numbers **/ + TYPE TGFN(modf)(TYPE value, TYPE *iptr) { switch (fpclassify(value)) { @@ -32,7 +33,5 @@ by ARGUMENT(iptr). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/pow.c b/src/math/pow.c index 8a070005..3400cdd1 100644 --- a/src/math/pow.c +++ b/src/math/pow.c @@ -1,10 +1,11 @@ # define TGSOURCE "pow.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** exponentiation **/ + TYPE TGFN(pow)(TYPE x, TYPE y) { int classx = fpclassify(x); @@ -114,7 +115,5 @@ compute ARGUMENT(x) raised to the power ARGUMENT(y). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sin.c b/src/math/sin.c index e93a663b..017b750a 100644 --- a/src/math/sin.c +++ b/src/math/sin.c @@ -1,10 +1,11 @@ # define TGSOURCE "sin.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** sine **/ + TYPE TGFN(sin)(TYPE x) { int MAXLOOPS = 10; @@ -52,7 +53,5 @@ compute sine of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sinh.c b/src/math/sinh.c index 2e8d498c..a39c0bbd 100644 --- a/src/math/sinh.c +++ b/src/math/sinh.c @@ -1,9 +1,10 @@ # define TGSOURCE "sinh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic sine **/ + TYPE TGFN(sinh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute hyperbolic sine of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/sqrt.c b/src/math/sqrt.c index a53d4750..e415bd65 100644 --- a/src/math/sqrt.c +++ b/src/math/sqrt.c @@ -1,9 +1,10 @@ # define TGSOURCE "sqrt.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** square root **/ + TYPE TGFN(sqrt)(TYPE x) { if (x < 0) { @@ -28,7 +29,5 @@ compute the principal square root of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/tan.c b/src/math/tan.c index 061e6cdd..8f11e02c 100644 --- a/src/math/tan.c +++ b/src/math/tan.c @@ -1,10 +1,11 @@ # define TGSOURCE "tan.c" +#include <errno.h> +#include <fenv.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" -#include "fenv.h" /** tangent **/ + TYPE TGFN(tan)(TYPE x) { switch (fpclassify(x)) { @@ -30,7 +31,5 @@ compute the tanget of ARGUMENT(x), in radians. /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ diff --git a/src/math/tanh.c b/src/math/tanh.c index cf5bf028..817cac35 100644 --- a/src/math/tanh.c +++ b/src/math/tanh.c @@ -1,9 +1,10 @@ # define TGSOURCE "tanh.c" +#include <errno.h> #include <math.h> #include "_tgmath.h" -#include "errno.h" /** hyperbolic tangent **/ + TYPE TGFN(tanh)(TYPE x) { switch (fpclassify(x)) { @@ -29,7 +30,5 @@ compute the hyperbolic tangent of ARGUMENT(x). /* IMPLEMENTATION(The value returned on a domain error, CONSTANT(HUGE_VAL)) LINK(m) -*/ -/* STDC(1) */ |
