Dummy.h

00001 /*
00002  * Expression Template Matrix Library
00003  *
00004  * Copyright (C) 2004 - 2006 Ricky Lung <mtlung@users.sourceforge.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 
00023 // Forward declaration
00024 template<class Rep> class ConstDummyView;
00025 
00027 template<class Rep>
00028 class DummyView : public DummyViewTag
00029 {
00030 public:
00031     typedef DummyView<Rep>      self_type;
00032     typedef DummyViewTag        exp_tag;
00033     typedef NullTag             extra_param_type;
00034     typedef ConstDummyView<Rep> const_view_type;
00035     COMMON_VIEW_TYPEDEFS();
00036 
00037     enum {
00038         ROWS = super_type::COLS,
00039         COLS = super_type::ROWS,
00040         IsLinear = true,
00041         IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00042         TNOP = Rep::TNOP,
00043         ENOP = Rep::ENOP,
00044         EXPLevel = Rep::EXPLevel + 1
00045     };
00046 
00048     typedef Mat<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00049 
00050     /************************************************/
00051     // Constructors
00052     EXMAT_INLINE2 DummyView(const self_type& self)
00053         : rep(self.rep) {}
00054     EXMAT_INLINE2 DummyView(super_type& mat)
00055         : rep(mat) {}
00057     template<class Rep2> EXMAT_INLINE2
00058     DummyView(const Rep2& self, super_type& mat)
00059         : rep(mat) {}
00060 
00062     EXMAT_INLINE2 self_type operator=(const_param_type s) {
00063         rep = s;
00064         return *this;
00065     }
00066     /************************************************/
00067     // Dimension information
00068     EXMAT_INLINE2 size_t size() const { return rep.size(); }
00069     EXMAT_INLINE2 size_t rows() const { return rep.rows(); }
00070     EXMAT_INLINE2 size_t cols() const { return rep.cols(); }
00071     /************************************************/
00072     // Index function (for internal use, no error checking applied)
00073     EXMAT_INLINE2 reference setAt(index_type i)
00074     {   return rep.setAt(i);    }
00075     EXMAT_INLINE2 const_reference getAt(index_type i) const
00076     {   return rep.getAt(i);    }
00077     EXMAT_INLINE2 reference setAt(index_type i, index_type j)
00078     {   return rep.setAt(i, j); }
00079     EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00080     {   return rep.getAt(i, j); }
00081 };
00085 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00086 Mat<ExpMat<DummyView<typename Rep::rep_type> >, ErrChk>
00087 dummy(Mat<Rep, ErrChk>& mat) {
00088     return ExpMat<DummyView<TTYPENAME Rep::rep_type> >(mat);
00089 }
00093 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00094 Vec<ExpMat<DummyView<typename Rep::rep_type> >, ErrChk>
00095 dummy(Vec<Rep, ErrChk>& vec) {
00096     return ExpMat<DummyView<TTYPENAME Rep::rep_type> >(vec);
00097 }
00098 #if HAVE_TT_PARAMETER
00099 
00102 template<class Rep, class ErrChk, template<class Rep, class ErrChk> class RepT, template<class RepT> class MathClass >
00103 EXMAT_INLINE2 static MathClass<RepT<ExpMat<ConstDummyView<Rep> >, ErrChk> >
00104 dummy(MathClass<RepT<Rep, ErrChk> >& vec) {
00105     return MathClass<RepT<ExpMat<ConstDummyView<Rep> >, ErrChk> >(ExpMat<ConstDummyView<Rep> >(vec));
00106 }
00107 #endif  // HAVE_TT_PARAMETER
00108 
00109 
00111 template<class Rep>
00112 class ConstDummyView : public DummyViewTag
00113 {
00114 public:
00115     typedef ConstDummyView<Rep> self_type;
00116     typedef DummyViewTag        exp_tag;
00117     typedef NullTag             extra_param_type;
00118     COMMON_CONST_VIEW_TYPEDEFS();
00119 
00120     enum {
00121         ROWS = super_type::COLS,
00122         COLS = super_type::ROWS,
00123         IsLinear = false,
00124         IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00125         TNOP = Rep::TNOP,
00126         ENOP = Rep::ENOP,
00127         EXPLevel = Rep::EXPLevel +1
00128     };
00129 
00131     typedef Mat<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00132 
00133     /************************************************/
00134     // Constructors
00135     EXMAT_INLINE2 ConstDummyView(const self_type& self)
00136         : rep(self.rep) {}
00137     EXMAT_INLINE2 ConstDummyView(const super_type& mat)
00138         : rep(mat) {}
00140     template<class Rep2> EXMAT_INLINE2
00141     ConstDummyView(const Rep2& self, const super_type& mat)
00142         : rep(mat) {}
00143 
00144     /************************************************/
00145     // Dimension information
00146     EXMAT_INLINE2 size_t size() const { return rep.size(); }
00147     EXMAT_INLINE2 size_t rows() const { return rep.cols(); }
00148     EXMAT_INLINE2 size_t cols() const { return rep.rows(); }
00149     /************************************************/
00150     // Index function (for internal use, no error checking applied)
00151     EXMAT_INLINE2 const_reference getAt(index_type i) const
00152     {   return rep.getAt(i);    }
00153     EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const
00154     {   return rep.getAt(i, j); }
00155 };
00159 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00160 const Mat<ExpMat<ConstDummyView<typename Rep::rep_type> >, ErrChk>
00161 dummy(const Mat<Rep, ErrChk>& mat) {
00162     return ExpMat<ConstDummyView<TTYPENAME Rep::rep_type> >(mat);
00163 }
00167 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00168 const Vec<ExpMat<ConstDummyView<typename Rep::rep_type> >, ErrChk>
00169 dummy(const Vec<Rep, ErrChk>& vec) {
00170     return ExpMat<ConstDummyView<TTYPENAME Rep::rep_type> >(vec);
00171 }
00172 #if HAVE_TT_PARAMETER
00173 
00176 template<class Rep, class ErrChk, template<class Rep, class ErrChk> class RepT, template<class RepT> class MathClass >
00177 EXMAT_INLINE2 static const MathClass<RepT<ExpMat<ConstDummyView<Rep> >, ErrChk> >
00178 dummy(const MathClass<RepT<Rep, ErrChk> >& vec) {
00179     return ExpMat<ConstDummyView<Rep> >(vec);
00180 }
00181 #endif  // HAVE_TT_PARAMETER

Generated on Sat May 6 23:11:55 2006 for Exmat by  doxygen 1.4.6-NO