include/opencv2/gpu/device/limits.hpp
Go to the documentation of this file.
00001 /*M///////////////////////////////////////////////////////////////////////////////////////
00002 //
00003 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
00004 //
00005 //  By downloading, copying, installing or using the software you agree to this license.
00006 //  If you do not agree to this license, do not download, install,
00007 //  copy or use the software.
00008 //
00009 //
00010 //                           License Agreement
00011 //                For Open Source Computer Vision Library
00012 //
00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
00015 // Third party copyrights are property of their respective owners.
00016 //
00017 // Redistribution and use in source and binary forms, with or without modification,
00018 // are permitted provided that the following conditions are met:
00019 //
00020 //   * Redistribution's of source code must retain the above copyright notice,
00021 //     this list of conditions and the following disclaimer.
00022 //
00023 //   * Redistribution's in binary form must reproduce the above copyright notice,
00024 //     this list of conditions and the following disclaimer in the documentation
00025 //     and/or other materials provided with the distribution.
00026 //
00027 //   * The name of the copyright holders may not be used to endorse or promote products
00028 //     derived from this software without specific prior written permission.
00029 //
00030 // This software is provided by the copyright holders and contributors "as is" and
00031 // any express or implied warranties, including, but not limited to, the implied
00032 // warranties of merchantability and fitness for a particular purpose are disclaimed.
00033 // In no event shall the Intel Corporation or contributors be liable for any direct,
00034 // indirect, incidental, special, exemplary, or consequential damages
00035 // (including, but not limited to, procurement of substitute goods or services;
00036 // loss of use, data, or profits; or business interruption) however caused
00037 // and on any theory of liability, whether in contract, strict liability,
00038 // or tort (including negligence or otherwise) arising in any way out of
00039 // the use of this software, even if advised of the possibility of such damage.
00040 //
00041 //M*/
00042 
00043 #ifndef __OPENCV_GPU_LIMITS_GPU_HPP__
00044 #define __OPENCV_GPU_LIMITS_GPU_HPP__
00045 
00046 #include <limits>
00047 #include "common.hpp"
00048 
00049 namespace cv { namespace gpu { namespace device
00050 {
00051     template<class T> struct numeric_limits
00052     {
00053         typedef T type;
00054         __device__ __forceinline__ static type min()  { return type(); };
00055         __device__ __forceinline__ static type max() { return type(); };
00056         __device__ __forceinline__ static type epsilon() { return type(); }
00057         __device__ __forceinline__ static type round_error() { return type(); }
00058         __device__ __forceinline__ static type denorm_min()  { return type(); }
00059         __device__ __forceinline__ static type infinity() { return type(); }
00060         __device__ __forceinline__ static type quiet_NaN() { return type(); }
00061         __device__ __forceinline__ static type signaling_NaN() { return T(); }
00062         static const bool is_signed;
00063     };
00064 
00065     template<> struct numeric_limits<bool>
00066     {
00067         typedef bool type;
00068         __device__ __forceinline__ static type min() { return false; };
00069         __device__ __forceinline__ static type max() { return true;  };
00070         __device__ __forceinline__ static type epsilon();
00071         __device__ __forceinline__ static type round_error();
00072         __device__ __forceinline__ static type denorm_min();
00073         __device__ __forceinline__ static type infinity();
00074         __device__ __forceinline__ static type quiet_NaN();
00075         __device__ __forceinline__ static type signaling_NaN();
00076         static const bool is_signed = false;
00077     };
00078 
00079     template<> struct numeric_limits<char>
00080     {
00081         typedef char type;
00082         __device__ __forceinline__ static type min() { return CHAR_MIN; };
00083         __device__ __forceinline__ static type max() { return CHAR_MAX; };
00084         __device__ __forceinline__ static type epsilon();
00085         __device__ __forceinline__ static type round_error();
00086         __device__ __forceinline__ static type denorm_min();
00087         __device__ __forceinline__ static type infinity();
00088         __device__ __forceinline__ static type quiet_NaN();
00089         __device__ __forceinline__ static type signaling_NaN();
00090         static const bool is_signed = (char)-1 == -1;
00091     };
00092 
00093     template<> struct numeric_limits<signed char>
00094     {
00095         typedef char type;
00096         __device__ __forceinline__ static type min() { return SCHAR_MIN; };
00097         __device__ __forceinline__ static type max() { return SCHAR_MAX; };
00098         __device__ __forceinline__ static type epsilon();
00099         __device__ __forceinline__ static type round_error();
00100         __device__ __forceinline__ static type denorm_min();
00101         __device__ __forceinline__ static type infinity();
00102         __device__ __forceinline__ static type quiet_NaN();
00103         __device__ __forceinline__ static type signaling_NaN();
00104         static const bool is_signed = (signed char)-1 == -1;
00105     };
00106 
00107     template<> struct numeric_limits<unsigned char>
00108     {
00109         typedef unsigned char type;
00110         __device__ __forceinline__ static type min() { return 0; };
00111         __device__ __forceinline__ static type max() { return UCHAR_MAX; };
00112         __device__ __forceinline__ static type epsilon();
00113         __device__ __forceinline__ static type round_error();
00114         __device__ __forceinline__ static type denorm_min();
00115         __device__ __forceinline__ static type infinity();
00116         __device__ __forceinline__ static type quiet_NaN();
00117         __device__ __forceinline__ static type signaling_NaN();
00118         static const bool is_signed = false;
00119     };
00120 
00121     template<> struct numeric_limits<short>
00122     {
00123         typedef short type;
00124         __device__ __forceinline__ static type min() { return SHRT_MIN; };
00125         __device__ __forceinline__ static type max() { return SHRT_MAX; };
00126         __device__ __forceinline__ static type epsilon();
00127         __device__ __forceinline__ static type round_error();
00128         __device__ __forceinline__ static type denorm_min();
00129         __device__ __forceinline__ static type infinity();
00130         __device__ __forceinline__ static type quiet_NaN();
00131         __device__ __forceinline__ static type signaling_NaN();
00132         static const bool is_signed = true;
00133     };
00134 
00135     template<> struct numeric_limits<unsigned short>
00136     {
00137         typedef unsigned short type;
00138         __device__ __forceinline__ static type min() { return 0; };
00139         __device__ __forceinline__ static type max() { return USHRT_MAX; };
00140         __device__ __forceinline__ static type epsilon();
00141         __device__ __forceinline__ static type round_error();
00142         __device__ __forceinline__ static type denorm_min();
00143         __device__ __forceinline__ static type infinity();
00144         __device__ __forceinline__ static type quiet_NaN();
00145         __device__ __forceinline__ static type signaling_NaN();
00146         static const bool is_signed = false;
00147     };
00148 
00149     template<> struct numeric_limits<int>
00150     {
00151         typedef int type;
00152         __device__ __forceinline__ static type min() { return INT_MIN; };
00153         __device__ __forceinline__ static type max() { return INT_MAX; };
00154         __device__ __forceinline__ static type epsilon();
00155         __device__ __forceinline__ static type round_error();
00156         __device__ __forceinline__ static type denorm_min();
00157         __device__ __forceinline__ static type infinity();
00158         __device__ __forceinline__ static type quiet_NaN();
00159         __device__ __forceinline__ static type signaling_NaN();
00160         static const bool is_signed = true;
00161     };
00162 
00163 
00164     template<> struct numeric_limits<unsigned int>
00165     {
00166         typedef unsigned int type;
00167         __device__ __forceinline__ static type min() { return 0; };
00168         __device__ __forceinline__ static type max() { return UINT_MAX; };
00169         __device__ __forceinline__ static type epsilon();
00170         __device__ __forceinline__ static type round_error();
00171         __device__ __forceinline__ static type denorm_min();
00172         __device__ __forceinline__ static type infinity();
00173         __device__ __forceinline__ static type quiet_NaN();
00174         __device__ __forceinline__ static type signaling_NaN();
00175         static const bool is_signed = false;
00176     };
00177 
00178     template<> struct numeric_limits<long>
00179     {
00180         typedef long type;
00181         __device__ __forceinline__ static type min() { return LONG_MIN; };
00182         __device__ __forceinline__ static type max() { return LONG_MAX; };
00183         __device__ __forceinline__ static type epsilon();
00184         __device__ __forceinline__ static type round_error();
00185         __device__ __forceinline__ static type denorm_min();
00186         __device__ __forceinline__ static type infinity();
00187         __device__ __forceinline__ static type quiet_NaN();
00188         __device__ __forceinline__ static type signaling_NaN();
00189         static const bool is_signed = true;
00190     };
00191 
00192     template<> struct numeric_limits<unsigned long>
00193     {
00194         typedef unsigned long type;
00195         __device__ __forceinline__ static type min() { return 0; };
00196         __device__ __forceinline__ static type max() { return ULONG_MAX; };
00197         __device__ __forceinline__ static type epsilon();
00198         __device__ __forceinline__ static type round_error();
00199         __device__ __forceinline__ static type denorm_min();
00200         __device__ __forceinline__ static type infinity();
00201         __device__ __forceinline__ static type quiet_NaN();
00202         __device__ __forceinline__ static type signaling_NaN();
00203         static const bool is_signed = false;
00204     };
00205 
00206     template<> struct numeric_limits<float>
00207     {
00208         typedef float type;
00209         __device__ __forceinline__ static type min() { return 1.175494351e-38f/*FLT_MIN*/; };
00210         __device__ __forceinline__ static type max() { return 3.402823466e+38f/*FLT_MAX*/; };
00211         __device__ __forceinline__ static type epsilon() { return 1.192092896e-07f/*FLT_EPSILON*/; };
00212         __device__ __forceinline__ static type round_error();
00213         __device__ __forceinline__ static type denorm_min();
00214         __device__ __forceinline__ static type infinity();
00215         __device__ __forceinline__ static type quiet_NaN();
00216         __device__ __forceinline__ static type signaling_NaN();
00217         static const bool is_signed = true;
00218     };
00219 
00220     template<> struct numeric_limits<double>
00221     {
00222         typedef double type;
00223         __device__ __forceinline__ static type min() { return 2.2250738585072014e-308/*DBL_MIN*/; };
00224         __device__ __forceinline__ static type max() { return 1.7976931348623158e+308/*DBL_MAX*/; };
00225         __device__ __forceinline__ static type epsilon();
00226         __device__ __forceinline__ static type round_error();
00227         __device__ __forceinline__ static type denorm_min();
00228         __device__ __forceinline__ static type infinity();
00229         __device__ __forceinline__ static type quiet_NaN();
00230         __device__ __forceinline__ static type signaling_NaN();
00231         static const bool is_signed = true;
00232     };
00233 }}} // namespace cv { namespace gpu { namespace device {
00234 
00235 #endif // __OPENCV_GPU_LIMITS_GPU_HPP__