![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
tvmet/tvmet.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: tvmet.h,v 1.21 2007-06-23 15:58:59 opetzold Exp $ |
madcowswe | 15:9c5aaeda36dc | 22 | */ |
madcowswe | 15:9c5aaeda36dc | 23 | |
madcowswe | 15:9c5aaeda36dc | 24 | #ifndef TVMET_H |
madcowswe | 15:9c5aaeda36dc | 25 | #define TVMET_H |
madcowswe | 15:9c5aaeda36dc | 26 | |
madcowswe | 15:9c5aaeda36dc | 27 | #include <tvmet/config.h> |
madcowswe | 15:9c5aaeda36dc | 28 | |
madcowswe | 15:9c5aaeda36dc | 29 | |
madcowswe | 15:9c5aaeda36dc | 30 | /*********************************************************************** |
madcowswe | 15:9c5aaeda36dc | 31 | * Compiler specifics |
madcowswe | 15:9c5aaeda36dc | 32 | ***********************************************************************/ |
madcowswe | 15:9c5aaeda36dc | 33 | #if defined(__GNUC__) |
madcowswe | 15:9c5aaeda36dc | 34 | # include <tvmet/config/config-gcc.h> |
madcowswe | 15:9c5aaeda36dc | 35 | #endif |
madcowswe | 15:9c5aaeda36dc | 36 | |
madcowswe | 15:9c5aaeda36dc | 37 | #if defined(__ICC) |
madcowswe | 15:9c5aaeda36dc | 38 | # include <tvmet/config/config-icc.h> |
madcowswe | 15:9c5aaeda36dc | 39 | #endif |
madcowswe | 15:9c5aaeda36dc | 40 | |
madcowswe | 15:9c5aaeda36dc | 41 | #if defined(__KCC) |
madcowswe | 15:9c5aaeda36dc | 42 | # include <tvmet/config/config-kcc.h> |
madcowswe | 15:9c5aaeda36dc | 43 | #endif |
madcowswe | 15:9c5aaeda36dc | 44 | |
madcowswe | 15:9c5aaeda36dc | 45 | #if defined(__PGI) |
madcowswe | 15:9c5aaeda36dc | 46 | # include <tvmet/config/config-pgi.h> |
madcowswe | 15:9c5aaeda36dc | 47 | #endif |
madcowswe | 15:9c5aaeda36dc | 48 | |
madcowswe | 15:9c5aaeda36dc | 49 | // vc7.1: 1310 and vc7.0 1300 |
madcowswe | 15:9c5aaeda36dc | 50 | #if defined(_MSC_VER) && (_MSC_VER >= 1310) |
madcowswe | 15:9c5aaeda36dc | 51 | # include <tvmet/config/config-vc71.h> |
madcowswe | 15:9c5aaeda36dc | 52 | #endif |
madcowswe | 15:9c5aaeda36dc | 53 | |
madcowswe | 15:9c5aaeda36dc | 54 | |
madcowswe | 15:9c5aaeda36dc | 55 | // give up for these cases |
madcowswe | 15:9c5aaeda36dc | 56 | #if !defined(TVMET_HAVE_MUTABLE) |
madcowswe | 15:9c5aaeda36dc | 57 | # error "Your compiler doesn't support the mutable keyword! Giving up." |
madcowswe | 15:9c5aaeda36dc | 58 | #endif |
madcowswe | 15:9c5aaeda36dc | 59 | |
madcowswe | 15:9c5aaeda36dc | 60 | #if !defined(TVMET_HAVE_TYPENAME) |
madcowswe | 15:9c5aaeda36dc | 61 | # error "Your compiler doesn't support the typename keyword! Giving up." |
madcowswe | 15:9c5aaeda36dc | 62 | #endif |
madcowswe | 15:9c5aaeda36dc | 63 | |
madcowswe | 15:9c5aaeda36dc | 64 | #if !defined(TVMET_HAVE_NAMESPACES) |
madcowswe | 15:9c5aaeda36dc | 65 | # error "Your compiler doesn't support the namespace concept! Giving up." |
madcowswe | 15:9c5aaeda36dc | 66 | #endif |
madcowswe | 15:9c5aaeda36dc | 67 | |
madcowswe | 15:9c5aaeda36dc | 68 | #if !defined(TVMET_HAVE_PARTIAL_SPECIALIZATION) |
madcowswe | 15:9c5aaeda36dc | 69 | # error "Your compiler doesn't support partial specialization! Giving up." |
madcowswe | 15:9c5aaeda36dc | 70 | #endif |
madcowswe | 15:9c5aaeda36dc | 71 | |
madcowswe | 15:9c5aaeda36dc | 72 | |
madcowswe | 15:9c5aaeda36dc | 73 | /* |
madcowswe | 15:9c5aaeda36dc | 74 | * other compiler specific stuff |
madcowswe | 15:9c5aaeda36dc | 75 | */ |
madcowswe | 15:9c5aaeda36dc | 76 | |
madcowswe | 15:9c5aaeda36dc | 77 | /** |
madcowswe | 15:9c5aaeda36dc | 78 | * \def TVMET_CXX_ALWAYS_INLINE |
madcowswe | 15:9c5aaeda36dc | 79 | * \brief Compiler specific stuff to force inline code if supported. |
madcowswe | 15:9c5aaeda36dc | 80 | * |
madcowswe | 15:9c5aaeda36dc | 81 | * Mainly, this declares the functions using g++'s |
madcowswe | 15:9c5aaeda36dc | 82 | * __attribute__((always_inline)). This features is enabled |
madcowswe | 15:9c5aaeda36dc | 83 | * on defined TVMET_OPTIMIZE. |
madcowswe | 15:9c5aaeda36dc | 84 | */ |
madcowswe | 15:9c5aaeda36dc | 85 | #if !defined(TVMET_CXX_ALWAYS_INLINE) |
madcowswe | 15:9c5aaeda36dc | 86 | #define TVMET_CXX_ALWAYS_INLINE |
madcowswe | 15:9c5aaeda36dc | 87 | #endif |
madcowswe | 15:9c5aaeda36dc | 88 | |
madcowswe | 15:9c5aaeda36dc | 89 | |
madcowswe | 15:9c5aaeda36dc | 90 | /* |
madcowswe | 15:9c5aaeda36dc | 91 | * Complexity triggers, compiler and architecture specific. |
madcowswe | 15:9c5aaeda36dc | 92 | * If not defined, use defaults. |
madcowswe | 15:9c5aaeda36dc | 93 | */ |
madcowswe | 15:9c5aaeda36dc | 94 | |
madcowswe | 15:9c5aaeda36dc | 95 | /** |
madcowswe | 15:9c5aaeda36dc | 96 | * \def TVMET_COMPLEXITY_DEFAULT_TRIGGER |
madcowswe | 15:9c5aaeda36dc | 97 | * \brief Trigger for changing the matrix-product strategy. |
madcowswe | 15:9c5aaeda36dc | 98 | */ |
madcowswe | 15:9c5aaeda36dc | 99 | #if !defined(TVMET_COMPLEXITY_DEFAULT_TRIGGER) |
madcowswe | 15:9c5aaeda36dc | 100 | # define TVMET_COMPLEXITY_DEFAULT_TRIGGER 1000 |
madcowswe | 15:9c5aaeda36dc | 101 | #endif |
madcowswe | 15:9c5aaeda36dc | 102 | |
madcowswe | 15:9c5aaeda36dc | 103 | /** |
madcowswe | 15:9c5aaeda36dc | 104 | * \def TVMET_COMPLEXITY_M_ASSIGN_TRIGGER |
madcowswe | 15:9c5aaeda36dc | 105 | * \brief Trigger for changing the matrix assign strategy. |
madcowswe | 15:9c5aaeda36dc | 106 | */ |
madcowswe | 15:9c5aaeda36dc | 107 | #if !defined(TVMET_COMPLEXITY_M_ASSIGN_TRIGGER) |
madcowswe | 15:9c5aaeda36dc | 108 | # define TVMET_COMPLEXITY_M_ASSIGN_TRIGGER 8*8 |
madcowswe | 15:9c5aaeda36dc | 109 | #endif |
madcowswe | 15:9c5aaeda36dc | 110 | |
madcowswe | 15:9c5aaeda36dc | 111 | /** |
madcowswe | 15:9c5aaeda36dc | 112 | * \def TVMET_COMPLEXITY_MM_TRIGGER |
madcowswe | 15:9c5aaeda36dc | 113 | * \brief Trigger for changing the matrix-matrix-product strategy. |
madcowswe | 15:9c5aaeda36dc | 114 | * One strategy to build the matrix-matrix-product is to use |
madcowswe | 15:9c5aaeda36dc | 115 | * meta templates. The other to use looping. |
madcowswe | 15:9c5aaeda36dc | 116 | */ |
madcowswe | 15:9c5aaeda36dc | 117 | #if !defined(TVMET_COMPLEXITY_MM_TRIGGER) |
madcowswe | 15:9c5aaeda36dc | 118 | # define TVMET_COMPLEXITY_MM_TRIGGER 8*8 |
madcowswe | 15:9c5aaeda36dc | 119 | #endif |
madcowswe | 15:9c5aaeda36dc | 120 | |
madcowswe | 15:9c5aaeda36dc | 121 | /** |
madcowswe | 15:9c5aaeda36dc | 122 | * \def TVMET_COMPLEXITY_V_ASSIGN_TRIGGER |
madcowswe | 15:9c5aaeda36dc | 123 | * \brief Trigger for changing the vector assign strategy. |
madcowswe | 15:9c5aaeda36dc | 124 | */ |
madcowswe | 15:9c5aaeda36dc | 125 | #if !defined(TVMET_COMPLEXITY_V_ASSIGN_TRIGGER) |
madcowswe | 15:9c5aaeda36dc | 126 | # define TVMET_COMPLEXITY_V_ASSIGN_TRIGGER 8 |
madcowswe | 15:9c5aaeda36dc | 127 | #endif |
madcowswe | 15:9c5aaeda36dc | 128 | |
madcowswe | 15:9c5aaeda36dc | 129 | /** |
madcowswe | 15:9c5aaeda36dc | 130 | * \def TVMET_COMPLEXITY_MV_TRIGGER |
madcowswe | 15:9c5aaeda36dc | 131 | * \brief Trigger for changing the matrix-vector strategy. |
madcowswe | 15:9c5aaeda36dc | 132 | * One strategy to build the matrix-vector-product is to use |
madcowswe | 15:9c5aaeda36dc | 133 | * meta templates. The other to use looping. |
madcowswe | 15:9c5aaeda36dc | 134 | */ |
madcowswe | 15:9c5aaeda36dc | 135 | #if !defined(TVMET_COMPLEXITY_MV_TRIGGER) |
madcowswe | 15:9c5aaeda36dc | 136 | # define TVMET_COMPLEXITY_MV_TRIGGER 8*8 |
madcowswe | 15:9c5aaeda36dc | 137 | #endif |
madcowswe | 15:9c5aaeda36dc | 138 | |
madcowswe | 15:9c5aaeda36dc | 139 | |
madcowswe | 15:9c5aaeda36dc | 140 | /*********************************************************************** |
madcowswe | 15:9c5aaeda36dc | 141 | * other specials |
madcowswe | 15:9c5aaeda36dc | 142 | ***********************************************************************/ |
madcowswe | 15:9c5aaeda36dc | 143 | #if defined(TVMET_HAVE_IEEE_MATH) |
madcowswe | 15:9c5aaeda36dc | 144 | # define _ALL_SOURCE |
madcowswe | 15:9c5aaeda36dc | 145 | # if !defined(_XOPEN_SOURCE) |
madcowswe | 15:9c5aaeda36dc | 146 | # define _XOPEN_SOURCE |
madcowswe | 15:9c5aaeda36dc | 147 | # endif |
madcowswe | 15:9c5aaeda36dc | 148 | # if !defined(_XOPEN_SOURCE_EXTENDED) |
madcowswe | 15:9c5aaeda36dc | 149 | # define _XOPEN_SOURCE_EXTENDED |
madcowswe | 15:9c5aaeda36dc | 150 | # endif |
madcowswe | 15:9c5aaeda36dc | 151 | #endif |
madcowswe | 15:9c5aaeda36dc | 152 | |
madcowswe | 15:9c5aaeda36dc | 153 | |
madcowswe | 15:9c5aaeda36dc | 154 | /** |
madcowswe | 15:9c5aaeda36dc | 155 | * \def TVMET_DEBUG |
madcowswe | 15:9c5aaeda36dc | 156 | * This is defined if <code>DEBUG</code> is defined. This enables runtime error |
madcowswe | 15:9c5aaeda36dc | 157 | * bounds checking. If you compile %tvmet from another source directory |
madcowswe | 15:9c5aaeda36dc | 158 | * which defines <code>DEBUG</code>, then <code>TVMET_DEBUG</code> will be |
madcowswe | 15:9c5aaeda36dc | 159 | * <b>not</b> defined (This behavior differs from release less than 0.6.0). |
madcowswe | 15:9c5aaeda36dc | 160 | */ |
madcowswe | 15:9c5aaeda36dc | 161 | |
madcowswe | 15:9c5aaeda36dc | 162 | |
madcowswe | 15:9c5aaeda36dc | 163 | /** |
madcowswe | 15:9c5aaeda36dc | 164 | * \def TVMET_OPTIMIZE |
madcowswe | 15:9c5aaeda36dc | 165 | * If this is defined tvmet uses some compiler specific keywords. |
madcowswe | 15:9c5aaeda36dc | 166 | * Mainly, this declares the functions using gcc's |
madcowswe | 15:9c5aaeda36dc | 167 | * <tt>__attribute__((always_inline))</tt>. This allows the |
madcowswe | 15:9c5aaeda36dc | 168 | * compiler to produce high efficient code even on less |
madcowswe | 15:9c5aaeda36dc | 169 | * optimization levels, like gcc's -O2 or even -O! |
madcowswe | 15:9c5aaeda36dc | 170 | * This is known to work with gcc v3.3.3 (and higher). |
madcowswe | 15:9c5aaeda36dc | 171 | * Using icc's v8 gnuc compatibility mode this may work, I've read |
madcowswe | 15:9c5aaeda36dc | 172 | * that it's using as an hint, this means you can have static inline |
madcowswe | 15:9c5aaeda36dc | 173 | * functions inside left. |
madcowswe | 15:9c5aaeda36dc | 174 | */ |
madcowswe | 15:9c5aaeda36dc | 175 | #if !defined(TVMET_OPTIMIZE) |
madcowswe | 15:9c5aaeda36dc | 176 | # undef TVMET_CXX_ALWAYS_INLINE |
madcowswe | 15:9c5aaeda36dc | 177 | # define TVMET_CXX_ALWAYS_INLINE |
madcowswe | 15:9c5aaeda36dc | 178 | #endif |
madcowswe | 15:9c5aaeda36dc | 179 | |
madcowswe | 15:9c5aaeda36dc | 180 | |
madcowswe | 15:9c5aaeda36dc | 181 | /*********************************************************************** |
madcowswe | 15:9c5aaeda36dc | 182 | * Namespaces |
madcowswe | 15:9c5aaeda36dc | 183 | ***********************************************************************/ |
madcowswe | 15:9c5aaeda36dc | 184 | |
madcowswe | 15:9c5aaeda36dc | 185 | |
madcowswe | 15:9c5aaeda36dc | 186 | /** |
madcowswe | 15:9c5aaeda36dc | 187 | * \namespace std |
madcowswe | 15:9c5aaeda36dc | 188 | * \brief Imported ISO/IEC 14882:1998 functions from std namespace. |
madcowswe | 15:9c5aaeda36dc | 189 | */ |
madcowswe | 15:9c5aaeda36dc | 190 | |
madcowswe | 15:9c5aaeda36dc | 191 | /** |
madcowswe | 15:9c5aaeda36dc | 192 | * \namespace tvmet |
madcowswe | 15:9c5aaeda36dc | 193 | * \brief The namespace for the Tiny %Vector %Matrix using Expression Templates Libary. |
madcowswe | 15:9c5aaeda36dc | 194 | */ |
madcowswe | 15:9c5aaeda36dc | 195 | |
madcowswe | 15:9c5aaeda36dc | 196 | /** |
madcowswe | 15:9c5aaeda36dc | 197 | * \namespace tvmet::meta |
madcowswe | 15:9c5aaeda36dc | 198 | * \brief Meta stuff inside here. |
madcowswe | 15:9c5aaeda36dc | 199 | */ |
madcowswe | 15:9c5aaeda36dc | 200 | |
madcowswe | 15:9c5aaeda36dc | 201 | /** |
madcowswe | 15:9c5aaeda36dc | 202 | * \namespace tvmet::loop |
madcowswe | 15:9c5aaeda36dc | 203 | * \brief Loop stuff inside here. |
madcowswe | 15:9c5aaeda36dc | 204 | */ |
madcowswe | 15:9c5aaeda36dc | 205 | |
madcowswe | 15:9c5aaeda36dc | 206 | /** |
madcowswe | 15:9c5aaeda36dc | 207 | * \namespace tvmet::element_wise |
madcowswe | 15:9c5aaeda36dc | 208 | * \brief Operators inside this namespace does elementwise operations. |
madcowswe | 15:9c5aaeda36dc | 209 | */ |
madcowswe | 15:9c5aaeda36dc | 210 | |
madcowswe | 15:9c5aaeda36dc | 211 | /** |
madcowswe | 15:9c5aaeda36dc | 212 | * \namespace tvmet::util |
madcowswe | 15:9c5aaeda36dc | 213 | * \brief Miscellaneous utility functions used. |
madcowswe | 15:9c5aaeda36dc | 214 | */ |
madcowswe | 15:9c5aaeda36dc | 215 | |
madcowswe | 15:9c5aaeda36dc | 216 | |
madcowswe | 15:9c5aaeda36dc | 217 | /*********************************************************************** |
madcowswe | 15:9c5aaeda36dc | 218 | * forwards |
madcowswe | 15:9c5aaeda36dc | 219 | ***********************************************************************/ |
madcowswe | 15:9c5aaeda36dc | 220 | #if defined(TVMET_HAVE_COMPLEX) |
madcowswe | 15:9c5aaeda36dc | 221 | namespace std { |
madcowswe | 15:9c5aaeda36dc | 222 | template<class T> class complex; |
madcowswe | 15:9c5aaeda36dc | 223 | } |
madcowswe | 15:9c5aaeda36dc | 224 | #endif |
madcowswe | 15:9c5aaeda36dc | 225 | |
madcowswe | 15:9c5aaeda36dc | 226 | |
madcowswe | 15:9c5aaeda36dc | 227 | /*********************************************************************** |
madcowswe | 15:9c5aaeda36dc | 228 | * other stuff |
madcowswe | 15:9c5aaeda36dc | 229 | ***********************************************************************/ |
madcowswe | 15:9c5aaeda36dc | 230 | #include <tvmet/TvmetBase.h> |
madcowswe | 15:9c5aaeda36dc | 231 | |
madcowswe | 15:9c5aaeda36dc | 232 | |
madcowswe | 15:9c5aaeda36dc | 233 | #endif // TVMET_H |
madcowswe | 15:9c5aaeda36dc | 234 | |
madcowswe | 15:9c5aaeda36dc | 235 | // Local Variables: |
madcowswe | 15:9c5aaeda36dc | 236 | // mode:C++ |
madcowswe | 15:9c5aaeda36dc | 237 | // tab-width:8 |
madcowswe | 15:9c5aaeda36dc | 238 | // End: |
madcowswe | 15:9c5aaeda36dc | 239 | // LocalWords: gnuc gcc's icc's std |