00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef TVMET_XPR_EVAL_H
00025 #define TVMET_XPR_EVAL_H
00026
00027 namespace tvmet {
00028
00029
00037 template<class E1, class E2, class E3>
00038 class XprEval
00039 : public TvmetBase< XprEval<E1, E2, E3> >
00040 {
00041 public:
00042 typedef E1 expr1_type;
00043 typedef E2 expr2_type;
00044 typedef E3 expr3_type;
00045
00046 typedef typename expr2_type::value_type value2_type;
00047 typedef typename expr3_type::value_type value3_type;
00048
00049 typedef typename
00050 PromoteTraits<value2_type, value3_type>::value_type value_type;
00051
00052 public:
00054 enum {
00055 ops_expr1 = E1::ops,
00056 ops_expr2 = E2::ops,
00057 ops_expr3 = E3::ops,
00058 ops = ops_expr1
00059 };
00060
00061 private:
00062 XprEval();
00063 XprEval& operator=(const XprEval<expr1_type, expr2_type, expr3_type>&);
00064
00065 public:
00067 explicit XprEval(const expr1_type& e1, const expr2_type& e2, const expr3_type& e3)
00068 : m_expr1(e1), m_expr2(e2), m_expr3(e3)
00069 { }
00070
00072 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
00073 XprEval(const XprEval& rhs)
00074 : m_expr1(rhs.m_expr1), m_expr2(rhs.m_expr2), m_expr3(rhs.m_expr3)
00075 { }
00076 #endif
00077
00078 public:
00080 value_type operator()(std::size_t i) const {
00081 return m_expr1(i) ? m_expr2(i) : m_expr3(i);
00082 }
00083
00085 value_type operator()(std::size_t i, std::size_t j) const {
00086 return m_expr1(i, j) ? m_expr2(i, j) : m_expr3(i, j);
00087 }
00088
00089 public:
00090 void print_xpr(std::ostream& os, std::size_t l=0) const {
00091 os << IndentLevel(l++)
00092 << "XprEval[" << ops << ", ("
00093 << ops_expr1 << ", " << ops_expr2 << ", " << ops_expr3 << ")]<"
00094 << std::endl;
00095 m_expr1.print_xpr(os, l);
00096 m_expr2.print_xpr(os, l);
00097 m_expr3.print_xpr(os, l);
00098 os << IndentLevel(--l)
00099 << ">," << std::endl;
00100 }
00101
00102 private:
00103 const expr1_type m_expr1;
00104 const expr2_type m_expr2;
00105 const expr3_type m_expr3;
00106 };
00107
00108
00109 }
00110
00111 #endif // TVMET_XPR_EVAL_H
00112
00113
00114
00115
00116