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_MTVPRODUCT_H
00025 #define TVMET_XPR_MTVPRODUCT_H
00026 
00027 #include <tvmet/meta/Gemtv.h>
00028 #include <tvmet/loop/Gemtv.h>
00029 
00030 namespace tvmet {
00031 
00032 
00041 template<class E1, std::size_t Rows, std::size_t Cols,
00042    class E2>
00043 class XprMtVProduct
00044   : public TvmetBase< XprMtVProduct<E1, Rows, Cols, E2> >
00045 {
00046   XprMtVProduct();
00047   XprMtVProduct& operator=(const XprMtVProduct&);
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         = Cols * Rows,
00061     N         = Cols * (Rows - 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 XprMtVProduct(const E1& lhs, const E2& rhs)
00071     : m_lhs(lhs), m_rhs(rhs)
00072   { }
00073 
00075 #if defined(TVMET_OPTIMIZE_XPR_MANUAL_CCTOR)
00076   XprMtVProduct(const XprMtVProduct& 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_gemtv(dispatch<true>, const E1& lhs, const E2& rhs, std::size_t i) {
00085     return meta::gemtv<Rows, Cols, 0>::prod(lhs, rhs, i);
00086   }
00087 
00089   static inline
00090   value_type do_gemtv(dispatch<false>, const E1& lhs, const E2& rhs, std::size_t i) {
00091     return loop::gemtv<Rows, Cols>::prod(lhs, rhs, i);
00092   }
00093 
00094 public:
00097   value_type operator()(std::size_t j) const {
00098     TVMET_RT_CONDITION(j < Cols , "XprMtVProduct Bounce Violation")
00099     return do_gemtv(dispatch<use_meta>(), m_lhs, m_rhs, j);
00100   }
00101 
00102 public: 
00103   void print_xpr(std::ostream& os, std::size_t l=0) const {
00104     os << IndentLevel(l++)
00105        << "XprMtVProduct[O=" << ops << ", (O1=" << ops_lhs << ", O2=" << ops_rhs << ")]<"
00106        << std::endl;
00107     m_lhs.print_xpr(os, l);
00108     os << IndentLevel(l)
00109        << "R=" << Rows << ", C=" << Cols << ",\n";
00110     m_rhs.print_xpr(os, l);
00111     os << IndentLevel(--l)
00112        << ">," << std::endl;
00113   }
00114 
00115 private:
00116   const E1              m_lhs;
00117   const E2              m_rhs;
00118 };
00119 
00120 
00121 } 
00122 
00123 #endif // TVMET_XPR_MTVPRODUCT_H
00124 
00125 
00126 
00127 
00128