Skip to content

Commit 87561bb

Browse files
committed
Implement hyperbolic ufuncs
1 parent 116a605 commit 87561bb

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

quaddtype/numpy_quaddtype/src/ops.hpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,42 @@ quad_atan(const Sleef_quad *op)
151151
return Sleef_atanq1_u10(*op);
152152
}
153153

154+
static inline Sleef_quad
155+
quad_sinh(const Sleef_quad *op)
156+
{
157+
return Sleef_sinhq1_u10(*op);
158+
}
159+
160+
static inline Sleef_quad
161+
quad_cosh(const Sleef_quad *op)
162+
{
163+
return Sleef_coshq1_u10(*op);
164+
}
165+
166+
static inline Sleef_quad
167+
quad_tanh(const Sleef_quad *op)
168+
{
169+
return Sleef_tanhq1_u10(*op);
170+
}
171+
172+
static inline Sleef_quad
173+
quad_asinh(const Sleef_quad *op)
174+
{
175+
return Sleef_asinhq1_u10(*op);
176+
}
177+
178+
static inline Sleef_quad
179+
quad_acosh(const Sleef_quad *op)
180+
{
181+
return Sleef_acoshq1_u10(*op);
182+
}
183+
184+
static inline Sleef_quad
185+
quad_atanh(const Sleef_quad *op)
186+
{
187+
return Sleef_atanhq1_u10(*op);
188+
}
189+
154190
// Unary long double operations
155191
typedef long double (*unary_op_longdouble_def)(const long double *);
156192

@@ -299,6 +335,42 @@ ld_atan(const long double *op)
299335
return atanl(*op);
300336
}
301337

338+
static inline long double
339+
ld_sinh(const long double *op)
340+
{
341+
return sinhl(*op);
342+
}
343+
344+
static inline long double
345+
ld_cosh(const long double *op)
346+
{
347+
return coshl(*op);
348+
}
349+
350+
static inline long double
351+
ld_tanh(const long double *op)
352+
{
353+
return tanhl(*op);
354+
}
355+
356+
static inline long double
357+
ld_asinh(const long double *op)
358+
{
359+
return asinhl(*op);
360+
}
361+
362+
static inline long double
363+
ld_acosh(const long double *op)
364+
{
365+
return acoshl(*op);
366+
}
367+
368+
static inline long double
369+
ld_atanh(const long double *op)
370+
{
371+
return atanhl(*op);
372+
}
373+
302374
// Unary Quad properties
303375
typedef npy_bool (*unary_prop_quad_def)(const Sleef_quad *);
304376

quaddtype/numpy_quaddtype/src/umath/unary_ops.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,5 +216,23 @@ init_quad_unary_ops(PyObject *numpy)
216216
if (create_quad_unary_ufunc<quad_atan, ld_atan>(numpy, "arctan") < 0) {
217217
return -1;
218218
}
219+
if (create_quad_unary_ufunc<quad_sinh, ld_sinh>(numpy, "sinh") < 0) {
220+
return -1;
221+
}
222+
if (create_quad_unary_ufunc<quad_cosh, ld_cosh>(numpy, "cosh") < 0) {
223+
return -1;
224+
}
225+
if (create_quad_unary_ufunc<quad_tanh, ld_tanh>(numpy, "tanh") < 0) {
226+
return -1;
227+
}
228+
if (create_quad_unary_ufunc<quad_asinh, ld_asinh>(numpy, "arcsinh") < 0) {
229+
return -1;
230+
}
231+
if (create_quad_unary_ufunc<quad_acosh, ld_acosh>(numpy, "arccosh") < 0) {
232+
return -1;
233+
}
234+
if (create_quad_unary_ufunc<quad_atanh, ld_atanh>(numpy, "arctanh") < 0) {
235+
return -1;
236+
}
219237
return 0;
220238
}

0 commit comments

Comments
 (0)