HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SYS_MathPermute.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: SYS_MathPermute.h ( SYS Library, C++)
7  *
8  * COMMENTS: This header file defines all the impure permutations of
9  * fpreal32 and fpreal64 for the SYS_Math.h library functions.
10  * All fpreal32's are cast up to fpreal64 for the computations.
11  */
12 
13 #ifndef __SYS_MathPermute__
14 #define __SYS_MathPermute__
15 
16 #ifndef __SYS_Math__
17  #error "SYS_MathPermute.h should only be included by SYS_Math.h"
18 #endif
19 
20 #define _ARGS_2_IMPL(fname, CONSTEXPR) \
21  static CONSTEXPR inline fpreal64 fname(fpreal32 a, fpreal64 b) \
22  { return fname((fpreal64)a, b); } \
23  static CONSTEXPR inline fpreal64 fname(fpreal64 a, fpreal32 b) \
24  { return fname(a, (fpreal64)b); } \
25 
26 #define ARGS_2(fname) _ARGS_2_IMPL(fname, )
27 #define ARGS_2_CE(fname) _ARGS_2_IMPL(fname, constexpr)
28 
29 #define _ARGS_3_IMPL(fname, CONSTEXPR) \
30  static CONSTEXPR inline fpreal64 fname(fpreal32 a, fpreal64 b, fpreal64 c) \
31  { return fname((fpreal64)a, b, c); } \
32  static CONSTEXPR inline fpreal64 fname(fpreal64 a, fpreal32 b, fpreal64 c) \
33  { return fname(a, (fpreal64)b, c); } \
34  static CONSTEXPR inline fpreal64 fname(fpreal32 a, fpreal32 b, fpreal64 c) \
35  { return fname((fpreal64)a, (fpreal64)b, c); } \
36  static CONSTEXPR inline fpreal64 fname(fpreal64 a, fpreal64 b, fpreal32 c) \
37  { return fname(a, b, (fpreal64)c); } \
38  static CONSTEXPR inline fpreal64 fname(fpreal32 a, fpreal64 b, fpreal32 c) \
39  { return fname((fpreal64)a, b, (fpreal64)c); } \
40  static CONSTEXPR inline fpreal64 fname(fpreal64 a, fpreal32 b, fpreal32 c) \
41  { return fname(a, (fpreal64)b, (fpreal64)c); }
42 
43 #define ARGS_3(fname) _ARGS_3_IMPL(fname, )
44 #define ARGS_3_CE(fname) _ARGS_3_IMPL(fname, constexpr)
45 
46 #define _ARGS_4_IMPL(fname, CONSTEXPR) \
47  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal32 b,fpreal32 c,fpreal32 d) \
48  { return fname(a, (fpreal64)b, (fpreal64)c, (fpreal64)d); } \
49  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal64 b,fpreal32 c,fpreal32 d) \
50  { return fname((fpreal64)a, b, (fpreal64)c, (fpreal64)d); } \
51  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal64 b,fpreal32 c,fpreal32 d) \
52  { return fname(a, b, (fpreal64)c, (fpreal64)d); } \
53  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal32 b,fpreal64 c,fpreal32 d) \
54  { return fname((fpreal64)a, (fpreal64)b, c, (fpreal64)d); } \
55  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal32 b,fpreal64 c,fpreal32 d) \
56  { return fname(a, (fpreal64)b, c, (fpreal64)d); } \
57  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal64 b,fpreal64 c,fpreal32 d) \
58  { return fname((fpreal64)a, b, c, (fpreal64)d); } \
59  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal64 b,fpreal64 c,fpreal32 d) \
60  { return fname(a, b, c, (fpreal64)d); } \
61  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal32 b,fpreal32 c,fpreal64 d) \
62  { return fname((fpreal64)a, (fpreal64)b, (fpreal64)c, d); } \
63  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal32 b,fpreal32 c,fpreal64 d) \
64  { return fname(a, (fpreal64)b, (fpreal64)c, d); } \
65  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal64 b,fpreal32 c,fpreal64 d) \
66  { return fname((fpreal64)a, b, (fpreal64)c, d); } \
67  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal64 b,fpreal32 c,fpreal64 d) \
68  { return fname(a, b, (fpreal64)c, d); } \
69  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal32 b,fpreal64 c,fpreal64 d) \
70  { return fname((fpreal64)a, (fpreal64)b, c, d); } \
71  static CONSTEXPR inline fpreal64 fname(fpreal64 a,fpreal32 b,fpreal64 c,fpreal64 d) \
72  { return fname(a, (fpreal64)b, c, d); } \
73  static CONSTEXPR inline fpreal64 fname(fpreal32 a,fpreal64 b,fpreal64 c,fpreal64 d) \
74  { return fname((fpreal64)a, b, c, d); }
75 
76 #define ARGS_4(fname) _ARGS_4_IMPL(fname, )
77 #define ARGS_4_CE(fname) _ARGS_4_IMPL(fname, constexpr)
78 
85 ARGS_3_CE(SYSavg)
86 ARGS_4_CE(SYSavg)
87 
90 ARGS_3_CE(SYSsmooth)
91 ARGS_4_CE(SYSsmooth)
92 
93 // TODO: SYSminmax
94 // TODO: SYSfit
95 
96 ARGS_2(SYSatan)
97 ARGS_2(SYSatan2)
98 ARGS_2(SYShypot)
99 
101 
102 static constexpr inline bool
104  { return SYSequalZero(v, (fpreal32)tol); }
105 
106 static constexpr inline bool
108  { return SYSequalZero(v, (fpreal64)tol); }
109 
110 #define _CMP_PERM_IMPL(fname, CONSTEXPR) \
111  static CONSTEXPR inline bool fname(fpreal32 a, fpreal32 b, fpreal64 tol) \
112  { return fname(a, b, (fpreal32)tol); } \
113  static CONSTEXPR inline bool fname(fpreal64 a, fpreal64 b, fpreal32 tol) \
114  { return fname(a, b, (fpreal64)tol); } \
115  static CONSTEXPR inline bool fname(fpreal32 a, fpreal64 b, fpreal32 tol) \
116  { return fname((fpreal64)a, b, (fpreal64)tol); } \
117  static CONSTEXPR inline bool fname(fpreal64 a, fpreal32 b, fpreal32 tol) \
118  { return fname(a, (fpreal64)b, (fpreal64)tol); } \
119  static CONSTEXPR inline bool fname(fpreal32 a, fpreal64 b, fpreal64 tol=SYS_FTOLERANCE_D) \
120  { return fname((fpreal64)a, b, tol); } \
121  static CONSTEXPR inline bool fname(fpreal64 a, fpreal32 b, fpreal64 tol=SYS_FTOLERANCE_D) \
122  { return fname(a, (fpreal64)b, tol); } \
123  static CONSTEXPR inline bool fname(fpreal32 a, int b, fpreal32 tol=SYS_FTOLERANCE) \
124  { return fname(a, (fpreal32)b, tol); } \
125  static CONSTEXPR inline bool fname(fpreal32 a, int b, fpreal64 tol) \
126  { return fname((fpreal64)a, (fpreal64)b, tol); } \
127  static CONSTEXPR inline bool fname(fpreal64 a, int b, fpreal64 tol=SYS_FTOLERANCE_D) \
128  { return fname(a, (fpreal64)b, tol); } \
129  static CONSTEXPR inline bool fname(int a, fpreal32 b, fpreal32 tol=SYS_FTOLERANCE) \
130  { return fname((fpreal32)a, b, tol); } \
131  static CONSTEXPR inline bool fname(int a, fpreal32 b, fpreal64 tol) \
132  { return fname((fpreal64)a, (fpreal64)b, tol); } \
133  static CONSTEXPR inline bool fname(int a, fpreal64 b, fpreal64 tol=SYS_FTOLERANCE_D) \
134  { return fname((fpreal64)a, b, tol); }
135 
136 #define CMP_PERM(fname) _CMP_PERM_IMPL(fname, )
137 #define CMP_PERM_CE(fname) _CMP_PERM_IMPL(fname, constexpr)
138 
139 CMP_PERM(SYSisEqual)
140 CMP_PERM_CE(SYSisGreater)
141 CMP_PERM_CE(SYSisGreaterOrEqual)
142 CMP_PERM_CE(SYSisLess)
143 CMP_PERM_CE(SYSisLessOrEqual)
144 
145 #undef CMP_PERM_CE
146 #undef CMP_PERM
147 #undef _CMP_PERM_IMPL
148 #undef ARGS_2_CE
149 #undef ARGS_2
150 #undef _ARGS_2_IMPL
151 #undef ARGS_3_CE
152 #undef ARGS_3
153 #undef _ARGS_3_IMPL
154 #undef ARGS_4_CE
155 #undef ARGS_4
156 #undef _ARGS_4_IMPL
157 
158 #endif
#define SYSmax(a, b)
Definition: SYS_Math.h:1513
#define ARGS_2_CE(fname)
UT_Matrix2T< T > SYSlerp(const UT_Matrix2T< T > &v1, const UT_Matrix2T< T > &v2, S t)
Definition: UT_Matrix2.h:652
float fpreal32
Definition: SYS_Types.h:200
double fpreal64
Definition: SYS_Types.h:201
#define ARGS_2(fname)
const GLdouble * v
Definition: glcorearb.h:837
SYS_API fpreal32 SYSroundAngle(fpreal32 base, fpreal32 source)
UT_Vector3T< T > SYSclamp(const UT_Vector3T< T > &v, const UT_Vector3T< T > &min, const UT_Vector3T< T > &max)
Definition: UT_Vector3.h:1039
#define ARGS_4_CE(fname)
#define CMP_PERM(fname)
bool SYSequalZero(const UT_Vector3T< T > &v)
Definition: UT_Vector3.h:1051
#define ARGS_3_CE(fname)
#define CMP_PERM_CE(fname)
#define SYSmin(a, b)
Definition: SYS_Math.h:1514