text:
#ifndef BOOST_PP_IS_ITERATING
    ///////////////////////////////////////////////////////////////////////////////
    /// \file make_expr.hpp
    /// Given a Fusion sequence of arguments and the type of a proto Expression,
    /// unpacks the sequence into the Expression.
    //
    //  Copyright 2007 Eric Niebler. Distributed under the Boost
    //  Software License, Version 1.0. (See accompanying file
    //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

    #ifndef BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005
    #define BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005

    #include <boost/xpressive/proto/detail/prefix.hpp>
    #include <boost/version.hpp>
    #include <boost/preprocessor/cat.hpp>
    #include <boost/preprocessor/control/if.hpp>
    #include <boost/preprocessor/control/expr_if.hpp>
    #include <boost/preprocessor/arithmetic/inc.hpp>
    #include <boost/preprocessor/arithmetic/dec.hpp>
    #include <boost/preprocessor/arithmetic/sub.hpp>
    #include <boost/preprocessor/punctuation/comma_if.hpp>
    #include <boost/preprocessor/iterate.hpp>
    #include <boost/preprocessor/facilities/intercept.hpp>
    #include <boost/preprocessor/comparison/greater.hpp>
    #include <boost/preprocessor/tuple/elem.hpp>
    #include <boost/preprocessor/tuple/to_list.hpp>
    #include <boost/preprocessor/logical/and.hpp>
    #include <boost/preprocessor/repetition/enum.hpp>
    #include <boost/preprocessor/repetition/enum_trailing.hpp>
    #include <boost/preprocessor/repetition/enum_params.hpp>
    #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
    #include <boost/preprocessor/repetition/enum_binary_params.hpp>
    #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
    #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
    #include <boost/preprocessor/repetition/repeat.hpp>
    #include <boost/preprocessor/repetition/repeat_from_to.hpp>
    #include <boost/preprocessor/seq/size.hpp>
    #include <boost/preprocessor/seq/enum.hpp>
    #include <boost/preprocessor/seq/seq.hpp>
    #include <boost/preprocessor/seq/to_tuple.hpp>
    #include <boost/preprocessor/seq/for_each_i.hpp>
    #include <boost/preprocessor/seq/pop_back.hpp>
    #include <boost/preprocessor/seq/push_back.hpp>
    #include <boost/preprocessor/seq/push_front.hpp>
    #include <boost/preprocessor/list/for_each_i.hpp>
    #include <boost/ref.hpp>
    #include <boost/mpl/apply_wrap.hpp>
    #include <boost/utility/enable_if.hpp>
    #include <boost/type_traits/is_same.hpp>
    #include <boost/type_traits/add_reference.hpp>
    #include <boost/type_traits/remove_reference.hpp>
    #include <boost/xpressive/proto/proto_fwd.hpp>
    #include <boost/xpressive/proto/traits.hpp>
    #include <boost/xpressive/proto/domain.hpp>
    #include <boost/xpressive/proto/generate.hpp>
    #if BOOST_VERSION >= 103500
    # include <boost/fusion/include/at.hpp>
    # include <boost/fusion/include/value_at.hpp>
    # include <boost/fusion/include/size.hpp>
    namespace boost { namespace proto { namespace detail
    {
        namespace fusion_ = fusion;
    }}}
    #else
    # include <boost/spirit/fusion/sequence/at.hpp>
    # include <boost/spirit/fusion/sequence/value_at.hpp>
    # include <boost/spirit/fusion/sequence/size.hpp>
    namespace boost { namespace proto { namespace detail { namespace fusion_
    {
        namespace result_of = fusion::meta;
        template<int N, typename Seq>
        typename result_of::at_c<Seq, N>::type at_c(Seq &seq) { return fusion::at<N>(seq); }
        template<int N, typename Seq>
        typename result_of::at_c<Seq const, N>::type at_c(Seq const &seq) { return fusion::at<N>(seq); }
    }}}}
    #endif
    #include <boost/xpressive/proto/detail/suffix.hpp>

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_AS_ARG_TYPE(Z, N, DATA)                                                     \
        typename boost::proto::result_of::as_arg<                                                   \
            BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, DATA), N)                                        \
          , BOOST_PP_TUPLE_ELEM(2, 1, DATA)                                                         \
        >::type                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_AS_ARG(Z, N, DATA)                                                          \
        boost::proto::as_arg<BOOST_PP_TUPLE_ELEM(2, 1, DATA) >(                                     \
            BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2, 0, DATA), N)                                        \
        )                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    # define BOOST_PROTO_AT_TYPE(Z, N, DATA)                                                        \
        typename remove_reference<                                                                  \
            typename detail::fusion_::result_of::value_at_c<BOOST_PP_TUPLE_ELEM(2, 0, DATA), N >::type       \
        >::type                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    # define BOOST_PROTO_AT(Z, N, DATA)                                                             \
        detail::fusion_::at_c<N >(BOOST_PP_TUPLE_ELEM(2, 0, DATA))                                           \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_AS_ARG_AT_TYPE(Z, N, DATA)                                                  \
        typename boost::proto::result_of::as_arg<                                                   \
            BOOST_PROTO_AT_TYPE(Z, N, DATA)                                                         \
          , BOOST_PP_TUPLE_ELEM(2, 1, DATA)                                                         \
        >::type                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_AS_ARG_AT(Z, N, DATA)                                                       \
        boost::proto::as_arg<BOOST_PP_TUPLE_ELEM(2, 1, DATA) >(                                     \
            BOOST_PROTO_AT(Z, N, DATA)                                                              \
        )                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TEMPLATE_AUX_(R, DATA, I, ELEM)                                      \
        (ELEM BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I)))                              \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TEMPLATE_YES_(R, DATA, I, ELEM)                                      \
        BOOST_PP_LIST_FOR_EACH_I_R(                                                                 \
            R                                                                                \
          , BOOST_PROTO_VARARG_TEMPLATE_AUX_                                                        \
          , I                                                                                \
          , BOOST_PP_TUPLE_TO_LIST(                                                                 \
                BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM))                                               \
              , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM))                                      \
            )                                                                                \
        )                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TEMPLATE_NO_(R, DATA, I, ELEM)                                       \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TEMPLATE_(R, DATA, I, ELEM)                                          \
        BOOST_PP_IF(                                                                                \
            BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM))                                                   \
          , BOOST_PROTO_VARARG_TEMPLATE_YES_                                                        \
          , BOOST_PROTO_VARARG_TEMPLATE_NO_                                                         \
        )(R, DATA, I, ELEM)                                                                         \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TYPE_AUX_(R, DATA, I, ELEM)                                          \
        (BOOST_PP_CAT(BOOST_PP_CAT(X, DATA), BOOST_PP_CAT(_, I)))                                   \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_TEMPLATE_PARAMS_YES_(R, DATA, I, ELEM)                                      \
        <                                                                                \
            BOOST_PP_SEQ_ENUM(                                                                      \
                BOOST_PP_LIST_FOR_EACH_I_R(                                                         \
                    R                                                                               \
                  , BOOST_PROTO_VARARG_TYPE_AUX_                                                    \
                  , I                                                                               \
                  , BOOST_PP_TUPLE_TO_LIST(                                                         \
                        BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM))                                       \
                      , BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_TAIL(ELEM))                              \
                    )                                                                               \
                )                                                                                \
            )                                                                                \
        >                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_TEMPLATE_PARAMS_NO_(R, DATA, I, ELEM)                                       \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_TYPE_(R, DATA, I, ELEM)                                              \
        BOOST_PP_COMMA_IF(I)                                                                        \
        BOOST_PP_SEQ_HEAD(ELEM)                                                                     \
        BOOST_PP_IF(                                                                                \
            BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM))                                                   \
          , BOOST_PROTO_TEMPLATE_PARAMS_YES_                                                        \
          , BOOST_PROTO_TEMPLATE_PARAMS_NO_                                                         \
        )(R, DATA, I, ELEM) BOOST_PP_EXPR_IF(BOOST_PP_GREATER(I, 1), const)                         \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_AS_EXPR_(R, DATA, I, ELEM)                                           \
        BOOST_PP_EXPR_IF(                                                                           \
            BOOST_PP_GREATER(I, 1)                                                                  \
          , ((                                                                                \
                BOOST_PP_SEQ_HEAD(ELEM)                                                             \
                BOOST_PP_IF(                                                                        \
                    BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(ELEM))                                           \
                  , BOOST_PROTO_TEMPLATE_PARAMS_YES_                                                \
                  , BOOST_PROTO_TEMPLATE_PARAMS_NO_                                                 \
                )(R, DATA, I, ELEM)()                                                               \
            ))                                                                                \
        )                                                                                \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_AS_ARG_(Z, N, DATA)                                                  \
        (BOOST_PP_CAT(DATA, N))                                                                     \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_SEQ_PUSH_FRONT(SEQ, ELEM)                                                   \
        BOOST_PP_SEQ_POP_BACK(BOOST_PP_SEQ_PUSH_FRONT(BOOST_PP_SEQ_PUSH_BACK(SEQ, _dummy_), ELEM))  \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_AS_PARAM_(Z, N, DATA)                                                \
        (BOOST_PP_CAT(DATA, N))                                                                     \
        /**/

    /// INTERNAL ONLY
    ///
    #define BOOST_PROTO_VARARG_FUN_(Z, N, DATA)                                                     \
        template<                                                                                \
            BOOST_PP_SEQ_ENUM(                                                                      \
                BOOST_PP_SEQ_FOR_EACH_I(                                                            \
                    BOOST_PROTO_VARARG_TEMPLATE_, ~                                                 \
                  , BOOST_PP_SEQ_PUSH_FRONT(                                                        \
                        BOOST_PROTO_SEQ_PUSH_FRONT(                                                 \
                            BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                         \
                          , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                       \
                        )                                                                           \
                      , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                             \
                    )                                                                               \
                )                                                                                \
                BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_PARAM_, typename A)                  \
            )                                                                                \
        >                                                                                \
        typename boost::proto::result_of::make_expr<                                                \
            BOOST_PP_SEQ_FOR_EACH_I(                                                                \
                BOOST_PROTO_VARARG_TYPE_, ~                                                         \
              , BOOST_PP_SEQ_PUSH_FRONT(                                                            \
                    BOOST_PROTO_SEQ_PUSH_FRONT(                                                     \
                        BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                             \
                      , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                           \
                    )                                                                               \
                  , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                                 \
                )                                                                                \
            )                                                                                \
            BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)                                               \
        >::type const                                                                               \
        BOOST_PP_TUPLE_ELEM(4, 0, DATA)(BOOST_PP_ENUM_BINARY_PARAMS_Z(Z, N, const A, &a))           \
        {                                                                                \
            return boost::proto::result_of::make_expr<                                              \
                BOOST_PP_SEQ_FOR_EACH_I(                                                            \
                    BOOST_PROTO_VARARG_TYPE_, ~                                                     \
                  , BOOST_PP_SEQ_PUSH_FRONT(                                                        \
                        BOOST_PROTO_SEQ_PUSH_FRONT(                                                 \
                            BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                         \
                          , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                       \
                        )                                                                           \
                      , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                             \
                    )                                                                               \
                )                                                                                \
                BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)                                           \
            >::call(                                                                                \
                BOOST_PP_SEQ_ENUM(                                                                  \
                    BOOST_PP_SEQ_FOR_EACH_I(                                                        \
                        BOOST_PROTO_VARARG_AS_EXPR_, ~                                              \
                      , BOOST_PP_SEQ_PUSH_FRONT(                                                    \
                            BOOST_PROTO_SEQ_PUSH_FRONT(                                             \
                                BOOST_PP_TUPLE_ELEM(4, 2, DATA)                                     \
                              , (BOOST_PP_TUPLE_ELEM(4, 3, DATA))                                   \
                            )                                                                       \
                          , BOOST_PP_TUPLE_ELEM(4, 1, DATA)                                         \
                        )                                                                           \
                    )                                                                               \
                    BOOST_PP_REPEAT_ ## Z(N, BOOST_PROTO_VARARG_AS_ARG_, a)                         \
                )                                                                                \
            );                                                                                \
        }                                                                                \
        /**/

    /// \code
    /// BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(
    ///     1
    ///   , construct
    ///   , boost::proto::default_domain
    ///   , (boost::proto::tag::function)
    ///   , ((op::construct)(typename)(int))
    /// )
    /// \endcode
    #define BOOST_PROTO_DEFINE_FUNCTION_TEMPLATE(ARGCOUNT, NAME, DOMAIN, TAG, BOUNDARGS)            \
        BOOST_PP_REPEAT_FROM_TO(                                                                    \
            ARGCOUNT                                                                                \
          , BOOST_PP_INC(ARGCOUNT)                                                                  \
          , BOOST_PROTO_VARARG_FUN_                                                                 \
          , (NAME, TAG, BOUNDARGS, DOMAIN)                                                          \
        )\
        /**/

    /// \code
    /// BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(
    ///     construct
    ///   , boost::proto::default_domain
    ///   , (boost::proto::tag::function)
    ///   , ((op::construct)(typename)(int))
    /// )
    /// \endcode
    #define BOOST_PROTO_DEFINE_VARARG_FUNCTION_TEMPLATE(NAME, DOMAIN, TAG, BOUNDARGS)               \
        BOOST_PP_REPEAT(                                                                            \
            BOOST_PP_SUB(BOOST_PP_INC(BOOST_PROTO_MAX_ARITY), BOOST_PP_SEQ_SIZE(BOUNDARGS))         \
          , BOOST_PROTO_VARARG_FUN_                                                                 \
          , (NAME, TAG, BOUNDARGS, DOMAIN)                                                          \
        )                                                                                \
        /**/

    namespace boost { namespace fusion
    {
        template<typename Function>
        class unfused_generic;
    }}

    namespace boost { namespace proto
    {
        namespace detail
        {
            template<
                typename Domain
                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
                    BOOST_PROTO_MAX_ARITY
                  , typename A
                  , = default_domain BOOST_PP_INTERCEPT
                )
            >
            struct deduce_domain_
            {
                typedef Domain type;
            };

            template<BOOST_PP_ENUM_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)>
            struct deduce_domain_<
                default_domain
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
            >
              : deduce_domain_<
                    typename domain_of<A0>::type
                  , BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PROTO_MAX_ARITY, A)
                >
            {};

            template<>
            struct deduce_domain_<default_domain>
            {
                typedef default_domain type;
            };

            template<typename Tag, typename Domain, typename Sequence, std::size_t Size>
            struct unpack_expr_
            {};

            template<typename Domain, typename Sequence>
            struct unpack_expr_<tag::terminal, Domain, Sequence, 1u>
            {
                typedef expr<
                    tag::terminal
                  , args0<typename fusion_::result_of::value_at_c<Sequence, 0>::type>
                > expr_type;

                typedef typename Domain::template apply<expr_type>::type type;

                static type const call(Sequence const &sequence)
                {
                    expr_type that = {fusion_::at_c<0>(sequence)};
                    return Domain::make(that);
                }
            };

            template<typename Sequence>
            struct unpack_expr_<tag::terminal, deduce_domain, Sequence, 1u>
              : unpack_expr_<tag::terminal, default_domain, Sequence, 1u>
            {};

            template<
                typename Tag
              , typename Domain
                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
                    BOOST_PROTO_MAX_ARITY
                  , typename A
                  , = void BOOST_PP_INTERCEPT
                )
              , typename _ = void
            >
            struct make_expr_
            {};

            template<typename Domain, typename A>
            struct make_expr_<tag::terminal, Domain, A
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, void BOOST_PP_INTERCEPT)>
            {
                typedef typename add_reference<A>::type reference;
                typedef expr<tag::terminal, args0<reference> > expr_type;
                typedef typename Domain::template apply<expr_type>::type type;

                static type const call(reference a)
                {
                    expr_type that = {a};
                    return Domain::make(that);
                }
            };

        #define BOOST_PP_ITERATION_PARAMS_1                                                         \
            (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 1))               \
            /**/

        #include BOOST_PP_ITERATE()
        }

        namespace result_of
        {
            template<typename Tag, typename Sequence, typename, typename>
            struct unpack_expr
              : detail::unpack_expr_<
                    Tag
                  , deduce_domain
                  , Sequence
                  , detail::fusion_::result_of::size<Sequence>::type::value
                >
            {};

            template<typename Tag, typename Domain, typename Sequence>
            struct unpack_expr<Tag, Domain, Sequence, typename Domain::proto_is_domain_>
              : detail::unpack_expr_<
                    Tag
                  , Domain
                  , Sequence
                  , detail::fusion_::result_of::size<Sequence>::type::value
                >
            {};

            template<
                typename Tag
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)
              , typename
              , typename
            >
            struct make_expr
              : make_expr<
                    Tag
                  , deduce_domain
                    BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
                >
            {};

            template<
                typename Tag
              , typename Domain
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)
            >
            struct make_expr<
                Tag
              , Domain
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
              , typename Domain::proto_is_domain_
            >
              : detail::make_expr_<
                    Tag
                  , Domain
                    BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
                >
            {};

            template<
                typename Tag
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, typename A)
            >
            struct make_expr<
                Tag
              , deduce_domain
                BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
              , void
            >
              : detail::make_expr_<
                    Tag
                  , typename detail::deduce_domain_<
                        typename domain_of<A0>::type
                      , BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PROTO_MAX_ARITY, A)
                    >::type
                    BOOST_PP_ENUM_TRAILING_PARAMS(BOOST_PROTO_MAX_ARITY, A)
                >
            {};
        }

        namespace functional
        {
            template<typename Tag, typename Domain>
            struct make_expr
            {
                template<typename Sig>
                struct result
                {};

                template<typename A>
                typename result_of::make_expr<Tag, Domain, A>::type const
                operator ()(A &a) const
                {
                    return result_of::make_expr<Tag, Domain, A>::call(a);
                }

        #define BOOST_PP_ITERATION_PARAMS_1                                                         \
            (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 2))               \
            /**/

        #include BOOST_PP_ITERATE()
            };

            template<typename Domain>
            struct make_expr<tag::terminal, Domain>
            {
                template<typename Sig>
                struct result
                {};

                template<typename This, typename A>
                struct result<This(A)>
                  : result_of::make_expr<tag::terminal, Domain, A>
                {};

                template<typename A>
                typename result_of::make_expr<tag::terminal, Domain, A>::type
                operator ()(A &a) const
                {
                    return result_of::make_expr<tag::terminal, Domain, A>::call(a);
                }

                template<typename A>
                typename result_of::make_expr<tag::terminal, Domain, A const>::type
                operator ()(A const &a) const
                {
                    return result_of::make_expr<tag::terminal, Domain, A const>::call(a);
                }
            };

            template<typename Tag, typename Domain>
            struct unpack_expr
            {
                template<typename Sig>
                struct result
                {};

                template<typename This, typename Sequence>
                struct result<This(Sequence)>
                  : result_of::unpack_expr<
                        Tag
                      , Domain
                      , typename detail::remove_cv_ref<Sequence>::type
                    >
                {};

                template<typename Sequence>
                typename result_of::unpack_expr<Tag, Domain, Sequence>::type
                operator ()(Sequence const &sequence) const
                {
                    return result_of::unpack_expr<Tag, Domain, Sequence>::call(sequence);
                }
            };

            template<typename Tag, typename Domain>
            struct unfused_expr_fun
            {
                template<typename Sequence>
                struct result
                  : result_of::unpack_expr<Tag, Domain, Sequence>
                {};

                template<typename Sequence>
                typename proto::result_of::unpack_expr<Tag, Domain, Sequence>::type
                operator ()(Sequence const &sequence) const
                {
                    return result_of::unpack_expr<Tag, Domain, Sequence>::call(sequence);
                }
            };

            template<typename Tag, typename Domain>
            struct unfused_expr
              : fusion::unfused_generic<unfused_expr_fun<Tag, Domain> >
            {};
        }

        /// unpack_expr
        ///
        template<typename Tag, typename Sequence>
        typename lazy_disable_if<
            is_domain<Sequence>
          , result_of::unpack_expr<Tag, Sequence>
        >::type const
        unpack_expr(Sequence const &sequence)
        {
            return result_of::unpack_expr<Tag, Sequence>::call(sequence);
        }

        /// \overload
        ///
        template<typename Tag, typename Domain, typename Sequence2>
        typename result_of::unpack_expr<Tag, Domain, Sequence2>::type const
        unpack_expr(Sequence2 const &sequence2)
        {
            return result_of::unpack_expr<Tag, Domain, Sequence2>::call(sequence2);
        }

        /// make_expr
        ///
        template<typename Tag, typename A0>
        typename lazy_disable_if<
            is_domain<A0>
          , result_of::make_expr<Tag, A0>
        >::type const
        make_expr(A0 &a0 BOOST_PROTO_DISABLE_IF_IS_CONST(A0))
        {
            return result_of::make_expr<Tag, A0>::call(a0);
        }

        /// \overload
        ///
        template<typename Tag, typename Domain, typename B0>
        typename result_of::make_expr<Tag, Domain, B0>::type const
        make_expr(B0 &b0 BOOST_PROTO_DISABLE_IF_IS_CONST(B0))
        {
            return result_of::make_expr<Tag, Domain, B0>::call(b0);
        }

    #define BOOST_PP_ITERATION_PARAMS_1                                                             \
        (4, (1, BOOST_PROTO_MAX_ARITY, <boost/xpressive/proto/make_expr.hpp>, 3))                   \
        /**/

    #include BOOST_PP_ITERATE()
    }}

    #undef BOOST_PROTO_AT
    #undef BOOST_PROTO_AT_TYPE
    #undef BOOST_PROTO_AS_ARG_AT
    #undef BOOST_PROTO_AS_ARG_AT_TYPE

    #endif // BOOST_PROTO_MAKE_EXPR_HPP_EAN_04_01_2005

