softfloat.hpp 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html
  4. // This file is based on files from package issued with the following license:
  5. /*============================================================================
  6. This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
  7. Package, Release 3c, by John R. Hauser.
  8. Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
  9. University of California. All rights reserved.
  10. Redistribution and use in source and binary forms, with or without
  11. modification, are permitted provided that the following conditions are met:
  12. 1. Redistributions of source code must retain the above copyright notice,
  13. this list of conditions, and the following disclaimer.
  14. 2. Redistributions in binary form must reproduce the above copyright notice,
  15. this list of conditions, and the following disclaimer in the documentation
  16. and/or other materials provided with the distribution.
  17. 3. Neither the name of the University nor the names of its contributors may
  18. be used to endorse or promote products derived from this software without
  19. specific prior written permission.
  20. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
  21. EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  22. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
  23. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
  24. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  26. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  27. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. =============================================================================*/
  31. #pragma once
  32. #ifndef softfloat_h
  33. #define softfloat_h 1
  34. #include "cvdef.h"
  35. namespace cv
  36. {
  37. /** @addtogroup core_utils_softfloat
  38. [SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is a software implementation
  39. of floating-point calculations according to IEEE 754 standard.
  40. All calculations are done in integers, that's why they are machine-independent and bit-exact.
  41. This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc.
  42. OpenCV contains a subset of SoftFloat partially rewritten to C++.
  43. ### Types
  44. There are two basic types: @ref softfloat and @ref softdouble.
  45. These types are binary compatible with float and double types respectively
  46. and support conversions to/from them.
  47. Other types from original SoftFloat library like fp16 or fp128 were thrown away
  48. as well as quiet/signaling NaN support, on-the-fly rounding mode switch
  49. and exception flags (though exceptions can be implemented in the future).
  50. ### Operations
  51. Both types support the following:
  52. - Construction from signed and unsigned 32-bit and 64 integers,
  53. float/double or raw binary representation
  54. - Conversions between each other, to float or double and to int
  55. using @ref cvRound, @ref cvTrunc, @ref cvFloor, @ref cvCeil or a bunch of
  56. saturate_cast functions
  57. - Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision
  58. - Comparison operations
  59. - Explicit sign, exponent and significand manipulation through get/set methods,
  60. number state indicators (isInf, isNan, isSubnormal)
  61. - Type-specific constants like eps, minimum/maximum value, best pi approximation, etc.
  62. - min(), max(), abs(), exp(), log() and pow() functions
  63. */
  64. //! @{
  65. struct softfloat;
  66. struct softdouble;
  67. struct CV_EXPORTS softfloat
  68. {
  69. public:
  70. /** @brief Default constructor */
  71. softfloat() { v = 0; }
  72. /** @brief Copy constructor */
  73. softfloat( const softfloat& c) { v = c.v; }
  74. /** @brief Assign constructor */
  75. softfloat& operator=( const softfloat& c )
  76. {
  77. if(&c != this) v = c.v;
  78. return *this;
  79. }
  80. /** @brief Construct from raw
  81. Builds new value from raw binary representation
  82. */
  83. static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; }
  84. /** @brief Construct from integer */
  85. explicit softfloat( const uint32_t );
  86. explicit softfloat( const uint64_t );
  87. explicit softfloat( const int32_t );
  88. explicit softfloat( const int64_t );
  89. #ifdef CV_INT32_T_IS_LONG_INT
  90. // for platforms with int32_t = long int
  91. explicit softfloat( const int a ) { *this = softfloat(static_cast<int32_t>(a)); }
  92. #endif
  93. /** @brief Construct from float */
  94. explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
  95. /** @brief Type casts */
  96. operator softdouble() const;
  97. operator float() const { Cv32suf s; s.u = v; return s.f; }
  98. /** @brief Basic arithmetics */
  99. softfloat operator + (const softfloat&) const;
  100. softfloat operator - (const softfloat&) const;
  101. softfloat operator * (const softfloat&) const;
  102. softfloat operator / (const softfloat&) const;
  103. softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; }
  104. /** @brief Remainder operator
  105. A quote from original SoftFloat manual:
  106. > The IEEE Standard remainder operation computes the value
  107. > a - n * b, where n is the integer closest to a / b.
  108. > If a / b is exactly halfway between two integers, n is the even integer
  109. > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
  110. > Depending on the relative magnitudes of the operands, the remainder functions
  111. > can take considerably longer to execute than the other SoftFloat functions.
  112. > This is an inherent characteristic of the remainder operation itself and is not a flaw
  113. > in the SoftFloat implementation.
  114. */
  115. softfloat operator % (const softfloat&) const;
  116. softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; }
  117. softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; }
  118. softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; }
  119. softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; }
  120. softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; }
  121. /** @brief Comparison operations
  122. - Any operation with NaN produces false
  123. + The only exception is when x is NaN: x != y for any y.
  124. - Positive and negative zeros are equal
  125. */
  126. bool operator == ( const softfloat& ) const;
  127. bool operator != ( const softfloat& ) const;
  128. bool operator > ( const softfloat& ) const;
  129. bool operator >= ( const softfloat& ) const;
  130. bool operator < ( const softfloat& ) const;
  131. bool operator <= ( const softfloat& ) const;
  132. /** @brief NaN state indicator */
  133. inline bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; }
  134. /** @brief Inf state indicator */
  135. inline bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; }
  136. /** @brief Subnormal number indicator */
  137. inline bool isSubnormal() const { return ((v >> 23) & 0xFF) == 0; }
  138. /** @brief Get sign bit */
  139. inline bool getSign() const { return (v >> 31) != 0; }
  140. /** @brief Construct a copy with new sign bit */
  141. inline softfloat setSign(bool sign) const { softfloat x; x.v = (v & ((1U << 31) - 1)) | ((uint32_t)sign << 31); return x; }
  142. /** @brief Get 0-based exponent */
  143. inline int getExp() const { return ((v >> 23) & 0xFF) - 127; }
  144. /** @brief Construct a copy with new 0-based exponent */
  145. inline softfloat setExp(int e) const { softfloat x; x.v = (v & 0x807fffff) | (((e + 127) & 0xFF) << 23 ); return x; }
  146. /** @brief Get a fraction part
  147. Returns a number 1 <= x < 2 with the same significand
  148. */
  149. inline softfloat getFrac() const
  150. {
  151. uint_fast32_t vv = (v & 0x007fffff) | (127 << 23);
  152. return softfloat::fromRaw(vv);
  153. }
  154. /** @brief Construct a copy with provided significand
  155. Constructs a copy of a number with significand taken from parameter
  156. */
  157. inline softfloat setFrac(const softfloat& s) const
  158. {
  159. softfloat x;
  160. x.v = (v & 0xff800000) | (s.v & 0x007fffff);
  161. return x;
  162. }
  163. /** @brief Zero constant */
  164. static softfloat zero() { return softfloat::fromRaw( 0 ); }
  165. /** @brief Positive infinity constant */
  166. static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); }
  167. /** @brief Default NaN constant */
  168. static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); }
  169. /** @brief One constant */
  170. static softfloat one() { return softfloat::fromRaw( 127 << 23 ); }
  171. /** @brief Smallest normalized value */
  172. static softfloat min() { return softfloat::fromRaw( 0x01 << 23 ); }
  173. /** @brief Difference between 1 and next representable value */
  174. static softfloat eps() { return softfloat::fromRaw( (127 - 23) << 23 ); }
  175. /** @brief Biggest finite value */
  176. static softfloat max() { return softfloat::fromRaw( (0xFF << 23) - 1 ); }
  177. /** @brief Correct pi approximation */
  178. static softfloat pi() { return softfloat::fromRaw( 0x40490fdb ); }
  179. uint32_t v;
  180. };
  181. /*----------------------------------------------------------------------------
  182. *----------------------------------------------------------------------------*/
  183. struct CV_EXPORTS softdouble
  184. {
  185. public:
  186. /** @brief Default constructor */
  187. softdouble() : v(0) { }
  188. /** @brief Copy constructor */
  189. softdouble( const softdouble& c) { v = c.v; }
  190. /** @brief Assign constructor */
  191. softdouble& operator=( const softdouble& c )
  192. {
  193. if(&c != this) v = c.v;
  194. return *this;
  195. }
  196. /** @brief Construct from raw
  197. Builds new value from raw binary representation
  198. */
  199. static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; }
  200. /** @brief Construct from integer */
  201. explicit softdouble( const uint32_t );
  202. explicit softdouble( const uint64_t );
  203. explicit softdouble( const int32_t );
  204. explicit softdouble( const int64_t );
  205. #ifdef CV_INT32_T_IS_LONG_INT
  206. // for platforms with int32_t = long int
  207. explicit softdouble( const int a ) { *this = softdouble(static_cast<int32_t>(a)); }
  208. #endif
  209. /** @brief Construct from double */
  210. explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
  211. /** @brief Type casts */
  212. operator softfloat() const;
  213. operator double() const { Cv64suf s; s.u = v; return s.f; }
  214. /** @brief Basic arithmetics */
  215. softdouble operator + (const softdouble&) const;
  216. softdouble operator - (const softdouble&) const;
  217. softdouble operator * (const softdouble&) const;
  218. softdouble operator / (const softdouble&) const;
  219. softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; }
  220. /** @brief Remainder operator
  221. A quote from original SoftFloat manual:
  222. > The IEEE Standard remainder operation computes the value
  223. > a - n * b, where n is the integer closest to a / b.
  224. > If a / b is exactly halfway between two integers, n is the even integer
  225. > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
  226. > Depending on the relative magnitudes of the operands, the remainder functions
  227. > can take considerably longer to execute than the other SoftFloat functions.
  228. > This is an inherent characteristic of the remainder operation itself and is not a flaw
  229. > in the SoftFloat implementation.
  230. */
  231. softdouble operator % (const softdouble&) const;
  232. softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; }
  233. softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; }
  234. softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; }
  235. softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; }
  236. softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; }
  237. /** @brief Comparison operations
  238. - Any operation with NaN produces false
  239. + The only exception is when x is NaN: x != y for any y.
  240. - Positive and negative zeros are equal
  241. */
  242. bool operator == ( const softdouble& ) const;
  243. bool operator != ( const softdouble& ) const;
  244. bool operator > ( const softdouble& ) const;
  245. bool operator >= ( const softdouble& ) const;
  246. bool operator < ( const softdouble& ) const;
  247. bool operator <= ( const softdouble& ) const;
  248. /** @brief NaN state indicator */
  249. inline bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; }
  250. /** @brief Inf state indicator */
  251. inline bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; }
  252. /** @brief Subnormal number indicator */
  253. inline bool isSubnormal() const { return ((v >> 52) & 0x7FF) == 0; }
  254. /** @brief Get sign bit */
  255. inline bool getSign() const { return (v >> 63) != 0; }
  256. /** @brief Construct a copy with new sign bit */
  257. softdouble setSign(bool sign) const { softdouble x; x.v = (v & ((1ULL << 63) - 1)) | ((uint_fast64_t)(sign) << 63); return x; }
  258. /** @brief Get 0-based exponent */
  259. inline int getExp() const { return ((v >> 52) & 0x7FF) - 1023; }
  260. /** @brief Construct a copy with new 0-based exponent */
  261. inline softdouble setExp(int e) const
  262. {
  263. softdouble x;
  264. x.v = (v & 0x800FFFFFFFFFFFFF) | ((uint_fast64_t)((e + 1023) & 0x7FF) << 52);
  265. return x;
  266. }
  267. /** @brief Get a fraction part
  268. Returns a number 1 <= x < 2 with the same significand
  269. */
  270. inline softdouble getFrac() const
  271. {
  272. uint_fast64_t vv = (v & 0x000FFFFFFFFFFFFF) | ((uint_fast64_t)(1023) << 52);
  273. return softdouble::fromRaw(vv);
  274. }
  275. /** @brief Construct a copy with provided significand
  276. Constructs a copy of a number with significand taken from parameter
  277. */
  278. inline softdouble setFrac(const softdouble& s) const
  279. {
  280. softdouble x;
  281. x.v = (v & 0xFFF0000000000000) | (s.v & 0x000FFFFFFFFFFFFF);
  282. return x;
  283. }
  284. /** @brief Zero constant */
  285. static softdouble zero() { return softdouble::fromRaw( 0 ); }
  286. /** @brief Positive infinity constant */
  287. static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); }
  288. /** @brief Default NaN constant */
  289. static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); }
  290. /** @brief One constant */
  291. static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); }
  292. /** @brief Smallest normalized value */
  293. static softdouble min() { return softdouble::fromRaw( (uint_fast64_t)( 0x01) << 52 ); }
  294. /** @brief Difference between 1 and next representable value */
  295. static softdouble eps() { return softdouble::fromRaw( (uint_fast64_t)( 1023 - 52 ) << 52 ); }
  296. /** @brief Biggest finite value */
  297. static softdouble max() { return softdouble::fromRaw( ((uint_fast64_t)(0x7FF) << 52) - 1 ); }
  298. /** @brief Correct pi approximation */
  299. static softdouble pi() { return softdouble::fromRaw( CV_BIG_INT(0x400921FB54442D18) ); }
  300. uint64_t v;
  301. };
  302. /*----------------------------------------------------------------------------
  303. *----------------------------------------------------------------------------*/
  304. /** @brief Fused Multiplication and Addition
  305. Computes (a*b)+c with single rounding
  306. */
  307. CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c);
  308. CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c);
  309. /** @brief Square root */
  310. CV_EXPORTS softfloat sqrt( const softfloat& a );
  311. CV_EXPORTS softdouble sqrt( const softdouble& a );
  312. }
  313. /*----------------------------------------------------------------------------
  314. | Ported from OpenCV and added for usability
  315. *----------------------------------------------------------------------------*/
  316. /** @brief Truncates number to integer with minimum magnitude */
  317. CV_EXPORTS int cvTrunc(const cv::softfloat& a);
  318. CV_EXPORTS int cvTrunc(const cv::softdouble& a);
  319. /** @brief Rounds a number to nearest even integer */
  320. CV_EXPORTS int cvRound(const cv::softfloat& a);
  321. CV_EXPORTS int cvRound(const cv::softdouble& a);
  322. /** @brief Rounds a number to nearest even long long integer */
  323. CV_EXPORTS int64_t cvRound64(const cv::softdouble& a);
  324. /** @brief Rounds a number down to integer */
  325. CV_EXPORTS int cvFloor(const cv::softfloat& a);
  326. CV_EXPORTS int cvFloor(const cv::softdouble& a);
  327. /** @brief Rounds number up to integer */
  328. CV_EXPORTS int cvCeil(const cv::softfloat& a);
  329. CV_EXPORTS int cvCeil(const cv::softdouble& a);
  330. namespace cv
  331. {
  332. /** @brief Saturate casts */
  333. template<typename _Tp> static inline _Tp saturate_cast(softfloat a) { return _Tp(a); }
  334. template<typename _Tp> static inline _Tp saturate_cast(softdouble a) { return _Tp(a); }
  335. template<> inline uchar saturate_cast<uchar>(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
  336. template<> inline uchar saturate_cast<uchar>(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
  337. template<> inline schar saturate_cast<schar>(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
  338. template<> inline schar saturate_cast<schar>(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
  339. template<> inline ushort saturate_cast<ushort>(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
  340. template<> inline ushort saturate_cast<ushort>(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
  341. template<> inline short saturate_cast<short>(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
  342. template<> inline short saturate_cast<short>(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
  343. template<> inline int saturate_cast<int>(softfloat a) { return cvRound(a); }
  344. template<> inline int saturate_cast<int>(softdouble a) { return cvRound(a); }
  345. template<> inline int64_t saturate_cast<int64_t>(softfloat a) { return cvRound(a); }
  346. template<> inline int64_t saturate_cast<int64_t>(softdouble a) { return cvRound64(a); }
  347. /** @brief Saturate cast to unsigned integer and unsigned long long integer
  348. We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
  349. */
  350. template<> inline unsigned saturate_cast<unsigned>(softfloat a) { return cvRound(a); }
  351. template<> inline unsigned saturate_cast<unsigned>(softdouble a) { return cvRound(a); }
  352. template<> inline uint64_t saturate_cast<uint64_t>(softfloat a) { return cvRound(a); }
  353. template<> inline uint64_t saturate_cast<uint64_t>(softdouble a) { return cvRound64(a); }
  354. /** @brief Min and Max functions */
  355. inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; }
  356. inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; }
  357. inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; }
  358. inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; }
  359. /** @brief Absolute value */
  360. inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; }
  361. inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; }
  362. /** @brief Exponent
  363. Special cases:
  364. - exp(NaN) is NaN
  365. - exp(-Inf) == 0
  366. - exp(+Inf) == +Inf
  367. */
  368. CV_EXPORTS softfloat exp( const softfloat& a);
  369. CV_EXPORTS softdouble exp( const softdouble& a);
  370. /** @brief Natural logarithm
  371. Special cases:
  372. - log(NaN), log(x < 0) are NaN
  373. - log(0) == -Inf
  374. */
  375. CV_EXPORTS softfloat log( const softfloat& a );
  376. CV_EXPORTS softdouble log( const softdouble& a );
  377. /** @brief Raising to the power
  378. Special cases:
  379. - x**NaN is NaN for any x
  380. - ( |x| == 1 )**Inf is NaN
  381. - ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf
  382. - ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0
  383. - x ** 0 == 1 for any x
  384. - x ** 1 == 1 for any x
  385. - NaN ** y is NaN for any other y
  386. - Inf**(y < 0) == 0
  387. - Inf ** y is +Inf for any other y
  388. - (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer
  389. - 0 ** 0 == 1
  390. - 0 ** (y < 0) is +Inf
  391. - 0 ** (y > 0) is 0
  392. */
  393. CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b);
  394. CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b);
  395. /** @brief Cube root
  396. Special cases:
  397. - cbrt(NaN) is NaN
  398. - cbrt(+/-Inf) is +/-Inf
  399. */
  400. CV_EXPORTS softfloat cbrt( const softfloat& a );
  401. /** @brief Sine
  402. Special cases:
  403. - sin(Inf) or sin(NaN) is NaN
  404. - sin(x) == x when sin(x) is close to zero
  405. */
  406. CV_EXPORTS softdouble sin( const softdouble& a );
  407. /** @brief Cosine
  408. *
  409. Special cases:
  410. - cos(Inf) or cos(NaN) is NaN
  411. - cos(x) == +/- 1 when cos(x) is close to +/- 1
  412. */
  413. CV_EXPORTS softdouble cos( const softdouble& a );
  414. }
  415. //! @}
  416. #endif