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,26 +129,27 @@ vips_math_build( VipsObject *object )
g_assert_not_reached(); \
}
/* inverse hyperbolic functions for old compilers
they were added to the standard in C99 and C++11
*/
/* Inverse hyperbolic functions for old compilers.
*
* They were added to the standard in C99 and C++11.
*/
#if ( \
(defined(__cplusplus) && __cplusplus >= 201103L) \
|| (defined(__STDC__) && __STDC_VERSION__ >= 199901L) \
(defined( __cplusplus ) && __cplusplus >= 201103L) || \
(defined( __STDC__ ) && __STDC_VERSION__ >= 199901L) \
)
#define HAS_INVERSE_HYPERBOLICS 1
#define HAS_INVERSE_HYPERBOLICS 1
#else
#define HAS_INVERSE_HYPERBOLICS 0
#define HAS_INVERSE_HYPERBOLICS 0
#endif
#if HAS_INVERSE_HYPERBOLICS
#define ASINH sinh
#define ACOSH cosh
#define ATANH tanh
#define ASINH( X ) (asinh( X ))
#define ACOSH( X ) (acosh( X ))
#define ATANH( X ) (atanh( X ))
#else
#define ASINH( X ) log((X) + sqrt( (X)*(X)+1 ))
#define ACOSH( X ) log((X) + sqrt( (X)*(X)-1 ))
#define ATANH( X ) (0.5 * log( (1+(X)) / (1-(X)) ))
#define ASINH( X ) (LOGZ( (X) + sqrt( (X) * (X) + 1.0 ) ))
#define ACOSH( X ) (LOGZ( (X) + sqrt( (X) * (X) - 1.0 ) ))
#define ATANH( X ) (0.5 * LOGZ( (1.0 + (X)) / (1.0 - (X)) ))
#endif
/* sin/cos/tan in degrees.
@ -189,9 +190,9 @@ vips_math_buffer( VipsArithmetic *arithmetic,
case VIPS_OPERATION_MATH_SINH: SWITCH( sinh ); break;
case VIPS_OPERATION_MATH_COSH: SWITCH( cosh ); break;
case VIPS_OPERATION_MATH_TANH: SWITCH( tanh ); break;
case VIPS_OPERATION_MATH_ASINH: SWITCH( ASINH ); break;
case VIPS_OPERATION_MATH_ACOSH: SWITCH( ACOSH ); break;
case VIPS_OPERATION_MATH_ATANH: SWITCH( ATANH ); break;
case VIPS_OPERATION_MATH_ASINH: SWITCH( ASINH ); break;
case VIPS_OPERATION_MATH_ACOSH: SWITCH( ACOSH ); break;
case VIPS_OPERATION_MATH_ATANH: SWITCH( ATANH ); break;
case VIPS_OPERATION_MATH_LOG: SWITCH( LOGZ ); break;
case VIPS_OPERATION_MATH_LOG10: SWITCH( LOGZ10 ); break;
case VIPS_OPERATION_MATH_EXP: SWITCH( exp ); break;

View File

@ -522,7 +522,7 @@ class TestArithmetic:
else:
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)
# this requires pyvips 2.1.16 for acosh
@ -536,7 +536,7 @@ class TestArithmetic:
else:
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)
# this requires pyvips 2.1.16 for atanh
@ -550,7 +550,7 @@ class TestArithmetic:
else:
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)
# this requires pyvips 2.1.16 for atan2