#elif BOOST_PP_ITERATION_FLAGS() == 1

    #define N BOOST_PP_ITERATION()
    #define M BOOST_PP_SUB(BOOST_PROTO_MAX_ARITY, N)

        template<typename Tag, typename Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
        struct make_expr_<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, A)
            BOOST_PP_ENUM_TRAILING_PARAMS(M, void BOOST_PP_INTERCEPT), void>
        {
            typedef expr<
                Tag
              , BOOST_PP_CAT(args, N)<BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG_TYPE, (A, Domain)) >
            > expr_type;

            typedef typename Domain::template apply<expr_type>::type type;

            static type const call(BOOST_PP_ENUM_BINARY_PARAMS(N, A, &a))
            {
                expr_type that = {
                    BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG, (a, Domain))
                };
                return Domain::make(that);
            }
        };

        template<typename Tag, typename Domain, typename Sequence>
        struct unpack_expr_<Tag, Domain, Sequence, N>
        {
            typedef expr<
                Tag
              , BOOST_PP_CAT(args, N)<
                    BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG_AT_TYPE, (Sequence const, Domain))
                >
            > expr_type;

            typedef typename Domain::template apply<expr_type>::type type;

            static type const call(Sequence const &sequence)
            {
                expr_type that = {
                    BOOST_PP_ENUM(N, BOOST_PROTO_AS_ARG_AT, (sequence, Domain))
                };
                return Domain::make(that);
            }
        };

        template<typename Tag, typename Sequence>
        struct unpack_expr_<Tag, deduce_domain, Sequence, N>
          : unpack_expr_<
                Tag
              , typename detail::deduce_domain_<
                    typename domain_of<
                        BOOST_PROTO_AT_TYPE(~, 0, (Sequence const, ~))
                    >::type
                    BOOST_PP_COMMA_IF(BOOST_PP_DEC(N))
                    BOOST_PP_ENUM_SHIFTED(N, BOOST_PROTO_AT_TYPE, (Sequence const, ~))
                >::type
              , Sequence
              , N
            >
        {};

    #undef N
    #undef M

