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/ndindex.hpp
#ifndef PYTHONIC_NUMPY_NDINDEX_HPP
#define PYTHONIC_NUMPY_NDINDEX_HPP

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

#include "pythonic/utils/functor.hpp"

#include <numeric>

PYTHONIC_NS_BEGIN

namespace numpy
{
  template <size_t N>
  ndindex_iterator<N>::ndindex_iterator()
  {
  }

  template <size_t N>
  ndindex_iterator<N>::ndindex_iterator(types::array<long, N> const &shape,
                                        long first)
      : index(first), shape(shape)
  {
  }

  template <size_t N>
  types::array<long, N> ndindex_iterator<N>::operator*() const
  {
    types::array<long, N> out;
    long mult = 1;
    for (long j = N - 1; j > 0; j--) {
      out[j] = (index / mult) % shape[j];
      mult *= shape[j];
    }
    out[0] = index / mult;
    return out;
  }

  template <size_t N>
  ndindex_iterator<N> &ndindex_iterator<N>::operator++()
  {
    ++index;
    return *this;
  }

  template <size_t N>
  ndindex_iterator<N> &ndindex_iterator<N>::operator+=(long n)
  {
    index += n;
    return *this;
  }

  template <size_t N>
  bool ndindex_iterator<N>::operator!=(ndindex_iterator<N> const &other) const
  {
    return index != other.index;
  }

  template <size_t N>
  bool ndindex_iterator<N>::operator<(ndindex_iterator<N> const &other) const
  {
    return index < other.index;
  }

  template <size_t N>
  long ndindex_iterator<N>::operator-(ndindex_iterator<N> const &other) const
  {
    return index - other.index;
  }

  template <size_t N>
  _ndindex<N>::_ndindex()
  {
  }

  template <size_t N>
  _ndindex<N>::_ndindex(types::array<long, N> const &shape)
      : ndindex_iterator<N>(shape, 0), shape(shape),
        end_iter(shape, std::accumulate(shape.begin(), shape.end(), 1L,
                                        std::multiplies<long>()))
  {
  }

  template <size_t N>
  typename _ndindex<N>::iterator &_ndindex<N>::begin()
  {
    return *this;
  }

  template <size_t N>
  typename _ndindex<N>::iterator const &_ndindex<N>::begin() const
  {
    return *this;
  }

  template <size_t N>
  typename _ndindex<N>::iterator _ndindex<N>::end() const
  {
    return end_iter;
  }

  template <class... Types>
  _ndindex<sizeof...(Types)> ndindex(Types... args)
  {
    return {types::make_tuple(args...)};
  }

  template <size_t N>
  _ndindex<N> ndindex(types::array<long, N> const &args)
  {
    return {args};
  }
  template <class... Tys>
  _ndindex<sizeof...(Tys)> ndindex(types::pshape<Tys...> const &args)
  {
    return {args};
  }
}
PYTHONIC_NS_END

#endif

Youez - 2016 - github.com/yon3zu
LinuXploit