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