Eurobot2012_Secondary

Fork of Eurobot_2012_Secondary by Shuto Naruse

Committer:
narshu
Date:
Wed Oct 17 22:25:31 2012 +0000
Revision:
1:cc2a9eb0bd55
Commit before publishing

Who changed what in which revision?

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