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