[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/wolfv/xtensor-python/speed/include/xtensor-python/pyvectorize.hpp [Back]  [Original]

/***************************************************************************
* Copyright (c) 2016, Johan Mabille and Sylvain Corlay                     *
*                                                                          *
* Distributed under the terms of the BSD 3-Clause License.                 *
*                                                                          *
* The full license is in the file LICENSE, distributed with this software. *
****************************************************************************/

#ifndef PY_VECTORIZE_HPP
#define PY_VECTORIZE_HPP

#include 

#include "pyarray.hpp"
#include "xtensor/xvectorize.hpp"

namespace xt
{

    template 
    struct pyvectorizer
    {
        xvectorizer m_vectorizer;

        template ::value>>
        pyvectorizer(F&& func)
            : m_vectorizer(std::forward(func))
        {
        }

        inline pyarray operator()(const pyarray&... args) const
        {
            pyarray res = m_vectorizer(args...);
            return res;
        }
    };

    /**
     * @brief Create numpy universal function from scalar function.
     */
    template 
    inline pyvectorizer pyvectorize(R (*f)(Args...))
    {
        return pyvectorizer(f);
    }

    /// @cond DOXYGEN_INCLUDE_OVERLOADS
    template 
    inline pyvectorizer pyvectorize(F&& f, R (*)(Args...))
    {
        return pyvectorizer(std::forward(f));
    }

    template 
    inline auto pyvectorize(F&& f) -> decltype(pyvectorize(std::forward(f), (detail::get_function_type*)nullptr))
    {
        return pyvectorize(std::forward(f), (detail::get_function_type*)nullptr);
    }
    /// @endcond
}

#endif

Web Proxy Viewer  |  New URL  |  Original Page