⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix_expression.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
        // Reverse iterators        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 ());        }        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 ());        }    private:        expression_closure_type e_;    };    template<class E, class F>    struct matrix_unary1_traits {        typedef matrix_unary1<E, F> expression_type;#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG        typedef expression_type result_type; #else        typedef typename E::matrix_temporary_type result_type;#endif    };    // (- m) [i] [j] = - m [i] [j]    template<class E>    BOOST_UBLAS_INLINE    typename matrix_unary1_traits<E, scalar_negate<typename E::value_type> >::result_type    operator - (const matrix_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME matrix_unary1_traits<E, scalar_negate<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (conj m) [i] [j] = conj (m [i] [j])    template<class E>     BOOST_UBLAS_INLINE    typename matrix_unary1_traits<E, scalar_conj<typename E::value_type> >::result_type    conj (const matrix_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME matrix_unary1_traits<E, scalar_conj<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (real m) [i] [j] = real (m [i] [j])    template<class E>     BOOST_UBLAS_INLINE    typename matrix_unary1_traits<E, scalar_real<typename E::value_type> >::result_type    real (const matrix_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME matrix_unary1_traits<E, scalar_real<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (imag m) [i] [j] = imag (m [i] [j])    template<class E>     BOOST_UBLAS_INLINE    typename matrix_unary1_traits<E, scalar_imag<typename E::value_type> >::result_type    imag (const matrix_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME matrix_unary1_traits<E, scalar_imag<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    template<class E, class F>    class matrix_unary2:        public matrix_expression<matrix_unary2<E, F> > {    public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING matrix_expression<matrix_unary2<E, F> >::operator ();#endif        typedef typename E::size_type size_type;        typedef typename E::difference_type difference_type;        typedef typename F::result_type value_type;        typedef value_type const_reference;        typedef typename boost::mpl::if_<boost::is_same<F,                                                         scalar_identity<value_type> >,                                          typename E::reference,                                          value_type>::type reference;    private:        typedef const value_type *const_pointer;        typedef typename boost::mpl::if_<boost::is_same<F,                                                         scalar_identity<typename E::value_type> >,                                          E,                                          const E>::type expression_type;        typedef F functor_type;        typedef typename boost::mpl::if_<boost::is_const<expression_type>,                                          typename E::const_closure_type,                                          typename E::closure_type>::type expression_closure_type;        typedef matrix_unary2<E, F> self_type;    public:        typedef const self_type const_closure_type;        typedef self_type closure_type;        // typedef typename E::orientation_category orientation_category;        typedef typename boost::mpl::if_<boost::is_same<typename E::orientation_category,                                                         row_major_tag>,                                          column_major_tag,                typename boost::mpl::if_<boost::is_same<typename E::orientation_category,                                                         column_major_tag>,                                          row_major_tag,                                          typename E::orientation_category>::type>::type orientation_category;        // typedef unknown_storage_tag storage_category;        typedef typename E::storage_category storage_category;        // Construction and destruction        BOOST_UBLAS_INLINE        matrix_unary2 ():            e_ () {}        BOOST_UBLAS_INLINE        // ISSUE may be used as mutable expression.        // matrix_unary2 (const expression_type &e):        explicit matrix_unary2 (expression_type &e):            e_ (e) {}        // Accessors        BOOST_UBLAS_INLINE        size_type size1 () const {            return e_.size2 ();        }        BOOST_UBLAS_INLINE        size_type size2 () const {            return e_.size1 ();        }#ifndef BOOST_UBLAS_NESTED_CLASS_DR45    private:#endif        // Expression accessors        BOOST_UBLAS_INLINE        const expression_closure_type &expression () const {            return e_;        }    public:        // Element access        BOOST_UBLAS_INLINE        const_reference operator () (size_type i, size_type j) const {            return functor_type::apply (e_ (j, i));        }        BOOST_UBLAS_INLINE        reference operator () (size_type i, size_type j) {            BOOST_STATIC_ASSERT ((boost::is_same<functor_type, scalar_identity<value_type > >::value));            return e_ (j, i);        }        // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const matrix_unary2 &mu2) const {            return (*this).expression ().same_closure (mu2.expression ());        }        // Iterator types    private:        typedef typename E::const_iterator1 const_iterator2_type;        typedef typename E::const_iterator2 const_iterator1_type;    public:#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR        typedef indexed_const_iterator1<const_closure_type, typename const_iterator1_type::iterator_category> const_iterator1;        typedef const_iterator1 iterator1;        typedef indexed_const_iterator2<const_closure_type, typename const_iterator2_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 (e_.find2 (rank, j, i));#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator1 (*this, it1.index2 (), it1.index1 ());#else            return const_iterator1 (*this, it1);#endif        }        BOOST_UBLAS_INLINE        const_iterator2 find2 (int rank, size_type i, size_type j) const {            const_iterator2_type it2 (e_.find1 (rank, j, i));#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator2 (*this, it2.index2 (), it2.index1 ());#else            return const_iterator2 (*this, it2);#endif        }        // Iterators enhance the iterators of the referenced expression        // with the unary functor.#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class const_iterator1:            public container_const_reference<matrix_unary2>,#ifndef BOOST_UBLAS_NO_ITERATOR_BASE_TRAITS            public iterator_base_traits<typename E::const_iterator2::iterator_category>::template                iterator_base<const_iterator1, value_type>::type {#else            public random_access_iterator_base<typename E::const_iterator2::iterator_category,                                               const_iterator1, value_type> {#endif        public:            typedef typename E::const_iterator2::iterator_category iterator_category;#ifdef BOOST_MSVC_STD_ITERATOR            typedef const_reference reference;#else            typedef typename matrix_unary2::difference_type difference_type;            typedef typename matrix_unary2::value_type value_type;            typedef typename matrix_unary2::const_reference reference;            typedef typename matrix_unary2::const_pointer pointer;#endif            typedef const_iterator2 dual_iterator_type;            typedef const_reverse_iterator2 dual_reverse_iterator_type;            // Construction and destruction            BOOST_UBLAS_INLINE            const_iterator1 ():                container_const_reference<self_type> (), it_ () {}            BOOST_UBLAS_INLINE            const_iterator1 (const self_type &mu, const const_iterator1_type &it):                container_const_reference<self_type> (mu), it_ (it) {}            // Arithmetic            BOOST_UBLAS_INLINE            const_iterator1 &operator ++ () {                ++ it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator -- () {                -- it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator += (difference_type n) {                it_ += n;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator -= (difference_type n) {                it_ -= n;                return *this;            }            BOOST_UBLAS_INLINE            difference_type operator - (const const_iterator1 &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ - it.it_;            }            // Dereference            BOOST_UBLAS_INLINE            const_reference operator * () const {                return functor_type::apply (*it_);            }#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION            BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION            typename self_type::#endif            const_iterator2 begin () const {                return (*this) ().find2 (1, index1 (), 0);            }            BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION            typename self_type::#endif            const_iterator2 end () const {                return (*this) ().find2 (1, index1 (), (*this) ().size2 ());            }            BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION            typename self_type::#endif            const_reverse_iterator2 rbegin () const {                return const_reverse_iterator2 (end ());            }            BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION            typename self_type::#endif            const_reverse_iterator2 rend () const {                return const_reverse_iterator2 (begin ());            }#endif            // Indices            BOOST_UBLAS_INLINE            size_type index1 () const {                return it_.index2 ();            }            BOOST_UBLAS_INLINE            size_type index2 () const {                return it_.index1 ();            }            // Assignment             BOOST_UBLAS_INLINE            const_iterator1 &operator = (const const_iterator1 &it) {                container_const_reference<self_type>::assign (&it ());                it_ = it.it_;                return *this;            }            // Comparison            BOOST_UBLAS_INLINE            bool operator == (const const_iterator1 &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ == it.it_;            }            BOOST_UBLAS_INLINE            bool operator < (const const_iterator1 &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ < it.it_;            }        private:            const_iterator1_type it_;        };#endif        BOOST_UBLAS_INLINE        const_iterator1 begin1 () const {            return find1 (0, 0, 0);        }        BOOST_UBLAS_INLINE        const_iterator1 end1 () const {            return find1 (0, size1 (), 0);        }#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class const_iterator2:            public contai

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -