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_MMTPRODUCT_H
00025 #define TVMET_XPR_MMTPRODUCT_H
00026
00027 #include <tvmet/meta/Gemmt.h>
00028 #include <tvmet/loop/Gemmt.h>
00029
00030 namespace tvmet {
00031
00032
00043 template<class E1, std::size_t Rows1, std::size_t Cols1,
00044 class E2, std::size_t Cols2>
00045 class XprMMtProduct
00046 : public TvmetBase< XprMMtProduct<E1, Rows1, Cols1, E2, Cols2> >
00047 {
00048 private:
00049 XprMMtProduct();
00050 XprMMtProduct& operator=(const XprMMtProduct&);
00051
00052 public:
00053 typedef typename PromoteTraits<
00054 typename E1::value_type,
00055 typename E2::value_type
00056 >::value_type value_type;
00057
00058 public:
00060 enum {
00061 ops_lhs = E1::ops,
00062 ops_rhs = E2::ops,
00063 Rows2 = Cols1,
00064 M = Rows1 * Cols1 * Rows1,
00065 N = Rows1 * (Cols1 - 1) * Rows2,
00066 ops_plus = M * NumericTraits<value_type>::ops_plus,
00067 ops_muls = N * NumericTraits<value_type>::ops_muls,
00068 ops = ops_plus + ops_muls,
00069 use_meta = Rows1*Rows2 < TVMET_COMPLEXITY_MM_TRIGGER ? true : false
00070 };
00071
00072 public:
00074 explicit XprMMtProduct(const E1& lhs, const E2& rhs)
00075 : m_lhs(lhs), m_rhs(rhs)
00076 { }
00077
00079 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
00080 XprMMtProduct(const XprMMtProduct& e)
00081 : m_lhs(e.m_lhs), m_rhs(e.m_rhs)
00082 { }
00083 #endif
00084
00085 private:
00087 static inline
00088 value_type do_gemmt(dispatch<true>, const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) {
00089 return meta::gemmt<Rows1, Cols1,
00090 Cols2,
00091 0>::prod(lhs, rhs, i, j);
00092 }
00093
00095 static inline
00096 value_type do_gemmt(dispatch<false>, const E1& lhs, const E2& rhs, std::size_t i, std::size_t j) {
00097 return loop::gemmt<Rows1, Cols1, Cols1>::prod(lhs, rhs, i, j);
00098 }
00099
00100 public:
00102 value_type operator()(std::size_t i, std::size_t j) const {
00103 TVMET_RT_CONDITION((i < Rows1) && (j < Rows2), "XprMMtProduct Bounce Violation")
00104 return do_gemmt(dispatch<use_meta>(), m_lhs, m_rhs, i, j);
00105 }
00106
00107 public:
00108 void print_xpr(std::ostream& os, std::size_t l=0) const {
00109 os << IndentLevel(l++)
00110 << "XprMMtProduct["
00111 << (use_meta ? "M" : "L") << ", O=" << ops
00112 << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<"
00113 << std::endl;
00114 m_lhs.print_xpr(os, l);
00115 os << IndentLevel(l)
00116 << "R1=" << Rows1 << ", C1=" << Cols1 << ",\n";
00117 m_rhs.print_xpr(os, l);
00118 os << IndentLevel(l)
00119 << "C2=" << Cols2 << ",\n"
00120 << "\n"
00121 << IndentLevel(--l)
00122 << ">," << std::endl;
00123 }
00124
00125 private:
00126 const E1 m_lhs;
00127 const E2 m_rhs;
00128 };
00129
00130
00131 }
00132
00133 #endif // TVMET_XPR_MMTPRODUCT_H
00134
00135
00136
00137
00138