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

📄 matrix_assign.hpp

📁 boost库提供标准的C++ API 配合dev c++使用,功能更加强大
💻 HPP
📖 第 1 页 / 共 5 页
字号:
#endif
#endif
        typename M::iterator2 it2 (m.begin2 ());
        typename M::iterator2 it2_end (m.end2 ());
        typename E::const_iterator2 it2e (e ().begin2 ());
        typename E::const_iterator2 it2e_end (e ().end2 ());
        while (it2 != it2_end && it2e != it2e_end) {
            int compare = it2.index2 () - it2e.index2 ();
            if (compare == 0) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
                typename M::iterator1 it1 (it2.begin ());
                typename M::iterator1 it1_end (it2.end ());
                typename E::const_iterator1 it1e (it2e.begin ());
                typename E::const_iterator1 it1e_end (it2e.end ());
#else
                typename M::iterator1 it1 (begin (it2, iterator2_tag ()));
                typename M::iterator1 it1_end (end (it2, iterator2_tag ()));
                typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ()));
                typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ()));
#endif
                while (it1 != it1_end && it1e != it1e_end) {
                    int compare = it1.index1 () - it1e.index1 ();
                    if (compare == 0) {
                        functor1_type () (*it1, *it1e);
                        ++ it1, ++ it1e;
                    } else if (compare < 0) {
                        functor1_type () (*it1, value_type ());
                        ++ it1;
                    } else if (compare > 0) {
#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
                        // Sparse proxies don't need to be conformant.
                        // Thanks to Michael Stevens for suggesting this.
                        size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
                        if (functor2_type::other (index1, index2)) {
                            // FIX: reduce fill in.
                            // functor1_type () (m (index1, index2), e () (index1, index2));
                            value_type t (*it1e);
                            if (t != value_type ()) {
                                functor1_type () (m (index1, index2), t);
                                restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
                                // The proxies could reference the same container.
                                restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
                            } else {
                                ++ it1e;
                            }
                        } else {
                            ++ it1e;
                        }
#else
                        ++ it1e;
#endif
                    }
                }
#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
                while (it1e != it1e_end) {
                    // Sparse proxies don't need to be conformant.
                    // Thanks to Michael Stevens for suggesting this.
                    size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
                    if (functor2_type::other (index1, index2)) {
                        // FIX: reduce fill in.
                        // functor1_type () (m (index1, index2), e () (index1, index2));
                        value_type t (*it1e);
                        if (t != value_type ()) {
                            functor1_type () (m (index1, index2), t);
                            // The proxies could reference the same container.
                            restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
                            restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
                        } else {
                            ++ it1e;
                        }
                    } else {
                        ++ it1e;
                    }
                }
#endif
                if (boost::is_same<BOOST_UBLAS_TYPENAME functor1_type::assign_category, assign_tag>::value) {
                    while (it1 != it1_end) {
                        functor1_type () (*it1, value_type ());
                        ++ it1;
                    }
                } else {
                    it1 = it1_end;
                }
                ++ it2, ++ it2e;
            } else if (compare < 0) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
                typename M::iterator1 it1 (it2.begin ());
                typename M::iterator1 it1_end (it2.end ());
#else
                typename M::iterator1 it1 (begin (it2, iterator2_tag ()));
                typename M::iterator1 it1_end (end (it2, iterator2_tag ()));
#endif
                if (boost::is_same<BOOST_UBLAS_TYPENAME functor1_type::assign_category, assign_tag>::value) {
                    while (it1 != it1_end) {
                        functor1_type () (*it1, value_type ());
                        ++ it1;
                    }
                } else {
                    it1 = it1_end;
                }
                ++ it2;
            } else if (compare > 0) {
#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
                typename M::iterator1 it1;
                typename M::iterator1 it1_end;
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
                typename E::const_iterator1 it1e (it2e.begin ());
                typename E::const_iterator1 it1e_end (it2e.end ());
#else
                typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ()));
                typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ()));
#endif
                while (it1e != it1e_end) {
                    // Sparse proxies don't need to be conformant.
                    // Thanks to Michael Stevens for suggesting this.
                    size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
                    if (functor2_type::other (index1, index2)) {
                        // FIX: reduce fill in.
                        // functor1_type () (m (index1, index2), e () (index1, index2));
                        value_type t (*it1e);
                        if (t != value_type ()) {
                            functor1_type () (m (index1, index2), t);
                            // The proxies could reference the same container.
                            restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
                            restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
                        } else {
                            ++ it1e;
                        }
                    } else {
                        ++ it1e;
                    }
                }
#endif
                ++ it2e;
            }
        }
#ifdef BOOST_UBLAS_NON_CONFORMANT_PROXIES
        while (it2e != it2e_end) {
            typename M::iterator1 it1;
            typename M::iterator1 it1_end;
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
            typename E::const_iterator1 it1e (it2e.begin ());
            typename E::const_iterator1 it1e_end (it2e.end ());
#else
            typename E::const_iterator1 it1e (begin (it2e, iterator2_tag ()));
            typename E::const_iterator1 it1e_end (end (it2e, iterator2_tag ()));
#endif
            while (it1e != it1e_end) {
                // Sparse proxies don't need to be conformant.
                // Thanks to Michael Stevens for suggesting this.
                size_type index1 (it1e.index1 ()), index2 (it1e.index2 ());
                if (functor2_type::other (index1, index2)) {
                    // FIX: reduce fill in.
                    // functor1_type () (m (index1, index2), e () (index1, index2));
                    value_type t (*it1e);
                    if (t != value_type ()) {
                        functor1_type () (m (index1, index2), t);
                        // The proxies could reference the same container.
                        restart (e, index1, index2, it2e, it2e_end, it1e, it1e_end, column_major_tag ());
                        restart (m, index1, index2, it2, it2_end, it1, it1_end, column_major_tag ());
                    } else {
                        ++ it1e;
                    }
                } else {
                    ++ it1e;
                }
            }
            ++ it2e;
        }