#elif BOOST_PP_ITERATION_FLAGS() == 2

    #define N BOOST_PP_ITERATION()

        template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
        struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
          : result_of::make_expr<
                Tag
              , Domain
                BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(
                    N
                  , typename remove_reference<A
                  , >::type BOOST_PP_INTERCEPT
                )
            >
        {};

        template<BOOST_PP_ENUM_PARAMS(N, typename A)>
        typename result_of::make_expr<
            Tag
          , Domain
            BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)
        >::type const
        operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a)) const
        {
            return result_of::make_expr<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>
                ::call(BOOST_PP_ENUM_PARAMS(N, a));
        }

    #undef N

#elif BOOST_PP_ITERATION_FLAGS() == 3

    #define N BOOST_PP_ITERATION()

        /// \overload
        ///
        template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
        typename lazy_disable_if<
            is_domain<A0>
          , result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>
        >::type const
        make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const A, &a))
        {
            return result_of::make_expr<Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>
                ::call(BOOST_PP_ENUM_PARAMS(N, a));
        }

        /// \overload
        ///
        template<typename Tag, typename Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, typename B)>
        typename result_of::make_expr<
            Tag
          , Domain
            BOOST_PP_ENUM_TRAILING_PARAMS(N, const B)
        >::type const
        make_expr(BOOST_PP_ENUM_BINARY_PARAMS(N, const B, &b))
        {
            return result_of::make_expr<Tag, Domain BOOST_PP_ENUM_TRAILING_PARAMS(N, const B)>
                ::call(BOOST_PP_ENUM_PARAMS(N, b));
        }

    #undef N

#endif // BOOST_PP_IS_ITERATING

max_stars_repo_name: foxostro/CheeseTesseract

max_issues_repo_name: foxostro/CheeseTesseract

max_forks_repo_name: foxostro/CheeseTesseract


text:
/***************************************************************************
 *   Copyright (C) by GFZ Potsdam                                          *
 *                                                                         *
 *   You can redistribute and/or modify this program under the             *
 *   terms of the SeisComP Public License.                                 *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   SeisComP Public License for more details.                             *
 ***************************************************************************/

#include <seiscomp3/seismology/regions/polygon.h>

#include <iostream>
#include <fstream>
#include <stdlib.h>

#include <boost/regex.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/path.hpp>

#define SEISCOMP_COMPONENT PolyRegion
#include <seiscomp3/logging/log.h>
#include <seiscomp3/core/system.h>

namespace fs = boost::filesystem;

