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

📄 matrix.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING matrix_expression<vector_of_vector<T, F, A> >::operator ();#endif        typedef typename A::size_type size_type;        typedef typename A::difference_type difference_type;        typedef T value_type;        typedef const T &const_reference;        typedef T &reference;        typedef A array_type;    private:        typedef T *pointer;        typedef F functor_type;        typedef vector_of_vector<T, F, A> self_type;    public:#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS        typedef const matrix_const_reference<const self_type> const_closure_type;#else        typedef const matrix_reference<const self_type> const_closure_type;#endif        typedef matrix_reference<self_type> closure_type;        typedef vector<T, typename A::value_type> vector_temporary_type;        typedef self_type matrix_temporary_type;        typedef dense_tag storage_category;        // This could be better for performance,        // typedef typename unknown_orientation_tag orientation_category;        // but others depend on the orientation information...        typedef typename functor_type::orientation_category orientation_category;        typedef concrete_tag simd_category;        // Construction and destruction        BOOST_UBLAS_INLINE        vector_of_vector ():            matrix_expression<self_type> (),            size1_ (0), size2_ (0), data_ (1) {}        BOOST_UBLAS_INLINE        vector_of_vector (size_type size1, size_type size2):            matrix_expression<self_type> (),            size1_ (size1), size2_ (size2), data_ (1) {            resize (size1, size2, true);        }        BOOST_UBLAS_INLINE        vector_of_vector (const vector_of_vector &m):            matrix_expression<self_type> (),            size1_ (m.size1_), size2_ (m.size2_), data_ (m.data_) {}        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector (const matrix_expression<AE> &ae):            matrix_expression<self_type> (),            size1_ (ae ().size1 ()), size2_ (ae ().size2 ()), data_ (functor_type::size1 (size1_, size2_) + 1) {            for (size_type k = 0; k < functor_type::size1 (size1_, size2_); ++ k)                data ()[k].resize (functor_type::size2 (size1_, size2_));            matrix_assign (scalar_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);        }        // Accessors        BOOST_UBLAS_INLINE        size_type size1 () const {            return size1_;        }        BOOST_UBLAS_INLINE        size_type size2 () const {             return size2_;        }        BOOST_UBLAS_INLINE        const array_type &data () const {            return data_;        }        BOOST_UBLAS_INLINE        array_type &data () {            return data_;        }        // Resizing        BOOST_UBLAS_INLINE        void resize (size_type size1, size_type size2, bool preserve = true) {            size1_ = size1;            size2_ = size2;            if (preserve)                data ().resize (functor_type::size1 (size1, size2) + 1, BOOST_UBLAS_TYPENAME array_type::value_type ());            else                data ().resize (functor_type::size1 (size1, size2) + 1);            for (size_type k = 0; k < functor_type::size1 (size1, size2); ++ k) {                if (preserve)                    data () [k].resize (functor_type::size2 (size1, size2), value_type ());                else                    data () [k].resize (functor_type::size2 (size1, size2));            }        }        // Element access        BOOST_UBLAS_INLINE        const_reference operator () (size_type i, size_type j) const {            return data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)];         }        BOOST_UBLAS_INLINE        reference operator () (size_type i, size_type j) {            return data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)];         }        // Assignment        BOOST_UBLAS_INLINE        vector_of_vector &operator = (const vector_of_vector &m) {            size1_ = m.size1_;            size2_ = m.size2_;            data () = m.data ();            return *this;        }        BOOST_UBLAS_INLINE        vector_of_vector &assign_temporary (vector_of_vector &m) {             swap (m);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector &operator = (const matrix_expression<AE> &ae) {             // return assign (self_type (ae));            self_type temporary (ae);            return assign_temporary (temporary);        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector &assign (const matrix_expression<AE> &ae) {             matrix_assign (scalar_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);             return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector& operator += (const matrix_expression<AE> &ae) {            // return assign (self_type (*this + ae));            self_type temporary (*this + ae);            return assign_temporary (temporary);        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector &plus_assign (const matrix_expression<AE> &ae) {             matrix_assign (scalar_plus_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);             return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector& operator -= (const matrix_expression<AE> &ae) {            // return assign (self_type (*this - ae));            self_type temporary (*this - ae);            return assign_temporary (temporary);        }        template<class AE>        BOOST_UBLAS_INLINE        vector_of_vector &minus_assign (const matrix_expression<AE> &ae) {            matrix_assign (scalar_minus_assign<reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);             return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        vector_of_vector& operator *= (const AT &at) {            matrix_assign_scalar (scalar_multiplies_assign<reference, AT> (), *this, at);            return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        vector_of_vector& operator /= (const AT &at) {            matrix_assign_scalar (scalar_divides_assign<reference, AT> (), *this, at);            return *this;        }        // Swapping        BOOST_UBLAS_INLINE        void swap (vector_of_vector &m) {            if (this != &m) {                std::swap (size1_, m.size1_);                std::swap (size2_, m.size2_);                data ().swap (m.data ());            }        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend void swap (vector_of_vector &m1, vector_of_vector &m2) {            m1.swap (m2);        }#endif        // Element insertion and erasure        // These functions should work with std::vector.        // Thanks to Kresimir Fresl for spotting this.        BOOST_UBLAS_INLINE        void insert (size_type i, size_type j, const_reference t) {            BOOST_UBLAS_CHECK (data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)] == value_type (0), bad_index ());            data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)] = t;         }        BOOST_UBLAS_INLINE        void erase (size_type i, size_type j) {            data () [functor_type::element1 (i, size1_, j, size2_)] [functor_type::element2 (i, size1_, j, size2_)] = value_type (0);         }        BOOST_UBLAS_INLINE        void clear () {            for (size_type k = 0; k < functor_type::size1 (size1_, size2_); ++ k)                // data () [k].clear ();                std::fill (data () [k].begin (), data () [k].end (), value_type (0));        }        // Iterator types    private:        // Use the vector iterator        typedef typename A::const_iterator vector_const_iterator_type;        typedef typename A::iterator vector_iterator_type;        typedef typename A::value_type::const_iterator const_iterator_type;        typedef typename A::value_type::iterator iterator_type;    public:#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR        typedef indexed_iterator1<self_type, dense_random_access_iterator_tag> iterator1;        typedef indexed_iterator2<self_type, dense_random_access_iterator_tag> iterator2;        typedef indexed_const_iterator1<self_type, dense_random_access_iterator_tag> const_iterator1;        typedef indexed_const_iterator2<self_type, dense_random_access_iterator_tag> const_iterator2;#else        class const_iterator1;        class iterator1;        class const_iterator2;        class iterator2;#endif#ifdef BOOST_MSVC_STD_ITERATOR        typedef reverse_iterator_base1<const_iterator1, value_type, const_reference> const_reverse_iterator1;        typedef reverse_iterator_base1<iterator1, value_type, reference> reverse_iterator1;        typedef reverse_iterator_base2<const_iterator2, value_type, const_reference> const_reverse_iterator2;        typedef reverse_iterator_base2<iterator2, value_type, reference> reverse_iterator2;#else        typedef reverse_iterator_base1<const_iterator1> const_reverse_iterator1;        typedef reverse_iterator_base1<iterator1> reverse_iterator1;        typedef reverse_iterator_base2<const_iterator2> const_reverse_iterator2;        typedef reverse_iterator_base2<iterator2> reverse_iterator2;#endif        // Element lookup        BOOST_UBLAS_INLINE        const_iterator1 find1 (int rank, size_type i, size_type j) const {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator1 (*this, i, j);#else            return const_iterator1 (*this, i, j, data () [functor_type::address1 (i, size1_, j, size2_)].begin ()  + functor_type::address2 (i, size1_, j, size2_));#endif        }        BOOST_UBLAS_INLINE        iterator1 find1 (int rank, size_type i, size_type j) {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return iterator1 (*this, i, j);#else            return iterator1 (*this, i, j, data () [functor_type::address1 (i, size1_, j, size2_)].begin ()  + functor_type::address2 (i, size1_, j, size2_));#endif        }        BOOST_UBLAS_INLINE        const_iterator2 find2 (int rank, size_type i, size_type j) const {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator2 (*this, i, j);#else            return const_iterator2 (*this, i, j, data () [functor_type::address1 (i, size1_, j, size2_)].begin ()  + functor_type::address2 (i, size1_, j, size2_));#endif        }        BOOST_UBLAS_INLINE        iterator2 find2 (int rank, size_type i, size_type j) {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return iterator2 (*this, i, j);#else            return iterator2 (*this, i, j, data () [functor_type::address1 (i, size1_, j, size2_)].begin () + functor_type::address2 (i, size1_, j, size2_));#endif        }#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class const_iterator1:            public container_const_reference<vector_of_vector>,            public random_access_iterator_base<dense_random_access_iterator_tag,                                               const_iterator1, value_type> {        public:            typedef dense_random_access_iterator_tag iterator_category;#ifdef BOOST_MSVC_STD_ITERATOR            typedef const_reference reference;#else            typedef typename vector_of_vector::value_type value_type;            typedef typename vector_of_vector::difference_type difference_type;            typedef typename vector_of_vector::const_reference reference;            typedef const typename vector_of_vector::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> (), i_ (), j_ (), it_ () {}            BOOST_UBLAS_INLINE            const_iterator1 (const self_type &m, size_type i, size_type j, const const_iterator_type &it):                container_const_reference<self_type> (m), i_ (i), j_ (j), it_ (it) {}            BOOST_UBLAS_INLINE            const_iterator1 (const iterator1 &it):                container_const_reference<self_type> (it ()), i_ (it.i_), j_ (it.j_), it_ (it.it_) {}            // Arithmetic            BOOST_UBLAS_INLINE            const_iterator1 &operator ++ () {                ++ i_;                const self_type &m = (*this) ();                if (functor_type::fast1 ())                    ++ it_;                else                     it_ = m.find1 (1, i_, j_).it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator -- () {                -- i_;                const self_type &m = (*this) ();                if (functor_type::fast1 ())                    -- it_;                else                    it_ = m.find1 (1, i_, j_).it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator += (difference_type n) {                i_ += n;                const self_type &m = (*this) ();                it_ = m.find1 (1, i_, j_).it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator1 &operator -= (difference_type n) {                i_ -= n;                const self_type &m = (*this) ();                it_ = m.find1 (1, i_, j_).it_;                return *this;            }            BOOST_UBLAS_INLINE            difference_type operator - (const const_iterator1 &it) const {                BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ());                BOOST_UBLAS_CHECK (index2 () == it.index2 (), bad_index ());                return index1 () - it.index1 ();            }            // Dereference            BOOST_UBLAS_INLINE            const_reference operator * () const {                BOOST_UBLAS_CHECK (index1 () < (*this) ().size1 (), bad_index ());

⌨️ 快捷键说明

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