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
Gemtm.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: 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 00034 /** 00035 * \class gemtm Gemtm.h "tvmet/meta/Gemtm.h" 00036 * \brief Meta class for trans(matrix)-matrix operations, like product. 00037 * using formula 00038 * \f[ 00039 * M_1^{T}\,M_2 00040 * \f] 00041 * \note The number of cols of matrix 2 have to be equal to number of rows of 00042 * matrix 1, since matrix 1 is transposed - the result is a (Cols1 x Cols2) 00043 * matrix. 00044 */ 00045 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) /**< recursive counter */ 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 00077 /** 00078 * \class gemtm<0,0,0,0> Gemtm.h "tvmet/meta/Gemtm.h" 00079 * \brief gemtm Specialized for recursion. 00080 */ 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:
Generated on Tue Jul 12 2022 21:02:12 by