namespace Seiscomp
{
namespace Geo
{

PolyRegions::PolyRegions()
{
}

PolyRegions::PolyRegions(const std::string& location)
{
	read(location);
}

PolyRegions::~PolyRegions() {
	for (size_t i = 0; i < _regions.size(); i++ ) {
		delete _regions[i];
	}
}

size_t PolyRegions::read(const std::string& location) {
	fs::path directory;
	try {
		directory = SC_FS_PATH(location);
	}
	catch ( ... ) {
		SEISCOMP_ERROR("Invalid path '%s'", location.c_str());
		return 0;
	}

	if ( !fs::exists(directory) )
		return regionCount();

	fs::directory_iterator end_itr;
	std::vector<std::string> files;

	try {
		for ( fs::directory_iterator itr(directory); itr != end_itr; ++itr ) {

			if ( fs::is_directory(*itr) )
				continue;

			if ( boost::regex_match(SC_FS_IT_LEAF(itr), boost::regex(".*\\.(?:fep)")) )
				files.push_back(SC_FS_IT_STR(itr));
		}
	}
	catch ( const std::exception &ex ) {
		SEISCOMP_ERROR("Reading regions: %s", ex.what());
		return regionCount();
	}

	std::sort(files.begin(), files.end());

	for ( size_t i = 0; i < files.size(); ++i ) {
		if ( !readFepBoundaries(files[i]) )
			SEISCOMP_ERROR("Error reading file: %s", files[i].c_str());
	}

	info();

	// store directory path the data was read from
	_dataDir = directory.string();

	return regionCount();
}

bool PolyRegions::readFepBoundaries(const std::string& filename) {
	SEISCOMP_DEBUG("reading boundary polygons from file: %s", filename.c_str());

	std::ifstream infile(filename.c_str());

	if ( infile.bad() )
		return false;

	boost::regex vertexLine("^\\s*([-+]?[0-9]*\\.?[0-9]+)\\s+([-+]?[0-9]*\\.?[0-9]+)(?:\\s+([^\\d\\s].*)$|\\s*$)");
	boost::regex LLine("^\\s*L\\s+(.*)$");
	boost::smatch what;

	std::string line;
	bool newPolygon = true;
	GeoFeature *pr = NULL;
	OPT(GeoCoordinate) last;

	while ( std::getline(infile, line) ) {
		if ( newPolygon ){
			pr = new GeoFeature();
			newPolygon = false;
		}

		if ( boost::regex_match(line, what, vertexLine) ) {
			if ( last ) pr->addVertex(*last);
			last = GeoCoordinate(atof(what.str(2).c_str()), atof(what.str(1).c_str())).normalize();
		}
		else if ( boost::regex_match(line, what, LLine) ) {
			if ( last && pr->vertices().size() > 0 ) {
				if ( *last != pr->vertices().back() )
					pr->addVertex(*last);
			}

			if ( pr->vertices().size() < 3 )
				delete pr;
			else {
				pr->setName(what.str(1));
				pr->setClosedPolygon(true);
				pr->updateBoundingBox();
				addRegion(pr);

				if ( pr->area() < 0 ) {
					SEISCOMP_WARNING("Polygon %s is defined counter-clockwise", pr->name().c_str());
					pr->invertOrder();
				}
			}

			last = Core::None;
			newPolygon = true;
		}
		else {
			//std::cout << "Warning: line ignored: " << line << std::endl;
		}

	}

	return true;
}

void PolyRegions::addRegion(GeoFeature *r) {
	_regions.push_back(r);
}

size_t PolyRegions::regionCount() const {
	return _regions.size();
}

GeoFeature *PolyRegions::region(int i) const{
	if( _regions.size() > 0 )
		return _regions[i];
	else
		return NULL;
}

void PolyRegions::print(){

	for ( size_t i = 0; i < _regions.size(); i++ ){
		std::cerr << region(i)->name() << std::endl;
		std::cerr <<  region(i)->vertices().size() << std::endl;

	//for (int j = 0; j < region(i)->vertexCount(); j++)
		//std::cerr << region(i)->vertex(j).lat << "\t" << region(i)->vertex(j).lon << std::endl;

	}

}

void PolyRegions::info(){

	SEISCOMP_DEBUG("Number of PolyRegions loaded: %lu", (unsigned long)_regions.size());

	int sum = 0;
	for ( size_t i = 0; i < _regions.size(); i++ )
		sum += region(i)->vertices().size();

	SEISCOMP_DEBUG("Total number of vertices read in: %d", sum);

}

GeoFeature *PolyRegions::findRegion(double lat, double lon) const {
	for ( size_t i = 0; i < regionCount(); ++i ) {
		if ( region(i)->contains(GeoCoordinate(lat, lon).normalize()) )
			return region(i);
	}

	return NULL;
}

std::string PolyRegions::findRegionName(double lat, double lon) const {
	GeoFeature *region = findRegion(lat, lon);
	if ( region )
		return region->name();

	return "";
}

}
}

ext: cpp

max_stars_repo_licenses: Naumen Condor-1.1 MS-PL

max_issues_repo_licenses: Naumen Condor-1.1 MS-PL

max_forks_repo_licenses: Naumen Condor-1.1 MS-PL


text:
#define BOOST_APPLICATION_FEATURE_NS_SELECT_BOOST

//[intro
#include <iostream>
#include <memory>
#include <boost/application.hpp>
#include <boost/test/unit_test.hpp>

// other unit
#include "myapp.h"

BOOST_AUTO_TEST_CASE(tunit_test)
{
   myapp app;
   application::global_context_ptr ctx = application::global_context::create();

   this_application()->insert<application::args>(
      std::make_shared<application::args>(unit_test::framework::master_test_suite().argc,
                                          unit_test::framework::master_test_suite().argv));

   BOOST_CHECK(application::launch<application::common>(app, ctx) == 0);

   application::global_context::destroy();
}


text:
#include <ros/ros.h>
#include <visualization_msgs/Marker.h>
#include <rosbag/bag.h>
#include <rosbag/view.h>
#include <geometry_msgs/Transform.h>
#include <sensor_msgs/JointState.h>
#include <gazebo_msgs/LinkStates.h>
#include <Eigen/Dense>

#include <boost/foreach.hpp>
#define foreach BOOST_FOREACH

visualization_msgs::Marker reached_points, robot_trail, points;
geometry_msgs::Point point_buffer;
double d;
void update_line(const gazebo_msgs::LinkStates::ConstPtr &pos)
{
    int L = pos->pose.size();

    point_buffer.x = 0.5*(pos->pose.at(L - 1).position.x + pos->pose.at(L - 2).position.x);
    point_buffer.y = 0.5*(pos->pose.at(L - 1).position.y + pos->pose.at(L - 2).position.y);
    point_buffer.z = 0.5*(pos->pose.at(L - 1).position.z + pos->pose.at(L - 2).position.z);

    if (robot_trail.points.size() < 800)
    {
        robot_trail.points.push_back(point_buffer);
    }
    else
    {
        robot_trail.points.erase(robot_trail.points.begin());
        robot_trail.points.push_back(point_buffer);
    }

}

void update_point(int data)
{

	double th = 0.02;
	if (data > 2)
		th = 0.06;
    for (int i = 0; i < robot_trail.points.size(); i++)
    {
        for (int j = 0; j < points.points.size(); j++)
        {
            d = sqrt(pow(robot_trail.points.at(i).x - points.points.at(j).x, 2) +
                     pow(robot_trail.points.at(i).y - points.points.at(j).y, 2) +
                     pow(robot_trail.points.at(i).z - points.points.at(j).z, 2));
            if (d < th)
            {
                reached_points.points.push_back(points.points.at(j));
                points.points.erase(points.points.begin() + j);
                return;
            }
        }
    }
}

Eigen::Matrix4d dh_matrix_standard(double a, double alpha, double d, double theta)
{
    Eigen::Matrix4d A;
    A(3, 3) = 1.0;
    A(3, 2) = 0.0;
    A(3, 1) = 0.0;
    A(3, 0) = 0.0;

    A(0, 0) = cos(theta);
    A(0, 1) = -sin(theta)*cos(alpha);
    A(0, 2) = sin(theta)*sin(alpha);
    A(0, 3) = a * cos(theta);

    A(1, 0) = sin(theta);
    A(1, 1) = cos(theta)*cos(alpha);
    A(1, 2) = -cos(theta)*sin(alpha);
    A(1, 3) = a * sin(theta);

    A(2, 0) = 0.0;
    A(2, 1) = sin(alpha);
    A(2, 2) = cos(alpha);
    A(2, 3) = d;

    return A;
}

Eigen::Matrix4d youbot_forward_kine(double joint[])
{

    double a[5] = {-0.033, 0.155, 0.135, -0.002, 0.0};
    double alpha[5] = {M_PI_2, 0.0, 0.0, M_PI_2, M_PI};
    double d[5] = {0.145, 0.0, 0.0, 0.0, -0.185};
    double theta[5] = {170*M_PI/180 - M_PI, M_PI_2 - 65*M_PI/180, 146*M_PI/180, -M_PI_2-102.5*M_PI/180, M_PI - 167.5*M_PI/180};

    Eigen::Matrix4d A = Eigen::Matrix4d::Identity(4, 4);

    for (int i = 0; i < 5;i++)
    {
        if (i == 0)
            A = A * dh_matrix_standard(a[i], alpha[i], d[i], theta[i] - joint[i]);
        else
            A = A * dh_matrix_standard(a[i], alpha[i], d[i], theta[i] + joint[i]);
    }

    return A;

}

