📄 matrix_expression.hpp
字号:
typename E::iterator1>::type iterator1; typedef typename E::const_iterator2 const_iterator2; typedef typename boost::mpl::if_<boost::is_const<E>, typename E::const_iterator2, typename E::iterator2>::type iterator2;#endif // Element lookup BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { return expression ().find1 (rank, i, j); } BOOST_UBLAS_INLINE iterator1 find1 (int rank, size_type i, size_type j) { return expression ().find1 (rank, i, j); } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { return expression ().find2 (rank, i, j); } BOOST_UBLAS_INLINE iterator2 find2 (int rank, size_type i, size_type j) { return expression ().find2 (rank, i, j); } // Iterators are the iterators of the referenced expression. BOOST_UBLAS_INLINE const_iterator1 begin1 () const { return expression ().begin1 (); } BOOST_UBLAS_INLINE const_iterator1 end1 () const { return expression ().end1 (); } BOOST_UBLAS_INLINE iterator1 begin1 () { return expression ().begin1 (); } BOOST_UBLAS_INLINE iterator1 end1 () { return expression ().end1 (); } BOOST_UBLAS_INLINE const_iterator2 begin2 () const { return expression ().begin2 (); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { return expression ().end2 (); } BOOST_UBLAS_INLINE iterator2 begin2 () { return expression ().begin2 (); } BOOST_UBLAS_INLINE iterator2 end2 () { return expression ().end2 (); } // Reverse iterators#ifdef BOOST_MSVC_STD_ITERATOR typedef reverse_iterator_base1<const_iterator1, value_type, const_reference> const_reverse_iterator1;#else typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;#endif BOOST_UBLAS_INLINE const_reverse_iterator1 rbegin1 () const { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); }#ifdef BOOST_MSVC_STD_ITERATOR typedef reverse_iterator_base1<iterator1, value_type, reference> reverse_iterator1;#else typedef reverse_iterator_base1<iterator1> reverse_iterator1;#endif BOOST_UBLAS_INLINE reverse_iterator1 rbegin1 () { return reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE reverse_iterator1 rend1 () { return reverse_iterator1 (begin1 ()); }#ifdef BOOST_MSVC_STD_ITERATOR typedef reverse_iterator_base2<const_iterator2, value_type, const_reference> const_reverse_iterator2;#else typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;#endif BOOST_UBLAS_INLINE const_reverse_iterator2 rbegin2 () const { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); }#ifdef BOOST_MSVC_STD_ITERATOR typedef reverse_iterator_base2<iterator2, value_type, reference> reverse_iterator2;#else typedef reverse_iterator_base2<iterator2> reverse_iterator2;#endif BOOST_UBLAS_INLINE reverse_iterator2 rbegin2 () { return reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE reverse_iterator2 rend2 () { return reverse_iterator2 (begin2 ()); } private: refered_type &e_; static refered_type nil_; }; template<class E> typename matrix_reference<E>::refered_type matrix_reference<E>::nil_#ifdef BOOST_UBLAS_STATIC_OLD_INIT = BOOST_UBLAS_TYPENAME matrix_reference<E>::refered_type()#endif ; template<class E1, class E2, class F> class vector_matrix_binary: public matrix_expression<vector_matrix_binary<E1, E2, F> > { public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS BOOST_UBLAS_USING matrix_expression<vector_matrix_binary<E1, E2, F> >::operator ();#endif typedef F functor_type; typedef typename promote_traits<typename E1::size_type, typename E2::size_type>::promote_type size_type; typedef typename promote_traits<typename E1::difference_type, typename E2::difference_type>::promote_type difference_type; typedef typename F::result_type value_type; typedef value_type const_reference; typedef const_reference reference; private: typedef const value_type *const_pointer; typedef E1 expression1_type; typedef E2 expression2_type; typedef typename E1::const_closure_type expression1_closure_type; typedef typename E2::const_closure_type expression2_closure_type; typedef vector_matrix_binary<E1, E2, F> self_type; public: typedef const self_type const_closure_type; typedef const_closure_type closure_type; typedef unknown_orientation_tag orientation_category; typedef unknown_storage_tag storage_category; // Construction and destruction BOOST_UBLAS_INLINE vector_matrix_binary (): e1_ (), e2_ () {} BOOST_UBLAS_INLINE vector_matrix_binary (const expression1_type &e1, const expression2_type &e2): e1_ (e1), e2_ (e2) {} // Accessors BOOST_UBLAS_INLINE size_type size1 () const { return e1_.size (); } BOOST_UBLAS_INLINE size_type size2 () const { return e2_.size (); }#ifndef BOOST_UBLAS_NESTED_CLASS_DR45 private:#endif // Expression accessors BOOST_UBLAS_INLINE const expression1_closure_type &expression1 () const { return e1_; } BOOST_UBLAS_INLINE const expression2_closure_type &expression2 () const { return e2_; } public: // Element access BOOST_UBLAS_INLINE const_reference operator () (size_type i, size_type j) const { return functor_type::apply (e1_ (i), e2_ (j)); } // Closure comparison BOOST_UBLAS_INLINE bool same_closure (const vector_matrix_binary &vmb) const { return (*this).expression1 ().same_closure (vmb.expression1 ()) && (*this).expression2 ().same_closure (vmb.expression2 ()); } // Iterator types private: typedef typename E1::const_iterator const_iterator1_type; typedef typename E2::const_iterator const_iterator2_type; public:#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR typedef typename iterator_restrict_traits<typename const_iterator1_type::iterator_category, typename const_iterator2_type::iterator_category>::iterator_category iterator_category; typedef indexed_const_iterator1<const_closure_type, iterator_category> const_iterator1; typedef const_iterator1 iterator1; typedef indexed_const_iterator2<const_closure_type, iterator_category> const_iterator2; typedef const_iterator2 iterator2;#else class const_iterator1; typedef const_iterator1 iterator1; class const_iterator2; typedef const_iterator2 iterator2;#endif#ifdef BOOST_MSVC_STD_ITERATOR typedef reverse_iterator_base1<const_iterator1, value_type, const_reference> const_reverse_iterator1; typedef reverse_iterator_base2<const_iterator2, value_type, const_reference> const_reverse_iterator2;#else typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1; typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;#endif // Element lookup BOOST_UBLAS_INLINE const_iterator1 find1 (int rank, size_type i, size_type j) const { const_iterator1_type it1 (e1_.find (i)); const_iterator1_type it1_end (e1_.find (size1 ())); const_iterator2_type it2 (e2_.find (j)); const_iterator2_type it2_end (e2_.find (size2 ())); if (it2 == it2_end || (rank == 1 && (it2.index () != j || *it2 == value_type (0)))) { it1 = it1_end; it2 = it2_end; }#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator1 (*this, it1.index (), it2.index ());#else#ifdef BOOST_UBLAS_USE_INVARIANT_HOISTING return const_iterator1 (*this, it1, it2, it2 != it2_end ? *it2 : value_type (0));#else return const_iterator1 (*this, it1, it2);#endif#endif } BOOST_UBLAS_INLINE const_iterator2 find2 (int rank, size_type i, size_type j) const { const_iterator2_type it2 (e2_.find (j)); const_iterator2_type it2_end (e2_.find (size2 ())); const_iterator1_type it1 (e1_.find (i)); const_iterator1_type it1_end (e1_.find (size1 ())); if (it1 == it1_end || (rank == 1 && (it1.index () != i || *it1 == value_type (0)))) { it2 = it2_end; it1 = it1_end; }#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR return const_iterator2 (*this, it1.index (), it2.index ());#else#ifdef BOOST_UBLAS_USE_INVARIANT_HOISTING return const_iterator2 (*this, it1, it2, it1 != it1_end ? *it1 : value_type (0));#else return const_iterator2 (*this, it1, it2);#endif#endif } // Iterators enhance the iterators of the referenced expressions // with the binary functor.#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator1: public container_const_reference<vector_matrix_binary>,#ifndef BOOST_UBLAS_NO_ITERATOR_BASE_TRAITS public iterator_base_traits<typename iterator_restrict_traits<typename E1::const_iterator::iterator_category, typename E2::const_iterator::iterator_category>::iterator_category>::template iterator_base<const_iterator1, value_type>::type {#else public random_access_iterator_base<typename iterator_restrict_traits<typename E1::const_iterator::iterator_category, typename E2::const_iterator::iterator_category>::iterator_category, const_iterator1, value_type> {#endif public: typedef typename iterator_restrict_traits<typename E1::const_iterator::iterator_category, typename E2::const_iterator::iterator_category>::iterator_category iterator_category;#ifdef BOOST_MSVC_STD_ITERATOR typedef const_reference reference;#else typedef typename vector_matrix_binary::difference_type difference_type; typedef typename vector_matrix_binary::value_type value_type; typedef typename vector_matrix_binary::const_reference reference; typedef typename vector_matrix_binary::const_pointer pointer;#endif typedef const_iterator2 dual_iterator_type; typedef const_reverse_iterator2 dual_reverse_iterator_type; // Construction and destruction#ifdef BOOST_UBLAS_USE_INVARIANT_HOISTING BOOST_UBLAS_INLINE const_iterator1 (): container_const_reference<self_type> (), it1_ (), it2_ (), t2_ () {} BOOST_UBLAS_INLINE const_iterator1 (const self_type &vmb, const const_iterator1_type &it1, const const_iterator2_type &it2, value_type t2): container_const_reference<self_type> (vmb), it1_ (it1), it2_ (it2), t2_ (t2) {}#else BOOST_UBLAS_INLINE const_iterator1 (): container_const_reference<self_type> (), it1_ (), it2_ () {} BOOST_UBLAS_INLINE const_iterator1 (const self_type &vmb, const const_iterator1_type &it1, const const_iterator2_type &it2): container_const_reference<self_type> (vmb), it1_ (it1), it2_ (it2) {}#endif // Arithmetic BOOST_UBLAS_INLINE const_iterator1 &operator ++ () { ++ it1_; return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator -- () { -- it1_; return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator += (difference_type n) { it1_ += n; return *this; } BOOST_UBLAS_INLINE const_iterator1 &operator -= (difference_type n) { it1_ -= n; return *this; } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator1 &it) const { BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ()); BOOST_UBLAS_CHECK (it2_ == it.it2_, external_logic ()); return it1_ - it.it1_; } // Dereference
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -