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

📄 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 页
字号:
////  Copyright (c) 2000-2002//  Joerg Walter, Mathias Koch////  Permission to use, copy, modify, distribute and sell this software//  and its documentation for any purpose is hereby granted without fee,//  provided that the above copyright notice appear in all copies and//  that both that copyright notice and this permission notice appear//  in supporting documentation.  The authors make no representations//  about the suitability of this software for any purpose.//  It is provided "as is" without express or implied warranty.////  The authors gratefully acknowledge the support of//  GeNeSys mbH & Co. KG in producing this work.//#ifndef BOOST_UBLAS_MATRIX_EXPRESSION_H#define BOOST_UBLAS_MATRIX_EXPRESSION_H#include <boost/numeric/ublas/vector_expression.hpp>// Expression templates based on ideas of Todd Veldhuizen and Geoffrey Furnish// Iterators based on ideas of Jeremy Sieknamespace boost { namespace numeric { namespace ublas {    // Base class Matrix Expressions - see the Barton Nackman trick    template<class E>    class matrix_expression:        public ublas_expression<E> {    public:        BOOST_STATIC_CONSTANT (unsigned, complexity = 0);        typedef E expression_type;        typedef matrix_tag type_category;        typedef abstract_tag simd_category;        // FIXME: Template instantiation order problem        // typedef typename E::size_type size_type;        typedef std::size_t size_type;        typedef noalias_proxy<E> noalias_proxy_type;        typedef const matrix_row<const E> const_matrix_row_type;        typedef matrix_row<E> matrix_row_type;        typedef const matrix_column<const E> const_matrix_column_type;        typedef matrix_column<E> matrix_column_type;        typedef const matrix_range<const E> const_matrix_range_type;        typedef matrix_range<E> matrix_range_type;        typedef const matrix_slice<const E> const_matrix_slice_type;        typedef matrix_slice<E> matrix_slice_type;        typedef const matrix_indirect<const E> const_matrix_indirect_type;        typedef matrix_indirect<E> matrix_indirect_type;        // This class could define an common interface for all        // statically derived expression type classes.        // Due to a compiler deficiency - one can not reference class typedefs of E        // on MSVC 6.0 (error C2027) - we only implement the casts.        BOOST_UBLAS_INLINE        const expression_type &operator () () const {            return *static_cast<const expression_type *> (this);        }        BOOST_UBLAS_INLINE        expression_type &operator () () {            return *static_cast<expression_type *> (this);        }        BOOST_UBLAS_INLINE        noalias_proxy_type noalias () {            return noalias_proxy_type (operator () ());        }        BOOST_UBLAS_INLINE        const_matrix_row_type operator [] (size_type i) const {            return const_matrix_row_type (operator () (), i);        }        BOOST_UBLAS_INLINE        matrix_row_type operator [] (size_type i) {            return matrix_row_type (operator () (), i);        }        BOOST_UBLAS_INLINE        const_matrix_row_type row (size_type i) const {            return const_matrix_row_type (operator () (), i);        }        BOOST_UBLAS_INLINE        matrix_row_type row (size_type i) {            return matrix_row_type (operator () (), i);        }        BOOST_UBLAS_INLINE        const_matrix_column_type column (size_type j) const {            return const_matrix_column_type (operator () (), j);        }        BOOST_UBLAS_INLINE        matrix_column_type column (size_type j) {            return matrix_column_type (operator () (), j);        }#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_INLINE        const_matrix_range_type operator () (const range &r1, const range &r2) const {            return const_matrix_range_type (operator () (), r1, r2);        }        BOOST_UBLAS_INLINE        matrix_range_type operator () (const range &r1, const range &r2) {            return matrix_range_type (operator () (), r1, r2);        }        BOOST_UBLAS_INLINE        const_matrix_slice_type operator () (const slice &s1, const slice &s2) const {            return const_matrix_slice_type (operator () (), s1, s2);        }        BOOST_UBLAS_INLINE        matrix_slice_type operator () (const slice &s1, const slice &s2) {            return matrix_slice_type (operator () (), s1, s2);        }        template<class A>        BOOST_UBLAS_INLINE        const_matrix_indirect_type operator () (const indirect_array<A> &ia1, const indirect_array<A> &ia2) const {            return const_matrix_indirect_type (operator () (), ia1, ia2);        }        template<class A>        BOOST_UBLAS_INLINE        matrix_indirect_type operator () (const indirect_array<A> &ia1, const indirect_array<A> &ia2) {            return matrix_indirect_type (operator () (), ia1, ia2);        }#else        BOOST_UBLAS_INLINE        const_matrix_range_type project (const range &r1, const range &r2) const {            return const_matrix_range_type (operator () (), r1, r2);        }        BOOST_UBLAS_INLINE        matrix_range_type project (const range &r1, const range &r2) {            return matrix_range_type (operator () (), r1, r2);        }        BOOST_UBLAS_INLINE        const_matrix_slice_type project (const slice &s1, const slice &s2) const {            return const_matrix_slice_type (operator () (), s1, s2);        }        BOOST_UBLAS_INLINE        matrix_slice_type project (const slice &s1, const slice &s2) {            return matrix_slice_type (operator () (), s1, s2);        }        template<class A>        BOOST_UBLAS_INLINE        const_matrix_indirect_type project (const indirect_array<A> &ia1, const indirect_array<A> &ia2) const {            return const_matrix_indirect_type (operator () (), ia1, ia2);        }        template<class A>        BOOST_UBLAS_INLINE        matrix_indirect_type project (const indirect_array<A> &ia1, const indirect_array<A> &ia2) {            return matrix_indirect_type (operator () (), ia1, ia2);        }#endif    };#ifdef BOOST_UBLAS_NO_NESTED_CLASS_RELATION    struct iterator1_tag {};    struct iterator2_tag {};    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_iterator_type begin (const I &it, iterator1_tag) {        return it ().find2 (1, it.index1 (), 0);    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_iterator_type end (const I &it, iterator1_tag) {        return it ().find2 (1, it.index1 (), it ().size2 ());    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_reverse_iterator_type rbegin (const I &it, iterator1_tag) {        return typename I::dual_reverse_iterator_type (end (it, iterator1_tag ()));    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_reverse_iterator_type rend (const I &it, iterator1_tag) {        return typename I::dual_reverse_iterator_type (begin (it, iterator1_tag ()));    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_iterator_type begin (const I &it, iterator2_tag) {        return it ().find1 (1, 0, it.index2 ());    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_iterator_type end (const I &it, iterator2_tag) {        return it ().find1 (1, it ().size1 (), it.index2 ());    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_reverse_iterator_type rbegin (const I &it, iterator2_tag) {        return typename I::dual_reverse_iterator_type (end (it, iterator2_tag ()));    }    template<class I>    BOOST_UBLAS_INLINE    typename I::dual_reverse_iterator_type rend (const I &it, iterator2_tag) {        return typename I::dual_reverse_iterator_type (begin (it, iterator2_tag ()));    }#endif    template<class E>    class matrix_reference:        public matrix_expression<matrix_reference<E> > {    public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING matrix_expression<matrix_reference<E> >::operator ();#endif        typedef typename E::size_type size_type;        typedef typename E::difference_type difference_type;        typedef typename E::value_type value_type;#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS        typedef typename E::const_reference const_reference;        typedef typename E::reference reference;#else        typedef typename E::const_reference const_reference;        typedef typename boost::mpl::if_<boost::is_const<E>,                                          typename E::const_reference,                                          typename E::reference>::type reference;#endif    private:        typedef matrix_reference<E> self_type;    public:        typedef E refered_type;        typedef const self_type const_closure_type;        typedef const_closure_type closure_type;        typedef typename E::orientation_category orientation_category;        typedef typename E::storage_category storage_category;        typedef typename E::simd_category simd_category;        // Construction and destruction        BOOST_UBLAS_INLINE        matrix_reference ():              e_ (nil_) {}        BOOST_UBLAS_INLINE        explicit matrix_reference (refered_type &e):              e_ (e) {}        // Accessors        BOOST_UBLAS_INLINE        size_type size1 () const {            return e_.size1 ();        }        BOOST_UBLAS_INLINE        size_type size2 () const {            return e_.size2 ();        }#ifndef BOOST_UBLAS_NESTED_CLASS_DR45    private:#endif        // Expression accessors - const correct        BOOST_UBLAS_INLINE        const refered_type &expression () const {            return e_;        }        BOOST_UBLAS_INLINE        refered_type &expression () {            return e_;        }    public:        // Element access#ifndef BOOST_UBLAS_REFERENCE_CONST_MEMBER        BOOST_UBLAS_INLINE        const_reference operator () (size_type i, size_type j) const {            return expression () (i, j);        }        BOOST_UBLAS_INLINE        reference operator () (size_type i, size_type j) {            return expression () (i, j);        }#else        BOOST_UBLAS_INLINE        reference operator () (size_type i, size_type j) const {            return expression () (i, j);        }#endif        // Assignment        BOOST_UBLAS_INLINE        matrix_reference &operator = (const matrix_reference &m) {            expression ().operator = (m);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &operator = (const matrix_expression<AE> &ae) {            expression ().operator = (ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &assign (const matrix_expression<AE> &ae) {            expression ().assign (ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &operator += (const matrix_expression<AE> &ae) {            expression ().operator += (ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &plus_assign (const matrix_expression<AE> &ae) {            expression ().plus_assign (ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &operator -= (const matrix_expression<AE> &ae) {            expression ().operator -= (ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        matrix_reference &minus_assign (const matrix_expression<AE> &ae) {            expression ().minus_assign (ae);            return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        matrix_reference &operator *= (const AT &at) {            expression ().operator *= (at);            return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        matrix_reference &operator /= (const AT &at) {            expression ().operator /= (at);            return *this;        }         // Swapping        BOOST_UBLAS_INLINE        void swap (matrix_reference &m) {            expression ().swap (m.expression ());        }        // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const matrix_reference &mr) const {            return &(*this).e_ == &mr.e_;        }        // Iterator types#ifndef BOOST_UBLAS_CT_REFERENCE_BASE_TYPEDEFS        typedef typename E::const_iterator1 const_iterator1;        typedef typename E::iterator1 iterator1;        typedef typename E::const_iterator2 const_iterator2;        typedef typename E::iterator2 iterator2;#else        typedef typename E::const_iterator1 const_iterator1;        typedef typename boost::mpl::if_<boost::is_const<E>,                                          typename E::const_iterator1,

⌨️ 快捷键说明

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