int main( int argc, char** argv )
{
    ros::init(argc, argv, "trail_node");
    ros::NodeHandle n;
    ros::Publisher marker_pub = n.advertise<visualization_msgs::Marker>("/visualization_marker", 10);
    ros::Subscriber traj_sub = n.subscribe<gazebo_msgs::LinkStates>("/gazebo/link_states", 10, update_line);
    ros::Rate r(20);

    int checkpoint_data = 1;

    //Define points message
    points.header.frame_id = robot_trail.header.frame_id = reached_points.header.frame_id = "/base_link";
    points.header.stamp = robot_trail.header.stamp = reached_points.header.stamp = ros::Time::now();
    points.ns = robot_trail.ns = reached_points.ns = "points_and_lines";
    points.action = robot_trail.action = reached_points.action = visualization_msgs::Marker::ADD;
    points.pose.orientation.w = robot_trail.pose.orientation.w = reached_points.pose.orientation.w = 1.0;

    points.id = 0;
    robot_trail.id = 1;
    reached_points.id = 2;

    points.type = visualization_msgs::Marker::POINTS;
    reached_points.type = visualization_msgs::Marker::POINTS;
    robot_trail.type = visualization_msgs::Marker::LINE_STRIP;

    // POINTS markers use x and y scale for width/height respectively
    points.scale.x = 0.01;
    points.scale.y = 0.01;

    // Unreached points are red
    points.color.r = 1.0f;
    points.color.a = 1.0;

    // POINTS markers use x and y scale for width/height respectively
    reached_points.scale.x = 0.01;
    reached_points.scale.y = 0.01;

    // Reached points are red
    reached_points.color.g = 1.0f;
    reached_points.color.a = 1.0;

    //Define the width of robot trail
    robot_trail.scale.x = 0.005;

    // Robot trails are white
    robot_trail.color.r = 1.0f;
    robot_trail.color.g = 1.0f;
    robot_trail.color.b = 1.0f;
    robot_trail.color.a = 1.0;

    rosbag::Bag bag;

    bag.open(MY_BAG_PATH, rosbag::bagmode::Read);

    std::vector<std::string> topics;

    if ((checkpoint_data == 1))
    {
        topics.push_back(std::string("joint_data"));
        rosbag::View view(bag, rosbag::TopicQuery(topics));

                foreach(rosbag::MessageInstance const m, view)
                    {
                        sensor_msgs::JointState::ConstPtr s = m.instantiate<sensor_msgs::JointState>();
                        if (s != NULL)
                        {

                            double joint[5];

                            for (int i = 0; i < 5; i++)
	                    	joint[i] = s->position.at(i);

                            Eigen::Matrix4d current_pose = youbot_forward_kine(joint);

                            geometry_msgs::Point p;
                            p.x = current_pose(0, 3);
                            p.y = current_pose(1, 3);
                            p.z = current_pose(2, 3);
                            points.points.push_back(p);

                        }

                    }

    }
    else
    {
        topics.push_back(std::string("target_position"));
        rosbag::View view(bag, rosbag::TopicQuery(topics));

                foreach(rosbag::MessageInstance const m, view)
                    {
                        geometry_msgs::Transform::ConstPtr s = m.instantiate<geometry_msgs::Transform>();
                        if (s != NULL)
                        {
                            geometry_msgs::Point p;
                            p.x = s->translation.x;
                            p.y = s->translation.y;
                            p.z = s->translation.z;
                            points.points.push_back(p);
                        }

                    }
    }

    bag.close();

    while (ros::ok())
    {
        marker_pub.publish(points);
        marker_pub.publish(robot_trail);
        marker_pub.publish(reached_points);

        update_point(checkpoint_data);

        ros::spinOnce();

        r.sleep();
    }
}

max_stars_repo_licenses: Unlicense MIT

max_issues_repo_licenses: Unlicense MIT

max_forks_repo_licenses: Unlicense MIT


text:
#include <iostream>
#include <boost/filesystem/path.hpp>
using namespace std;
namespace fs = boost::filesystem;
int main(int argc, char** argv)
{

	try
	{
		fs::path my_path("test/test.txt");
		cout << "current path is      " << my_path << endl;
		cout << "parent path is       " << my_path.parent_path() << endl;
	}
	catch(std::exception& e) {
		cerr << endl << "Error during execution: " << e.what() << endl << endl;
		return EXIT_FAILURE;
	}
	return EXIT_SUCCESS;
}


text:
/*
 * 	surgeme_server.hpp
 *
 *	Author(s): Tamas D. Nagy
 *	Created on: 2017-11-06
 *
 *	Separated ROS node to support preempted irob_msgs/Surgeme actions.
 *  Contains the implementation of surgemes, like
 *	grasp, release, cut, nav_to_pos, etc.
 *  Handles instrument info to decide is the surgeme is executable with the
 *  installed instrument, and calculate using the length of jaws.
 *
 */

#ifndef SURGAME_SERVER_HPP_
#define SURGAME_SERVER_HPP_

#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ros/ros.h>
#include <ros/package.h>
#include <std_msgs/String.h>
#include <geometry_msgs/PoseStamped.h>
#include <std_msgs/Float32.h>
#include <Eigen/Dense>
#include <Eigen/Geometry>
#include <irob_utils/tool_pose.hpp>
#include <irob_utils/trajectory.hpp>
#include <irob_utils/abstract_directions.hpp>
#include <irob_utils/utils.hpp>
#include <irob_general_robot/robot_client.hpp>
#include <actionlib/server/simple_action_server.h>
#include <actionlib/client/simple_action_client.h>
#include <actionlib/client/terminal_state.h>
#include <irob_msgs/ToolPoseStamped.h>
#include <sensor_msgs/JointState.h>
#include <cmath>
#include <tf2/LinearMath/Quaternion.h>
#include <tf2_ros/transform_broadcaster.h>
#include <geometry_msgs/TransformStamped.h>

#include <irob_msgs/SurgemeAction.h>

namespace saf {

class SurgemeServer {

public:

  struct SurgemeSetting {
    double jaw_open_angle;
    double jaw_closed_angle;
    Eigen::Vector3d t;	// translation

    friend std::ostream& operator<<(std::ostream&, const SurgemeSetting&);
  };

protected:
  RobotClient arm;
  ros::NodeHandle nh;
  tf2_ros::TransformBroadcaster br_ori;
  tf2_ros::TransformBroadcaster br_new;

  // Action servers
  actionlib::SimpleActionServer<irob_msgs::SurgemeAction> as;

  static const double DEFAULT_LOOP_RATE;					// Hz

public:
  SurgemeServer(ros::NodeHandle, std::string, double);		// dt
  ~SurgemeServer();

  // Callbacks

  void surgemeActionCB(
      const irob_msgs::SurgemeGoalConstPtr &);

  ToolPose getPoseCurrent();

  sensor_msgs::JointState getJointStateCurrent();

  std::string getArmName();

protected:

  // Methods for surgeme execution
  void stop();

  void nav_to_pos(ToolPose ,std::vector<ToolPose>, InterpolationMethod, double);

  void grasp(ToolPose, ToolPose, double, double, std::vector<ToolPose>,
             InterpolationMethod,
             double, double);

  void cut(ToolPose, ToolPose, double, std::vector<ToolPose>,
           InterpolationMethod,
           double, double);

  void push(ToolPose, ToolPose, Eigen::Vector3d, std::vector<ToolPose>,
            InterpolationMethod,
            double, double);

  void dissect(ToolPose, ToolPose, Eigen::Vector3d,double, std::vector<ToolPose>,
               InterpolationMethod,
               double, double);

  void release(ToolPose, double,
               double, double);

  void place(ToolPose, ToolPose, double, std::vector<ToolPose>, InterpolationMethod,
             double);

  void manipulate(Eigen::Vector3d,
                  double);

  void move_cam(Eigen::Vector3d, Eigen::Vector3d,
                  double);

  bool waitForActionDone(std::string);
  void handleActionState(std::string, bool = false);
  bool isAbleToDoSurgeme(int);
  irob_msgs::InstrumentJawPart findInstrumentJawPartForSurgeme(int);
  SurgemeSetting calcSurgemeSetting(int, irob_msgs::InstrumentJawPart,
                                    Eigen::Quaternion<double>, double, double = 1.0);

};

}
#endif /* SURGAME_SERVER_HPP_ */

ext: hpp

max_stars_repo_name: ABC-iRobotics/irob-saf

max_issues_repo_name: ABC-iRobotics/irob-saf

max_forks_repo_name: ABC-iRobotics/irob-saf


text:
#include <iostream>
#include <Eigen/Dense>
#include <chrono>
#include "DriverParser.h"
#include "Object3D.h"
#include "CameraSpecifications.h"
#include "CameraPictureTaker.h"

