ShLibArith.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2006 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #include "ShLib.hpp" // ShLibArith needs to be included from within ShLib
00021 
00022 #ifndef SHLIBARITH_HPP
00023 #define SHLIBARITH_HPP
00024 
00025 #include "ShGeneric.hpp"
00026 
00027 #ifndef _WIN32
00028 namespace SH {
00029 
00039 template<int N, typename T1, typename T2>
00040 ShGeneric<N, CT1T2> operator+(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00041 template<int N, typename T1, typename T2>
00042 ShGeneric<N, CT1T2> operator+(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00043 template<int N, typename T1, typename T2>
00044 ShGeneric<N, CT1T2> operator+(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00045 template<typename T1, typename T2>
00046 ShGeneric<1, CT1T2> operator+(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00047 SH_SHLIB_CONST_SCALAR_OP_DECL(operator+);
00048 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator+);
00049 
00054 template<int N, typename T1, typename T2>
00055 ShGeneric<N, CT1T2> operator-(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00056 template<int N, typename T1, typename T2>
00057 ShGeneric<N, CT1T2> operator-(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00058 template<int N, typename T1, typename T2>
00059 ShGeneric<N, CT1T2> operator-(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00060 template<typename T1, typename T2>
00061 ShGeneric<1, CT1T2> operator-(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00062 SH_SHLIB_CONST_SCALAR_OP_DECL(operator-);
00063 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator-);
00064 
00070 template<int N, typename T1, typename T2>
00071 ShGeneric<N, CT1T2> operator*(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00072 template<int N, typename T1, typename T2>
00073 ShGeneric<N, CT1T2> operator*(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00074 template<int N, typename T1, typename T2>
00075 ShGeneric<N, CT1T2> operator*(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00076 template<typename T1, typename T2>
00077 ShGeneric<1, CT1T2> operator*(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00078 SH_SHLIB_CONST_SCALAR_OP_DECL(operator*);
00079 SH_SHLIB_CONST_N_OP_BOTH_DECL(operator*);
00080 
00086 template<int N, typename T1, typename T2>
00087 ShGeneric<N, CT1T2> operator/(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00088 template<int N, typename T1, typename T2>
00089 ShGeneric<N, CT1T2> operator/(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00090 template<int N, typename T1, typename T2>
00091 ShGeneric<N, CT1T2> operator/(const ShGeneric<1, T1>& left, const ShGeneric<N, T2>& right);
00092 template<typename T1, typename T2>
00093 ShGeneric<1, CT1T2> operator/(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00094 SH_SHLIB_CONST_SCALAR_OP_DECL(operator/);
00095 SH_SHLIB_CONST_N_OP_LEFT_DECL(operator/);
00096 
00097 
00102 template<int N, typename T>
00103 ShGeneric<N, T> exp(const ShGeneric<N, T>& var);
00104 
00109 template<int N, typename T>
00110 ShGeneric<N, T> exp2(const ShGeneric<N, T>& var);
00111 
00116 template<int N, typename T>
00117 ShGeneric<N, T> exp(const ShGeneric<N, T>& var);
00118 
00123 template<int N, typename T>
00124 ShGeneric<N, T> expm1(const ShGeneric<N, T>& x);
00125 
00130 template<int N, typename T>
00131 ShGeneric<N, T> log(const ShGeneric<N, T>& var);
00132 
00137 template<int N, typename T>
00138 ShGeneric<N, T> log2(const ShGeneric<N, T>& var);
00139 
00144 template<int N, typename T>
00145 ShGeneric<N, T> log(const ShGeneric<N, T>& var);
00146 
00151 template<int N, typename T>
00152 ShGeneric<N, T> logp1(const ShGeneric<N, T>& x);
00153 
00158 template<int N, typename T1, typename T2, typename T3>
00159 ShGeneric<N, CT1T2>
00160 pow(const ShGeneric<N, T1>& left, const ShGeneric<N, T2>& right);
00161 template<int N, typename T1, typename T2, typename T3>
00162 ShGeneric<N, CT1T2>
00163 pow(const ShGeneric<N, T1>& left, const ShGeneric<1, T2>& right);
00164 template<typename T1, typename T2, typename T3>
00165 ShGeneric<1, CT1T2> pow(const ShGeneric<1, T1>& left, const ShGeneric<1, T2>& right);
00166 
00167 SH_SHLIB_CONST_SCALAR_OP_DECL(pow);
00168 SH_SHLIB_CONST_N_OP_RIGHT_DECL(pow);
00169 
00175 template<int N, typename T1, typename T2, typename T3>
00176 ShGeneric<N, CT1T2T3>
00177 mad(const ShGeneric<N, T1>& m1, const ShGeneric<N, T2>& m2, 
00178     const ShGeneric<N, T3>& a);
00179 template<int N, typename T1, typename T2, typename T3>
00180 ShGeneric<N, CT1T2T3>
00181 mad(const ShGeneric<N, T1>& m1, const ShGeneric<1, T2>& m2, 
00182     const ShGeneric<N, T3>& a);
00183 template<int N, typename T1, typename T2, typename T3>
00184 ShGeneric<N, CT1T2T3>
00185 mad(const ShGeneric<1, T1>& m1, const ShGeneric<N, T2>& m2, 
00186     const ShGeneric<N, T3>& a);
00187 template<typename T1, typename T2, typename T3>
00188 ShGeneric<1, CT1T2T3>
00189 mad(const ShGeneric<1, T1>& m1, const ShGeneric<1, T2>& m2, 
00190     const ShGeneric<1, T3>& a);
00191 
00192 template<int N, typename T1, typename T2> 
00193 ShGeneric<N, CT1T2> 
00194 mad(const CT1T2& m1, const ShGeneric<N, T1>& m2, const ShGeneric<N, T2>& a);
00195 template<int N, typename T1, typename T2> 
00196 ShGeneric<N, CT1T2>
00197 mad(const ShGeneric<N, T1>& m1, const CT1T2& m2, const ShGeneric<N, T2>& a);
00198 
00199 /* Reciprocal
00200  * One divided by the given value, for each component.
00201  */
00202 template<int N, typename T>
00203 ShGeneric<N, T> rcp(const ShGeneric<N, T>& var);
00204 
00205 /* Square root.
00206  * The square root of each component of the input is evaluated.
00207  */
00208 template<int N, typename T>
00209 ShGeneric<N, T> sqrt(const ShGeneric<N, T>& var);
00210 
00211 /* Reciprocal square root.
00212  * The inverse of the square root of each component of the input is evaluated.
00213  */
00214 template<int N, typename T>
00215 ShGeneric<N, T> rsqrt(const ShGeneric<N, T>& var);
00216 
00217 /* Cube root.
00218  * The cube root of each component of the input is evaluated.
00219  */
00220 template<int N, typename T>
00221 ShGeneric<N, T> cbrt(const ShGeneric<N, T>& var);
00222 
00229 template<int N, typename T1, typename T2, typename T3>
00230 ShGeneric<N, CT1T2T3>
00231 lerp(const ShGeneric<N, T1>& f, const ShGeneric<N, T2>& a, 
00232                      const ShGeneric<N, T3>& b);
00233 template<int N, typename T1, typename T2, typename T3>
00234 ShGeneric<N, CT1T2T3>
00235 lerp(const ShGeneric<1, T1>& f, const ShGeneric<N, T2>& a, 
00236                      const ShGeneric<N, T3>& b);
00237 template<typename T1, typename T2, typename T3>
00238 ShGeneric<1, CT1T2T3> 
00239 lerp(const ShGeneric<1, T1>& f, const ShGeneric<1, T2>& a, 
00240      const ShGeneric<1, T3>& b);
00241 
00242 template<int N, typename T1, typename T2>
00243 ShGeneric<N, CT1T2>
00244 lerp(const CT1T2& f, const ShGeneric<N, T1>& a, const ShGeneric<N, T2>& b);
00245 
00246 
00247 /* Sum of components.
00248  * Addition of all components into a single result.
00249  */
00250 template<int N, typename T>
00251 ShGeneric<1, T> sum(const ShGeneric<N, T>& var);
00252 
00253 /* Product of components.
00254  * Multiplication of all components into a single result.
00255  */
00256 template<int N, typename T>
00257 ShGeneric<1, T> prod(const ShGeneric<N, T>& var);
00258 
00259 }
00260 #endif
00261 
00262 #include "ShLibArithImpl.hpp"
00263 
00264 #endif

Generated on Thu Feb 16 14:51:33 2006 for Sh by  doxygen 1.4.6