/usr/include/synfig-1.0/synfig/real.h is in libsynfig-dev 1.2.1-0ubuntu4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | /* === S Y N F I G ========================================================= */
/*! \file real.h
** \brief Provides the synfig::Real typedef
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of
** the License, or (at your option) any later version.
**
** This package is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** General Public License for more details.
** \endlegal
*/
/* ========================================================================= */
/* === S T A R T =========================================================== */
#ifndef __SYNFIG_REAL_H
#define __SYNFIG_REAL_H
#include <cmath>
#include <functional>
/* === T Y P E D E F S ===================================================== */
namespace synfig {
/*! \typedef Real
** \todo writeme
*/
typedef double Real;
template<typename T>
inline T real_low_precision()
{ return T(1e-6); }
template<typename T>
inline T real_precision()
{ return T(1e-8); }
template<typename T>
inline T real_high_precision()
{ return T(1e-10); }
// comparison should be symmetric
// approximate_equal(a, b) absolutely identical to approximate_equal(b, a)
// this code should be equal to code of functions less and less_or_equal
template<typename T>
inline bool approximate_equal_custom(const T &a, const T &b, const T &precision)
{ return a < b ? b - a < precision : a - b < precision; }
template<typename T>
inline bool approximate_not_equal_custom(const T &a, const T &b, const T &precision)
{ return !approximate_equal_custom(a, b, precision); }
template<typename T>
inline bool approximate_less_custom(const T &a, const T &b, const T &precision)
{ return a < b && b - a >= precision; }
template<typename T>
inline bool approximate_greater_custom(const T &a, const T &b, const T &precision)
{ return approximate_less_custom(b, a, precision); }
template<typename T>
inline bool approximate_less_or_equal_custom(const T &a, const T &b, const T &precision)
{ return a < b || a - b < precision; }
template<typename T>
inline bool approximate_greater_or_equal_custom(const T &a, const T &b, const T &precision)
{ return approximate_less_or_equal_custom(b, a, precision); }
template<typename T>
inline T approximate_floor_custom(const T &a, const T &precision)
{ return std::floor(a + precision); }
template<typename T>
inline T approximate_ceil_custom(const T &a, const T &precision)
{ return std::ceil(a - precision); }
template<typename T>
inline bool approximate_equal(const T &a, const T &b)
{ return approximate_equal_custom(a, b, real_precision<T>()); }
template<typename T>
inline bool approximate_not_equal(const T &a, const T &b)
{ return approximate_not_equal_custom(a, b, real_precision<T>()); }
template<typename T>
inline bool approximate_less(const T &a, const T &b)
{ return approximate_less_custom(a, b, real_precision<T>()); }
template<typename T>
inline bool approximate_greater(const T &a, const T &b)
{ return approximate_greater_custom(a, b, real_precision<T>()); }
template<typename T>
inline bool approximate_less_or_equal(const T &a, const T &b)
{ return approximate_less_or_equal_custom(a, b, real_precision<T>()); }
template<typename T>
inline bool approximate_greater_or_equal(const T &a, const T &b)
{ return approximate_greater_or_equal_custom(a, b, real_precision<T>()); }
template<typename T>
inline T approximate_floor(const T &a)
{ return approximate_floor_custom(a, real_precision<T>()); }
template<typename T>
inline T approximate_ceil(const T &a)
{ return approximate_ceil_custom(a, real_precision<T>()); }
template<typename T>
inline bool approximate_equal_lp(const T &a, const T &b)
{ return approximate_equal_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline bool approximate_not_equal_lp(const T &a, const T &b)
{ return approximate_not_equal_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline bool approximate_less_lp(const T &a, const T &b)
{ return approximate_less_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline bool approximate_greater_lp(const T &a, const T &b)
{ return approximate_greater_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline bool approximate_less_or_equal_lp(const T &a, const T &b)
{ return approximate_less_or_equal_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline bool approximate_greater_or_equal_lp(const T &a, const T &b)
{ return approximate_greater_or_equal_custom(a, b, real_low_precision<T>()); }
template<typename T>
inline T approximate_floor_lp(const T &a)
{ return approximate_floor_custom(a, real_low_precision<T>()); }
template<typename T>
inline T approximate_ceil_lp(const T &a)
{ return approximate_ceil_custom(a, real_low_precision<T>()); }
template<typename T>
inline bool approximate_equal_hp(const T &a, const T &b)
{ return approximate_equal_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline bool approximate_not_equal_hp(const T &a, const T &b)
{ return approximate_not_equal_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline bool approximate_less_hp(const T &a, const T &b)
{ return approximate_less_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline bool approximate_greater_hp(const T &a, const T &b)
{ return approximate_greater_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline bool approximate_less_or_equal_hp(const T &a, const T &b)
{ return approximate_less_or_equal_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline bool approximate_greater_or_equal_hp(const T &a, const T &b)
{ return approximate_greater_or_equal_custom(a, b, real_high_precision<T>()); }
template<typename T>
inline T approximate_floor_hp(const T &a)
{ return approximate_floor_custom(a, real_high_precision<T>()); }
template<typename T>
inline T approximate_ceil_hp(const T &a)
{ return approximate_ceil_custom(a, real_high_precision<T>()); }
template<typename T, bool func(const T&, const T&)>
struct RealFunctionWrapper : public std::binary_function<T,T,bool>
{ bool operator() (const T &a, const T &b) const { return func(a, b); } };
}; // END of namespace synfig
/* === E N D =============================================================== */
#endif
|