using Eigen::MatrixXd;
int main(int argc, char* argv[]) {
    std::chrono::steady_clock::time_point begin = std::chrono::steady_clock::now();

    if (argc != 3) {
        std::cout << "invalid command line usage" << std::endl;
        return 1;
    }

    std::string fileName = argv[1];
    std::string outPutFileName = argv[2];
    DriverParser parser(fileName);
    parser.parse();

    CameraSpecification *specs = parser.getCameraSpecs();

    std::vector<Object3D> models;

    for (int i = 0; i < parser.getTransformations()->size(); ++i) {
        Object3D object3D(parser.getTransformations()->at(i).getFileName());
        object3D.performTransformation(&parser.getTransformations()->at(i));

        models.push_back(object3D);
    }

    CameraPictureTaker imageMaker(specs, &models, parser.getLighting(), parser.getSpheres());
    imageMaker.printImageToFile(outPutFileName);

    std::chrono::steady_clock::time_point end = std::chrono::steady_clock::now();

    std::cout << "Execution time: "  << (double) std::chrono::duration_cast<std::chrono::microseconds>(end - begin).count() / 1000000.0 << 's' << std::endl;
}


text:
/*
 libs/numeric/odeint/examples/stochastic_euler.hpp

 Copyright 2012 Karsten Ahnert
 Copyright 2012-2013 Mario Mulansky
 Copyright 2013 Pascal Germroth

 Stochastic euler stepper example and Ornstein-Uhlenbeck process

 Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or
 copy at http://www.boost.org/LICENSE_1_0.txt)
 */

#include <boost/array.hpp>

#include <boost/numeric/odeint.hpp>

typedef boost::array< double , 1 > state_type;

using namespace boost::numeric::odeint;

//[ generation_functions_own_steppers
class custom_stepper
{
public:

    typedef double value_type;
    // ...
};

class custom_controller
{
    // ...
};

class custom_dense_output
{
    // ...
};
//]

//[ generation_functions_get_controller
namespace boost { namespace numeric { namespace odeint {

template<>
struct get_controller< custom_stepper >
{
    typedef custom_controller type;
};

} } }
//]

//[ generation_functions_controller_factory
namespace boost { namespace numeric { namespace odeint {

template<>
struct controller_factory< custom_stepper , custom_controller >
{
    custom_controller operator()( double abs_tol , double rel_tol , const custom_stepper & ) const
    {
        return custom_controller();
    }

    custom_controller operator()( double abs_tol , double rel_tol , double max_dt ,
                                  const custom_stepper & ) const
    {
        // version with maximal allowed step size max_dt
        return custom_controller();
    }
};

} } }
//]

int main( int argc , char **argv )
{
    {
        typedef runge_kutta_dopri5< state_type > stepper_type;

        /*
        //[ generation_functions_syntax_auto
        auto stepper1 = make_controlled( 1.0e-6 , 1.0e-6 , stepper_type() );
        // or with max step size limit:
        // auto stepper1 = make_controlled( 1.0e-6 , 1.0e-6 , 0.01, stepper_type() );

        auto stepper2 = make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() );
        //]
        */

        //[ generation_functions_syntax_result_of
        boost::numeric::odeint::result_of::make_controlled< stepper_type >::type stepper3 = make_controlled( 1.0e-6 , 1.0e-6 , stepper_type() );
        (void)stepper3;
        boost::numeric::odeint::result_of::make_dense_output< stepper_type >::type stepper4 = make_dense_output( 1.0e-6 , 1.0e-6 , stepper_type() );
        (void)stepper4;
        //]
    }

    {
        /*
        //[ generation_functions_example_custom_controller
        auto stepper5 = make_controlled( 1.0e-6 , 1.0e-6 , custom_stepper() );
        //]
        */

        boost::numeric::odeint::result_of::make_controlled< custom_stepper >::type stepper5 = make_controlled( 1.0e-6 , 1.0e-6 , custom_stepper() );
        (void)stepper5;
    }
    return 0;
}

max_stars_repo_name: cpp-pm/boost

max_issues_repo_name: cpp-pm/boost

max_forks_repo_name: cpp-pm/boost


text:
#ifndef BOOSTFLYWEIGHT_HPP
#define BOOSTFLYWEIGHT_HPP
#include <boost/flyweight.hpp>
#include <string>

using namespace std;

namespace boost_flyweigth {

struct User
{
   boost::flyweight< string > first_name, last_name;

   User(string const& f_name, string const& l_name) : first_name(f_name), last_name(l_name)
   {
   }

   string const&
   firstName() const
   {
      return first_name.get();
   }

   string const&
   lastName() const
   {
      return last_name.get();
   }

   friend ostream&
   operator<<(ostream& os, const User& user)
   {
      os << "first_name[" << user.first_name.get_key() << "]: " << user.firstName() << " last_name[" << user.last_name.get_key()
         << "]: " << user.lastName();
      return os;
   }
};

} // namespace boost_flyweigth

#endif // BOOSTFLYWEIGHT_HPP


text:
/*
 * Copyright (C) 2013-2014, The OpenFlint Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS-IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "FlintDaemon.h"
#include "utils/Logging.h"

#include "discovery/mdns/MDNS.h"
#include "discovery/mdns/MDNSDef.h"

#include "boost/tokenizer.hpp"
#include "boost/regex.hpp"
#include "boost/dynamic_bitset.hpp"
#include <boost/lexical_cast.hpp>
#include "boost/array.hpp"
#include "boost/algorithm/string.hpp"

#include <map>
#include <vector>
#include "discovery/mdns/MDNSDef.h"

/**
 * TODO:
 * 5. implement peer server
 */

int main(int argc, char **argv) {
	flint::FlintDaemon daemon;
	daemon.start();
	flint::FlintDaemon::ERROR_CODE error = daemon.getErrorCode();
	if (error != flint::FlintDaemon::NONE_ERROR) {
		LOG_ERROR << "daemon exist: error " << error;
	}
	return 0;
}

max_stars_repo_name: jsli/flingd-cc

max_issues_repo_name: jsli/flingd-cc

max_forks_repo_name: jsli/flingd-cc


text:
#include <cassert>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include "client.hpp"

using namespace ULogger;

const std::string Client::MSG_RECEIVED = "RCVD!";

Client::Client() :
    m_running(false),
    m_port(0)
{
}

Client::Client(const std::string &id, size_t port) :
    m_id(id),
	m_running(false),
    m_port(port)
{
}

Client::~Client()
{
    if (m_running) {
        Stop();
    }
}

void Client::SetId(const std::string &id)
{
    if (m_running)
        return;

    m_workerMutex.lock();
    m_id = id;
    m_workerMutex.unlock();
}

void Client::SetPort(const size_t port)
{
    if (m_running)
        return;

    m_workerMutex.lock();
    m_port = port;
    m_workerMutex.unlock();
}

bool Client::IsRunning()
{
    return m_running;
}

void Client::Start()
{
    m_workerMutex.lock();

    assert(boost::algorithm::trim_copy(m_id) != "");
    assert(m_port != 0);

    if (m_running) {
        m_workerMutex.unlock();
        return;
    }

    std::string tcpURL((boost::format("tcp://localhost:%1%") % boost::lexical_cast<std::string>(m_port)).str());

    m_context = ContextPtr(new zmq::context_t(1));
    m_socket = SocketPtr(new zmq::socket_t(*m_context.get(), ZMQ_REQ));

    int linger = 0;
    m_socket->setsockopt(ZMQ_LINGER, &linger, sizeof(linger));

    m_socket->connect(tcpURL.c_str());

    m_running = true;

    m_workerThread = ThreadPtr(new boost::thread(&Client::SendRequests, this));
    m_workerThread->detach();

    m_workerMutex.unlock();
}

void Client::Stop()
{
    m_workerMutex.lock();

    if (!m_running) {
        m_workerMutex.unlock();
        return;
    }

    m_running = false;
    m_workerThread->interrupt();

    std::string tcpURL((boost::format("tcp://localhost:%1%") % boost::lexical_cast<std::string>(m_port)).str());
    zmq_disconnect((void *)m_socket.get(), tcpURL.c_str());

    try {
        m_socket->close();
        m_context->close();
    } catch(...) {
    }

    m_workerThread.reset();
    m_socket.reset();
    m_context.reset();

    m_workerMutex.unlock();
}

void Client::SendMessage(const std::string &msg)
{
    if (!m_running)
		return;

    m_dataMutex.lock();
    m_requests.push(msg);
    m_dataMutex.unlock();
}

std::string Client::GetMessage(const zmq::message_t &msg)
{
    return std::string(static_cast<const char *>(msg.data()), msg.size());
}

void Client::SendRequest(const std::string &req)
{
    boost::property_tree::ptree reqTree;
    reqTree.put("req.clientId", m_id);
    reqTree.put("req.message", req);

    std::stringstream reqStream;
    boost::property_tree::write_json(reqStream, reqTree);
    std::string reqJSON(reqStream.str());

    zmq::message_t request(reqJSON.size());
    memcpy(request.data(), reqJSON.data(), reqJSON.size());

    bool rc = false;
    do {
        boost::this_thread::disable_interruption di;
        m_workerMutex.lock();
        try {
            rc = m_socket->send(request, ZMQ_NOBLOCK);
        } catch (...){
        }
        m_workerMutex.unlock();

        if (rc) {
            zmq::message_t response;
            do {
                m_workerMutex.lock();
                try {
                    rc = m_socket->recv(&response, ZMQ_NOBLOCK);
                } catch (...){
                }
                m_workerMutex.unlock();

                if (rc) {
                    if (GetMessage(response) == Client::MSG_RECEIVED) {
                        if (!OnMessageSent.empty()) {
                            OnMessageSent(req);
                        }
                    }
                }
                boost::this_thread::restore_interruption ri(di);
                boost::this_thread::interruption_point();
            } while (!rc);
        }

        boost::this_thread::restore_interruption ri(di);
        boost::this_thread::interruption_point();
    } while (!rc);
}

