2014 Eurobot fork

Dependencies:   mbed-rtos mbed QEI

Committer:
rsavitski
Date:
Tue Oct 15 12:19:32 2013 +0000
Revision:
92:4a1225fbb146
Parent:
15:9c5aaeda36dc
touch: ripped out 2013-specific bits. Need to address "2014" comments. Rewrite AI layer and other deleted parts.

Who changed what in which revision?

UserRevisionLine numberNew 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: TvmetBase.h,v 1.17 2007-06-23 15:58:58 opetzold Exp $
madcowswe 15:9c5aaeda36dc 22 */
madcowswe 15:9c5aaeda36dc 23
madcowswe 15:9c5aaeda36dc 24 #ifndef TVMET_BASE_H
madcowswe 15:9c5aaeda36dc 25 #define TVMET_BASE_H
madcowswe 15:9c5aaeda36dc 26
madcowswe 15:9c5aaeda36dc 27 #include <iostream>//<iosfwd> // io streams forward declaration
madcowswe 15:9c5aaeda36dc 28 #include <typeinfo> // rtti: used by Xpr.h level printing
madcowswe 15:9c5aaeda36dc 29 #include <cmath> // unary and binary math
madcowswe 15:9c5aaeda36dc 30 #include <cstdlib> // labs
madcowswe 15:9c5aaeda36dc 31
madcowswe 15:9c5aaeda36dc 32 #if defined(WIN32) && defined(_MSC_VER) && (_MSC_VER == 1310)
madcowswe 15:9c5aaeda36dc 33 #include <string> // operator<<(ostream) here defined
madcowswe 15:9c5aaeda36dc 34 #endif
madcowswe 15:9c5aaeda36dc 35
madcowswe 15:9c5aaeda36dc 36 #if defined(__APPLE_CC__)
madcowswe 15:9c5aaeda36dc 37 // Mac OS X builds seems to miss these functions inside cmath
madcowswe 15:9c5aaeda36dc 38 extern "C" int isnan(double);
madcowswe 15:9c5aaeda36dc 39 extern "C" int isinf(double);
madcowswe 15:9c5aaeda36dc 40 #endif
madcowswe 15:9c5aaeda36dc 41
madcowswe 15:9c5aaeda36dc 42 namespace tvmet {
madcowswe 15:9c5aaeda36dc 43
madcowswe 15:9c5aaeda36dc 44
madcowswe 15:9c5aaeda36dc 45 /**
madcowswe 15:9c5aaeda36dc 46 * \class TvmetBase TvmetBase.h "tvmet/TvmetBase.h"
madcowswe 15:9c5aaeda36dc 47 * \brief Base class
madcowswe 15:9c5aaeda36dc 48 * Used for static polymorph call of print_xpr
madcowswe 15:9c5aaeda36dc 49 */
madcowswe 15:9c5aaeda36dc 50 template<class E> class TvmetBase { };
madcowswe 15:9c5aaeda36dc 51
madcowswe 15:9c5aaeda36dc 52
madcowswe 15:9c5aaeda36dc 53 /**
madcowswe 15:9c5aaeda36dc 54 * \class IndentLevel TvmetBase.h "tvmet/TvmetBase.h"
madcowswe 15:9c5aaeda36dc 55 * \brief Prints the level indent.
madcowswe 15:9c5aaeda36dc 56 */
madcowswe 15:9c5aaeda36dc 57 class IndentLevel : public TvmetBase< IndentLevel >
madcowswe 15:9c5aaeda36dc 58 {
madcowswe 15:9c5aaeda36dc 59 public:
madcowswe 15:9c5aaeda36dc 60 IndentLevel(std::size_t level) : m_level(level) { }
madcowswe 15:9c5aaeda36dc 61
madcowswe 15:9c5aaeda36dc 62 std::ostream& print_xpr(std::ostream& os) const {
madcowswe 15:9c5aaeda36dc 63 for(std::size_t i = 0; i != m_level; ++i) os << " ";
madcowswe 15:9c5aaeda36dc 64 return os;
madcowswe 15:9c5aaeda36dc 65 }
madcowswe 15:9c5aaeda36dc 66
madcowswe 15:9c5aaeda36dc 67 private:
madcowswe 15:9c5aaeda36dc 68 std::size_t m_level;
madcowswe 15:9c5aaeda36dc 69 };
madcowswe 15:9c5aaeda36dc 70
madcowswe 15:9c5aaeda36dc 71
madcowswe 15:9c5aaeda36dc 72 /**
madcowswe 15:9c5aaeda36dc 73 * \fn operator<<(std::ostream& os, const TvmetBase<E>& e)
madcowswe 15:9c5aaeda36dc 74 * \brief overloaded ostream operator using static polymorphic.
madcowswe 15:9c5aaeda36dc 75 * \ingroup _binary_operator
madcowswe 15:9c5aaeda36dc 76 */
madcowswe 15:9c5aaeda36dc 77 template<class E>
madcowswe 15:9c5aaeda36dc 78 inline
madcowswe 15:9c5aaeda36dc 79 std::ostream& operator<<(std::ostream& os, const TvmetBase<E>& e) {
madcowswe 15:9c5aaeda36dc 80 static_cast<const E&>(e).print_xpr(os);
madcowswe 15:9c5aaeda36dc 81 return os;
madcowswe 15:9c5aaeda36dc 82 }
madcowswe 15:9c5aaeda36dc 83
madcowswe 15:9c5aaeda36dc 84
madcowswe 15:9c5aaeda36dc 85 /**
madcowswe 15:9c5aaeda36dc 86 * \class dispatch TvmetBase.h "tvmet/TvmetBase.h"
madcowswe 15:9c5aaeda36dc 87 * \brief Class helper to distuingish between e.g. meta
madcowswe 15:9c5aaeda36dc 88 * and loop strategy used.
madcowswe 15:9c5aaeda36dc 89 */
madcowswe 15:9c5aaeda36dc 90 template<bool> struct dispatch;
madcowswe 15:9c5aaeda36dc 91
madcowswe 15:9c5aaeda36dc 92 /**
madcowswe 15:9c5aaeda36dc 93 * \class dispatch<true> TvmetBase.h "tvmet/TvmetBase.h"
madcowswe 15:9c5aaeda36dc 94 * \brief specialized.
madcowswe 15:9c5aaeda36dc 95 */
madcowswe 15:9c5aaeda36dc 96 template<> struct dispatch<true> { };
madcowswe 15:9c5aaeda36dc 97
madcowswe 15:9c5aaeda36dc 98 /**
madcowswe 15:9c5aaeda36dc 99 * \class dispatch<false> TvmetBase.h "tvmet/TvmetBase.h"
madcowswe 15:9c5aaeda36dc 100 * \brief specialized.
madcowswe 15:9c5aaeda36dc 101 */
madcowswe 15:9c5aaeda36dc 102 template<> struct dispatch<false> { };
madcowswe 15:9c5aaeda36dc 103
madcowswe 15:9c5aaeda36dc 104
madcowswe 15:9c5aaeda36dc 105 } // namespace tvmet
madcowswe 15:9c5aaeda36dc 106
madcowswe 15:9c5aaeda36dc 107 #endif // TVMET_BASE_H
madcowswe 15:9c5aaeda36dc 108
madcowswe 15:9c5aaeda36dc 109 // Local Variables:
madcowswe 15:9c5aaeda36dc 110 // mode:C++
madcowswe 15:9c5aaeda36dc 111 // tab-width:8
madcowswe 15:9c5aaeda36dc 112 // End: