00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 #ifndef SHLIBBOOLEANIMPL_HPP
00028 #define SHLIBBOOLEANIMPL_HPP
00029
00030 #include "ShLibBoolean.hpp"
00031 #include "ShInstructions.hpp"
00032 #include "ShAttrib.hpp"
00033
00034 namespace SH {
00035
00036 template<int N, typename T1, typename T2>
00037 ShGeneric<N, CT1T2> operator<(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00038 {
00039 ShAttrib<N, SH_TEMP, CT1T2> t;
00040 shSLT(t, left, right);
00041 return t;
00042 }
00043 template<int N, typename T1, typename T2>
00044 ShGeneric<N, CT1T2> operator<(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00045 {
00046 ShAttrib<N, SH_TEMP, CT1T2> t;
00047 shSLT(t, left, right);
00048 return t;
00049 }
00050 template<int N, typename T1, typename T2>
00051 ShGeneric<N, CT1T2> operator<(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00052 {
00053 ShAttrib<N, SH_TEMP, CT1T2> t;
00054 shSLT(t, left, right);
00055 return t;
00056 }
00057 template<typename T1, typename T2>
00058 ShGeneric<1, CT1T2> operator<(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00059 {
00060 ShAttrib<1, SH_TEMP, CT1T2> t;
00061 shSLT(t, left, right);
00062 return t;
00063 }
00064 SH_SHLIB_CONST_SCALAR_OP(operator<);
00065 SH_SHLIB_CONST_N_OP_BOTH(operator<);
00066
00067 template<int N, typename T1, typename T2>
00068 ShGeneric<N, CT1T2> operator<=(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00069 {
00070 ShAttrib<N, SH_TEMP, CT1T2> t;
00071 shSLE(t, left, right);
00072 return t;
00073 }
00074 template<int N, typename T1, typename T2>
00075 ShGeneric<N, CT1T2> operator<=(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00076 {
00077 ShAttrib<N, SH_TEMP, CT1T2> t;
00078 shSLE(t, left, right);
00079 return t;
00080 }
00081 template<int N, typename T1, typename T2>
00082 ShGeneric<N, CT1T2> operator<=(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00083 {
00084 ShAttrib<N, SH_TEMP, CT1T2> t;
00085 shSLE(t, left, right);
00086 return t;
00087 }
00088 template<typename T1, typename T2>
00089 ShGeneric<1, CT1T2> operator<=(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00090 {
00091 ShAttrib<1, SH_TEMP, CT1T2> t;
00092 shSLE(t, left, right);
00093 return t;
00094 }
00095 SH_SHLIB_CONST_SCALAR_OP(operator<=);
00096 SH_SHLIB_CONST_N_OP_BOTH(operator<=);
00097
00098 template<int N, typename T1, typename T2>
00099 ShGeneric<N, CT1T2> operator>(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00100 {
00101 ShAttrib<N, SH_TEMP, CT1T2> t;
00102 shSGT(t, left, right);
00103 return t;
00104 }
00105 template<int N, typename T1, typename T2>
00106 ShGeneric<N, CT1T2> operator>(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00107 {
00108 ShAttrib<N, SH_TEMP, CT1T2> t;
00109 shSGT(t, left, right);
00110 return t;
00111 }
00112 template<int N, typename T1, typename T2>
00113 ShGeneric<N, CT1T2> operator>(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00114 {
00115 ShAttrib<N, SH_TEMP, CT1T2> t;
00116 shSGT(t, left, right);
00117 return t;
00118 }
00119 template<typename T1, typename T2>
00120 ShGeneric<1, CT1T2> operator>(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00121 {
00122 ShAttrib<1, SH_TEMP, CT1T2> t;
00123 shSGT(t, left, right);
00124 return t;
00125 }
00126 SH_SHLIB_CONST_SCALAR_OP(operator>);
00127 SH_SHLIB_CONST_N_OP_BOTH(operator>);
00128
00129 template<int N, typename T1, typename T2>
00130 ShGeneric<N, CT1T2> operator>=(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00131 {
00132 ShAttrib<N, SH_TEMP, CT1T2> t;
00133 shSGE(t, left, right);
00134 return t;
00135 }
00136 template<int N, typename T1, typename T2>
00137 ShGeneric<N, CT1T2> operator>=(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00138 {
00139 ShAttrib<N, SH_TEMP, CT1T2> t;
00140 shSGE(t, left, right);
00141 return t;
00142 }
00143 template<int N, typename T1, typename T2>
00144 ShGeneric<N, CT1T2> operator>=(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00145 {
00146 ShAttrib<N, SH_TEMP, CT1T2> t;
00147 shSGE(t, left, right);
00148 return t;
00149 }
00150 template<typename T1, typename T2>
00151 ShGeneric<1, CT1T2> operator>=(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00152 {
00153 ShAttrib<1, SH_TEMP, CT1T2> t;
00154 shSGE(t, left, right);
00155 return t;
00156 }
00157 SH_SHLIB_CONST_SCALAR_OP(operator>=);
00158 SH_SHLIB_CONST_N_OP_BOTH(operator>=);
00159
00160 template<int N, typename T1, typename T2>
00161 ShGeneric<N, CT1T2> operator==(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00162 {
00163 ShAttrib<N, SH_TEMP, CT1T2> t;
00164 shSEQ(t, left, right);
00165 return t;
00166 }
00167 template<int N, typename T1, typename T2>
00168 ShGeneric<N, CT1T2> operator==(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00169 {
00170 ShAttrib<N, SH_TEMP, CT1T2> t;
00171 shSEQ(t, left, right);
00172 return t;
00173 }
00174 template<int N, typename T1, typename T2>
00175 ShGeneric<N, CT1T2> operator==(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00176 {
00177 ShAttrib<N, SH_TEMP, CT1T2> t;
00178 shSEQ(t, left, right);
00179 return t;
00180 }
00181 template<typename T1, typename T2>
00182 ShGeneric<1, CT1T2> operator==(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00183 {
00184 ShAttrib<1, SH_TEMP, CT1T2> t;
00185 shSEQ(t, left, right);
00186 return t;
00187 }
00188 SH_SHLIB_CONST_SCALAR_OP(operator==);
00189 SH_SHLIB_CONST_N_OP_BOTH(operator==);
00190
00191 template<int N, typename T1, typename T2>
00192 ShGeneric<N, CT1T2> operator!=(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right)
00193 {
00194 ShAttrib<N, SH_TEMP, CT1T2> t;
00195 shSNE(t, left, right);
00196 return t;
00197 }
00198 template<int N, typename T1, typename T2>
00199 ShGeneric<N, CT1T2> operator!=(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right)
00200 {
00201 ShAttrib<N, SH_TEMP, CT1T2> t;
00202 shSNE(t, left, right);
00203 return t;
00204 }
00205 template<int N, typename T1, typename T2>
00206 ShGeneric<N, CT1T2> operator!=(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right)
00207 {
00208 ShAttrib<N, SH_TEMP, CT1T2> t;
00209 shSNE(t, left, right);
00210 return t;
00211 }
00212 template<typename T1, typename T2>
00213 ShGeneric<1, CT1T2> operator!=(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right)
00214 {
00215 ShAttrib<1, SH_TEMP, CT1T2> t;
00216 shSNE(t, left, right);
00217 return t;
00218 }
00219 SH_SHLIB_CONST_SCALAR_OP(operator!=);
00220 SH_SHLIB_CONST_N_OP_BOTH(operator!=);
00221
00222 template<int N, typename T1, typename T2, typename T3>
00223 ShGeneric<N, CT1T2T3> cond(const ShGeneric<N, T1>& condition, const ShGeneric<N, T2>& left,
00224 const ShGeneric<N, T3>& right)
00225 {
00226 ShAttrib<N, SH_TEMP, CT1T2T3> t;
00227 shCOND(t, condition, left, right);
00228 return t;
00229 }
00230 template<int N, typename T1, typename T2, typename T3>
00231 ShGeneric<N, CT1T2T3> cond(const ShGeneric<1, T1>& condition, const ShGeneric<N, T2>& left,
00232 const ShGeneric<N, T3>& right)
00233 {
00234 ShAttrib<N, SH_TEMP, CT1T2T3> t;
00235 shCOND(t, condition, left, right);
00236 return t;
00237 }
00238 template<typename T1, typename T2, typename T3>
00239 ShGeneric<1, CT1T2T3> cond(const ShGeneric<1, T1>& condition, const ShGeneric<1, T2>& left,
00240 const ShGeneric<1, T3>& right)
00241 {
00242 ShAttrib<1, SH_TEMP, CT1T2T3> t;
00243 shCOND(t, condition, left, right);
00244 return t;
00245 }
00246
00247
00248
00249 template<int N, typename T>
00250 ShGeneric<N, T> operator!(const ShGeneric<N, T>& a)
00251 {
00252 return 1.0f - (a > 0.0f);
00253 }
00254
00255
00256 template<int N, typename T1, typename T2>
00257 ShGeneric<N, CT1T2> operator&&(const ShGeneric<N, T1>& a, const ShGeneric<N, T2>& b)
00258 {
00259 return min(a,b);
00260 }
00261
00262 template<int N, typename T1, typename T2>
00263 ShGeneric<N, CT1T2> operator||(const ShGeneric<N, T1>& a, const ShGeneric<N, T2>& b)
00264 {
00265 return max(a,b);
00266 }
00267
00268 template<int N, typename T>
00269 ShGeneric<1, T> any(const ShGeneric<N, T>& a)
00270 {
00271 ShAttrib<1, SH_TEMP, T> t = a(0);
00272 for (int i = 1; i < N; i++) {
00273 t = t || a(i);
00274 }
00275 return t;
00276 }
00277
00278 template<int N, typename T>
00279 ShGeneric<1, T> all(const ShGeneric<N, T>& a)
00280 {
00281 ShAttrib<1, SH_TEMP, T> t = a(0);
00282 for (int i = 1; i < N; i++) {
00283 t = t && a(i);
00284 }
00285 return t;
00286 }
00287
00288 }
00289
00290 #endif