#endif
        if (boost::is_same<BOOST_UBLAS_TYPENAME functor1_type::assign_category, assign_tag>::value) {
            while (it2 != it2_end) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
                typename M::iterator1 it1 (it2.begin ());
                typename M::iterator1 it1_end (it2.end ());
#else
                typename M::iterator1 it1 (begin (it2, iterator2_tag ()));
                typename M::iterator1 it1_end (end (it2, iterator2_tag ()));
#endif
                while (it1 != it1_end) {
                    functor1_type () (*it1, value_type ());
                    ++ it1;
                }
                ++ it2;
            }
        } else {
            it2 = it2_end;
        }
#ifdef BOOST_UBLAS_TYPE_CHECK
        if (! disable_type_check)
            BOOST_UBLAS_CHECK (equals (m, cm), external_logic ());
#endif
    }

    // Dispatcher
    template<class F, class M, class E>
    BOOST_UBLAS_INLINE
    void matrix_assign (F, M &m, const matrix_expression<E> &e) {
        typedef F functor_type;
        typedef typename matrix_assign_traits<BOOST_UBLAS_TYPENAME M::storage_category,
                                              BOOST_UBLAS_TYPENAME F::assign_category,
                                              BOOST_UBLAS_TYPENAME E::const_iterator1::iterator_category,
                                              BOOST_UBLAS_TYPENAME E::const_iterator2::iterator_category>::storage_category storage_category;
        // FIXME: can't we improve the dispatch here?
        // typedef typename M::orientation_category orientation_category;
        typedef typename boost::mpl::if_c<boost::is_same<BOOST_UBLAS_TYPENAME E::orientation_category, unknown_orientation_tag>::value,
                                          BOOST_UBLAS_TYPENAME M::orientation_category ,
                                          BOOST_UBLAS_TYPENAME E::orientation_category >::type orientation_category;
        matrix_assign (functor_type (), m, e, full (), storage_category (), orientation_category ());
    }
    template<class F1, class M, class E, class F2>
    BOOST_UBLAS_INLINE
    void matrix_assign (F1, M &m, const matrix_expression<E> &e, F2) {
        typedef F1 functor1_type;
        typedef F2 functor2_type;
        typedef typename matrix_assign_traits<BOOST_UBLAS_TYPENAME M::storage_category,
                                              BOOST_UBLAS_TYPENAME F1::assign_category,
                                              BOOST_UBLAS_TYPENAME E::const_iterator1::iterator_category,
                                              BOOST_UBLAS_TYPENAME E::const_iterator2::iterator_category>::storage_category storage_category;
        // FIXME: can't we improve the dispatch here?
        // typedef typename M::orientation_category orientation_category;
        typedef typename boost::mpl::if_c<boost::is_same<BOOST_UBLAS_TYPENAME E::orientation_category, unknown_orientation_tag>::value,
                                          BOOST_UBLAS_TYPENAME M::orientation_category ,
                                          BOOST_UBLAS_TYPENAME E::orientation_category >::type orientation_category;
        matrix_assign (functor1_type (), m, e, functor2_type (), storage_category (), orientation_category ());
    }

    template<class LS, class RI1, class RI2>
    struct matrix_swap_traits {
        typedef LS storage_category;
    };

    template<>
    struct matrix_swap_traits<dense_proxy_tag, sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag> {
        typedef sparse_proxy_tag storage_category;
    };

    template<>
    struct matrix_swap_traits<packed_proxy_tag, sparse_bidirectional_iterator_tag, sparse_bidirectional_iterator_tag> {
        typedef sparse_proxy_tag storage_category;
    };

    // Dense (proxy) row major case
    template<class F, class M, class E>
    // This function seems to be big. So we do not let the compiler inline it.
    // BOOST_UBLAS_INLINE
    void matrix_swap (F, M &m, matrix_expression<E> &e, full, dense_proxy_tag, row_major_tag) {
        typedef F functor_type;
        typedef typename M::size_type size_type;
        typedef typename M::difference_type difference_type;
        typename M::iterator1 it1 (m.begin1 ());
        typename E::iterator1 it1e (e ().begin1 ());
        difference_type size1 (BOOST_UBLAS_SAME (m.size1 (), size_type (e ().end1 () - it1e)));
        while (-- size1 >= 0) {
#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION
            typename M::iterator2 it2 (it1.begin ());
            typename E::iterator2 it2e (it1e.begin ());
            difference_type size2 (BOOST_UBLAS_SAME (m.size2 (), size_type (it1e.end () - it2e)));
#else
            typename M::iterator2 it2 (begin (it1, iterator1_tag ()));
            typename E::iterator2 it2e (begin (it1e, iterator1_tag ()));
            difference_type size2 (BOOST_UBLAS_SAME (m.size2 (), size_type (end (it1e, iterator1_tag ()) - it2e)));
#endif
            while (-- size2 >= 0)
                functor_type () (*it2, *it2e), ++ it2, ++ it2e;
            ++ it1, ++ it1e;
        }
    }
    // Dense (proxy) column 

⌨️ 快捷键说明

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