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: MatrixRow.h,v 1.18 2007-06-23 15:59:00 opetzold Exp $
narshu 25:143b19c1fb05 22 */
narshu 25:143b19c1fb05 23
narshu 25:143b19c1fb05 24 #ifndef TVMET_XPR_MATRIX_ROW_H
narshu 25:143b19c1fb05 25 #define TVMET_XPR_MATRIX_ROW_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 XprMatrixRow MatrixRow.h "tvmet/xpr/MatrixRow.h"
narshu 25:143b19c1fb05 32 * \brief Expression on matrix used for access on the row vector.
narshu 25:143b19c1fb05 33 */
narshu 25:143b19c1fb05 34 template<class E, std::size_t Rows, std::size_t Cols>
narshu 25:143b19c1fb05 35 class XprMatrixRow
narshu 25:143b19c1fb05 36 : public TvmetBase< XprMatrixRow<E, Rows, Cols> >
narshu 25:143b19c1fb05 37 {
narshu 25:143b19c1fb05 38 XprMatrixRow();
narshu 25:143b19c1fb05 39 XprMatrixRow& operator=(const XprMatrixRow&);
narshu 25:143b19c1fb05 40
narshu 25:143b19c1fb05 41 public:
narshu 25:143b19c1fb05 42 typedef typename E::value_type value_type;
narshu 25:143b19c1fb05 43
narshu 25:143b19c1fb05 44 public:
narshu 25:143b19c1fb05 45 /** Complexity counter. */
narshu 25:143b19c1fb05 46 enum {
narshu 25:143b19c1fb05 47 ops_expr = E::ops,
narshu 25:143b19c1fb05 48 ops = ops_expr/Rows // equal Col accesses
narshu 25:143b19c1fb05 49 };
narshu 25:143b19c1fb05 50
narshu 25:143b19c1fb05 51 public:
narshu 25:143b19c1fb05 52 /** Constructor. */
narshu 25:143b19c1fb05 53 explicit XprMatrixRow(const E& e, std::size_t no)
narshu 25:143b19c1fb05 54 : m_expr(e), m_row(no)
narshu 25:143b19c1fb05 55 {
narshu 25:143b19c1fb05 56 TVMET_RT_CONDITION(no < Rows, "XprMatrixRow Bounce Violation")
narshu 25:143b19c1fb05 57 }
narshu 25:143b19c1fb05 58
narshu 25:143b19c1fb05 59 /** Copy Constructor. Not explicit! */
narshu 25:143b19c1fb05 60 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
narshu 25:143b19c1fb05 61 XprMatrixRow(const XprMatrixRow& rhs)
narshu 25:143b19c1fb05 62 : m_expr(rhs.m_expr), m_row(rhs.m_row)
narshu 25:143b19c1fb05 63 { }
narshu 25:143b19c1fb05 64 #endif
narshu 25:143b19c1fb05 65
narshu 25:143b19c1fb05 66 value_type operator()(std::size_t j) const {
narshu 25:143b19c1fb05 67 TVMET_RT_CONDITION(j < Cols, "XprMatrixRow Bounce Violation")
narshu 25:143b19c1fb05 68 return m_expr(m_row, j);
narshu 25:143b19c1fb05 69 }
narshu 25:143b19c1fb05 70
narshu 25:143b19c1fb05 71 public: // debugging Xpr parse tree
narshu 25:143b19c1fb05 72 void print_xpr(std::ostream& os, std::size_t l=0) const {
narshu 25:143b19c1fb05 73 os << IndentLevel(l++)
narshu 25:143b19c1fb05 74 << "XprMatrixRow[O=" << ops << ", (O=" << ops_expr << ")]<"
narshu 25:143b19c1fb05 75 << std::endl;
narshu 25:143b19c1fb05 76 m_expr.print_xpr(os, l);
narshu 25:143b19c1fb05 77 os << IndentLevel(l)
narshu 25:143b19c1fb05 78 << "R=" << Rows << ", C=" << Cols << std::endl
narshu 25:143b19c1fb05 79 << IndentLevel(--l) << ">"
narshu 25:143b19c1fb05 80 << ((l != 0) ? "," : "") << std::endl;
narshu 25:143b19c1fb05 81 }
narshu 25:143b19c1fb05 82
narshu 25:143b19c1fb05 83 private:
narshu 25:143b19c1fb05 84 const E m_expr;
narshu 25:143b19c1fb05 85 const std::size_t m_row;
narshu 25:143b19c1fb05 86 };
narshu 25:143b19c1fb05 87
narshu 25:143b19c1fb05 88
narshu 25:143b19c1fb05 89 }
narshu 25:143b19c1fb05 90
narshu 25:143b19c1fb05 91 #endif // TVMET_XPR_MATRIX_ROW_H
narshu 25:143b19c1fb05 92
narshu 25:143b19c1fb05 93 // Local Variables:
narshu 25:143b19c1fb05 94 // mode:C++
narshu 25:143b19c1fb05 95 // tab-width:8
narshu 25:143b19c1fb05 96 // End: