ShLibVector.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 SHLIBVECTOR_HPP
00021 #define SHLIBVECTOR_HPP
00022 
00023 #include "ShAttrib.hpp"
00024 #include "ShLib.hpp"
00025 
00026 namespace SH {
00027 
00028 SH_SHLIB_USUAL_NON_UNIT_OPS_RETTYPE(SH_VECTOR, SH_VECTOR);
00029 
00030 template<int N, ShBindingType B1, typename T, bool S1> 
00031 ShAttrib<N, SH_TEMP, T, SH_VECTOR, false>
00032 abs(const ShAttrib<N, B1, T, SH_VECTOR, S1>& var) 
00033 { 
00034   ShGeneric<N, T> t = abs(static_cast< ShGeneric<N, T> >(var)); 
00035   ShAttrib<N, SH_TEMP, T, SH_VECTOR, 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_VECTOR, false> 
00041 normalize(const ShAttrib<N, B1, T, SH_VECTOR, S1>& var) 
00042 {
00043   ShGeneric<N, T> t = normalize(static_cast< ShGeneric<N, T> >(var)); 
00044   ShAttrib<N, SH_TEMP, T, SH_VECTOR, false> vec(t.node(), t.swizzle(), t.neg()); 
00045   return vec;
00046 }
00047 
00048 SH_SHLIB_USUAL_SUBTRACT(SH_VECTOR);
00049 
00050 SH_SHLIB_LEFT_MATRIX_OPERATION(SH_VECTOR, 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_VECTOR, S1>& a, const ShAttrib<N, B2, T, SH_VECTOR, S2>& b)
00055 {
00056   return dot(a, b);
00057 }
00058 
00059 }
00060 
00061 #endif

Generated on Wed Nov 9 15:29:35 2005 for Sh by  doxygen 1.4.5