/NeonProject/app/src/main/cpp/cvlib/cv_neon_mathfun.h

https://github.com/dingjikerbo/Android-Boost · C Header · 63 lines · 21 code · 16 blank · 26 comment · 0 complexity · 69d386ba907baf14693fc79e4c0ed491 MD5 · raw file

  1. /*
  2. * Implementation approximate Math library in Neon and single float.
  3. * Exp Log Sin Cos is almost the same Julien Pommier's NEON implementation.
  4. * Some of the algorithms not is based on the cephes math library.
  5. *
  6. * liuyang.10 2018.06.24
  7. */
  8. #ifndef __CV_LIBRARY_NEON_MATHFUN_H__
  9. #define __CV_LIBRARY_NEON_MATHFUN_H__
  10. namespace cv_maths
  11. {
  12. #ifdef __ARM_NEON__
  13. #include <arm_neon.h>
  14. /* natural logarithm computed for 4 simultaneous float
  15. return NaN for x <= 0
  16. */
  17. float32x4_t log_ps(float32x4_t x);
  18. /* exp() computed for 4 float at once */
  19. float32x4_t exp_ps(float32x4_t x);
  20. /* evaluation of 4 sines & cosines at once.
  21. The code is the exact rewriting of the cephes sinf function.
  22. Precision is excellent as long as x < 8192 (I did not bother to
  23. take into account the special handling they have for greater values
  24. -- it does not return garbage for arguments over 8192, though, but
  25. the extra precision is missing).
  26. Note that it is such that sinf((float)M_PI) = 8.74e-8, which is the
  27. surprising but correct result.
  28. Note also that when you compute sin(x), cos(x) is available at
  29. almost no extra price so both sin_ps and cos_ps make use of
  30. sincos_ps..
  31. */
  32. void sincos_ps(float32x4_t x,float32x4_t *ysin,float32x4_t *ycos);
  33. float32x4_t sin_ps(float32x4_t x);
  34. float32x4_t cos_ps(float32x4_t x);
  35. float32x4_t tanf_cephes(float32x4_t x );
  36. float32x4_t cotf_cephes(float32x4_t x );
  37. float32x4_t exp_remez(float32x4_t x);
  38. float32x4_t inv_sqrt_float32x4( float32x4_t xx );
  39. float32x4_t q_rsqrt_float32x4( float32x4_t xx);
  40. float32x4_t atanf_cephes(float32x4_t xx);
  41. float32x4_t atan2f_cephes(float32x4_t y,float32x4_t x);
  42. }
  43. #endif // __ARM_NEON__
  44. #endif // __NEON_MATHFUN_H__