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_MVPRODUCT_H
00025 #define TVMET_XPR_MVPRODUCT_H
00026
00027 #include <tvmet/meta/Gemv.h>
00028 #include <tvmet/loop/Gemv.h>
00029
00030 namespace tvmet {
00031
00032
00041 template<class E1, std::size_t Rows, std::size_t Cols,
00042 class E2>
00043 class XprMVProduct
00044 : public TvmetBase< XprMVProduct<E1, Rows, Cols, E2> >
00045 {
00046 XprMVProduct();
00047 XprMVProduct& operator=(const XprMVProduct&);
00048
00049 public:
00050 typedef typename PromoteTraits<
00051 typename E1::value_type,
00052 typename E2::value_type
00053 >::value_type value_type;
00054
00055 public:
00057 enum {
00058 ops_lhs = E1::ops,
00059 ops_rhs = E2::ops,
00060 M = Rows * Cols,
00061 N = Rows * (Cols - 1),
00062 ops_plus = M * NumericTraits<value_type>::ops_plus,
00063 ops_muls = N * NumericTraits<value_type>::ops_muls,
00064 ops = ops_plus + ops_muls,
00065 use_meta = Rows*Cols < TVMET_COMPLEXITY_MV_TRIGGER ? true : false
00066 };
00067
00068 public:
00070 explicit XprMVProduct(const E1& lhs, const E2& rhs)
00071 : m_lhs(lhs), m_rhs(rhs)
00072 { }
00073
00075 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
00076 XprMVProduct(const XprMVProduct& e)
00077 : m_lhs(e.m_lhs), m_rhs(e.m_rhs)
00078 { }
00079 #endif
00080
00081 private:
00083 static inline
00084 value_type do_gemv(dispatch<true>, const E1& lhs, const E2& rhs, std::size_t j) {
00085 return meta::gemv<Rows, Cols,
00086 0>::prod(lhs, rhs, j);
00087 }
00088
00090 static inline
00091 value_type do_gemv(dispatch<false>, const E1& lhs, const E2& rhs, std::size_t j) {
00092 return loop::gemv<Rows, Cols>::prod(lhs, rhs, j);
00093 }
00094
00095 public:
00098 value_type operator()(std::size_t j) const {
00099 TVMET_RT_CONDITION(j < Rows , "XprMVProduct Bounce Violation")
00100 return do_gemv(dispatch<use_meta>(), m_lhs, m_rhs, j);
00101 }
00102
00103 public:
00104 void print_xpr(std::ostream& os, std::size_t l=0) const {
00105 os << IndentLevel(l++)
00106 << "XprMVProduct["
00107 << (use_meta ? "M" : "L") << ", O=" << ops
00108 << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<"
00109 << std::endl;
00110 m_lhs.print_xpr(os, l);
00111 os << IndentLevel(l)
00112 << "R=" << Rows << ", C=" << Cols << ",\n";
00113 m_rhs.print_xpr(os, l);
00114 os << IndentLevel(--l)
00115 << ">," << std::endl;
00116 }
00117
00118 private:
00119 const E1 m_lhs;
00120 const E2 m_rhs;
00121 };
00122
00123
00124 }
00125
00126 #endif // TVMET_XPR_MVPRODUCT_H
00127
00128
00129
00130
00131