fix inverse hyperbolics

oop, typo
This commit is contained in:
John Cupitt 2021-11-02 22:58:19 +00:00
parent d8c04011ea
commit c6d863f9d3
2 changed files with 20 additions and 19 deletions

View File

@ -129,12 +129,13 @@ vips_math_build( VipsObject *object )
g_assert_not_reached(); \ g_assert_not_reached(); \
} }
/* inverse hyperbolic functions for old compilers /* Inverse hyperbolic functions for old compilers.
they were added to the standard in C99 and C++11 *
* They were added to the standard in C99 and C++11.
*/ */
#if ( \ #if ( \
(defined(__cplusplus) && __cplusplus >= 201103L) \ (defined( __cplusplus ) && __cplusplus >= 201103L) || \
|| (defined(__STDC__) && __STDC_VERSION__ >= 199901L) \ (defined( __STDC__ ) && __STDC_VERSION__ >= 199901L) \
) )
#define HAS_INVERSE_HYPERBOLICS 1 #define HAS_INVERSE_HYPERBOLICS 1
#else #else
@ -142,13 +143,13 @@ vips_math_build( VipsObject *object )
#endif #endif
#if HAS_INVERSE_HYPERBOLICS #if HAS_INVERSE_HYPERBOLICS
#define ASINH sinh #define ASINH( X ) (asinh( X ))
#define ACOSH cosh #define ACOSH( X ) (acosh( X ))
#define ATANH tanh #define ATANH( X ) (atanh( X ))
#else #else
#define ASINH( X ) log((X) + sqrt( (X)*(X)+1 )) #define ASINH( X ) (LOGZ( (X) + sqrt( (X) * (X) + 1.0 ) ))
#define ACOSH( X ) log((X) + sqrt( (X)*(X)-1 )) #define ACOSH( X ) (LOGZ( (X) + sqrt( (X) * (X) - 1.0 ) ))
#define ATANH( X ) (0.5 * log( (1+(X)) / (1-(X)) )) #define ATANH( X ) (0.5 * LOGZ( (1.0 + (X)) / (1.0 - (X)) ))
#endif #endif
/* sin/cos/tan in degrees. /* sin/cos/tan in degrees.

View File

@ -522,7 +522,7 @@ class TestArithmetic:
else: else:
return math.asinh(x) return math.asinh(x)
im = (pyvips.Image.black(100, 100) + [1, 2, 3]) / 3.0 im = (pyvips.Image.black(100, 100) + [4, 5, 6]) / 3.0
self.run_unary([im], my_asinh, fmt=noncomplex_formats) self.run_unary([im], my_asinh, fmt=noncomplex_formats)
# this requires pyvips 2.1.16 for acosh # this requires pyvips 2.1.16 for acosh
@ -536,7 +536,7 @@ class TestArithmetic:
else: else:
return math.acosh(x) return math.acosh(x)
im = (pyvips.Image.black(100, 100) + [1, 2, 3]) / 3.0 im = (pyvips.Image.black(100, 100) + [4, 5, 6]) / 3.0
self.run_unary([im], my_acosh, fmt=noncomplex_formats) self.run_unary([im], my_acosh, fmt=noncomplex_formats)
# this requires pyvips 2.1.16 for atanh # this requires pyvips 2.1.16 for atanh
@ -550,7 +550,7 @@ class TestArithmetic:
else: else:
return math.atanh(x) return math.atanh(x)
im = (pyvips.Image.black(100, 100) + [1, 2, 3]) / 3.0 im = (pyvips.Image.black(100, 100) + [0, 1, 2]) / 3.0
self.run_unary([im], my_atanh, fmt=noncomplex_formats) self.run_unary([im], my_atanh, fmt=noncomplex_formats)
# this requires pyvips 2.1.16 for atan2 # this requires pyvips 2.1.16 for atan2