openCV library for Renesas RZ/A

Dependents:   RZ_A2M_Mbed_samples

Committer:
RyoheiHagimoto
Date:
Fri Jan 29 04:53:38 2021 +0000
Revision:
0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RyoheiHagimoto 0:0e0631af0305 1 /*M///////////////////////////////////////////////////////////////////////////////////////
RyoheiHagimoto 0:0e0631af0305 2 //
RyoheiHagimoto 0:0e0631af0305 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
RyoheiHagimoto 0:0e0631af0305 4 //
RyoheiHagimoto 0:0e0631af0305 5 // By downloading, copying, installing or using the software you agree to this license.
RyoheiHagimoto 0:0e0631af0305 6 // If you do not agree to this license, do not download, install,
RyoheiHagimoto 0:0e0631af0305 7 // copy or use the software.
RyoheiHagimoto 0:0e0631af0305 8 //
RyoheiHagimoto 0:0e0631af0305 9 //
RyoheiHagimoto 0:0e0631af0305 10 // License Agreement
RyoheiHagimoto 0:0e0631af0305 11 // For Open Source Computer Vision Library
RyoheiHagimoto 0:0e0631af0305 12 //
RyoheiHagimoto 0:0e0631af0305 13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 15 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
RyoheiHagimoto 0:0e0631af0305 16 // Copyright (C) 2015, Itseez Inc., all rights reserved.
RyoheiHagimoto 0:0e0631af0305 17 // Third party copyrights are property of their respective owners.
RyoheiHagimoto 0:0e0631af0305 18 //
RyoheiHagimoto 0:0e0631af0305 19 // Redistribution and use in source and binary forms, with or without modification,
RyoheiHagimoto 0:0e0631af0305 20 // are permitted provided that the following conditions are met:
RyoheiHagimoto 0:0e0631af0305 21 //
RyoheiHagimoto 0:0e0631af0305 22 // * Redistribution's of source code must retain the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 23 // this list of conditions and the following disclaimer.
RyoheiHagimoto 0:0e0631af0305 24 //
RyoheiHagimoto 0:0e0631af0305 25 // * Redistribution's in binary form must reproduce the above copyright notice,
RyoheiHagimoto 0:0e0631af0305 26 // this list of conditions and the following disclaimer in the documentation
RyoheiHagimoto 0:0e0631af0305 27 // and/or other materials provided with the distribution.
RyoheiHagimoto 0:0e0631af0305 28 //
RyoheiHagimoto 0:0e0631af0305 29 // * The name of the copyright holders may not be used to endorse or promote products
RyoheiHagimoto 0:0e0631af0305 30 // derived from this software without specific prior written permission.
RyoheiHagimoto 0:0e0631af0305 31 //
RyoheiHagimoto 0:0e0631af0305 32 // This software is provided by the copyright holders and contributors "as is" and
RyoheiHagimoto 0:0e0631af0305 33 // any express or implied warranties, including, but not limited to, the implied
RyoheiHagimoto 0:0e0631af0305 34 // warranties of merchantability and fitness for a particular purpose are disclaimed.
RyoheiHagimoto 0:0e0631af0305 35 // In no event shall the Intel Corporation or contributors be liable for any direct,
RyoheiHagimoto 0:0e0631af0305 36 // indirect, incidental, special, exemplary, or consequential damages
RyoheiHagimoto 0:0e0631af0305 37 // (including, but not limited to, procurement of substitute goods or services;
RyoheiHagimoto 0:0e0631af0305 38 // loss of use, data, or profits; or business interruption) however caused
RyoheiHagimoto 0:0e0631af0305 39 // and on any theory of liability, whether in contract, strict liability,
RyoheiHagimoto 0:0e0631af0305 40 // or tort (including negligence or otherwise) arising in any way out of
RyoheiHagimoto 0:0e0631af0305 41 // the use of this software, even if advised of the possibility of such damage.
RyoheiHagimoto 0:0e0631af0305 42 //
RyoheiHagimoto 0:0e0631af0305 43 //M*/
RyoheiHagimoto 0:0e0631af0305 44
RyoheiHagimoto 0:0e0631af0305 45 #ifndef OPENCV_CORE_FAST_MATH_HPP
RyoheiHagimoto 0:0e0631af0305 46 #define OPENCV_CORE_FAST_MATH_HPP
RyoheiHagimoto 0:0e0631af0305 47
RyoheiHagimoto 0:0e0631af0305 48 #include "opencv2/core/cvdef.h"
RyoheiHagimoto 0:0e0631af0305 49
RyoheiHagimoto 0:0e0631af0305 50 //! @addtogroup core_utils
RyoheiHagimoto 0:0e0631af0305 51 //! @{
RyoheiHagimoto 0:0e0631af0305 52
RyoheiHagimoto 0:0e0631af0305 53 /****************************************************************************************\
RyoheiHagimoto 0:0e0631af0305 54 * fast math *
RyoheiHagimoto 0:0e0631af0305 55 \****************************************************************************************/
RyoheiHagimoto 0:0e0631af0305 56
RyoheiHagimoto 0:0e0631af0305 57 #if defined __BORLANDC__
RyoheiHagimoto 0:0e0631af0305 58 # include <fastmath.h>
RyoheiHagimoto 0:0e0631af0305 59 #elif defined __cplusplus
RyoheiHagimoto 0:0e0631af0305 60 # include <cmath>
RyoheiHagimoto 0:0e0631af0305 61 #else
RyoheiHagimoto 0:0e0631af0305 62 # include <math.h>
RyoheiHagimoto 0:0e0631af0305 63 #endif
RyoheiHagimoto 0:0e0631af0305 64
RyoheiHagimoto 0:0e0631af0305 65 #ifdef HAVE_TEGRA_OPTIMIZATION
RyoheiHagimoto 0:0e0631af0305 66 # include "tegra_round.hpp"
RyoheiHagimoto 0:0e0631af0305 67 #endif
RyoheiHagimoto 0:0e0631af0305 68
RyoheiHagimoto 0:0e0631af0305 69 #if CV_VFP
RyoheiHagimoto 0:0e0631af0305 70 // 1. general scheme
RyoheiHagimoto 0:0e0631af0305 71 #define ARM_ROUND(_value, _asm_string) \
RyoheiHagimoto 0:0e0631af0305 72 int res; \
RyoheiHagimoto 0:0e0631af0305 73 float temp; \
RyoheiHagimoto 0:0e0631af0305 74 (void)temp; \
RyoheiHagimoto 0:0e0631af0305 75 asm(_asm_string : [res] "=r" (res), [temp] "=w" (temp) : [value] "w" (_value)); \
RyoheiHagimoto 0:0e0631af0305 76 return res
RyoheiHagimoto 0:0e0631af0305 77 // 2. version for double
RyoheiHagimoto 0:0e0631af0305 78 #ifdef __clang__
RyoheiHagimoto 0:0e0631af0305 79 #define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %[value] \n vmov %[res], %[temp]")
RyoheiHagimoto 0:0e0631af0305 80 #else
RyoheiHagimoto 0:0e0631af0305 81 #define ARM_ROUND_DBL(value) ARM_ROUND(value, "vcvtr.s32.f64 %[temp], %P[value] \n vmov %[res], %[temp]")
RyoheiHagimoto 0:0e0631af0305 82 #endif
RyoheiHagimoto 0:0e0631af0305 83 // 3. version for float
RyoheiHagimoto 0:0e0631af0305 84 #define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
RyoheiHagimoto 0:0e0631af0305 85 #endif // CV_VFP
RyoheiHagimoto 0:0e0631af0305 86
RyoheiHagimoto 0:0e0631af0305 87 /** @brief Rounds floating-point number to the nearest integer
RyoheiHagimoto 0:0e0631af0305 88
RyoheiHagimoto 0:0e0631af0305 89 @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the
RyoheiHagimoto 0:0e0631af0305 90 result is not defined.
RyoheiHagimoto 0:0e0631af0305 91 */
RyoheiHagimoto 0:0e0631af0305 92 CV_INLINE int
RyoheiHagimoto 0:0e0631af0305 93 cvRound( double value )
RyoheiHagimoto 0:0e0631af0305 94 {
RyoheiHagimoto 0:0e0631af0305 95 #if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
RyoheiHagimoto 0:0e0631af0305 96 && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 97 __m128d t = _mm_set_sd( value );
RyoheiHagimoto 0:0e0631af0305 98 return _mm_cvtsd_si32(t);
RyoheiHagimoto 0:0e0631af0305 99 #elif defined _MSC_VER && defined _M_IX86
RyoheiHagimoto 0:0e0631af0305 100 int t;
RyoheiHagimoto 0:0e0631af0305 101 __asm
RyoheiHagimoto 0:0e0631af0305 102 {
RyoheiHagimoto 0:0e0631af0305 103 fld value;
RyoheiHagimoto 0:0e0631af0305 104 fistp t;
RyoheiHagimoto 0:0e0631af0305 105 }
RyoheiHagimoto 0:0e0631af0305 106 return t;
RyoheiHagimoto 0:0e0631af0305 107 #elif ((defined _MSC_VER && defined _M_ARM) || defined CV_ICC || \
RyoheiHagimoto 0:0e0631af0305 108 defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
RyoheiHagimoto 0:0e0631af0305 109 TEGRA_ROUND_DBL(value);
RyoheiHagimoto 0:0e0631af0305 110 #elif defined CV_ICC || defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 111 # if CV_VFP
RyoheiHagimoto 0:0e0631af0305 112 ARM_ROUND_DBL(value);
RyoheiHagimoto 0:0e0631af0305 113 # else
RyoheiHagimoto 0:0e0631af0305 114 return (int)lrint(value);
RyoheiHagimoto 0:0e0631af0305 115 # endif
RyoheiHagimoto 0:0e0631af0305 116 #else
RyoheiHagimoto 0:0e0631af0305 117 /* it's ok if round does not comply with IEEE754 standard;
RyoheiHagimoto 0:0e0631af0305 118 the tests should allow +/-1 difference when the tested functions use round */
RyoheiHagimoto 0:0e0631af0305 119 return (int)(value + (value >= 0 ? 0.5 : -0.5));
RyoheiHagimoto 0:0e0631af0305 120 #endif
RyoheiHagimoto 0:0e0631af0305 121 }
RyoheiHagimoto 0:0e0631af0305 122
RyoheiHagimoto 0:0e0631af0305 123
RyoheiHagimoto 0:0e0631af0305 124 /** @brief Rounds floating-point number to the nearest integer not larger than the original.
RyoheiHagimoto 0:0e0631af0305 125
RyoheiHagimoto 0:0e0631af0305 126 The function computes an integer i such that:
RyoheiHagimoto 0:0e0631af0305 127 \f[i \le \texttt{value} < i+1\f]
RyoheiHagimoto 0:0e0631af0305 128 @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the
RyoheiHagimoto 0:0e0631af0305 129 result is not defined.
RyoheiHagimoto 0:0e0631af0305 130 */
RyoheiHagimoto 0:0e0631af0305 131 CV_INLINE int cvFloor( double value )
RyoheiHagimoto 0:0e0631af0305 132 {
RyoheiHagimoto 0:0e0631af0305 133 #if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 134 __m128d t = _mm_set_sd( value );
RyoheiHagimoto 0:0e0631af0305 135 int i = _mm_cvtsd_si32(t);
RyoheiHagimoto 0:0e0631af0305 136 return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i)));
RyoheiHagimoto 0:0e0631af0305 137 #elif defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 138 int i = (int)value;
RyoheiHagimoto 0:0e0631af0305 139 return i - (i > value);
RyoheiHagimoto 0:0e0631af0305 140 #else
RyoheiHagimoto 0:0e0631af0305 141 int i = cvRound(value);
RyoheiHagimoto 0:0e0631af0305 142 float diff = (float)(value - i);
RyoheiHagimoto 0:0e0631af0305 143 return i - (diff < 0);
RyoheiHagimoto 0:0e0631af0305 144 #endif
RyoheiHagimoto 0:0e0631af0305 145 }
RyoheiHagimoto 0:0e0631af0305 146
RyoheiHagimoto 0:0e0631af0305 147 /** @brief Rounds floating-point number to the nearest integer not smaller than the original.
RyoheiHagimoto 0:0e0631af0305 148
RyoheiHagimoto 0:0e0631af0305 149 The function computes an integer i such that:
RyoheiHagimoto 0:0e0631af0305 150 \f[i \le \texttt{value} < i+1\f]
RyoheiHagimoto 0:0e0631af0305 151 @param value floating-point number. If the value is outside of INT_MIN ... INT_MAX range, the
RyoheiHagimoto 0:0e0631af0305 152 result is not defined.
RyoheiHagimoto 0:0e0631af0305 153 */
RyoheiHagimoto 0:0e0631af0305 154 CV_INLINE int cvCeil( double value )
RyoheiHagimoto 0:0e0631af0305 155 {
RyoheiHagimoto 0:0e0631af0305 156 #if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 157 __m128d t = _mm_set_sd( value );
RyoheiHagimoto 0:0e0631af0305 158 int i = _mm_cvtsd_si32(t);
RyoheiHagimoto 0:0e0631af0305 159 return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t));
RyoheiHagimoto 0:0e0631af0305 160 #elif defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 161 int i = (int)value;
RyoheiHagimoto 0:0e0631af0305 162 return i + (i < value);
RyoheiHagimoto 0:0e0631af0305 163 #else
RyoheiHagimoto 0:0e0631af0305 164 int i = cvRound(value);
RyoheiHagimoto 0:0e0631af0305 165 float diff = (float)(i - value);
RyoheiHagimoto 0:0e0631af0305 166 return i + (diff < 0);
RyoheiHagimoto 0:0e0631af0305 167 #endif
RyoheiHagimoto 0:0e0631af0305 168 }
RyoheiHagimoto 0:0e0631af0305 169
RyoheiHagimoto 0:0e0631af0305 170 /** @brief Determines if the argument is Not A Number.
RyoheiHagimoto 0:0e0631af0305 171
RyoheiHagimoto 0:0e0631af0305 172 @param value The input floating-point value
RyoheiHagimoto 0:0e0631af0305 173
RyoheiHagimoto 0:0e0631af0305 174 The function returns 1 if the argument is Not A Number (as defined by IEEE754 standard), 0
RyoheiHagimoto 0:0e0631af0305 175 otherwise. */
RyoheiHagimoto 0:0e0631af0305 176 CV_INLINE int cvIsNaN( double value )
RyoheiHagimoto 0:0e0631af0305 177 {
RyoheiHagimoto 0:0e0631af0305 178 Cv64suf ieee754;
RyoheiHagimoto 0:0e0631af0305 179 ieee754.f = value;
RyoheiHagimoto 0:0e0631af0305 180 return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
RyoheiHagimoto 0:0e0631af0305 181 ((unsigned)ieee754.u != 0) > 0x7ff00000;
RyoheiHagimoto 0:0e0631af0305 182 }
RyoheiHagimoto 0:0e0631af0305 183
RyoheiHagimoto 0:0e0631af0305 184 /** @brief Determines if the argument is Infinity.
RyoheiHagimoto 0:0e0631af0305 185
RyoheiHagimoto 0:0e0631af0305 186 @param value The input floating-point value
RyoheiHagimoto 0:0e0631af0305 187
RyoheiHagimoto 0:0e0631af0305 188 The function returns 1 if the argument is a plus or minus infinity (as defined by IEEE754 standard)
RyoheiHagimoto 0:0e0631af0305 189 and 0 otherwise. */
RyoheiHagimoto 0:0e0631af0305 190 CV_INLINE int cvIsInf( double value )
RyoheiHagimoto 0:0e0631af0305 191 {
RyoheiHagimoto 0:0e0631af0305 192 Cv64suf ieee754;
RyoheiHagimoto 0:0e0631af0305 193 ieee754.f = value;
RyoheiHagimoto 0:0e0631af0305 194 return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
RyoheiHagimoto 0:0e0631af0305 195 (unsigned)ieee754.u == 0;
RyoheiHagimoto 0:0e0631af0305 196 }
RyoheiHagimoto 0:0e0631af0305 197
RyoheiHagimoto 0:0e0631af0305 198 #ifdef __cplusplus
RyoheiHagimoto 0:0e0631af0305 199
RyoheiHagimoto 0:0e0631af0305 200 /** @overload */
RyoheiHagimoto 0:0e0631af0305 201 CV_INLINE int cvRound(float value)
RyoheiHagimoto 0:0e0631af0305 202 {
RyoheiHagimoto 0:0e0631af0305 203 #if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && \
RyoheiHagimoto 0:0e0631af0305 204 defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 205 __m128 t = _mm_set_ss( value );
RyoheiHagimoto 0:0e0631af0305 206 return _mm_cvtss_si32(t);
RyoheiHagimoto 0:0e0631af0305 207 #elif defined _MSC_VER && defined _M_IX86
RyoheiHagimoto 0:0e0631af0305 208 int t;
RyoheiHagimoto 0:0e0631af0305 209 __asm
RyoheiHagimoto 0:0e0631af0305 210 {
RyoheiHagimoto 0:0e0631af0305 211 fld value;
RyoheiHagimoto 0:0e0631af0305 212 fistp t;
RyoheiHagimoto 0:0e0631af0305 213 }
RyoheiHagimoto 0:0e0631af0305 214 return t;
RyoheiHagimoto 0:0e0631af0305 215 #elif ((defined _MSC_VER && defined _M_ARM) || defined CV_ICC || \
RyoheiHagimoto 0:0e0631af0305 216 defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
RyoheiHagimoto 0:0e0631af0305 217 TEGRA_ROUND_FLT(value);
RyoheiHagimoto 0:0e0631af0305 218 #elif defined CV_ICC || defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 219 # if CV_VFP
RyoheiHagimoto 0:0e0631af0305 220 ARM_ROUND_FLT(value);
RyoheiHagimoto 0:0e0631af0305 221 # else
RyoheiHagimoto 0:0e0631af0305 222 return (int)lrintf(value);
RyoheiHagimoto 0:0e0631af0305 223 # endif
RyoheiHagimoto 0:0e0631af0305 224 #else
RyoheiHagimoto 0:0e0631af0305 225 /* it's ok if round does not comply with IEEE754 standard;
RyoheiHagimoto 0:0e0631af0305 226 the tests should allow +/-1 difference when the tested functions use round */
RyoheiHagimoto 0:0e0631af0305 227 return (int)(value + (value >= 0 ? 0.5f : -0.5f));
RyoheiHagimoto 0:0e0631af0305 228 #endif
RyoheiHagimoto 0:0e0631af0305 229 }
RyoheiHagimoto 0:0e0631af0305 230
RyoheiHagimoto 0:0e0631af0305 231 /** @overload */
RyoheiHagimoto 0:0e0631af0305 232 CV_INLINE int cvRound( int value )
RyoheiHagimoto 0:0e0631af0305 233 {
RyoheiHagimoto 0:0e0631af0305 234 return value;
RyoheiHagimoto 0:0e0631af0305 235 }
RyoheiHagimoto 0:0e0631af0305 236
RyoheiHagimoto 0:0e0631af0305 237 /** @overload */
RyoheiHagimoto 0:0e0631af0305 238 CV_INLINE int cvFloor( float value )
RyoheiHagimoto 0:0e0631af0305 239 {
RyoheiHagimoto 0:0e0631af0305 240 #if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 241 __m128 t = _mm_set_ss( value );
RyoheiHagimoto 0:0e0631af0305 242 int i = _mm_cvtss_si32(t);
RyoheiHagimoto 0:0e0631af0305 243 return i - _mm_movemask_ps(_mm_cmplt_ss(t, _mm_cvtsi32_ss(t,i)));
RyoheiHagimoto 0:0e0631af0305 244 #elif defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 245 int i = (int)value;
RyoheiHagimoto 0:0e0631af0305 246 return i - (i > value);
RyoheiHagimoto 0:0e0631af0305 247 #else
RyoheiHagimoto 0:0e0631af0305 248 int i = cvRound(value);
RyoheiHagimoto 0:0e0631af0305 249 float diff = (float)(value - i);
RyoheiHagimoto 0:0e0631af0305 250 return i - (diff < 0);
RyoheiHagimoto 0:0e0631af0305 251 #endif
RyoheiHagimoto 0:0e0631af0305 252 }
RyoheiHagimoto 0:0e0631af0305 253
RyoheiHagimoto 0:0e0631af0305 254 /** @overload */
RyoheiHagimoto 0:0e0631af0305 255 CV_INLINE int cvFloor( int value )
RyoheiHagimoto 0:0e0631af0305 256 {
RyoheiHagimoto 0:0e0631af0305 257 return value;
RyoheiHagimoto 0:0e0631af0305 258 }
RyoheiHagimoto 0:0e0631af0305 259
RyoheiHagimoto 0:0e0631af0305 260 /** @overload */
RyoheiHagimoto 0:0e0631af0305 261 CV_INLINE int cvCeil( float value )
RyoheiHagimoto 0:0e0631af0305 262 {
RyoheiHagimoto 0:0e0631af0305 263 #if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
RyoheiHagimoto 0:0e0631af0305 264 __m128 t = _mm_set_ss( value );
RyoheiHagimoto 0:0e0631af0305 265 int i = _mm_cvtss_si32(t);
RyoheiHagimoto 0:0e0631af0305 266 return i + _mm_movemask_ps(_mm_cmplt_ss(_mm_cvtsi32_ss(t,i), t));
RyoheiHagimoto 0:0e0631af0305 267 #elif defined __GNUC__
RyoheiHagimoto 0:0e0631af0305 268 int i = (int)value;
RyoheiHagimoto 0:0e0631af0305 269 return i + (i < value);
RyoheiHagimoto 0:0e0631af0305 270 #else
RyoheiHagimoto 0:0e0631af0305 271 int i = cvRound(value);
RyoheiHagimoto 0:0e0631af0305 272 float diff = (float)(i - value);
RyoheiHagimoto 0:0e0631af0305 273 return i + (diff < 0);
RyoheiHagimoto 0:0e0631af0305 274 #endif
RyoheiHagimoto 0:0e0631af0305 275 }
RyoheiHagimoto 0:0e0631af0305 276
RyoheiHagimoto 0:0e0631af0305 277 /** @overload */
RyoheiHagimoto 0:0e0631af0305 278 CV_INLINE int cvCeil( int value )
RyoheiHagimoto 0:0e0631af0305 279 {
RyoheiHagimoto 0:0e0631af0305 280 return value;
RyoheiHagimoto 0:0e0631af0305 281 }
RyoheiHagimoto 0:0e0631af0305 282
RyoheiHagimoto 0:0e0631af0305 283 /** @overload */
RyoheiHagimoto 0:0e0631af0305 284 CV_INLINE int cvIsNaN( float value )
RyoheiHagimoto 0:0e0631af0305 285 {
RyoheiHagimoto 0:0e0631af0305 286 Cv32suf ieee754;
RyoheiHagimoto 0:0e0631af0305 287 ieee754.f = value;
RyoheiHagimoto 0:0e0631af0305 288 return (ieee754.u & 0x7fffffff) > 0x7f800000;
RyoheiHagimoto 0:0e0631af0305 289 }
RyoheiHagimoto 0:0e0631af0305 290
RyoheiHagimoto 0:0e0631af0305 291 /** @overload */
RyoheiHagimoto 0:0e0631af0305 292 CV_INLINE int cvIsInf( float value )
RyoheiHagimoto 0:0e0631af0305 293 {
RyoheiHagimoto 0:0e0631af0305 294 Cv32suf ieee754;
RyoheiHagimoto 0:0e0631af0305 295 ieee754.f = value;
RyoheiHagimoto 0:0e0631af0305 296 return (ieee754.u & 0x7fffffff) == 0x7f800000;
RyoheiHagimoto 0:0e0631af0305 297 }
RyoheiHagimoto 0:0e0631af0305 298
RyoheiHagimoto 0:0e0631af0305 299 #endif // __cplusplus
RyoheiHagimoto 0:0e0631af0305 300
RyoheiHagimoto 0:0e0631af0305 301 //! @} core_utils
RyoheiHagimoto 0:0e0631af0305 302
RyoheiHagimoto 0:0e0631af0305 303 #endif