void Client::SendRequests()
{
    while(m_running) {
        if (m_requests.size() > 0) {
            m_dataMutex.lock();
            std::string messageStr(m_requests.front());
            m_requests.pop();
            m_dataMutex.unlock();
            SendRequest(messageStr);
        }
        boost::this_thread::interruption_point();
    }
}


text:
// Copyright 2017 Peter Dimov.
// Distributed under the Boost Software License, Version 1.0.

#ifndef BOOST_HASH2_IS_RANGE_HPP_INCLUDED
#define BOOST_HASH2_IS_RANGE_HPP_INCLUDED

#include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/declval.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/core/enable_if.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <iterator>

namespace boost
{
namespace hash2
{

#if !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR) && !BOOST_WORKAROUND(BOOST_GCC, < 40700)

namespace detail
{

template<class It> true_type is_range_check( It first, It last, typename std::iterator_traits<It>::difference_type* = 0 );

template<class T> decltype( is_range_check( declval<T&>().begin(), declval<T&>().end() ) ) is_range_( int );
template<class T> false_type is_range_( ... );

} // namespace detail

template<class T> struct is_range: decltype( detail::is_range_<T>( 0 ) )
{
};

#else

namespace detail
{

template<class T, class E = true_type> struct is_range_: false_type
{
};

template<class T> struct is_range_< T, integral_constant< bool,
        is_same<typename T::value_type, typename std::iterator_traits<typename T::iterator>::value_type>::value &&
        is_same<typename T::value_type, typename std::iterator_traits<typename T::const_iterator>::value_type>::value &&
        is_integral<typename T::size_type>::value
    > >: true_type
{
};

} // namespace detail

template<class T> struct is_range: detail::is_range_<T>
{
};

#endif // !defined(BOOST_NO_CXX11_DECLTYPE) && !defined(BOOST_NO_SFINAE_EXPR)

} // namespace hash2
} // namespace boost

#endif // #ifndef BOOST_HASH2_IS_RANGE_HPP_INCLUDED


text:
/*
    Copyright 2005-2007 Adobe Systems Incorporated
    Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
    or a copy at http://stlab.adobe.com/licenses.html)
*/

/*************************************************************************************************/

#ifndef ADOBE_ADAM_PARSER_HPP
#define ADOBE_ADAM_PARSER_HPP

#include <adobe/config.hpp>

#include <iosfwd>
#include <string>

#include <boost/function.hpp>

#include <adobe/array.hpp>
#include <adobe/istream.hpp>
#include <adobe/string.hpp>
#include <adobe/vector.hpp>

/*!
\defgroup adam_reference Property Model Language Reference
\ingroup property_model

The Property Model Library is a runtime library (see \ref adam_engine). The Property Model Language
and \ref adamparser are facilities provided to make it easier to assemble an adobe::sheet_t from a
simple declaration. This manual describes the Property Model Language.

The language is divided into three parts, \ref expression_lexical_conventions, \ref
expression_expressions, and \ref sheet_declarations. The first two parts are shared by the Layout
Library Language, and describe in the \ref expression_reference.

\section sheet_declarations Sheet Declarations

\subsection adam_grammar Property Model Grammar
\verbatim
translation_unit        = { sheet_specifier }.
sheet_specifier         = [lead_comment] "sheet" identifier "{" { qualified_cell_decl } "}"
                            [trail_comment].

qualified_cell_decl     = interface_set_decl | input_set_decl | output_set_decl
                            | constant_set_decl | logic_set_decl | invariant_set_decl
                            | external_set_decl.

interface_set_decl      = "interface"   ":" { [lead_comment] interface_cell_decl }.
input_set_decl          = "input"       ":" { [lead_comment] input_cell_decl }.
output_set_decl         = "output"      ":" { [lead_comment] output_cell_decl }.
constant_set_decl       = "constant"    ":" { [lead_comment] constant_cell_decl }.
logic_set_decl          = "logic"       ":" { [lead_comment] logic_cell_decl }.
invariant_set_decl      = "invariant"   ":" { [lead_comment] invariant_cell_decl }.
external_set_decl       = "external"    ":" { [lead_comment] identifier end_statement }.

interface_cell_decl     = ["unlink"] identifier [initializer] [define_expression] end_statement.
input_cell_decl         = identifier [initializer] end_statement.

output_cell_decl        = named_decl.
constant_cell_decl      = identifier initializer end_statement.
logic_cell_decl         = named_decl | relate_decl.
invariant_cell_decl     = named_decl.

relate_decl             = [conditional] "relate" "{" relate_expression relate_expression
                            { relate_expression } "}" [trail_comment].
relate_expression       = [lead_comment] identifier { "," identifier } define_expression
                            end_statement.
named_decl              = identifier define_expression end_statement.

initializer             = ":" expression.
conditional             = "when" "(" expression ")".

define_expression       = "<==" expression.

end_statement           = ";" [trail_comment].

keywords                += "sheet" | "interface" | "input" | "output" | "constant" | "logic"
                             | "invariant" | "unlink" | "when" | "relate" | "external".
\endverbatim

\subsection cell_qualifiers Cell Access Specifiers

\subsection initialization Initialization

\subsection advanced_features Advanced Features

\subsubsection external_types External Types and Functions
Although there are a set of types provided by the language, the type system is extensible to support
any C++ type through external functions and values introduced from outside of the system. For
example, if an external function were provided to supply an image, other functions could be provided
to operator on that image. External functions can be provided through the virtual machine API [ref].
An external function to get an image from a URL might look this:

\code
struct image_type { }; // some image structure
image_type get_image_for_url(const char* url); // Some external function to get an image

adobe::value_t get_image(const adobe::array_t& parameters)
{
    return adobe::value_t(get_image(parameters[0].get<std::string>().c_str()));
}
\endcode

A function to operate on the image might look like this:

\code
void guassian_blur(image_type& image); // Some external operation

adobe::value_t blur_image(const adobe::array_t& parameters)
{
    image_type result = parameters[0].get<image_type>();
    guassian_blur(result);
    return result;
}
\endcode

After registering these functions with the virtual machine - the following expressions are valid:

\verbatim
get_image("http:\\local\my_image.jpg") == get_image("http:\\local\my_other_image.jpg")
blur_image(get_image("http:\\local\my_image.jpg"))
\endverbatim
*/

/*************************************************************************************************/

namespace adobe {

/*************************************************************************************************/

struct adam_callback_suite_t
{
    enum cell_type_t
    {
        input_k,            // array_t is an initializer
        output_k,           // array_t is an expression
        constant_k,         // array_t is an initializer
        logic_k,            // array_t is an expression
        invariant_k         // array_t is an expression
    };

    struct relation_t
    {
        vector<name_t>      name_set_m;
        line_position_t     position_m;
        array_t             expression_m;
        string_t            detailed_m;
        string_t            brief_m;
    };

    typedef boost::function<void (  cell_type_t             type,
                                    name_t                  cell_name,
                                    const line_position_t&  position,
                                    const array_t&          expr_or_init,
                                    const std::string&      brief,
                                    const std::string&      detailed)>      add_cell_proc_t;

    typedef boost::function<void (  const line_position_t&  position,
                                    const array_t&          conditional,
                                    const relation_t*       first,
                                    const relation_t*       last,
                                    const std::string&      brief,
                                    const std::string&      detailed)>      add_relation_proc_t; // REVISIT (sparent) where's brief?

    typedef boost::function<void (  name_t                  cell_name,
                                    bool                    linked,
                                    const line_position_t&  position1,
                                    const array_t&          initializer,
                                    const line_position_t&  position2,
                                    const array_t&          expression,
                                    const std::string&      brief,
                                    const std::string&      detailed)>      add_interface_proc_t;

    typedef boost::function<void (  name_t                  cell_name,
                                    const line_position_t&  position,
                                    const std::string&      brief,
                                    const std::string&      detailed)>      add_external_proc_t;

    add_cell_proc_t         add_cell_proc_m;
    add_relation_proc_t     add_relation_proc_m;
    add_interface_proc_t    add_interface_proc_m;
    add_external_proc_t     add_external_proc_m;
};

/*************************************************************************************************/

void parse(std::istream& stream, const line_position_t& position, const adam_callback_suite_t& callbacks);

/*************************************************************************************************/

array_t parse_adam_expression(const std::string& expression);

/*************************************************************************************************/

} // namespace adobe

/*************************************************************************************************/

#endif // ADOBE_ADAM_PARSER_HPP

/*************************************************************************************************/

max_stars_repo_name: andyprowl/virtual-concepts

max_issues_repo_name: brycelelbach/asl

max_forks_repo_name: brycelelbach/asl


