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

ShLibNormal.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 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 #ifndef SHLIBNORMAL_HPP
00021 #define SHLIBNORMAL_HPP
00022 
00023 #include "ShAttrib.hpp"
00024 #include "ShLib.hpp"
00025 
00026 namespace SH {
00027 
00028 SH_SHLIB_USUAL_NON_UNIT_OPS_RETTYPE(SH_NORMAL, SH_NORMAL);
00029 
00030 template<int N, ShBindingType B1, typename T, bool S1>
00031 ShAttrib<N, SH_TEMP, T, SH_NORMAL, false>
00032 abs(const ShAttrib<N, B1, T, SH_NORMAL, S1>& var)
00033 {
00034   ShGeneric<N, T> t = abs(static_cast< ShGeneric<N, T> >(var));
00035   ShAttrib<N, SH_TEMP, T, SH_NORMAL, false> vec(t.node(), t.swizzle(), t.neg());
00036   return vec;
00037 }
00038 
00039 template<int N, ShBindingType B1, typename T, bool S1>
00040 ShAttrib<N, SH_TEMP, T, SH_NORMAL, false>
00041 normalize(const ShAttrib<N, B1, T, SH_NORMAL, S1>& var)
00042 {
00043   ShGeneric<N, T> t = normalize(static_cast< ShGeneric<N, T> >(var));
00044   ShAttrib<N, SH_TEMP, T, SH_NORMAL, false> vec(t.node(), t.swizzle(), t.neg());
00045   return vec;
00046 }
00047 
00048 SH_SHLIB_USUAL_SUBTRACT(SH_NORMAL);
00049 
00050 SH_SHLIB_LEFT_MATRIX_OPERATION(SH_NORMAL, operator|, M);
00051 
00052 template<int N, ShBindingType B1, ShBindingType B2, typename T, bool S1, bool S2>
00053 ShGeneric<1, T>
00054 operator|(const ShAttrib<N, B1, T, SH_NORMAL, S1>& a, const ShAttrib<N, B2, T, SH_NORMAL, S2>& b)
00055 {
00056   return dot(a, b);
00057 }
00058 
00059 template<int N, ShBindingType B1, ShBindingType B2, typename T, bool S1, bool S2>
00060 ShGeneric<1, T> 
00061 operator|(const ShAttrib<N, B1, T, SH_VECTOR, S1>& a, const ShAttrib<N, B2, T, SH_NORMAL, S2>& b)
00062 {
00063   return dot(a, b);
00064 }
00065 
00066 template<int N, ShBindingType B1, ShBindingType B2, typename T, bool S1, bool S2>
00067 ShGeneric<1, T>
00068 operator|(const ShAttrib<N, B1, T, SH_NORMAL, S1>& a, const ShAttrib<N, B2, T, SH_VECTOR, S2>& b)
00069 {
00070   return dot(a, b);
00071 }
00072 
00073 }
00074 
00075 #endif

Generated on Thu Jul 28 17:33:03 2005 for Sh by  doxygen 1.4.3-20050530