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

ShLibArith.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This software is provided 'as-is', without any express or implied
00006 // warranty. In no event will the authors be held liable for any damages
00007 // arising from the use of this software.
00008 // 
00009 // Permission is granted to anyone to use this software for any purpose,
00010 // including commercial applications, and to alter it and redistribute it
00011 // freely, subject to the following restrictions:
00012 // 
00013 // 1. The origin of this software must not be misrepresented; you must
00014 // not claim that you wrote the original software. If you use this
00015 // software in a product, an acknowledgment in the product documentation
00016 // would be appreciated but is not required.
00017 // 
00018 // 2. Altered source versions must be plainly marked as such, and must
00019 // not be misrepresented as being the original software.
00020 // 
00021 // 3. This notice may not be removed or altered from any source
00022 // distribution.
00024 #ifndef SHLIBARITH_HPP
00025 #define SHLIBARITH_HPP
00026 
00027 #include "ShGeneric.hpp"
00028 #include "ShLib.hpp"
00029 
00030 #ifndef WIN32
00031 namespace SH {
00032 
00042 template<int N, typename T1, typename T2>
00043 ShGeneric<N, CT1T2> operator+(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00044 template<int N, typename T1, typename T2>
00045 ShGeneric<N, CT1T2> operator+(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00046 template<int N, typename T1, typename T2>
00047 ShGeneric<N, CT1T2> operator+(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00048 template<typename T1, typename T2>
00049 ShGeneric<1, CT1T2> operator+(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00050 SH_SHLIB_CONST_SCALAR_OP_DECL(operator+);
00051 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator+);
00052 
00057 template<int N, typename T1, typename T2>
00058 ShGeneric<N, CT1T2> operator-(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00059 template<int N, typename T1, typename T2>
00060 ShGeneric<N, CT1T2> operator-(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00061 template<int N, typename T1, typename T2>
00062 ShGeneric<N, CT1T2> operator-(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00063 template<typename T1, typename T2>
00064 ShGeneric<1, CT1T2> operator-(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00065 SH_SHLIB_CONST_SCALAR_OP_DECL(operator-);
00066 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator-);
00067 
00073 template<int N, typename T1, typename T2>
00074 ShGeneric<N, CT1T2> operator*(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00075 template<int N, typename T1, typename T2>
00076 ShGeneric<N, CT1T2> operator*(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00077 template<int N, typename T1, typename T2>
00078 ShGeneric<N, CT1T2> operator*(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00079 template<typename T1, typename T2>
00080 ShGeneric<1, CT1T2> operator*(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00081 SH_SHLIB_CONST_SCALAR_OP_DECL(operator*);
00082 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator*);
00083 
00089 template<int N, typename T1, typename T2>
00090 ShGeneric<N, CT1T2> operator/(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00091 template<int N, typename T1, typename T2>
00092 ShGeneric<N, CT1T2> operator/(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00093 template<int N, typename T1, typename T2>
00094 ShGeneric<N, CT1T2> operator/(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00095 template<typename T1, typename T2>
00096 ShGeneric<1, CT1T2> operator/(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00097 SH_SHLIB_CONST_SCALAR_OP_DECL(operator/);
00098 SH_SHLIB_CONST_N_OP_LEFT_DECL(operator/);
00099 
00100 
00105 template<int N, typename T>
00106 ShGeneric<N, T> exp(const ShGeneric<N, T>& var);
00107 
00112 template<int N, typename T>
00113 ShGeneric<N, T> exp2(const ShGeneric<N, T>& var);
00114 
00119 template<int N, typename T>
00120 ShGeneric<N, T> exp(const ShGeneric<N, T>& var);
00121 
00126 template<int N, typename T>
00127 ShGeneric<N, T> expm1(const ShGeneric<N, T>& x);
00128 
00133 template<int N, typename T>
00134 ShGeneric<N, T> log(const ShGeneric<N, T>& var);
00135 
00140 template<int N, typename T>
00141 ShGeneric<N, T> log2(const ShGeneric<N, T>& var);
00142 
00147 template<int N, typename T>
00148 ShGeneric<N, T> log(const ShGeneric<N, T>& var);
00149 
00154 template<int N, typename T>
00155 ShGeneric<N, T> logp1(const ShGeneric<N, T>& x);
00156 
00161 template<int N, typename T1, typename T2, typename T3>
00162 ShGeneric<N, CT1T2>
00163 pow(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00164 template<int N, typename T1, typename T2, typename T3>
00165 ShGeneric<N, CT1T2>
00166 pow(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00167 template<typename T1, typename T2, typename T3>
00168 ShGeneric<1, CT1T2> pow(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00169 
00170 SH_SHLIB_CONST_SCALAR_OP_DECL(pow);
00171 SH_SHLIB_CONST_N_OP_RIGHT_DECL(pow);
00172 
00178 template<int N, typename T1, typename T2, typename T3>
00179 ShGeneric<N, CT1T2T3>
00180 mad(const ShGeneric<N, T1>& m1, const ShGeneric<N, T2>& m2, 
00181                     const ShGeneric<N, T3>& a);
00182 template<int N, typename T1, typename T2, typename T3>
00183 ShGeneric<N, CT1T2T3>
00184 mad(const ShGeneric<N, T1>& m1, const ShGeneric<1, T2>& m2, 
00185                     const ShGeneric<N, T3>& a);
00186 template<int N, typename T1, typename T2, typename T3>
00187 ShGeneric<N, CT1T2T3>
00188 mad(const ShGeneric<1, T1>& m1, const ShGeneric<N, T2>& m2, 
00189                     const ShGeneric<N, T3>& a);
00190 template<typename T1, typename T2, typename T3>
00191 ShGeneric<1, CT1T2T3> mad(const ShGeneric<1, T1>& m1, const ShGeneric<1, T2>& m2, 
00192                     const ShGeneric<1, T3>& a);
00193 
00194 //@todo type should not use double here, but overloading problems need to be
00195 //resolved
00196 //template<int N, typename T> 
00197 //ShGeneric<N, T> 
00198 //mad(T m1, const ShGeneric<N, T>& m2, const ShGeneric<N, T>& a);
00199 //template<int N, typename T> 
00200 //ShGeneric<N, T>
00201 //mad(const ShGeneric<N, T>& m1, T m2, const ShGeneric<N, T>& a);
00202 
00203 //@todo type not sure these are a good idea
00204 template<int N, typename T1, typename T2> 
00205 ShGeneric<N, CT1T2> 
00206 mad(double m1, const ShGeneric<N, T1>& m2, const ShGeneric<N, T2>& a);
00207 template<int N, typename T1, typename T2> 
00208 ShGeneric<N, CT1T2>
00209 mad(const ShGeneric<N, T1>& m1, double m2, const ShGeneric<N, T2>& a);
00210 
00211 /* Reciprocal
00212  * One divided by the given value, for each component.
00213  */
00214 template<int N, typename T>
00215 ShGeneric<N, T> rcp(const ShGeneric<N, T>& var);
00216 
00217 /* Square root.
00218  * The square root of each component of the input is evaluated.
00219  */
00220 template<int N, typename T>
00221 ShGeneric<N, T> sqrt(const ShGeneric<N, T>& var);
00222 
00223 /* Reciprocal square root.
00224  * The inverse of the square root of each component of the input is evaluated.
00225  */
00226 template<int N, typename T>
00227 ShGeneric<N, T> rsqrt(const ShGeneric<N, T>& var);
00228 
00229 /* Cube root.
00230  * The cube root of each component of the input is evaluated.
00231  */
00232 template<int N, typename T>
00233 ShGeneric<N, T> cbrt(const ShGeneric<N, T>& var);
00234 
00241 template<int N, typename T1, typename T2, typename T3>
00242 ShGeneric<N, CT1T2T3>
00243 lerp(const ShGeneric<N, T1>& f, const ShGeneric<N, T2>& a, 
00244                      const ShGeneric<N, T3>& b);
00245 template<int N, typename T1, typename T2, typename T3>
00246 ShGeneric<N, CT1T2T3>
00247 lerp(const ShGeneric<1, T1>& f, const ShGeneric<N, T2>& a, 
00248                      const ShGeneric<N, T3>& b);
00249 template<typename T1, typename T2, typename T3>
00250 ShGeneric<1, CT1T2T3> 
00251 lerp(const ShGeneric<1, T1>& f, const ShGeneric<1, T2>& a, 
00252      const ShGeneric<1, T3>& b);
00253 
00254 template<int N, typename T1, typename T2>
00255 ShGeneric<N, CT1T2>
00256 lerp(double f, const ShGeneric<N, T1>& a, const ShGeneric<N, T2>& b);
00257 
00258 
00259 /* Sum of components.
00260  * Addition of all components into a single result.
00261  */
00262 template<int N, typename T>
00263 ShGeneric<1, T> sum(const ShGeneric<N, T>& var);
00264 
00265 /* Product of components.
00266  * Multiplication of all components into a single result.
00267  */
00268 template<int N, typename T>
00269 ShGeneric<1, T> prod(const ShGeneric<N, T>& var);
00270 
00271 }
00272 #endif
00273 
00274 #include "ShLibArithImpl.hpp"
00275 
00276 #endif

Generated on Thu Apr 21 17:32:47 2005 for Sh by  doxygen 1.4.2