<commit_before>#ifndef PYTHONIC_INCLUDE_NUMPY_POWER_HPP
#define PYTHONIC_INCLUDE_NUMPY_POWER_HPP

#include "pythonic/include/types/numpy_op_helper.hpp"
#include "pythonic/include/utils/meta.hpp"
#include "pythonic/include/utils/numpy_traits.hpp"
#include "pythonic/include/utils/functor.hpp"

#include <boost/simd/function/pow.hpp>
#ifdef USE_GMP
#include "pythonic/types/long.hpp"
#endif

PYTHONIC_NS_BEGIN

namespace numpy
{
  namespace wrapper
  {
    template <class T0, class T1>
    auto pow(T0 const &t0, T1 const &t1) -> decltype(
        boost::simd::pow((typename std::common_type<T0, T1>::type)t0,
                         (typename std::common_type<T0, T1>::type)t1))
    {
      return boost::simd::pow((typename std::common_type<T0, T1>::type)t0,
                              (typename std::common_type<T0, T1>::type)t1);
    }
    // See https://github.com/MetaScale/nt2/issues/794
    double pow(long const &n, double const &m)
    {
      return pow(static_cast<double>(n), m);
    }
    template <class T>
    std::complex<T> pow(T const &n, std::complex<T> const &m)<commit_msg>Fix performance issue with np.power when second argument is an integer<commit_after>#ifndef PYTHONIC_INCLUDE_NUMPY_POWER_HPP
#define PYTHONIC_INCLUDE_NUMPY_POWER_HPP

#include "pythonic/include/types/numpy_op_helper.hpp"
#include "pythonic/include/utils/meta.hpp"
#include "pythonic/include/utils/numpy_traits.hpp"
#include "pythonic/include/utils/functor.hpp"

#include <boost/simd/function/pow.hpp>
#ifdef USE_GMP
#include "pythonic/types/long.hpp"
#endif

PYTHONIC_NS_BEGIN

namespace numpy
{
  namespace wrapper
  {
    template <class T0, class T1>
    auto pow(T0 const &t0, T1 const &t1) -> typename std::enable_if<
        !std::is_integral<T1>::value,
        decltype(boost::simd::pow((typename std::common_type<T0, T1>::type)t0,
                                  (typename std::common_type<T0, T1>::type)
                                      t1))>::type
    {
      return boost::simd::pow((typename std::common_type<T0, T1>::type)t0,
                              (typename std::common_type<T0, T1>::type)t1);
    }

    template <class T0, class T1>
    auto pow(T0 const &t0, T1 const &t1) ->
        typename std::enable_if<std::is_integral<T1>::value, T0>::type
    {
      T0 a = t0;
      T1 b = t1;
      const int recip = b < 0;
      T0 r = 1;
      while (1) {
        if (b & 1)
          r *= a;
        b /= 2;
        if (b == 0)
          break;
        a *= a;
      }
      return recip ? 1 / r : r;
    }

    // See https://github.com/MetaScale/nt2/issues/794
    double pow(long const &n, double const &m)
    {
      return pow(static_cast<double>(n), m);
    }
    template <class T>
    std::complex<T> pow(T const &n, std::complex<T> const &m)
{'fraction_non_alphanumeric': 0.13822894168466524, 'fraction_numerical': 0.02339812814974802, 'mean_word_length': 2.8068493150684932, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4139639', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1010, 'n_words': 205}