text: #include <boost/container/pmr/flat_set.hpp>

max_stars_repo_name: miathedev/BoostForArduino

max_issues_repo_name: miathedev/BoostForArduino

max_forks_repo_name: miathedev/BoostForArduino


text:
/*
 * Copyright (c) 2013 Masahide Kashiwagi (kashi@waseda.jp)
 */

#ifndef MAKE_CANDIDATE_HPP
#define MAKE_CANDIDATE_HPP

#include <boost/numeric/ublas/vector.hpp>

/*
 * calculate radius of candidate set from newton step vector
 */

namespace kv {

template <class T> void make_candidate(boost::numeric::ublas::vector<T>& x)
{
	int n = x.size();
	int i;

#ifdef NEWTON_TWICE
	T m(0.);
	for (i=0; i<n; i++) {
		if (x(i) > m) m = x(i);
	}
	for (i=0; i<n; i++) x(i) = 2. * m;
#else
	T av(0.);

	for (i=0; i<n; i++) av += x(i);

	av /= n;

	for (i=0; i<n; i++) x(i) += av;
#endif
}

} // namespace kv

#endif // MAKE_CANDIDATE_HPP

max_stars_repo_name: soonho-tri/kv

max_issues_repo_name: takafumihoriuchi/HyLaGI

max_forks_repo_name: takafumihoriuchi/HyLaGI


text: #include <boost/fusion/sequence/comparison.hpp>


text:
#include "../../include/waveO2/observer.hpp"
#include "../../include/waveO2/utilities.hpp"
#include "../../include/mymfem/utilities.hpp"

#include <fstream>
#include <iostream>
#include <Eigen/Core>

#include <filesystem>
namespace fs = std::filesystem;

//! Constructor
WaveO2Observer
:: WaveO2Observer (const nlohmann::json& config, int lx)
    : BaseObserver (config, lx)
{
    std::string problem_type = config["problem_type"];

    m_bool_error = false;
    if (config.contains("eval_error")) {
        m_bool_error = config["eval_error"];
    }

    std::string base_out_dir = "../output";
    if (config.contains("base_out_dir")) {
        base_out_dir = config["base_out_dir"];
    }

    std::string sub_out_dir = "wave_"+problem_type;
    if (config.contains("sub_out_dir")) {
        sub_out_dir = config["sub_out_dir"];
    }

    m_output_dir = base_out_dir+"/"+sub_out_dir+"/lx"
            +std::to_string(lx)+"/";
    m_solName_suffix = "_lx"+std::to_string(lx);

    if (m_bool_dumpOut) {
        fs::create_directories(m_output_dir);
    }
}

//! Sets the exact solution coefficients
//! and auxiliary variables needed
void WaveO2Observer
:: set (std::shared_ptr<WaveO2TestCases>& testCase,
        std::shared_ptr<WaveO2XtFEM>& discr)
{
    m_testCase = testCase;
    m_discr = discr;

    m_xndim = discr->get_xMesh()->Dimension();
    m_tVspace = m_discr->get_tFespace();
    m_xVspace = m_discr->get_xFespaces();

    if (m_bool_error)
    {
        m_uECoeff = std::make_unique
                <WaveO2ExactSolutionCoeff>(m_testCase);
        m_dudtECoeff = std::make_unique
                <WaveO2ExactGradtSolutionCoeff>(m_testCase);
        m_dudxECoeff = std::make_unique
                <WaveO2ExactGradxSolutionCoeff>(m_testCase);

        m_uE = std::make_unique<GridFunction>(m_xVspace);
        m_dudtE = std::make_unique<GridFunction>(m_xVspace);
    }
}

//! Computes H1 error for solution
std::tuple <double, double, double, double> WaveO2Observer
:: eval_xH1Error (std::shared_ptr<GridFunction>& u,
                  double t) const
{
    double erruL2=0, uEL2=0;
    double erruH1=0, uEH1=0;

    ConstantCoefficient zero(0);
    ConstantCoefficient one(1.0);
    VectorFunctionCoefficient zeroVec(m_xndim, zeroFn);

    // L2 error in solution
    m_uECoeff->SetTime(t);
    m_uE->ProjectCoefficient(*m_uECoeff);
    uEL2 = m_uE->ComputeL2Error(zero);
    erruL2 = u->ComputeL2Error(*m_uECoeff);

    // H1 error in solution
    m_dudxECoeff->SetTime(t);
    uEH1 = m_uE->ComputeH1Error(&zero, &zeroVec, &one,
                                1.0, 1);
    erruH1 = u->ComputeH1Error(m_uECoeff.get(),
                               m_dudxECoeff.get(),
                               &one, 1.0, 1);

    return {std::move(erruL2), std::move(uEL2),
                std::move(erruH1), std::move(uEH1)};
}

// End of file

max_stars_repo_name: pratyuksh/FEMWave

max_issues_repo_name: pratyuksh/FEMWave

max_forks_repo_name: pratyuksh/FEMWave


text:
//==============================================================================
//         Copyright 2003 - 2011   LASMEA UMR 6602 CNRS/Univ. Clermont II
//         Copyright 2009 - 2011   LRI    UMR 8623 CNRS/Univ Paris Sud XI
//
//          Distributed under the Boost Software License, Version 1.0.
//                 See accompanying file LICENSE.txt or copy at
//                     http://www.boost.org/LICENSE_1_0.txt
//==============================================================================
#ifndef NT2_CORE_FUNCTIONS_SCALAR_NUMEL_HPP_INCLUDED
#define NT2_CORE_FUNCTIONS_SCALAR_NUMEL_HPP_INCLUDED

#include <nt2/core/functions/numel.hpp>
#include <boost/mpl/identity.hpp>
#include <boost/mpl/size_t.hpp>
#include <boost/mpl/if.hpp>
#include <boost/fusion/include/fold.hpp>
#include <boost/fusion/include/advance.hpp>
#include <boost/fusion/include/value_at.hpp>
#include <boost/fusion/include/empty.hpp>
#include <nt2/core/utility/of_size/mpl_value.hpp>
#include <boost/fusion/include/iterator_range.hpp>
#include <boost/simd/operator/functions/scalar/multiplies.hpp>
#include <boost/dispatch/meta/strip.hpp>

namespace nt2 { namespace ext
{
  BOOST_DISPATCH_IMPLEMENT  ( numel_, tag::cpu_
                            , (A0), (scalar_< unspecified_<A0> >)
                            )
  {
    typedef boost::mpl::size_t<1> result_type;

    BOOST_FORCEINLINE
    result_type operator()(const A0&) const { return result_type(); }
  };

  BOOST_DISPATCH_IMPLEMENT  ( numel_, tag::cpu_
                            , (A0)(A1)
                            , (scalar_< unspecified_<A0> >)
                              (mpl_integral_< scalar_< unspecified_<A1> > >)
                            )
  {
    typedef boost::mpl::size_t<1> result_type;

    BOOST_FORCEINLINE
    result_type operator()(const A0&, const A1&) const { return result_type(); }
  };

  BOOST_DISPATCH_IMPLEMENT  ( numel_, tag::cpu_
                            , (A0)
                            , (fusion_sequence_<A0>)
                            )
  {
    // multiplies functor
    typedef typename boost::dispatch::
            make_functor<boost::simd::tag::multiplies_, A0>::type     func_t;
    using seq_t = typename boost::dispatch::meta::strip<A0>::type;
    using result_type = decltype(boost::fusion::fold( std::declval<seq_t>()
                                , boost::mpl::integral_c<std::size_t,1>()
                                , func_t()
                                ));

    BOOST_FORCEINLINE
    result_type operator()(A0 const& a0) const
    {
      return boost::fusion::fold( a0
                                , boost::mpl::integral_c<std::size_t,1>()
                                , func_t()
                                );
    }
  };

  BOOST_DISPATCH_IMPLEMENT  ( numel_, tag::cpu_
                            , (A0)(A1)
                            , (fusion_sequence_<A0>)
                              (mpl_integral_< scalar_< unspecified_<A1> > >)
                            )
  {
    typedef typename boost::dispatch::
            make_functor<boost::simd::tag::multiplies_, A0>::type  func_t;

    typedef typename boost::fusion::result_of::begin<A0>::type  begin_t;
    typedef typename boost::fusion::result_of::end<A0>::type    end_t;
    typedef typename boost::fusion::result_of::
                            advance<begin_t, A1>::type          new_begin_t;
    typedef boost::fusion::iterator_range<new_begin_t, end_t>   it_t;

    typedef typename  boost::fusion::result_of::
                      value_at<A0, boost::mpl::int_<0> >::type  first_t;

    typedef typename  boost::fusion::result_of
                           ::fold< it_t const
                                 , boost::mpl::integral_c<std::size_t,1> const
                                 , func_t
                                 >::type                      result_type;

    BOOST_FORCEINLINE
    result_type operator()(A0 const& a0, const A1&) const
    {
      return boost::fusion::fold( it_t(new_begin_t(a0), end_t(a0))
                                , boost::mpl::integral_c<std::size_t,1>()
                                , func_t()
                                );
    }
  };
} }

#endif