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
tvmet/meta/Gemtv.h@1:cc2a9eb0bd55, 2012-10-17 (annotated)
- Committer:
- narshu
- Date:
- Wed Oct 17 22:25:31 2012 +0000
- Revision:
- 1:cc2a9eb0bd55
Commit before publishing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
narshu | 1:cc2a9eb0bd55 | 1 | /* |
narshu | 1:cc2a9eb0bd55 | 2 | * Tiny Vector Matrix Library |
narshu | 1:cc2a9eb0bd55 | 3 | * Dense Vector Matrix Libary of Tiny size using Expression Templates |
narshu | 1:cc2a9eb0bd55 | 4 | * |
narshu | 1:cc2a9eb0bd55 | 5 | * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net> |
narshu | 1:cc2a9eb0bd55 | 6 | * |
narshu | 1:cc2a9eb0bd55 | 7 | * This library is free software; you can redistribute it and/or |
narshu | 1:cc2a9eb0bd55 | 8 | * modify it under the terms of the GNU Lesser General Public |
narshu | 1:cc2a9eb0bd55 | 9 | * License as published by the Free Software Foundation; either |
narshu | 1:cc2a9eb0bd55 | 10 | * version 2.1 of the License, or (at your option) any later version. |
narshu | 1:cc2a9eb0bd55 | 11 | * |
narshu | 1:cc2a9eb0bd55 | 12 | * This library is distributed in the hope that it will be useful, |
narshu | 1:cc2a9eb0bd55 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
narshu | 1:cc2a9eb0bd55 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
narshu | 1:cc2a9eb0bd55 | 15 | * Lesser General Public License for more details. |
narshu | 1:cc2a9eb0bd55 | 16 | * |
narshu | 1:cc2a9eb0bd55 | 17 | * You should have received a copy of the GNU Lesser General Public |
narshu | 1:cc2a9eb0bd55 | 18 | * License along with this library; if not, write to the Free Software |
narshu | 1:cc2a9eb0bd55 | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
narshu | 1:cc2a9eb0bd55 | 20 | * |
narshu | 1:cc2a9eb0bd55 | 21 | * $Id: Gemtv.h,v 1.8 2007-06-23 15:58:59 opetzold Exp $ |
narshu | 1:cc2a9eb0bd55 | 22 | */ |
narshu | 1:cc2a9eb0bd55 | 23 | |
narshu | 1:cc2a9eb0bd55 | 24 | #ifndef TVMET_META_GEMTV_H |
narshu | 1:cc2a9eb0bd55 | 25 | #define TVMET_META_GEMTV_H |
narshu | 1:cc2a9eb0bd55 | 26 | |
narshu | 1:cc2a9eb0bd55 | 27 | #include <tvmet/xpr/Null.h> |
narshu | 1:cc2a9eb0bd55 | 28 | |
narshu | 1:cc2a9eb0bd55 | 29 | namespace tvmet { |
narshu | 1:cc2a9eb0bd55 | 30 | |
narshu | 1:cc2a9eb0bd55 | 31 | namespace meta { |
narshu | 1:cc2a9eb0bd55 | 32 | |
narshu | 1:cc2a9eb0bd55 | 33 | |
narshu | 1:cc2a9eb0bd55 | 34 | /** |
narshu | 1:cc2a9eb0bd55 | 35 | * \class gemtv Gemtv.h "tvmet/meta/Gemtv.h" |
narshu | 1:cc2a9eb0bd55 | 36 | * \brief Meta class for matrix-transpose-vector operations. |
narshu | 1:cc2a9eb0bd55 | 37 | * using formula |
narshu | 1:cc2a9eb0bd55 | 38 | * \f[ |
narshu | 1:cc2a9eb0bd55 | 39 | * M^T\,v |
narshu | 1:cc2a9eb0bd55 | 40 | * \f] |
narshu | 1:cc2a9eb0bd55 | 41 | */ |
narshu | 1:cc2a9eb0bd55 | 42 | template<std::size_t Rows, std::size_t Cols, |
narshu | 1:cc2a9eb0bd55 | 43 | std::size_t I> |
narshu | 1:cc2a9eb0bd55 | 44 | class gemtv |
narshu | 1:cc2a9eb0bd55 | 45 | { |
narshu | 1:cc2a9eb0bd55 | 46 | gemtv(); |
narshu | 1:cc2a9eb0bd55 | 47 | gemtv(const gemtv&); |
narshu | 1:cc2a9eb0bd55 | 48 | gemtv& operator=(const gemtv&); |
narshu | 1:cc2a9eb0bd55 | 49 | |
narshu | 1:cc2a9eb0bd55 | 50 | private: |
narshu | 1:cc2a9eb0bd55 | 51 | enum { |
narshu | 1:cc2a9eb0bd55 | 52 | doIt = I < (Rows-1) /**< recursive counter */ |
narshu | 1:cc2a9eb0bd55 | 53 | }; |
narshu | 1:cc2a9eb0bd55 | 54 | |
narshu | 1:cc2a9eb0bd55 | 55 | public: |
narshu | 1:cc2a9eb0bd55 | 56 | /** Meta template for %Matrix lhs %Vector rhs product. */ |
narshu | 1:cc2a9eb0bd55 | 57 | template<class E1, class E2> |
narshu | 1:cc2a9eb0bd55 | 58 | static inline |
narshu | 1:cc2a9eb0bd55 | 59 | typename PromoteTraits< |
narshu | 1:cc2a9eb0bd55 | 60 | typename E1::value_type, |
narshu | 1:cc2a9eb0bd55 | 61 | typename E2::value_type |
narshu | 1:cc2a9eb0bd55 | 62 | >::value_type |
narshu | 1:cc2a9eb0bd55 | 63 | prod(const E1& lhs, const E2& rhs, std::size_t j) { |
narshu | 1:cc2a9eb0bd55 | 64 | return lhs(I, j) * rhs(I) |
narshu | 1:cc2a9eb0bd55 | 65 | + gemtv<Rows * doIt, Cols * doIt, |
narshu | 1:cc2a9eb0bd55 | 66 | (I+1)* doIt>::prod(lhs, rhs, j); |
narshu | 1:cc2a9eb0bd55 | 67 | } |
narshu | 1:cc2a9eb0bd55 | 68 | }; |
narshu | 1:cc2a9eb0bd55 | 69 | |
narshu | 1:cc2a9eb0bd55 | 70 | |
narshu | 1:cc2a9eb0bd55 | 71 | /** |
narshu | 1:cc2a9eb0bd55 | 72 | * \class gemtv<0,0,0> Gemtv.h "tvmet/meta/Gemtv.h" |
narshu | 1:cc2a9eb0bd55 | 73 | * \brief gemtv Specialized for recursion |
narshu | 1:cc2a9eb0bd55 | 74 | */ |
narshu | 1:cc2a9eb0bd55 | 75 | template<> |
narshu | 1:cc2a9eb0bd55 | 76 | class gemtv<0,0,0> |
narshu | 1:cc2a9eb0bd55 | 77 | { |
narshu | 1:cc2a9eb0bd55 | 78 | gemtv(); |
narshu | 1:cc2a9eb0bd55 | 79 | gemtv(const gemtv&); |
narshu | 1:cc2a9eb0bd55 | 80 | gemtv& operator=(const gemtv&); |
narshu | 1:cc2a9eb0bd55 | 81 | |
narshu | 1:cc2a9eb0bd55 | 82 | public: |
narshu | 1:cc2a9eb0bd55 | 83 | template<class E1, class E2> |
narshu | 1:cc2a9eb0bd55 | 84 | static inline |
narshu | 1:cc2a9eb0bd55 | 85 | XprNull prod(const E1&, const E2&, std::size_t) { |
narshu | 1:cc2a9eb0bd55 | 86 | return XprNull(); |
narshu | 1:cc2a9eb0bd55 | 87 | } |
narshu | 1:cc2a9eb0bd55 | 88 | }; |
narshu | 1:cc2a9eb0bd55 | 89 | |
narshu | 1:cc2a9eb0bd55 | 90 | |
narshu | 1:cc2a9eb0bd55 | 91 | } // namespace meta |
narshu | 1:cc2a9eb0bd55 | 92 | |
narshu | 1:cc2a9eb0bd55 | 93 | } // namespace tvmet |
narshu | 1:cc2a9eb0bd55 | 94 | |
narshu | 1:cc2a9eb0bd55 | 95 | #endif /* TVMET_META_GEMTV_H */ |
narshu | 1:cc2a9eb0bd55 | 96 | |
narshu | 1:cc2a9eb0bd55 | 97 | // Local Variables: |
narshu | 1:cc2a9eb0bd55 | 98 | // mode:C++ |
narshu | 1:cc2a9eb0bd55 | 99 | // tab-width:8 |
narshu | 1:cc2a9eb0bd55 | 100 | // End: |