This is the Tiny Vector Matrix Expression Templates library found at http://tvmet.sourceforge.net. It is the fastest and most compact matrix lib out there (for < 10x10 matricies). I have done some minor tweaks to make it compile for mbed. For examples and hints on how to use, see: http://tvmet.sourceforge.net/usage.html
Dependents: Eurobot_2012_Secondary
Diff: xpr/Identity.h
- Revision:
- 0:feb4117d16d8
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/xpr/Identity.h Wed Mar 28 15:53:45 2012 +0000 @@ -0,0 +1,68 @@ +/* + * $Id: Identity.h,v 1.4 2006-11-21 18:43:09 opetzold Exp $ + */ + +#ifndef TVMET_XPR_IDENTITY_H +#define TVMET_XPR_IDENTITY_H + + +namespace tvmet { + + +/** + * \class XprIdentity Identity.h "tvmet/xpr/Identity.h" + * \brief Expression for the identity matrix. + * + * This expression doesn't hold any other expression, it + * simply returns 1 or 0 depends where the row and column + * element excess is done. + * + * \since release 1.6.0 + * \sa identity + */ +template<class T, std::size_t Rows, std::size_t Cols> +struct XprIdentity + : public TvmetBase< XprIdentity<T, Rows, Cols> > +{ + XprIdentity& operator=(const XprIdentity&); + +public: + typedef T value_type; + +public: + /** Complexity counter. */ + enum { + ops_assign = Rows * Cols, + ops = ops_assign + }; + +public: + /** access by index. */ + value_type operator()(std::size_t i, std::size_t j) const { + return i==j ? 1 : 0; + } + +public: // debugging Xpr parse tree + void print_xpr(std::ostream& os, std::size_t l=0) const { + os << IndentLevel(l++) + << "XprIdentity[O="<< ops << ")]<" + << std::endl; + os << IndentLevel(l) + << typeid(T).name() << "," + << "R=" << Rows << ", C=" << Cols << std::endl; + os << IndentLevel(--l) << ">" + << ((l != 0) ? "," : "") << std::endl; + } +}; + + +} // namespace tvmet + + +#endif // TVMET_XPR_IDENTITY_H + + +// Local Variables: +// mode:C++ +// tab-width:8 +// End: