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 Rep> class ConstCofactorsView;
00025
00027 template<class Rep>
00028 class ConstCofactorsView : public CofactorsViewTag
00029 {
00030 public:
00031 typedef ConstCofactorsView<Rep> self_type;
00032 typedef CofactorsViewTag exp_tag;
00033 typedef NullTag extra_param_type;
00034
00035
00036 typedef typename Rep::rep_type super_type;
00037 typedef self_type rep_type;
00038 typedef super_type inner_rep_type;
00039 typedef self_type const_view_type;
00040 typedef typename super_type::row_type row_type;
00041 typedef const ExpRow<self_type> const_row_type;
00042 typedef typename super_type::col_type col_type;
00043 typedef typename super_type::value_type value_type;
00044 typedef value_type reference;
00045 typedef const value_type const_reference;
00046 typedef typename super_type::index_type index_type;
00047 typedef typename super_type::param_type param_type;
00048 typedef typename super_type::const_param_type const_param_type;
00049 typedef const_mat_iterator<self_type> iterator;
00050 typedef const_mat_iterator<self_type> const_iterator;
00051 typename OperandTypeChooser<super_type>::RET rep;
00052 EXMAT_INLINE2 const_iterator begin() const
00053 { return const_iterator(*this, 0, 0); }
00054 EXMAT_INLINE2 const_iterator end() const
00055 { return const_iterator(*this, rows(), 0); }
00056
00057 enum {
00058 ROWS = super_type::COLS,
00059 COLS = super_type::ROWS,
00060 IsLinear = false,
00061 IsLinearRecursive = IsLinear && super_type::IsLinearRecursive,
00062 ENOP = (ROWS == 0 || COLS == 0) ? -1 :
00063 DynConstMinorView<Rep>::TNOP +
00064 exmat::PNS::DeterminantComplexity<ROWS-1>::RET +
00065 4,
00066 TNOP = (ROWS == 0 || COLS == 0) ? -1 : ENOP * ROWS * COLS,
00067 EXPLevel = Rep::EXPLevel + 1
00068 };
00069
00071 typedef Mat<DenseMatCon<value_type,ROWS,COLS>, EmptyErrorChecker> temp_type;
00072
00073
00074
00075 EXMAT_INLINE2 ConstCofactorsView(const self_type& self)
00076 : rep(self.rep) {}
00077 EXMAT_INLINE2 ConstCofactorsView(const Rep& mat)
00078 : rep(mat) { ComErrCheck(); }
00080 template<class Rep2> EXMAT_INLINE2
00081 ConstCofactorsView(const Rep2& self, const Rep& mat)
00082 : rep(mat) {}
00083
00084
00085
00086 EXMAT_INLINE2 size_t size() const { return rep.size(); }
00087 EXMAT_INLINE2 size_t rows() const { return rep.rows(); }
00088 EXMAT_INLINE2 size_t cols() const { return rep.cols(); }
00089
00090
00091 EXMAT_INLINE2 const_reference getAt(index_type i) const
00092 { return this->getAt(i/cols(), i%cols()); }
00093 EXMAT_INLINE2 const_reference getAt(index_type i, index_type j) const {
00094 return determinant(
00095 minor( Mat<ExpMat<ConstDummyView<TTYPENAME Rep::rep_type> >, EmptyErrorChecker>(
00096 ExpMat<ConstDummyView<TTYPENAME Rep::rep_type> >(rep)
00097 ), i, j)
00098 ) * ( (i+j) % 2 == 0 ? 1 : -1 );
00099 }
00100
00101 private:
00102
00103 EXMAT_INLINE2 void ComErrCheck() {
00104 DefaultErrorChecker::AssertCompat(
00105 rows() == cols()
00106 );
00107 }
00108 };
00112 template<class Rep, class ErrChk> EXMAT_INLINE2 static
00113 const Mat<ExpMat<ConstCofactorsView<Rep> >, ErrChk>
00114 cofactors(const Mat<Rep, ErrChk>& mat) {
00115 return Mat<ExpMat<ConstCofactorsView<Rep> >, ErrChk>(
00116 ExpMat<ConstCofactorsView<Rep> >(mat)
00117 );
00118 }