SourceForge Logo Tiny Vector Matrix library using Expression Templates Sourceforge Project Page

include/tvmet/meta/Gemmt.h

Go to the documentation of this file.
00001 /*
00002  * Tiny Vector Matrix Library
00003  * Dense Vector Matrix Libary of Tiny size using Expression Templates
00004  *
00005  * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * $Id: Gemmt.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_META_GEMMT_H
00025 #define TVMET_META_GEMMT_H
00026 
00027 #include <tvmet/xpr/Null.h>
00028 
00029 namespace tvmet {
00030 
00031 namespace meta {
00032 
00033 
00044 template<std::size_t Rows1, std::size_t Cols1,
00045    std::size_t Cols2,
00046    std::size_t K>
00047 class gemmt
00048 {
00049   gemmt();
00050   gemmt(const gemmt&);
00051   gemmt& operator=(const gemmt&);
00052 
00053 private:
00054   enum {
00055     doIt = (K != Cols2 - 1)     
00056   };
00057 
00058 public:
00059   template<class E1, class E2>
00060   static inline
00061   typename PromoteTraits<
00062     typename E1::value_type,
00063     typename E2::value_type
00064   >::value_type
00065   prod(const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) {
00066     return lhs(i, K) * rhs(j, K)
00067       + gemmt<Rows1 * doIt, Cols1 * doIt,
00068               Cols2 * doIt,
00069               (K+1) * doIt>::prod(lhs, rhs, i, j);
00070   }
00071 };
00072 
00073 
00078 template<>
00079 class gemmt<0,0,0,0>
00080 {
00081   gemmt();
00082   gemmt(const gemmt&);
00083   gemmt& operator=(const gemmt&);
00084 
00085 public:
00086   template<class E1, class E2>
00087   static inline
00088   XprNull prod(const E1&, const E2&, std::size_t, std::size_t) {
00089     return XprNull();
00090   }
00091 };
00092 
00093 
00094 } // namespace meta
00095 
00096 } // namespace tvmet
00097 
00098 #endif /* TVMET_META_GEMMT_H */
00099 
00100 // Local Variables:
00101 // mode:C++
00102 // tab-width:8
00103 // End:

Author: