00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 template<class Rep1, class Rep2> class ConstHMergeView;
00025
00027 template<class Rep1, class Rep2>
00028 class HMergeView : public HMergeViewTag
00029 {
00030 public:
00031 typedef HMergeView<Rep1, Rep2> self_type;
00032 typedef HMergeViewTag exp_tag;
00033 typedef NullTag extra_param_type;
00034 typedef ConstHMergeView<Rep1, Rep2> const_view_type;
00035
00036 typedef self_type rep_type;
00037 typedef self_type super_type;
00038 typedef ExpRow<self_type> row_type;
00039 typedef const ExpRow<self_type> const_row_type;
00040 typedef typename Rep1::col_type col_type;
00041 typedef HEleType(typename Rep1::value_type, typename Rep2::value_type) value_type;
00042 typedef typename Rep1::index_type index_type;
00043 typedef typename Loki::TypeTraits<value_type>::ParameterType param_type;
00044 typedef typename Loki::TypeTraits<const value_type>::ParameterType const_param_type;
00045 typedef mat_iterator<self_type> iterator;
00046 typedef const_mat_iterator<self_type> const_iterator;
00047 typedef typename Rep1::rep_type left_type;
00048 typedef typename Rep2::rep_type right_type;
00049 typedef typename BinViewValueTypeChooser<left_type,
00050 right_type,value_type>::RET reference;
00051 typedef typename BinViewValueTypeChooser<left_type,
00052 right_type,const value_type>::RET const_reference;
00053 left_type& leftOp;
00054 right_type& rightOp;
00055
00056
00057 EXMAT_INLINE2 iterator begin()
00058 { return iterator(*this, 0, 0); }
00059 EXMAT_INLINE2 const_iterator begin() const
00060 { return const_iterator(*this, 0, 0); }
00061 EXMAT_INLINE2 iterator end()
00062 { return iterator(*this, rows(), 0); }
00063 EXMAT_INLINE2 const_iterator end() const
00064 { return const_iterator(*this, rows(), 0); }
00065
00066
00067 enum {
00068 ROWS = (int(Rep1::ROWS) == 0) ? int(Rep2::ROWS) : int(Rep1::ROWS),
00069 COLS = (int(Rep1::COLS) == 0 || int(Rep2::COLS) == 0) ? 0 : int(Rep1::COLS+Rep2::COLS),
00070 IsLinear = true,
00071 IsLinearRecursive = IsLinear && (bool(Rep1::IsLinearRecursive) && bool(Rep2::IsLinearRecursive)),
00072 TNOP = 0,
00073 ENOP = 0,
00074 EXPLevel = (int(Rep1::EXPLevel) > int(Rep2::EXPLevel)) ? int(Rep1::EXPLevel + 1) : int(Rep2::EXPLevel + 1)
00075 };
00076
00078 typedef Mat<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00079
00080
00081
00082 EXMAT_INLINE2 HMergeView(const self_type& self)
00083 : leftOp(self.leftOp), rightOp(self.rightOp) {}
00084 EXMAT_INLINE2 HMergeView(left_type& mat1, right_type& mat2)
00085 : leftOp(mat1), rightOp(mat2) {}
00087 template<class Rep3> EXMAT_INLINE2
00088 HMergeView(const Rep3& self, left_type& mat1, right_type& mat2)
00089 : leftOp(mat1), rightOp(mat2) {}
00090
00092 EXMAT_INLINE2 self_type operator=(const_param_type s) {
00093 leftOp = rightOp = s;
00094 return *this;
00095 }
00096
00097
00098 EXMAT_INLINE2 size_t size() const { return leftOp.size() + rightOp.size(); }
00099 EXMAT_INLINE2 size_t rows() const {
00100 return (left_type::ROWS == 0) ? rightOp.rows() : leftOp.rows();
00101 }
00102 EXMAT_INLINE2 size_t cols() const { return leftOp.cols() + rightOp.cols(); }
00103
00104
00105 EXMAT_INLINE2 reference setAt(index_type i) {
00106 return this->setAt(i/this->cols(), i%this->cols());
00107 }
00108 EXMAT_INLINE2 const_reference getAt(index_type i) {
00109 return this->getAt(i/this->cols(), i%this->cols());
00110 }
00111 EXMAT_INLINE2 reference setAt(index_type i, index_type j) {
00112 if(j < leftOp.cols())
00113 return leftOp.setAt(i, j);
00114 else
00115 return rightOp.setAt(i, j-leftOp.cols());
00116 }
00117 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const {
00118 if(j < leftOp.cols())
00119 return leftOp.getAt(i, j);
00120 else
00121 return rightOp.getAt(i, j-leftOp.cols());
00122 }
00123 };
00127 template<class Rep1, class ErrChk1, class Rep2, class ErrChk2> EXMAT_INLINE2 static
00128 Mat<ExpMat<HMergeView<typename Rep1::rep_type, typename Rep2::rep_type> >, DefaultErrorChecker>
00129 hMerge(Mat<Rep1, ErrChk1>& mat1, Mat<Rep2, ErrChk2>& mat2) {
00130 return ExpMat<HMergeView<TTYPENAME Rep1::rep_type, TTYPENAME Rep2::rep_type> >(mat1, mat2);
00131 }
00132
00133
00135 template<class Rep1, class Rep2>
00136 class ConstHMergeView : public HMergeViewTag
00137 {
00138 public:
00139 typedef ConstHMergeView<Rep1, Rep2> self_type;
00140 typedef HMergeViewTag exp_tag;
00141 typedef NullTag extra_param_type;
00142 typedef self_type const_view_type;
00143
00144 typedef self_type rep_type;
00145 typedef self_type super_type;
00146 typedef const ExpRow<self_type> row_type;
00147 typedef const ExpRow<self_type> const_row_type;
00148 typedef typename Rep1::col_type col_type;
00149 typedef HEleType(typename Rep1::value_type, typename Rep2::value_type) value_type;
00150 typedef typename Rep1::index_type index_type;
00151 typedef typename Loki::TypeTraits<value_type>::ParameterType param_type;
00152 typedef typename Loki::TypeTraits<const value_type>::ParameterType const_param_type;
00153 typedef const_mat_iterator<self_type> iterator;
00154 typedef const_mat_iterator<self_type> const_iterator;
00155 typedef typename Rep1::rep_type left_type;
00156 typedef typename Rep2::rep_type right_type;
00157 typedef typename BinViewValueTypeChooser<left_type,
00158 right_type,const value_type>::RET reference;
00159 typedef reference const_reference;
00160 typename OperandTypeChooser<left_type>::RET leftOp;
00161 typename OperandTypeChooser<right_type>::RET rightOp;
00162
00163
00164 EXMAT_INLINE2 const_iterator begin() const
00165 { return const_iterator(*this, 0, 0); }
00166 EXMAT_INLINE2 const_iterator end() const
00167 { return const_iterator(*this, rows(), 0); }
00168
00169
00170 enum {
00171 ROWS = (int(Rep1::ROWS) == 0) ? int(Rep2::ROWS) : int(Rep1::ROWS),
00172 COLS = (int(Rep1::COLS) == 0 || int(Rep2::COLS) == 0) ? 0 : int(Rep1::COLS+Rep2::COLS),
00173 IsLinear = true,
00174 IsLinearRecursive = IsLinear && (bool(Rep1::IsLinearRecursive) && bool(Rep2::IsLinearRecursive)),
00175 TNOP = 0,
00176 ENOP = 0,
00177 EXPLevel = (int(Rep1::EXPLevel) > int(Rep2::EXPLevel)) ? int(Rep1::EXPLevel + 1) : int(Rep2::EXPLevel + 1)
00178 };
00179
00181 typedef Mat<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00182
00183
00184
00185 EXMAT_INLINE2 ConstHMergeView(const self_type& self)
00186 : leftOp(self.leftOp), rightOp(self.rightOp) {}
00187 EXMAT_INLINE2 ConstHMergeView(const left_type& mat1, const right_type& mat2)
00188 : leftOp(mat1), rightOp(mat2) {}
00190 template<class Rep3> EXMAT_INLINE2
00191 ConstHMergeView(const Rep3& self, const left_type& mat1, const right_type& mat2)
00192 : leftOp(mat1), rightOp(mat2) {}
00193
00194
00195
00196 EXMAT_INLINE2 size_t size() const { return leftOp.size() + rightOp.size(); }
00197 EXMAT_INLINE2 size_t rows() const {
00198 return (left_type::ROWS == 0) ? rightOp.rows() : leftOp.rows();
00199 }
00200 EXMAT_INLINE2 size_t cols() const { return leftOp.cols() + rightOp.cols(); }
00201
00202
00203 EXMAT_INLINE2 const_reference getAt(index_type i) {
00204 return this->getAt(i/this->cols(), i%this->cols());
00205 }
00206 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const {
00207 if(j < leftOp.cols())
00208 return leftOp.getAt(i, j);
00209 else
00210 return rightOp.getAt(i, j-leftOp.cols());
00211 }
00212 };
00216 template<class Rep1, class ErrChk1, class Rep2, class ErrChk2> EXMAT_INLINE2 static
00217 const Mat<ExpMat<ConstHMergeView<typename Rep1::rep_type, typename Rep2::rep_type> >, DefaultErrorChecker>
00218 hMerge(const Mat<Rep1, ErrChk1>& mat1, const Mat<Rep2, ErrChk2>& mat2) {
00219 return ExpMat<ConstHMergeView<TTYPENAME Rep1::rep_type, TTYPENAME Rep2::rep_type> >(mat1, mat2);
00220 }