ICRS Eurobot 2013

Dependencies:   mbed mbed-rtos Servo QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Gemtv.h Source File

Gemtv.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: Gemtv.h,v 1.8 2007-06-23 15:58:59 opetzold Exp $
00022  */
00023 
00024 #ifndef TVMET_META_GEMTV_H
00025 #define TVMET_META_GEMTV_H
00026 
00027 #include <tvmet/xpr/Null.h>
00028 
00029 namespace tvmet {
00030 
00031 namespace meta {
00032 
00033 
00034 /**
00035  * \class gemtv Gemtv.h "tvmet/meta/Gemtv.h"
00036  * \brief Meta class for matrix-transpose-vector operations.
00037  *        using formula
00038  *        \f[
00039  *        M^T\,v
00040  *        \f]
00041  */
00042 template<std::size_t Rows, std::size_t Cols,
00043      std::size_t I>
00044 class gemtv
00045 {
00046   gemtv();
00047   gemtv(const gemtv&);
00048   gemtv& operator=(const gemtv&);
00049 
00050 private:
00051   enum {
00052     doIt = I < (Rows-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 j) {
00064     return lhs(I, j) * rhs(I)
00065       + gemtv<Rows * doIt, Cols * doIt,
00066               (I+1)* doIt>::prod(lhs, rhs, j);
00067   }
00068 };
00069 
00070 
00071 /**
00072  * \class gemtv<0,0,0> Gemtv.h "tvmet/meta/Gemtv.h"
00073  * \brief gemtv Specialized for recursion
00074  */
00075 template<>
00076 class gemtv<0,0,0>
00077 {
00078   gemtv();
00079   gemtv(const gemtv&);
00080   gemtv& operator=(const gemtv&);
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_GEMTV_H */
00096 
00097 // Local Variables:
00098 // mode:C++
00099 // tab-width:8
00100 // End: