2014 Eurobot fork
Dependencies: mbed-rtos mbed QEI
tvmet/Extremum.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: Extremum.h,v 1.10 2007-06-23 15:58:58 opetzold Exp $ |
madcowswe | 15:9c5aaeda36dc | 22 | */ |
madcowswe | 15:9c5aaeda36dc | 23 | |
madcowswe | 15:9c5aaeda36dc | 24 | #ifndef TVMET_EXTREMUM_H |
madcowswe | 15:9c5aaeda36dc | 25 | #define TVMET_EXTREMUM_H |
madcowswe | 15:9c5aaeda36dc | 26 | |
madcowswe | 15:9c5aaeda36dc | 27 | namespace tvmet { |
madcowswe | 15:9c5aaeda36dc | 28 | |
madcowswe | 15:9c5aaeda36dc | 29 | |
madcowswe | 15:9c5aaeda36dc | 30 | /** |
madcowswe | 15:9c5aaeda36dc | 31 | * \class matrix_tag Extremum.h "tvmet/Extremum.h" |
madcowswe | 15:9c5aaeda36dc | 32 | * \brief For use with Extremum to simplify max handling. |
madcowswe | 15:9c5aaeda36dc | 33 | * This allows the min/max functions to return an Extremum object. |
madcowswe | 15:9c5aaeda36dc | 34 | */ |
madcowswe | 15:9c5aaeda36dc | 35 | struct matrix_tag { }; |
madcowswe | 15:9c5aaeda36dc | 36 | |
madcowswe | 15:9c5aaeda36dc | 37 | |
madcowswe | 15:9c5aaeda36dc | 38 | /** |
madcowswe | 15:9c5aaeda36dc | 39 | * \class vector_tag Extremum.h "tvmet/Extremum.h" |
madcowswe | 15:9c5aaeda36dc | 40 | * \brief For use with Extremum to simplify max handling. |
madcowswe | 15:9c5aaeda36dc | 41 | * This allows the min/max functions to return an Extremum object. |
madcowswe | 15:9c5aaeda36dc | 42 | */ |
madcowswe | 15:9c5aaeda36dc | 43 | struct vector_tag { }; |
madcowswe | 15:9c5aaeda36dc | 44 | |
madcowswe | 15:9c5aaeda36dc | 45 | |
madcowswe | 15:9c5aaeda36dc | 46 | /** |
madcowswe | 15:9c5aaeda36dc | 47 | * \class Extremum Extremum.h "tvmet/Extremum.h" |
madcowswe | 15:9c5aaeda36dc | 48 | * \brief Generell class for storing extremums determined by min/max. |
madcowswe | 15:9c5aaeda36dc | 49 | */ |
madcowswe | 15:9c5aaeda36dc | 50 | template<class T1, class T2, class Tag> |
madcowswe | 15:9c5aaeda36dc | 51 | class Extremum { }; |
madcowswe | 15:9c5aaeda36dc | 52 | |
madcowswe | 15:9c5aaeda36dc | 53 | |
madcowswe | 15:9c5aaeda36dc | 54 | /** |
madcowswe | 15:9c5aaeda36dc | 55 | * \class Extremum<T1, T2, vector_tag> Extremum.h "tvmet/Extremum.h" |
madcowswe | 15:9c5aaeda36dc | 56 | * \brief Partial specialzed for vectors to store extremums by value and index. |
madcowswe | 15:9c5aaeda36dc | 57 | */ |
madcowswe | 15:9c5aaeda36dc | 58 | template<class T1, class T2> |
madcowswe | 15:9c5aaeda36dc | 59 | class Extremum<T1, T2, vector_tag> |
madcowswe | 15:9c5aaeda36dc | 60 | { |
madcowswe | 15:9c5aaeda36dc | 61 | public: |
madcowswe | 15:9c5aaeda36dc | 62 | typedef T1 value_type; |
madcowswe | 15:9c5aaeda36dc | 63 | typedef T2 index_type; |
madcowswe | 15:9c5aaeda36dc | 64 | |
madcowswe | 15:9c5aaeda36dc | 65 | public: |
madcowswe | 15:9c5aaeda36dc | 66 | Extremum(value_type value, index_type index) |
madcowswe | 15:9c5aaeda36dc | 67 | : m_value(value), m_index(index) { } |
madcowswe | 15:9c5aaeda36dc | 68 | value_type value() const { return m_value; } |
madcowswe | 15:9c5aaeda36dc | 69 | index_type index() const { return m_index; } |
madcowswe | 15:9c5aaeda36dc | 70 | |
madcowswe | 15:9c5aaeda36dc | 71 | private: |
madcowswe | 15:9c5aaeda36dc | 72 | value_type m_value; |
madcowswe | 15:9c5aaeda36dc | 73 | index_type m_index; |
madcowswe | 15:9c5aaeda36dc | 74 | }; |
madcowswe | 15:9c5aaeda36dc | 75 | |
madcowswe | 15:9c5aaeda36dc | 76 | |
madcowswe | 15:9c5aaeda36dc | 77 | /** |
madcowswe | 15:9c5aaeda36dc | 78 | * \class Extremum<T1, T2, matrix_tag> Extremum.h "tvmet/Extremum.h" |
madcowswe | 15:9c5aaeda36dc | 79 | * \brief Partial specialzed for matrix to store extremums by value, row and column. |
madcowswe | 15:9c5aaeda36dc | 80 | */ |
madcowswe | 15:9c5aaeda36dc | 81 | template<class T1, class T2> |
madcowswe | 15:9c5aaeda36dc | 82 | class Extremum<T1, T2, matrix_tag> |
madcowswe | 15:9c5aaeda36dc | 83 | { |
madcowswe | 15:9c5aaeda36dc | 84 | public: |
madcowswe | 15:9c5aaeda36dc | 85 | typedef T1 value_type; |
madcowswe | 15:9c5aaeda36dc | 86 | typedef T2 index_type; |
madcowswe | 15:9c5aaeda36dc | 87 | |
madcowswe | 15:9c5aaeda36dc | 88 | public: |
madcowswe | 15:9c5aaeda36dc | 89 | Extremum(value_type value, index_type row, index_type col) |
madcowswe | 15:9c5aaeda36dc | 90 | : m_value(value), m_row(row), m_col(col) { } |
madcowswe | 15:9c5aaeda36dc | 91 | value_type value() const { return m_value; } |
madcowswe | 15:9c5aaeda36dc | 92 | index_type row() const { return m_row; } |
madcowswe | 15:9c5aaeda36dc | 93 | index_type col() const { return m_col; } |
madcowswe | 15:9c5aaeda36dc | 94 | |
madcowswe | 15:9c5aaeda36dc | 95 | private: |
madcowswe | 15:9c5aaeda36dc | 96 | value_type m_value; |
madcowswe | 15:9c5aaeda36dc | 97 | index_type m_row, m_col; |
madcowswe | 15:9c5aaeda36dc | 98 | }; |
madcowswe | 15:9c5aaeda36dc | 99 | |
madcowswe | 15:9c5aaeda36dc | 100 | |
madcowswe | 15:9c5aaeda36dc | 101 | } // namespace tvmet |
madcowswe | 15:9c5aaeda36dc | 102 | |
madcowswe | 15:9c5aaeda36dc | 103 | #endif // TVMET_EXTREMUM_H |
madcowswe | 15:9c5aaeda36dc | 104 | |
madcowswe | 15:9c5aaeda36dc | 105 | // Local Variables: |
madcowswe | 15:9c5aaeda36dc | 106 | // mode:C++ |
madcowswe | 15:9c5aaeda36dc | 107 | // tab-width:8 |
madcowswe | 15:9c5aaeda36dc | 108 | // End: |