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

📄 vector_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 页
字号:
                return *this;            }            // Comparison            BOOST_UBLAS_INLINE            bool operator == (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ == it.it_;            }            BOOST_UBLAS_INLINE            bool operator < (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ < it.it_;            }        private:            const_iterator_type it_;        };#endif        BOOST_UBLAS_INLINE        const_iterator begin () const {            return find (0);         }        BOOST_UBLAS_INLINE        const_iterator end () const {            return find (size ());        }        // Reverse iterator#ifdef BOOST_MSVC_STD_ITERATOR        typedef reverse_iterator_base<const_iterator, value_type, const_reference> const_reverse_iterator;#else        typedef reverse_iterator_base<const_iterator> const_reverse_iterator;#endif        BOOST_UBLAS_INLINE        const_reverse_iterator rbegin () const {            return const_reverse_iterator (end ());        }        BOOST_UBLAS_INLINE        const_reverse_iterator rend () const {            return const_reverse_iterator (begin ());        }    private:        expression_closure_type e_;    };    template<class E, class F>    struct vector_unary_traits {        typedef vector_unary<E, F> expression_type;//FIXME// #ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG        typedef expression_type result_type;// #else//         typedef typename E::vector_temporary_type result_type;// #endif    };    // (- v) [i] = - v [i]    template<class E>     BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_negate<typename E::value_type> >::result_type    operator - (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_negate<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (conj v) [i] = conj (v [i])    template<class E>     BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type    conj (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_conj<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (real v) [i] = real (v [i])    template<class E>    BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_real<typename E::value_type> >::result_type    real (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_real<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (imag v) [i] = imag (v [i])    template<class E>    BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_imag<typename E::value_type> >::result_type    imag (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_imag<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (trans v) [i] = v [i]    template<class E>    BOOST_UBLAS_INLINE    typename vector_unary_traits<const E, scalar_identity<typename E::value_type> >::result_type    trans (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<const E, scalar_identity<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    template<class E>    BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_identity<typename E::value_type> >::result_type    trans (vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_identity<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    // (herm v) [i] = conj (v [i])    template<class E>    BOOST_UBLAS_INLINE    typename vector_unary_traits<E, scalar_conj<typename E::value_type> >::result_type    herm (const vector_expression<E> &e) {        typedef BOOST_UBLAS_TYPENAME vector_unary_traits<E, scalar_conj<BOOST_UBLAS_TYPENAME E::value_type> >::expression_type expression_type;        return expression_type (e ());    }    template<class E1, class E2, class F>    class vector_binary:        public vector_expression<vector_binary<E1, E2, F> > {    public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING vector_expression<vector_binary<E1, E2, F> >::operator ();#endif        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 F functor_type;        typedef typename E1::const_closure_type expression1_closure_type;        typedef typename E2::const_closure_type expression2_closure_type;        typedef vector_binary<E1, E2, F> self_type;    public:        typedef const self_type const_closure_type;        typedef const_closure_type closure_type;        typedef unknown_storage_tag storage_category;        // Construction and destruction        BOOST_UBLAS_INLINE        vector_binary ():            e1_ (), e2_ () {}        BOOST_UBLAS_INLINE        vector_binary (const expression1_type &e1, const expression2_type &e2):            e1_ (e1), e2_ (e2) {}        // Accessors        BOOST_UBLAS_INLINE        size_type size () const {             return BOOST_UBLAS_SAME (e1_.size (), e2_.size ());         }    private:        // Expression accesors        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) const {            return functor_type::apply (e1_ (i), e2_ (i));        }        BOOST_UBLAS_INLINE        const_reference operator [] (size_type i) const {            return functor_type::apply (e1_ [i], e2_ [i]);        }        // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const vector_binary &vb) const {            return (*this).expression1 ().same_closure (vb.expression1 ()) &&                   (*this).expression2 ().same_closure (vb.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_iterator<const_closure_type, iterator_category> const_iterator;        typedef const_iterator iterator;#else        class const_iterator;        typedef const_iterator iterator;#endif        // Element lookup        BOOST_UBLAS_INLINE        const_iterator find (size_type i) const {            const_iterator1_type it1 (e1_.find (i));            const_iterator1_type it1_end (e1_.find (size ()));            const_iterator2_type it2 (e2_.find (i));            const_iterator2_type it2_end (e2_.find (size ()));            i = (std::min) (it1 != it1_end ? it1.index () : size (),                          it2 != it2_end ? it2.index () : size ());#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator (*this, i);#else            return const_iterator (*this, i, it1, it1_end, it2, it2_end);#endif        }        // Iterator merges the iterators of the referenced expressions and        // enhances them with the binary functor.#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class const_iterator:            public container_const_reference<vector_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_iterator, 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_iterator, 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_binary::difference_type difference_type;            typedef typename vector_binary::value_type value_type;            typedef typename vector_binary::const_reference reference;            typedef typename vector_binary::const_pointer pointer;#endif            // Construction and destruction            BOOST_UBLAS_INLINE            const_iterator ():                container_const_reference<self_type> (), i_ (), it1_ (), it1_end_ (), it2_ (), it2_end_ () {}            BOOST_UBLAS_INLINE            const_iterator (const self_type &vb, size_type i,                            const const_iterator1_type &it1, const const_iterator1_type &it1_end,                            const const_iterator2_type &it2, const const_iterator2_type &it2_end):                container_const_reference<self_type> (vb), i_ (i), it1_ (it1), it1_end_ (it1_end), it2_ (it2), it2_end_ (it2_end) {}            // Dense specializations            BOOST_UBLAS_INLINE            void increment (dense_random_access_iterator_tag) {                ++ i_, ++ it1_, ++ it2_;            }            BOOST_UBLAS_INLINE            void decrement (dense_random_access_iterator_tag) {                -- i_, -- it1_, -- it2_;            }            BOOST_UBLAS_INLINE            value_type dereference (dense_random_access_iterator_tag) const {                return functor_type::apply (*it1_, *it2_);            }            // Packed specializations            BOOST_UBLAS_INLINE            void increment (packed_random_access_iterator_tag) {                if (it1_ != it1_end_)                    if (it1_.index () <= i_)                        ++ it1_;                if (it2_ != it2_end_)                    if (it2_.index () <= i_)                        ++ it2_;                ++ i_;            }            BOOST_UBLAS_INLINE            void decrement (packed_random_access_iterator_tag) {                if (it1_ != it1_end_)                    if (i_ <= it1_.index ())                        -- it1_;                if (it2_ != it2_end_)                    if (i_ <= it2_.index ())                        -- it2_;                -- i_;            }            BOOST_UBLAS_INLINE            value_type dereference (packed_random_access_iterator_tag) const {                value_type t1 = value_type (0);                if (it1_ != it1_end_)                    if (it1_.index () == i_)                        t1 = *it1_;                value_type t2 = value_type (0);                if (it2_ != it2_end_)                    if (it2_.index () == i_)                        t2 = *it2_;                return functor_type::apply (t1, t2);            }            // Sparse specializations            BOOST_UBLAS_INLINE            void increment (sparse_bidirectional_iterator_tag) {                size_type index1 = (*this) ().size ();                if (it1_ != it1_end_) {                    if  (it1_.index () <= i_)                        ++ it1_;                    if (it1_ != it1_end_)                        index1 = it1_.index ();                }                size_type index2 = (*this) ().size ();                if (it2_ != it2_end_) {                    if (it2_.index () <= i_)                        ++ it2_;                    if (it2_ != it2_end_)                        index2 = it2_.index ();                }                i_ = (std::min) (index1, index2);            }            BOOST_UBLAS_INLINE            void decrement (sparse_bidirectional_iterator_tag) {                size_type index1 = (*this) ().size ();                if (it1_ != it1_end_) {                    if (i_ <= it1_.index ())                        -- it1_;                    if (it1_ != it1_end_)                        index1 = it1_.index ();                }                size_type index2 = (*this) ().size ();                if (it2_ != it2_end_) {                    if (i_ <= it2_.index ())                        -- it2_;                    if (it2_ != it2_end_)                        index2 = it2_.index ();                }                i_ = (std::max) (index1, index2);            }            BOOST_UBLAS_INLINE            value_type dereference (sparse_bidirectional_iterator_tag) const {                value_type t1 = value_type (0);                if (it1_ != it1_end_)                    if (it1_.index () == i_)                        t1 = *it1_;                value_type t2 = value_type (0);                if (it2_ != it2_end_)

⌨️ 快捷键说明

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