Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Wed Oct 17 22:22:47 2012 +0000
Revision:
26:0995f61cb7b8
Parent:
25:143b19c1fb05
Eurobot 2012 Primary;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
narshu 25:143b19c1fb05 1 /*
narshu 25:143b19c1fb05 2 * Tiny Vector Matrix Library
narshu 25:143b19c1fb05 3 * Dense Vector Matrix Libary of Tiny size using Expression Templates
narshu 25:143b19c1fb05 4 *
narshu 25:143b19c1fb05 5 * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
narshu 25:143b19c1fb05 6 *
narshu 25:143b19c1fb05 7 * This library is free software; you can redistribute it and/or
narshu 25:143b19c1fb05 8 * modify it under the terms of the GNU Lesser General Public
narshu 25:143b19c1fb05 9 * License as published by the Free Software Foundation; either
narshu 25:143b19c1fb05 10 * version 2.1 of the License, or (at your option) any later version.
narshu 25:143b19c1fb05 11 *
narshu 25:143b19c1fb05 12 * This library is distributed in the hope that it will be useful,
narshu 25:143b19c1fb05 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
narshu 25:143b19c1fb05 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
narshu 25:143b19c1fb05 15 * Lesser General Public License for more details.
narshu 25:143b19c1fb05 16 *
narshu 25:143b19c1fb05 17 * You should have received a copy of the GNU Lesser General Public
narshu 25:143b19c1fb05 18 * License along with this library; if not, write to the Free Software
narshu 25:143b19c1fb05 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
narshu 25:143b19c1fb05 20 *
narshu 25:143b19c1fb05 21 * $Id: Extremum.h,v 1.10 2007-06-23 15:58:58 opetzold Exp $
narshu 25:143b19c1fb05 22 */
narshu 25:143b19c1fb05 23
narshu 25:143b19c1fb05 24 #ifndef TVMET_EXTREMUM_H
narshu 25:143b19c1fb05 25 #define TVMET_EXTREMUM_H
narshu 25:143b19c1fb05 26
narshu 25:143b19c1fb05 27 namespace tvmet {
narshu 25:143b19c1fb05 28
narshu 25:143b19c1fb05 29
narshu 25:143b19c1fb05 30 /**
narshu 25:143b19c1fb05 31 * \class matrix_tag Extremum.h "tvmet/Extremum.h"
narshu 25:143b19c1fb05 32 * \brief For use with Extremum to simplify max handling.
narshu 25:143b19c1fb05 33 * This allows the min/max functions to return an Extremum object.
narshu 25:143b19c1fb05 34 */
narshu 25:143b19c1fb05 35 struct matrix_tag { };
narshu 25:143b19c1fb05 36
narshu 25:143b19c1fb05 37
narshu 25:143b19c1fb05 38 /**
narshu 25:143b19c1fb05 39 * \class vector_tag Extremum.h "tvmet/Extremum.h"
narshu 25:143b19c1fb05 40 * \brief For use with Extremum to simplify max handling.
narshu 25:143b19c1fb05 41 * This allows the min/max functions to return an Extremum object.
narshu 25:143b19c1fb05 42 */
narshu 25:143b19c1fb05 43 struct vector_tag { };
narshu 25:143b19c1fb05 44
narshu 25:143b19c1fb05 45
narshu 25:143b19c1fb05 46 /**
narshu 25:143b19c1fb05 47 * \class Extremum Extremum.h "tvmet/Extremum.h"
narshu 25:143b19c1fb05 48 * \brief Generell class for storing extremums determined by min/max.
narshu 25:143b19c1fb05 49 */
narshu 25:143b19c1fb05 50 template<class T1, class T2, class Tag>
narshu 25:143b19c1fb05 51 class Extremum { };
narshu 25:143b19c1fb05 52
narshu 25:143b19c1fb05 53
narshu 25:143b19c1fb05 54 /**
narshu 25:143b19c1fb05 55 * \class Extremum<T1, T2, vector_tag> Extremum.h "tvmet/Extremum.h"
narshu 25:143b19c1fb05 56 * \brief Partial specialzed for vectors to store extremums by value and index.
narshu 25:143b19c1fb05 57 */
narshu 25:143b19c1fb05 58 template<class T1, class T2>
narshu 25:143b19c1fb05 59 class Extremum<T1, T2, vector_tag>
narshu 25:143b19c1fb05 60 {
narshu 25:143b19c1fb05 61 public:
narshu 25:143b19c1fb05 62 typedef T1 value_type;
narshu 25:143b19c1fb05 63 typedef T2 index_type;
narshu 25:143b19c1fb05 64
narshu 25:143b19c1fb05 65 public:
narshu 25:143b19c1fb05 66 Extremum(value_type value, index_type index)
narshu 25:143b19c1fb05 67 : m_value(value), m_index(index) { }
narshu 25:143b19c1fb05 68 value_type value() const { return m_value; }
narshu 25:143b19c1fb05 69 index_type index() const { return m_index; }
narshu 25:143b19c1fb05 70
narshu 25:143b19c1fb05 71 private:
narshu 25:143b19c1fb05 72 value_type m_value;
narshu 25:143b19c1fb05 73 index_type m_index;
narshu 25:143b19c1fb05 74 };
narshu 25:143b19c1fb05 75
narshu 25:143b19c1fb05 76
narshu 25:143b19c1fb05 77 /**
narshu 25:143b19c1fb05 78 * \class Extremum<T1, T2, matrix_tag> Extremum.h "tvmet/Extremum.h"
narshu 25:143b19c1fb05 79 * \brief Partial specialzed for matrix to store extremums by value, row and column.
narshu 25:143b19c1fb05 80 */
narshu 25:143b19c1fb05 81 template<class T1, class T2>
narshu 25:143b19c1fb05 82 class Extremum<T1, T2, matrix_tag>
narshu 25:143b19c1fb05 83 {
narshu 25:143b19c1fb05 84 public:
narshu 25:143b19c1fb05 85 typedef T1 value_type;
narshu 25:143b19c1fb05 86 typedef T2 index_type;
narshu 25:143b19c1fb05 87
narshu 25:143b19c1fb05 88 public:
narshu 25:143b19c1fb05 89 Extremum(value_type value, index_type row, index_type col)
narshu 25:143b19c1fb05 90 : m_value(value), m_row(row), m_col(col) { }
narshu 25:143b19c1fb05 91 value_type value() const { return m_value; }
narshu 25:143b19c1fb05 92 index_type row() const { return m_row; }
narshu 25:143b19c1fb05 93 index_type col() const { return m_col; }
narshu 25:143b19c1fb05 94
narshu 25:143b19c1fb05 95 private:
narshu 25:143b19c1fb05 96 value_type m_value;
narshu 25:143b19c1fb05 97 index_type m_row, m_col;
narshu 25:143b19c1fb05 98 };
narshu 25:143b19c1fb05 99
narshu 25:143b19c1fb05 100
narshu 25:143b19c1fb05 101 } // namespace tvmet
narshu 25:143b19c1fb05 102
narshu 25:143b19c1fb05 103 #endif // TVMET_EXTREMUM_H
narshu 25:143b19c1fb05 104
narshu 25:143b19c1fb05 105 // Local Variables:
narshu 25:143b19c1fb05 106 // mode:C++
narshu 25:143b19c1fb05 107 // tab-width:8
narshu 25:143b19c1fb05 108 // End: