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 * $Id: Identity.h,v 1.4 2006-11-21 18:43:09 opetzold Exp $
narshu 25:143b19c1fb05 3 */
narshu 25:143b19c1fb05 4
narshu 25:143b19c1fb05 5 #ifndef TVMET_XPR_IDENTITY_H
narshu 25:143b19c1fb05 6 #define TVMET_XPR_IDENTITY_H
narshu 25:143b19c1fb05 7
narshu 25:143b19c1fb05 8
narshu 25:143b19c1fb05 9 namespace tvmet {
narshu 25:143b19c1fb05 10
narshu 25:143b19c1fb05 11
narshu 25:143b19c1fb05 12 /**
narshu 25:143b19c1fb05 13 * \class XprIdentity Identity.h "tvmet/xpr/Identity.h"
narshu 25:143b19c1fb05 14 * \brief Expression for the identity matrix.
narshu 25:143b19c1fb05 15 *
narshu 25:143b19c1fb05 16 * This expression doesn't hold any other expression, it
narshu 25:143b19c1fb05 17 * simply returns 1 or 0 depends where the row and column
narshu 25:143b19c1fb05 18 * element excess is done.
narshu 25:143b19c1fb05 19 *
narshu 25:143b19c1fb05 20 * \since release 1.6.0
narshu 25:143b19c1fb05 21 * \sa identity
narshu 25:143b19c1fb05 22 */
narshu 25:143b19c1fb05 23 template<class T, std::size_t Rows, std::size_t Cols>
narshu 25:143b19c1fb05 24 struct XprIdentity
narshu 25:143b19c1fb05 25 : public TvmetBase< XprIdentity<T, Rows, Cols> >
narshu 25:143b19c1fb05 26 {
narshu 25:143b19c1fb05 27 XprIdentity& operator=(const XprIdentity&);
narshu 25:143b19c1fb05 28
narshu 25:143b19c1fb05 29 public:
narshu 25:143b19c1fb05 30 typedef T value_type;
narshu 25:143b19c1fb05 31
narshu 25:143b19c1fb05 32 public:
narshu 25:143b19c1fb05 33 /** Complexity counter. */
narshu 25:143b19c1fb05 34 enum {
narshu 25:143b19c1fb05 35 ops_assign = Rows * Cols,
narshu 25:143b19c1fb05 36 ops = ops_assign
narshu 25:143b19c1fb05 37 };
narshu 25:143b19c1fb05 38
narshu 25:143b19c1fb05 39 public:
narshu 25:143b19c1fb05 40 /** access by index. */
narshu 25:143b19c1fb05 41 value_type operator()(std::size_t i, std::size_t j) const {
narshu 25:143b19c1fb05 42 return i==j ? 1 : 0;
narshu 25:143b19c1fb05 43 }
narshu 25:143b19c1fb05 44
narshu 25:143b19c1fb05 45 public: // debugging Xpr parse tree
narshu 25:143b19c1fb05 46 void print_xpr(std::ostream& os, std::size_t l=0) const {
narshu 25:143b19c1fb05 47 os << IndentLevel(l++)
narshu 25:143b19c1fb05 48 << "XprIdentity[O="<< ops << ")]<"
narshu 25:143b19c1fb05 49 << std::endl;
narshu 25:143b19c1fb05 50 os << IndentLevel(l)
narshu 25:143b19c1fb05 51 << typeid(T).name() << ","
narshu 25:143b19c1fb05 52 << "R=" << Rows << ", C=" << Cols << std::endl;
narshu 25:143b19c1fb05 53 os << IndentLevel(--l) << ">"
narshu 25:143b19c1fb05 54 << ((l != 0) ? "," : "") << std::endl;
narshu 25:143b19c1fb05 55 }
narshu 25:143b19c1fb05 56 };
narshu 25:143b19c1fb05 57
narshu 25:143b19c1fb05 58
narshu 25:143b19c1fb05 59 } // namespace tvmet
narshu 25:143b19c1fb05 60
narshu 25:143b19c1fb05 61
narshu 25:143b19c1fb05 62 #endif // TVMET_XPR_IDENTITY_H
narshu 25:143b19c1fb05 63
narshu 25:143b19c1fb05 64
narshu 25:143b19c1fb05 65 // Local Variables:
narshu 25:143b19c1fb05 66 // mode:C++
narshu 25:143b19c1fb05 67 // tab-width:8
narshu 25:143b19c1fb05 68 // End: