Cooper Liu
/
Eurobot2013_Co-Processor
working version with calibration done
Fork of Eurobot2013 by
tvmet/xpr/Literal.h@1:6799c07fe510, 2012-11-07 (annotated)
- Committer:
- sv
- Date:
- Wed Nov 07 14:37:35 2012 +0000
- Revision:
- 1:6799c07fe510
Preliminary copy of 2012 code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sv | 1:6799c07fe510 | 1 | /* |
sv | 1:6799c07fe510 | 2 | * Tiny Vector Matrix Library |
sv | 1:6799c07fe510 | 3 | * Dense Vector Matrix Libary of Tiny size using Expression Templates |
sv | 1:6799c07fe510 | 4 | * |
sv | 1:6799c07fe510 | 5 | * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net> |
sv | 1:6799c07fe510 | 6 | * |
sv | 1:6799c07fe510 | 7 | * This library is free software; you can redistribute it and/or |
sv | 1:6799c07fe510 | 8 | * modify it under the terms of the GNU Lesser General Public |
sv | 1:6799c07fe510 | 9 | * License as published by the Free Software Foundation; either |
sv | 1:6799c07fe510 | 10 | * version 2.1 of the License, or (at your option) any later version. |
sv | 1:6799c07fe510 | 11 | * |
sv | 1:6799c07fe510 | 12 | * This library is distributed in the hope that it will be useful, |
sv | 1:6799c07fe510 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
sv | 1:6799c07fe510 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
sv | 1:6799c07fe510 | 15 | * Lesser General Public License for more details. |
sv | 1:6799c07fe510 | 16 | * |
sv | 1:6799c07fe510 | 17 | * You should have received a copy of the GNU Lesser General Public |
sv | 1:6799c07fe510 | 18 | * License along with this library; if not, write to the Free Software |
sv | 1:6799c07fe510 | 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
sv | 1:6799c07fe510 | 20 | * |
sv | 1:6799c07fe510 | 21 | * $Id: Literal.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $ |
sv | 1:6799c07fe510 | 22 | */ |
sv | 1:6799c07fe510 | 23 | |
sv | 1:6799c07fe510 | 24 | #ifndef TVMET_XPR_LITERAL_H |
sv | 1:6799c07fe510 | 25 | #define TVMET_XPR_LITERAL_H |
sv | 1:6799c07fe510 | 26 | |
sv | 1:6799c07fe510 | 27 | namespace tvmet { |
sv | 1:6799c07fe510 | 28 | |
sv | 1:6799c07fe510 | 29 | |
sv | 1:6799c07fe510 | 30 | /** |
sv | 1:6799c07fe510 | 31 | * \class XprLiteral Literal.h "tvmet/xpr/Literal.h" |
sv | 1:6799c07fe510 | 32 | * \brief Specify literals like scalars into the expression. |
sv | 1:6799c07fe510 | 33 | * This expression is used for vectors and matrices - the |
sv | 1:6799c07fe510 | 34 | * decision is done by the access operator. |
sv | 1:6799c07fe510 | 35 | */ |
sv | 1:6799c07fe510 | 36 | template<class T> |
sv | 1:6799c07fe510 | 37 | class XprLiteral |
sv | 1:6799c07fe510 | 38 | : public TvmetBase< XprLiteral<T> > |
sv | 1:6799c07fe510 | 39 | { |
sv | 1:6799c07fe510 | 40 | XprLiteral(); |
sv | 1:6799c07fe510 | 41 | XprLiteral& operator=(const XprLiteral&); |
sv | 1:6799c07fe510 | 42 | |
sv | 1:6799c07fe510 | 43 | public: |
sv | 1:6799c07fe510 | 44 | typedef T value_type; |
sv | 1:6799c07fe510 | 45 | |
sv | 1:6799c07fe510 | 46 | public: |
sv | 1:6799c07fe510 | 47 | /** Complexity counter. */ |
sv | 1:6799c07fe510 | 48 | enum { |
sv | 1:6799c07fe510 | 49 | ops = 1 |
sv | 1:6799c07fe510 | 50 | }; |
sv | 1:6799c07fe510 | 51 | |
sv | 1:6799c07fe510 | 52 | public: |
sv | 1:6799c07fe510 | 53 | /** Constructor by value for literals . */ |
sv | 1:6799c07fe510 | 54 | explicit XprLiteral(value_type value) |
sv | 1:6799c07fe510 | 55 | : m_data(value) |
sv | 1:6799c07fe510 | 56 | { } |
sv | 1:6799c07fe510 | 57 | |
sv | 1:6799c07fe510 | 58 | /** Copy Constructor. Not explicit! */ |
sv | 1:6799c07fe510 | 59 | #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) |
sv | 1:6799c07fe510 | 60 | XprLiteral(const XprLiteral& e) |
sv | 1:6799c07fe510 | 61 | : m_data(e.m_data) |
sv | 1:6799c07fe510 | 62 | { } |
sv | 1:6799c07fe510 | 63 | #endif |
sv | 1:6799c07fe510 | 64 | |
sv | 1:6799c07fe510 | 65 | /** Index operator, gives the value for vectors. */ |
sv | 1:6799c07fe510 | 66 | value_type operator()(std::size_t) const { return m_data; } |
sv | 1:6799c07fe510 | 67 | |
sv | 1:6799c07fe510 | 68 | /** Index operator for arrays/matrices. */ |
sv | 1:6799c07fe510 | 69 | value_type operator()(std::size_t, std::size_t) const { return m_data; } |
sv | 1:6799c07fe510 | 70 | |
sv | 1:6799c07fe510 | 71 | public: // debugging Xpr parse tree |
sv | 1:6799c07fe510 | 72 | void print_xpr(std::ostream& os, std::size_t l=0) const { |
sv | 1:6799c07fe510 | 73 | os << IndentLevel(l++) << "XprLiteral[O=" << ops << "]<T=" |
sv | 1:6799c07fe510 | 74 | << typeid(value_type).name() |
sv | 1:6799c07fe510 | 75 | << ">," << std::endl; |
sv | 1:6799c07fe510 | 76 | } |
sv | 1:6799c07fe510 | 77 | |
sv | 1:6799c07fe510 | 78 | private: |
sv | 1:6799c07fe510 | 79 | const value_type m_data; |
sv | 1:6799c07fe510 | 80 | }; |
sv | 1:6799c07fe510 | 81 | |
sv | 1:6799c07fe510 | 82 | |
sv | 1:6799c07fe510 | 83 | } // namespace tvmet |
sv | 1:6799c07fe510 | 84 | |
sv | 1:6799c07fe510 | 85 | #endif // TVMET_XPR_LITERAL_H |
sv | 1:6799c07fe510 | 86 | |
sv | 1:6799c07fe510 | 87 | // Local Variables: |
sv | 1:6799c07fe510 | 88 | // mode:C++ |
sv | 1:6799c07fe510 | 89 | // tab-width:8 |
sv | 1:6799c07fe510 | 90 | // End: |