Eurobot2012_Primary

Dependencies:   mbed Eurobot_2012_Primary

Committer:
narshu
Date:
Wed Oct 17 22:22:28 2012 +0000
Revision:
25:143b19c1fb05
Commit before publishing;

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: Gemmt.h,v 1.13 2007-06-23 15:58:59 opetzold Exp $
narshu 25:143b19c1fb05 22 */
narshu 25:143b19c1fb05 23
narshu 25:143b19c1fb05 24 #ifndef TVMET_META_GEMMT_H
narshu 25:143b19c1fb05 25 #define TVMET_META_GEMMT_H
narshu 25:143b19c1fb05 26
narshu 25:143b19c1fb05 27 #include <tvmet/xpr/Null.h>
narshu 25:143b19c1fb05 28
narshu 25:143b19c1fb05 29 namespace tvmet {
narshu 25:143b19c1fb05 30
narshu 25:143b19c1fb05 31 namespace meta {
narshu 25:143b19c1fb05 32
narshu 25:143b19c1fb05 33
narshu 25:143b19c1fb05 34 /**
narshu 25:143b19c1fb05 35 * \class gemmt Gemmt.h "tvmet/meta/Gemmt.h"
narshu 25:143b19c1fb05 36 * \brief Meta class for product matrix-transpose(matrix) operations.
narshu 25:143b19c1fb05 37 * using formula
narshu 25:143b19c1fb05 38 * \f[
narshu 25:143b19c1fb05 39 * M_1\,M_2^{T}
narshu 25:143b19c1fb05 40 * \f]
narshu 25:143b19c1fb05 41 * \note The rows of matrix 2 have to be equal to cols of matrix 1. The result
narshu 25:143b19c1fb05 42 * is a rows1 * cols2 matrix.
narshu 25:143b19c1fb05 43 */
narshu 25:143b19c1fb05 44 template<std::size_t Rows1, std::size_t Cols1,
narshu 25:143b19c1fb05 45 std::size_t Cols2,
narshu 25:143b19c1fb05 46 std::size_t K>
narshu 25:143b19c1fb05 47 class gemmt
narshu 25:143b19c1fb05 48 {
narshu 25:143b19c1fb05 49 gemmt();
narshu 25:143b19c1fb05 50 gemmt(const gemmt&);
narshu 25:143b19c1fb05 51 gemmt& operator=(const gemmt&);
narshu 25:143b19c1fb05 52
narshu 25:143b19c1fb05 53 private:
narshu 25:143b19c1fb05 54 enum {
narshu 25:143b19c1fb05 55 doIt = (K != Cols2 - 1) /**< recursive counter */
narshu 25:143b19c1fb05 56 };
narshu 25:143b19c1fb05 57
narshu 25:143b19c1fb05 58 public:
narshu 25:143b19c1fb05 59 template<class E1, class E2>
narshu 25:143b19c1fb05 60 static inline
narshu 25:143b19c1fb05 61 typename PromoteTraits<
narshu 25:143b19c1fb05 62 typename E1::value_type,
narshu 25:143b19c1fb05 63 typename E2::value_type
narshu 25:143b19c1fb05 64 >::value_type
narshu 25:143b19c1fb05 65 prod(const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) {
narshu 25:143b19c1fb05 66 return lhs(i, K) * rhs(j, K)
narshu 25:143b19c1fb05 67 + gemmt<Rows1 * doIt, Cols1 * doIt,
narshu 25:143b19c1fb05 68 Cols2 * doIt,
narshu 25:143b19c1fb05 69 (K+1) * doIt>::prod(lhs, rhs, i, j);
narshu 25:143b19c1fb05 70 }
narshu 25:143b19c1fb05 71 };
narshu 25:143b19c1fb05 72
narshu 25:143b19c1fb05 73
narshu 25:143b19c1fb05 74 /**
narshu 25:143b19c1fb05 75 * \class gemmt<0,0,0,0> Gemmt.h "tvmet/meta/Gemmt.h"
narshu 25:143b19c1fb05 76 * \brief gemmt Specialized for recursion.
narshu 25:143b19c1fb05 77 */
narshu 25:143b19c1fb05 78 template<>
narshu 25:143b19c1fb05 79 class gemmt<0,0,0,0>
narshu 25:143b19c1fb05 80 {
narshu 25:143b19c1fb05 81 gemmt();
narshu 25:143b19c1fb05 82 gemmt(const gemmt&);
narshu 25:143b19c1fb05 83 gemmt& operator=(const gemmt&);
narshu 25:143b19c1fb05 84
narshu 25:143b19c1fb05 85 public:
narshu 25:143b19c1fb05 86 template<class E1, class E2>
narshu 25:143b19c1fb05 87 static inline
narshu 25:143b19c1fb05 88 XprNull prod(const E1&, const E2&, std::size_t, std::size_t) {
narshu 25:143b19c1fb05 89 return XprNull();
narshu 25:143b19c1fb05 90 }
narshu 25:143b19c1fb05 91 };
narshu 25:143b19c1fb05 92
narshu 25:143b19c1fb05 93
narshu 25:143b19c1fb05 94 } // namespace meta
narshu 25:143b19c1fb05 95
narshu 25:143b19c1fb05 96 } // namespace tvmet
narshu 25:143b19c1fb05 97
narshu 25:143b19c1fb05 98 #endif /* TVMET_META_GEMMT_H */
narshu 25:143b19c1fb05 99
narshu 25:143b19c1fb05 100 // Local Variables:
narshu 25:143b19c1fb05 101 // mode:C++
narshu 25:143b19c1fb05 102 // tab-width:8
narshu 25:143b19c1fb05 103 // End: