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