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

include/tvmet/meta/Gemtm.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: Gemtm.h,v 1.12 2007-06-23 15:58:59 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_META_GEMTM_H
00025 #define TVMET_META_GEMTM_H
00026 
00027 #include <tvmet/xpr/Null.h>
00028 
00029 namespace tvmet {
00030 
00031 namespace meta {
00032 
00033 
00046 template<std::size_t Rows1, std::size_t Cols1,
00047    std::size_t Cols2,
00048    std::size_t K>
00049 class gemtm
00050 {
00051 private:
00052   gemtm();
00053   gemtm(const gemtm&);
00054   gemtm& operator=(const gemtm&);
00055 
00056 private:
00057   enum {
00058     doIt = (K != Rows1 - 1)     
00059   };
00060 
00061 public:
00062   template<class E1, class E2>
00063   static inline
00064   typename PromoteTraits<
00065     typename E1::value_type,
00066     typename E2::value_type
00067   >::value_type
00068   prod(const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) {
00069     return lhs(K, i) * rhs(K, j)
00070       + gemtm<Rows1 * doIt, Cols1 * doIt,
00071               Cols2 * doIt,
00072               (K+1) * doIt>::prod(lhs, rhs, i, j);
00073   }
00074 };
00075 
00076 
00081 template<>
00082 class gemtm<0,0,0,0>
00083 {
00084   gemtm();
00085   gemtm(const gemtm&);
00086   gemtm& operator=(const gemtm&);
00087 
00088 public:
00089   template<class E1, class E2>
00090   static inline
00091   XprNull prod(const E1&, const E2&, std::size_t, std::size_t) {
00092     return XprNull();
00093   }
00094 };
00095 
00096 
00097 } // namespace meta
00098 
00099 } // namespace tvmet
00100 
00101 #endif /* TVMET_META_GEMTM_H */
00102 
00103 // Local Variables:
00104 // mode:C++
00105 // tab-width:8
00106 // End:

Author: