Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Eurobot_2012_Secondary by
Gemm.h
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: Gemm.h,v 1.15 2007-06-23 15:58:59 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_META_GEMM_H 00025 #define TVMET_META_GEMM_H 00026 00027 #include <tvmet/xpr/Null.h> 00028 00029 namespace tvmet { 00030 00031 namespace meta { 00032 00033 00034 /** 00035 * \class gemm Gemm.h "tvmet/meta/Gemm.h" 00036 * \brief Meta class for matrix-matrix operations, like product 00037 * using formula 00038 * \f[ 00039 * M_1\,M_2 00040 * \f] 00041 * \note The rows of matrix 2 have to be equal to cols of matrix 1. 00042 */ 00043 template<std::size_t Rows1, std::size_t Cols1, 00044 std::size_t Cols2, 00045 std::size_t K> 00046 class gemm 00047 { 00048 gemm(); 00049 gemm(const gemm&); 00050 gemm& operator=(const gemm&); 00051 00052 private: 00053 enum { 00054 doIt = (K != Cols1 - 1) /**< recursive counter */ 00055 }; 00056 00057 public: 00058 template<class E1, class E2> 00059 static inline 00060 typename PromoteTraits< 00061 typename E1::value_type, 00062 typename E2::value_type 00063 >::value_type 00064 prod(const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) { 00065 return lhs(i, K) * rhs(K, j) 00066 + gemm<Rows1 * doIt, Cols1 * doIt, 00067 Cols2 * doIt, 00068 (K+1) * doIt>::prod(lhs, rhs, i, j); 00069 } 00070 }; 00071 00072 00073 /** 00074 * \class gemm<0,0,0,0> Gemm.h "tvmet/meta/Gemm.h" 00075 * \brief gemm Specialized for recursion. 00076 */ 00077 template<> 00078 class gemm<0,0,0,0> 00079 { 00080 gemm(); 00081 gemm(const gemm&); 00082 gemm& operator=(const gemm&); 00083 00084 public: 00085 template<class E1, class E2> 00086 static inline 00087 XprNull prod(const E1&, const E2&, std::size_t, std::size_t) { 00088 return XprNull(); 00089 } 00090 }; 00091 00092 00093 } // namespace meta 00094 00095 } // namespace tvmet 00096 00097 #endif /* TVMET_META_GEMM_H */ 00098 00099 // Local Variables: 00100 // mode:C++ 00101 // tab-width:8 00102 // End:
Generated on Tue Jul 12 2022 21:02:12 by
