Skip to content

Commit 82030d5

Browse files
committed
w
1 parent df6e25e commit 82030d5

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

src/expression.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -379,35 +379,23 @@ std::vector<int> eval_list_expression(const std::string& expr, const std::vector
379379
}
380380
else if (t == "acosh")
381381
{
382-
#if NCNN_SIMPLEMATH
383-
NCNN_LOGE("acosh not implemented in simplemath!");
384-
#else
385382
r = acoshf(a);
386-
#endif
387383
}
388384
else if (t == "asin")
389385
{
390386
r = asinf(a);
391387
}
392388
else if (t == "asinh")
393389
{
394-
#if NCNN_SIMPLEMATH
395-
NCNN_LOGE("asinh not implemented in simplemath!");
396-
#else
397390
r = asinhf(a);
398-
#endif
399391
}
400392
else if (t == "atan")
401393
{
402394
r = atanf(a);
403395
}
404396
else if (t == "atanh")
405397
{
406-
#if NCNN_SIMPLEMATH
407-
NCNN_LOGE("atanh not implemented in simplemath!");
408-
#else
409398
r = atanhf(a);
410-
#endif
411399
}
412400
else if (t == "cos")
413401
{

src/simplemath.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,26 +320,41 @@ float atan2f(float y, float x)
320320
}
321321
}
322322

323-
float sinhf(float v)
323+
float sinhf(float x)
324324
{
325-
return 0.5 * (expf(v) - expf(-v));
325+
return 0.5 * (expf(x) - expf(-x));
326326
}
327327

328-
float coshf(float v)
328+
float coshf(float x)
329329
{
330-
return 0.5 * (expf(v) + expf(-v));
330+
return 0.5 * (expf(x) + expf(-x));
331331
}
332332

333-
float tanhf(float v)
333+
float tanhf(float x)
334334
{
335-
if (v >= 8 || v <= -8)
335+
if (x >= 8 || x <= -8)
336336
{
337-
return copysignf(1, v);
337+
return copysignf(1, x);
338338
}
339-
float exp2v = expf(2 * v);
339+
float exp2v = expf(2 * x);
340340
return (exp2v - 1) / (exp2v + 1);
341341
}
342342

343+
float asinhf(float x)
344+
{
345+
return logf(x + sqrtf(x * x + 1));
346+
}
347+
348+
float acoshf(float x)
349+
{
350+
return logf(x + sqrtf(x * x - 1));
351+
}
352+
353+
float atanhf(float x)
354+
{
355+
return 0.5f * logf((1 + x) / (1 - x));
356+
}
357+
343358
/*
344359
* ====================================================
345360
* power functions

src/simplemath.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ NCNN_EXPORT float atan2f(float, float);
5555
NCNN_EXPORT float sinhf(float);
5656
NCNN_EXPORT float coshf(float);
5757
NCNN_EXPORT float tanhf(float);
58+
NCNN_EXPORT float asinhf(float);
59+
NCNN_EXPORT float acoshf(float);
60+
NCNN_EXPORT float atanhf(float);
5861

5962
/*
6063
* ====================================================

0 commit comments

Comments
 (0)