ICRS Eurobot 2013
Dependencies: mbed mbed-rtos Servo QEI
tvmet/AliasProxy.h@15:9c5aaeda36dc, 2013-04-06 (annotated)
- Committer:
- madcowswe
- Date:
- Sat Apr 06 20:57:54 2013 +0000
- Revision:
- 15:9c5aaeda36dc
Encoders fairly tuned, still has random noise in it
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
madcowswe | 15:9c5aaeda36dc | 1 | /* |
madcowswe | 15:9c5aaeda36dc | 2 | * Tiny Vector Matrix Library |
madcowswe | 15:9c5aaeda36dc | 3 | * Dense Vector Matrix Libary of Tiny size using Expression Templates |
madcowswe | 15:9c5aaeda36dc | 4 | * |
madcowswe | 15:9c5aaeda36dc | 5 | * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net> |
madcowswe | 15:9c5aaeda36dc | 6 | * |
madcowswe | 15:9c5aaeda36dc | 7 | * This library is free software; you can redistribute it and/or |
madcowswe | 15:9c5aaeda36dc | 8 | * modify it under the terms of the GNU Lesser General Public |
madcowswe | 15:9c5aaeda36dc | 9 | * License as published by the Free Software Foundation; either |
madcowswe | 15:9c5aaeda36dc | 10 | * version 2.1 of the License, or (at your option) any later version. |
madcowswe | 15:9c5aaeda36dc | 11 | * |
madcowswe | 15:9c5aaeda36dc | 12 | * This library is distributed in the hope that it will be useful, |
madcowswe | 15:9c5aaeda36dc | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
madcowswe | 15:9c5aaeda36dc | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
madcowswe | 15:9c5aaeda36dc | 15 | * Lesser General Public License for more details. |
madcowswe | 15:9c5aaeda36dc | 16 | * |
madcowswe | 15:9c5aaeda36dc | 17 | * You should have received a copy of the GNU Lesser General Public |
madcowswe | 15:9c5aaeda36dc | 18 | * License along with this library; if not, write to the Free Software |
madcowswe | 15:9c5aaeda36dc | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
madcowswe | 15:9c5aaeda36dc | 20 | * |
madcowswe | 15:9c5aaeda36dc | 21 | * $Id: AliasProxy.h,v 1.8 2007-06-23 15:58:58 opetzold Exp $ |
madcowswe | 15:9c5aaeda36dc | 22 | */ |
madcowswe | 15:9c5aaeda36dc | 23 | |
madcowswe | 15:9c5aaeda36dc | 24 | #ifndef TVMET_ALIAS_PROXY_H |
madcowswe | 15:9c5aaeda36dc | 25 | #define TVMET_ALIAS_PROXY_H |
madcowswe | 15:9c5aaeda36dc | 26 | |
madcowswe | 15:9c5aaeda36dc | 27 | namespace tvmet { |
madcowswe | 15:9c5aaeda36dc | 28 | |
madcowswe | 15:9c5aaeda36dc | 29 | |
madcowswe | 15:9c5aaeda36dc | 30 | /** forwards */ |
madcowswe | 15:9c5aaeda36dc | 31 | template<class E> class AliasProxy; |
madcowswe | 15:9c5aaeda36dc | 32 | |
madcowswe | 15:9c5aaeda36dc | 33 | |
madcowswe | 15:9c5aaeda36dc | 34 | /** |
madcowswe | 15:9c5aaeda36dc | 35 | * \brief Simplify syntax for alias Matrices and Vectors, |
madcowswe | 15:9c5aaeda36dc | 36 | * where aliasing left hand values appear in the |
madcowswe | 15:9c5aaeda36dc | 37 | * expression. |
madcowswe | 15:9c5aaeda36dc | 38 | * \par Example: |
madcowswe | 15:9c5aaeda36dc | 39 | * \code |
madcowswe | 15:9c5aaeda36dc | 40 | * typedef tvmet::Matrix<double, 10, 10> matrix_type; |
madcowswe | 15:9c5aaeda36dc | 41 | * matrix_type m; |
madcowswe | 15:9c5aaeda36dc | 42 | * ... |
madcowswe | 15:9c5aaeda36dc | 43 | * alias(m) += trans(m); |
madcowswe | 15:9c5aaeda36dc | 44 | * \endcode |
madcowswe | 15:9c5aaeda36dc | 45 | * \sa AliasProxy |
madcowswe | 15:9c5aaeda36dc | 46 | * \sa Some Notes \ref alias |
madcowswe | 15:9c5aaeda36dc | 47 | */ |
madcowswe | 15:9c5aaeda36dc | 48 | template<class E> |
madcowswe | 15:9c5aaeda36dc | 49 | AliasProxy<E> alias(E& expr) { return AliasProxy<E>(expr); } |
madcowswe | 15:9c5aaeda36dc | 50 | |
madcowswe | 15:9c5aaeda36dc | 51 | |
madcowswe | 15:9c5aaeda36dc | 52 | /** |
madcowswe | 15:9c5aaeda36dc | 53 | * \class AliasProxy AliasProxy.h "tvmet/AliasProxy.h" |
madcowswe | 15:9c5aaeda36dc | 54 | * \brief Assign proxy for alias Matrices and Vectors. |
madcowswe | 15:9c5aaeda36dc | 55 | * |
madcowswe | 15:9c5aaeda36dc | 56 | * A short lived object to provide simplified alias syntax. |
madcowswe | 15:9c5aaeda36dc | 57 | * Only the friend function alias is allowed to create |
madcowswe | 15:9c5aaeda36dc | 58 | * such a object. The proxy calls the appropriate member |
madcowswe | 15:9c5aaeda36dc | 59 | * alias_xyz() which have to use temporaries to avoid |
madcowswe | 15:9c5aaeda36dc | 60 | * overlapping memory regions. |
madcowswe | 15:9c5aaeda36dc | 61 | * \sa alias |
madcowswe | 15:9c5aaeda36dc | 62 | * \sa Some Notes \ref alias |
madcowswe | 15:9c5aaeda36dc | 63 | * \note Thanks to ublas-dev group, where the principle idea |
madcowswe | 15:9c5aaeda36dc | 64 | * comes from. |
madcowswe | 15:9c5aaeda36dc | 65 | */ |
madcowswe | 15:9c5aaeda36dc | 66 | template<class E> |
madcowswe | 15:9c5aaeda36dc | 67 | class AliasProxy |
madcowswe | 15:9c5aaeda36dc | 68 | { |
madcowswe | 15:9c5aaeda36dc | 69 | AliasProxy(const AliasProxy&); |
madcowswe | 15:9c5aaeda36dc | 70 | AliasProxy& operator=(const AliasProxy&); |
madcowswe | 15:9c5aaeda36dc | 71 | |
madcowswe | 15:9c5aaeda36dc | 72 | friend AliasProxy<E> alias<>(E& expr); |
madcowswe | 15:9c5aaeda36dc | 73 | |
madcowswe | 15:9c5aaeda36dc | 74 | public: |
madcowswe | 15:9c5aaeda36dc | 75 | AliasProxy(E& expr) : m_expr(expr) { } |
madcowswe | 15:9c5aaeda36dc | 76 | |
madcowswe | 15:9c5aaeda36dc | 77 | |
madcowswe | 15:9c5aaeda36dc | 78 | template<class E2> |
madcowswe | 15:9c5aaeda36dc | 79 | E& operator=(const E2& expr) { |
madcowswe | 15:9c5aaeda36dc | 80 | return m_expr.alias_assign(expr); |
madcowswe | 15:9c5aaeda36dc | 81 | } |
madcowswe | 15:9c5aaeda36dc | 82 | |
madcowswe | 15:9c5aaeda36dc | 83 | template<class E2> |
madcowswe | 15:9c5aaeda36dc | 84 | E& operator+=(const E2& expr) { |
madcowswe | 15:9c5aaeda36dc | 85 | return m_expr.alias_add_eq(expr); |
madcowswe | 15:9c5aaeda36dc | 86 | } |
madcowswe | 15:9c5aaeda36dc | 87 | |
madcowswe | 15:9c5aaeda36dc | 88 | template<class E2> |
madcowswe | 15:9c5aaeda36dc | 89 | E& operator-=(const E2& expr) { |
madcowswe | 15:9c5aaeda36dc | 90 | return m_expr.alias_sub_eq(expr); |
madcowswe | 15:9c5aaeda36dc | 91 | } |
madcowswe | 15:9c5aaeda36dc | 92 | |
madcowswe | 15:9c5aaeda36dc | 93 | template<class E2> |
madcowswe | 15:9c5aaeda36dc | 94 | E& operator*=(const E2& expr) { |
madcowswe | 15:9c5aaeda36dc | 95 | return m_expr.alias_mul_eq(expr); |
madcowswe | 15:9c5aaeda36dc | 96 | } |
madcowswe | 15:9c5aaeda36dc | 97 | |
madcowswe | 15:9c5aaeda36dc | 98 | template<class E2> |
madcowswe | 15:9c5aaeda36dc | 99 | E& operator/=(const E2& expr) { |
madcowswe | 15:9c5aaeda36dc | 100 | return m_expr.alias_div_eq(expr); |
madcowswe | 15:9c5aaeda36dc | 101 | } |
madcowswe | 15:9c5aaeda36dc | 102 | |
madcowswe | 15:9c5aaeda36dc | 103 | private: |
madcowswe | 15:9c5aaeda36dc | 104 | E& m_expr; |
madcowswe | 15:9c5aaeda36dc | 105 | }; |
madcowswe | 15:9c5aaeda36dc | 106 | |
madcowswe | 15:9c5aaeda36dc | 107 | |
madcowswe | 15:9c5aaeda36dc | 108 | #if 0 |
madcowswe | 15:9c5aaeda36dc | 109 | namespace element_wise { |
madcowswe | 15:9c5aaeda36dc | 110 | // \todo to write |
madcowswe | 15:9c5aaeda36dc | 111 | template<class E, class E2> |
madcowswe | 15:9c5aaeda36dc | 112 | E& operator/=(AliasProxy<E>& proxy, const E2& rhs) { |
madcowswe | 15:9c5aaeda36dc | 113 | return proxy.div_upd(rhs); |
madcowswe | 15:9c5aaeda36dc | 114 | } |
madcowswe | 15:9c5aaeda36dc | 115 | |
madcowswe | 15:9c5aaeda36dc | 116 | } |
madcowswe | 15:9c5aaeda36dc | 117 | #endif |
madcowswe | 15:9c5aaeda36dc | 118 | |
madcowswe | 15:9c5aaeda36dc | 119 | |
madcowswe | 15:9c5aaeda36dc | 120 | } // namespace tvmet |
madcowswe | 15:9c5aaeda36dc | 121 | |
madcowswe | 15:9c5aaeda36dc | 122 | |
madcowswe | 15:9c5aaeda36dc | 123 | #endif /* TVMET_ALIAS_PROXY_H */ |
madcowswe | 15:9c5aaeda36dc | 124 | |
madcowswe | 15:9c5aaeda36dc | 125 | // Local Variables: |
madcowswe | 15:9c5aaeda36dc | 126 | // mode:C++ |
madcowswe | 15:9c5aaeda36dc | 127 | // tab-width:8 |
madcowswe | 15:9c5aaeda36dc | 128 | // End: |