Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
UnOperator.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: UnOperator.h,v 1.17 2007-06-23 15:59:00 opetzold Exp $ 00022 */ 00023 00024 #ifndef TVMET_XPR_UNOPERATOR_H 00025 #define TVMET_XPR_UNOPERATOR_H 00026 00027 namespace tvmet { 00028 00029 00030 /** 00031 * \class XprUnOp UnOperator.h "tvmet/xpr/UnOperator.h" 00032 * \brief Unary operator working on one subexpression. 00033 * 00034 * Using the access operator() the unary operation will be evaluated. 00035 */ 00036 template<class UnOp, class E> 00037 class XprUnOp 00038 : public TvmetBase< XprUnOp<UnOp, E> > 00039 { 00040 XprUnOp(); 00041 XprUnOp& operator=(const XprUnOp&); 00042 00043 public: 00044 typedef typename UnOp::value_type value_type; 00045 00046 public: 00047 /** Complexity counter. */ 00048 enum { 00049 ops_expr = E::ops, 00050 ops = 1 * ops_expr 00051 }; 00052 00053 public: 00054 /** Constructor for an expressions. */ 00055 explicit XprUnOp(const E& e) 00056 : m_expr(e) 00057 { } 00058 00059 /** Copy Constructor. Not explicit! */ 00060 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR) 00061 XprUnOp(const XprUnOp& e) 00062 : m_expr(e.m_expr) 00063 { } 00064 #endif 00065 00066 /** Index operator, evaluates the expression inside. */ 00067 value_type operator()(std::size_t i) const { 00068 return UnOp::apply_on(m_expr(i)); 00069 } 00070 00071 /** index operator for arrays/matrices. */ 00072 value_type operator()(std::size_t i, std::size_t j) const { 00073 return UnOp::apply_on(m_expr(i, j)); 00074 } 00075 00076 public: // debugging Xpr parse tree 00077 void print_xpr(std::ostream& os, std::size_t l=0) const { 00078 os << IndentLevel(l++) 00079 << "XprUnOp[O="<< ops << ", (O=" << ops_expr << ")]<" 00080 << std::endl; 00081 UnOp::print_xpr(os, l); 00082 m_expr.print_xpr(os, l); 00083 os << IndentLevel(--l) 00084 << ">," << std::endl; 00085 } 00086 00087 private: 00088 const E m_expr; 00089 }; 00090 00091 00092 } // namespace tvmet 00093 00094 #endif // TVMET_XPR_UNOPERATOR_H 00095 00096 // Local Variables: 00097 // mode:C++ 00098 // tab-width:8 00099 // End:
Generated on Tue Jul 12 2022 19:50:03 by
1.7.2