This is some awesome robot code

Dependencies:   mbed-rtos mbed QEI

Fork of ICRSEurobot13 by Thomas Branch

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Gemv.h Source File

Gemv.h

00001 /*
00002  * Tiny Vector Matrix Library
00003  * Dense Vector Matrix Libary of Tiny size using Expression Templates
00004  *
00005  * Copyright (C) 2001 - 2007 Olaf Petzold <opetzold@users.sourceforge.net>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  * $Id: Gemv.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_META_GEMV_H
00025 #define TVMET_META_GEMV_H
00026 
00027 #include <tvmet/xpr/Null.h>
00028 
00029 namespace tvmet {
00030 
00031 namespace meta {
00032 
00033 
00034 /**
00035  * \class gemv Gemv.h "tvmet/meta/Gemv.h"
00036  * \brief Meta class for matrix-vector operations.
00037  *        using formula
00038  *        \f[
00039  *        M\,v
00040  *        \f]
00041  */
00042 template<std::size_t Rows, std::size_t Cols,
00043      std::size_t J>
00044 class gemv
00045 {
00046   gemv();
00047   gemv(const gemv&);
00048   gemv& operator=(const gemv&);
00049 
00050 private:
00051   enum {
00052     doIt = J < (Cols-1)          /**< recursive counter */
00053   };
00054 
00055 public:
00056   /** Meta template for %Matrix lhs %Vector rhs product. */
00057   template<class E1, class E2>
00058   static inline
00059   typename PromoteTraits<
00060     typename E1::value_type,
00061     typename E2::value_type
00062   >::value_type
00063   prod(const E1& lhs, const E2& rhs, std::size_t i) {
00064     return lhs(i, J) * rhs(J)
00065       + gemv<Rows * doIt, Cols * doIt,
00066              (J+1)* doIt>::prod(lhs, rhs, i);
00067   }
00068 };
00069 
00070 
00071 /**
00072  * \class gemv<0,0,0> Gemv.h "tvmet/meta/Gemv.h"
00073  * \brief gemv Specialized for recursion
00074  */
00075 template<>
00076 class gemv<0,0,0>
00077 {
00078   gemv();
00079   gemv(const gemv&);
00080   gemv& operator=(const gemv&);
00081 
00082 public:
00083   template<class E1, class E2>
00084   static inline
00085   XprNull prod(const E1&, const E2&, std::size_t) {
00086     return XprNull();
00087   }
00088 };
00089 
00090 
00091 } // namespace meta
00092 
00093 } // namespace tvmet
00094 
00095 #endif /* TVMET_META_GEMV_H */
00096 
00097 // Local Variables:
00098 // mode:C++
00099 // tab-width:8
00100 // End: