403Webshell
Server IP : 217.160.0.212  /  Your IP : 216.73.216.141
Web Server : Apache
System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64
User : sws1073854427 ( 1073854427)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/pythran/pythonic/numpy/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/pythran/pythonic/numpy//around.hpp
#ifndef PYTHONIC_NUMPY_AROUND_HPP
#define PYTHONIC_NUMPY_AROUND_HPP

#include "pythonic/include/numpy/around.hpp"

#include "pythonic/numpy/rint.hpp"
#include "pythonic/numpy/power.hpp"
#include "pythonic/numpy/asarray.hpp"
#include "pythonic/numpy/floor_divide.hpp"
#include "pythonic/numpy/float64.hpp"
#include "pythonic/numpy/multiply.hpp"

PYTHONIC_NS_BEGIN

namespace numpy
{
  // fast path
  template <class E>
  auto around(E &&a) -> decltype(functor::rint{}(std::forward<E>(a)))
  {
    return functor::rint{}(std::forward<E>(a));
  }

  // generic floating point version, pure numpy_expr
  template <class E>
  auto around(E &&a, long decimals) -> typename std::enable_if<
      !std::is_integral<
          typename types::dtype_of<typename std::decay<E>::type>::type>::value,
      decltype(functor::rint{}(functor::multiply{}(
                   std::forward<E>(a),
                   std::declval<typename types::dtype_of<
                       typename std::decay<E>::type>::type>())) /
               std::declval<typename types::dtype_of<
                   typename std::decay<E>::type>::type>())>::type
  {
    typename types::dtype_of<typename std::decay<E>::type>::type const fact =
        functor::power{}(10., decimals);
    return functor::rint{}(functor::multiply{}(std::forward<E>(a), fact)) /
           fact;
  }

  // the integer version is only relevant when decimals < 0
  template <class E>
  auto around(E &&a, long decimals) -> typename std::enable_if<
      std::is_integral<
          typename types::dtype_of<typename std::decay<E>::type>::type>::value,
      decltype(numpy::functor::floor_divide{}(
                   functor::float64{}(std::forward<E>(a)),
                   std::declval<typename types::dtype_of<
                       typename std::decay<E>::type>::type>()) *
               std::declval<typename types::dtype_of<
                   typename std::decay<E>::type>::type>())>::type
  {
    typename types::dtype_of<typename std::decay<E>::type>::type const fact =
        functor::power{}(10L, std::max(0L, -decimals));
    return pythonic::numpy::functor::floor_divide{}(
               functor::float64{}(std::forward<E>(a)), fact) *
           fact;
  }
}
PYTHONIC_NS_END

#endif

Youez - 2016 - github.com/yon3zu
LinuXploit