Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ShLibArith.hpp

00001 // Sh: A GPU metaprogramming language. 00002 // 00003 // Copyright (c) 2003 University of Waterloo Computer Graphics Laboratory 00004 // Project administrator: Michael D. McCool 00005 // Authors: Zheng Qin, Stefanus Du Toit, Kevin Moule, Tiberiu S. Popa, 00006 // Michael D. McCool 00007 // 00008 // This software is provided 'as-is', without any express or implied 00009 // warranty. In no event will the authors be held liable for any damages 00010 // arising from the use of this software. 00011 // 00012 // Permission is granted to anyone to use this software for any purpose, 00013 // including commercial applications, and to alter it and redistribute it 00014 // freely, subject to the following restrictions: 00015 // 00016 // 1. The origin of this software must not be misrepresented; you must 00017 // not claim that you wrote the original software. If you use this 00018 // software in a product, an acknowledgment in the product documentation 00019 // would be appreciated but is not required. 00020 // 00021 // 2. Altered source versions must be plainly marked as such, and must 00022 // not be misrepresented as being the original software. 00023 // 00024 // 3. This notice may not be removed or altered from any source 00025 // distribution. 00027 #ifndef SHLIBARITH_HPP 00028 #define SHLIBARITH_HPP 00029 00030 #include "ShGeneric.hpp" 00031 #include "ShLib.hpp" 00032 00033 namespace SH { 00034 00044 template<int N, typename T> 00045 ShGeneric<N, T> operator+(const ShGeneric<N, T>& left, const ShGeneric<N, T>& right); 00046 template<int N, typename T> 00047 ShGeneric<N, T> operator+(const ShGeneric<1, T>& left, const ShGeneric<N, T>& right); 00048 template<int N, typename T> 00049 ShGeneric<N, T> operator+(const ShGeneric<N, T>& left, const ShGeneric<1, T>& right); 00050 template<typename T> 00051 ShGeneric<1, T> operator+(const ShGeneric<1, T>& left, const ShGeneric<1, T>& right); 00052 SH_SHLIB_CONST_SCALAR_OP(operator+); 00053 SH_SHLIB_CONST_N_OP_BOTH(operator+); 00054 00059 template<int N, typename T> 00060 ShGeneric<N, T> operator-(const ShGeneric<N, T>& left, const ShGeneric<N, T>& right); 00061 template<int N, typename T> 00062 ShGeneric<N, T> operator-(const ShGeneric<1, T>& left, const ShGeneric<N, T>& right); 00063 template<int N, typename T> 00064 ShGeneric<N, T> operator-(const ShGeneric<N, T>& left, const ShGeneric<1, T>& right); 00065 template<typename T> 00066 ShGeneric<1, T> operator-(const ShGeneric<1, T>& left, const ShGeneric<1, T>& right); 00067 SH_SHLIB_CONST_SCALAR_OP(operator-); 00068 SH_SHLIB_CONST_N_OP_BOTH(operator-); 00069 00075 template<int N, typename T> 00076 ShGeneric<N, T> operator*(const ShGeneric<N, T>& left, const ShGeneric<N, T>& right); 00077 template<int N, typename T> 00078 ShGeneric<N, T> operator*(const ShGeneric<1, T>& left, const ShGeneric<N, T>& right); 00079 template<int N, typename T> 00080 ShGeneric<N, T> operator*(const ShGeneric<N, T>& left, const ShGeneric<1, T>& right); 00081 template<typename T> 00082 ShGeneric<1, T> operator*(const ShGeneric<1, T>& left, const ShGeneric<1, T>& right); 00083 SH_SHLIB_CONST_SCALAR_OP(operator*); 00084 SH_SHLIB_CONST_N_OP_BOTH(operator*); 00085 00091 template<int N, typename T> 00092 ShGeneric<N, T> operator/(const ShGeneric<N, T>& left, const ShGeneric<N, T>& right); 00093 template<int N, typename T> 00094 ShGeneric<N, T> operator/(const ShGeneric<N, T>& left, const ShGeneric<1, T>& right); 00095 template<int N, typename T> 00096 ShGeneric<N, T> operator/(const ShGeneric<1, T>& left, const ShGeneric<N, T>& right); 00097 template<typename T> 00098 ShGeneric<1, T> operator/(const ShGeneric<1, T>& left, const ShGeneric<1, T>& right); 00099 SH_SHLIB_CONST_SCALAR_OP(operator/); 00100 SH_SHLIB_CONST_N_OP_LEFT(operator/); 00101 00102 00107 template<int N, typename T> 00108 ShGeneric<N, T> exp(const ShGeneric<N, T>& var); 00109 00114 template<int N, typename T> 00115 ShGeneric<N, T> exp2(const ShGeneric<N, T>& var); 00116 00121 template<int N, typename T> 00122 ShGeneric<N, T> exp(const ShGeneric<N, T>& var); 00123 00128 template<int N, typename T> 00129 ShGeneric<N, T> expm1(const ShGeneric<N, T>& x); 00130 00135 template<int N, typename T> 00136 ShGeneric<N, T> log(const ShGeneric<N, T>& var); 00137 00142 template<int N, typename T> 00143 ShGeneric<N, T> log2(const ShGeneric<N, T>& var); 00144 00149 template<int N, typename T> 00150 ShGeneric<N, T> log(const ShGeneric<N, T>& var); 00151 00156 template<int N, typename T> 00157 ShGeneric<N, T> logp1(const ShGeneric<N, T>& x); 00158 00163 template<int N, typename T> 00164 ShGeneric<N, T> pow(const ShGeneric<N, T>& left, const ShGeneric<N, T>& right); 00165 template<int N, typename T> 00166 ShGeneric<N, T> pow(const ShGeneric<N, T>& left, const ShGeneric<1, T>& right); 00167 template<typename T> 00168 ShGeneric<1, T> pow(const ShGeneric<1, T>& left, const ShGeneric<1, T>& right); 00169 00170 SH_SHLIB_CONST_SCALAR_OP(pow); 00171 SH_SHLIB_CONST_N_OP_RIGHT(pow); 00172 00178 template<int N, typename T> 00179 ShGeneric<N, T> mad(const ShGeneric<N, T>& m1, const ShGeneric<N, T>& m2, 00180 const ShGeneric<N, T>& a); 00181 template<int N, typename T> 00182 ShGeneric<N, T> mad(const ShGeneric<N, T>& m1, const ShGeneric<1, T>& m2, 00183 const ShGeneric<N, T>& a); 00184 template<int N, typename T> 00185 ShGeneric<N, T> mad(const ShGeneric<1, T>& m1, const ShGeneric<N, T>& m2, 00186 const ShGeneric<N, T>& a); 00187 template<typename T> 00188 ShGeneric<1, T> mad(const ShGeneric<1, T>& m1, const ShGeneric<1, T>& m2, 00189 const ShGeneric<1, T>& a); 00190 00191 template<int N, typename T> 00192 ShGeneric<N, T> mad(T m1, const ShGeneric<N, T>& m2, const ShGeneric<N, T>& a); 00193 template<int N, typename T> 00194 ShGeneric<N, T> mad(double m1, const ShGeneric<N, T>& m2, const ShGeneric<N, T>& a); 00195 template<int N, typename T> 00196 ShGeneric<N, T> mad(const ShGeneric<N, T>& m1, T m2, const ShGeneric<N, T>& a); 00197 template<int N, typename T> 00198 ShGeneric<N, T> mad(const ShGeneric<N, T>& m1, double m2, const ShGeneric<N, T>& a); 00199 00200 /* Reciprocal 00201 * One divided by the given value, for each component. 00202 */ 00203 template<int N, typename T> 00204 ShGeneric<N, T> rcp(const ShGeneric<N, T>& var); 00205 00206 /* Square root. 00207 * The square root of each component of the input is evaluated. 00208 */ 00209 template<int N, typename T> 00210 ShGeneric<N, T> sqrt(const ShGeneric<N, T>& var); 00211 00212 /* Reciprocal square root. 00213 * The inverse of the square root of each component of the input is evaluated. 00214 */ 00215 template<int N, typename T> 00216 ShGeneric<N, T> rsqrt(const ShGeneric<N, T>& var); 00217 00218 /* Cube root. 00219 * The cube root of each component of the input is evaluated. 00220 */ 00221 template<int N, typename T> 00222 ShGeneric<N, T> cbrt(const ShGeneric<N, T>& var); 00223 00230 template<int N, typename T> 00231 ShGeneric<N, T> lerp(const ShGeneric<N, T>& f, const ShGeneric<N, T>& a, 00232 const ShGeneric<N, T>& b); 00233 template<int N, typename T> 00234 ShGeneric<N, T> lerp(const ShGeneric<1, T>& f, const ShGeneric<N, T>& a, 00235 const ShGeneric<N, T>& b); 00236 template<typename T> 00237 ShGeneric<1, T> lerp(const ShGeneric<1, T>& f, const ShGeneric<1, T>& a, 00238 const ShGeneric<1, T>& b); 00239 template<int N, typename T> 00240 ShGeneric<N, T> lerp(T f, const ShGeneric<N, T>& a, 00241 const ShGeneric<N, T>& b); 00242 00243 00244 /* Sum of components. 00245 * Addition of all components into a single result. 00246 */ 00247 template<int N, typename T> 00248 ShGeneric<1, T> sum(const ShGeneric<N, T>& var); 00249 00250 /* Product of components. 00251 * Multiplication of all components into a single result. 00252 */ 00253 template<int N, typename T> 00254 ShGeneric<1, T> prod(const ShGeneric<N, T>& var); 00255 00256 } 00257 00258 #include "ShLibArithImpl.hpp" 00259 00260 #endif

Generated on Mon Oct 18 14:17:39 2004 for Sh by doxygen 1.3.7