From e7f3f0f49596fba751fdb7c6310083a9d552af52 Mon Sep 17 00:00:00 2001 From: robot-piglet Date: Sun, 30 Nov 2025 19:44:05 +0300 Subject: Intermediate changes commit_hash:0bde86dc1169b5ec3d7f1262262be69fa22b0121 --- contrib/python/pythran/.dist-info/METADATA | 5 +- contrib/python/pythran/README.rst | 2 +- contrib/python/pythran/pythran/analyses/aliases.py | 13 +- .../pythran/pythran/analyses/dependencies.py | 2 + contrib/python/pythran/pythran/backend.py | 13 +- contrib/python/pythran/pythran/config.py | 23 + contrib/python/pythran/pythran/cxxgen.py | 2 +- contrib/python/pythran/pythran/cxxtypes.py | 154 +- contrib/python/pythran/pythran/dist.py | 18 +- .../pythran/pythonic/__dispatch__/count.hpp | 3 +- .../pythran/pythran/pythonic/__dispatch__/pop.hpp | 3 +- .../pythran/pythran/pythonic/__dispatch__/sort.hpp | 12 +- .../pythran/pythonic/__dispatch__/update.hpp | 3 +- .../pythran/pythran/pythonic/array/array.hpp | 7 +- .../pythran/pythran/pythonic/bisect/bisect.hpp | 6 +- .../pythran/pythonic/bisect/bisect_left.hpp | 3 +- .../pythran/pythran/pythonic/builtins/bin.hpp | 3 +- .../pythran/pythran/pythonic/builtins/bool_.hpp | 24 + .../pythran/pythran/pythonic/builtins/complex.hpp | 25 + .../pythran/pythran/pythonic/builtins/dict.hpp | 41 +- .../pythran/pythonic/builtins/dict/fromkeys.hpp | 6 +- .../pythran/pythran/pythonic/builtins/dict/get.hpp | 3 +- .../pythran/pythonic/builtins/enumerate.hpp | 29 +- .../pythran/pythran/pythonic/builtins/filter.hpp | 36 +- .../pythran/pythran/pythonic/builtins/float_.hpp | 25 + .../pythran/pythran/pythonic/builtins/in.hpp | 3 +- .../pythran/pythran/pythonic/builtins/iter.hpp | 4 +- .../pythran/pythran/pythonic/builtins/len.hpp | 2 +- .../pythran/pythran/pythonic/builtins/list.hpp | 42 +- .../pythran/pythonic/builtins/list/extend.hpp | 8 +- .../pythran/pythonic/builtins/list/sort.hpp | 5 +- .../pythran/pythran/pythonic/builtins/map.hpp | 109 +- .../pythran/pythran/pythonic/builtins/max.hpp | 6 +- .../pythran/pythran/pythonic/builtins/min.hpp | 6 +- .../pythran/pythran/pythonic/builtins/minmax.hpp | 21 +- .../pythran/pythran/pythonic/builtins/ord.hpp | 5 +- .../pythran/pythran/pythonic/builtins/pow.hpp | 3 +- .../pythran/pythonic/builtins/pythran/len_set.hpp | 4 +- .../pythonic/builtins/pythran/static_if.hpp | 3 +- .../pythran/pythran/pythonic/builtins/range.hpp | 15 +- .../pythran/pythran/pythonic/builtins/reduce.hpp | 18 +- .../pythran/pythran/pythonic/builtins/reversed.hpp | 3 +- .../pythran/pythran/pythonic/builtins/set.hpp | 32 +- .../pythran/pythonic/builtins/set/difference.hpp | 3 +- .../pythonic/builtins/set/difference_update.hpp | 9 +- .../pythran/pythonic/builtins/set/intersection.hpp | 7 +- .../pythonic/builtins/set/intersection_update.hpp | 9 +- .../pythonic/builtins/set/symmetric_difference.hpp | 8 +- .../builtins/set/symmetric_difference_update.hpp | 9 +- .../pythran/pythonic/builtins/set/union_.hpp | 8 +- .../pythran/pythran/pythonic/builtins/slice.hpp | 27 +- .../pythran/pythran/pythonic/builtins/sorted.hpp | 46 +- .../pythran/pythran/pythonic/builtins/str.hpp | 24 + .../pythran/pythonic/builtins/str/__mod__.hpp | 6 +- .../pythran/pythonic/builtins/str/capitalize.hpp | 3 +- .../pythran/pythonic/builtins/str/endswith.hpp | 3 +- .../pythran/pythran/pythonic/builtins/str/find.hpp | 3 +- .../pythran/pythonic/builtins/str/isalpha.hpp | 4 +- .../pythran/pythonic/builtins/str/isdigit.hpp | 4 +- .../pythran/pythran/pythonic/builtins/str/join.hpp | 32 +- .../pythran/pythonic/builtins/str/lower.hpp | 3 +- .../pythran/pythonic/builtins/str/replace.hpp | 5 +- .../pythran/pythonic/builtins/str/split.hpp | 13 +- .../pythran/pythonic/builtins/str/splitlines.hpp | 35 - .../pythran/pythonic/builtins/str/startswith.hpp | 6 +- .../pythran/pythonic/builtins/str/strip.hpp | 3 +- .../pythran/pythonic/builtins/str/upper.hpp | 3 +- .../pythran/pythran/pythonic/builtins/sum.hpp | 14 +- .../pythran/pythran/pythonic/builtins/tuple.hpp | 66 +- .../pythran/pythran/pythonic/builtins/type.hpp | 131 +- .../pythran/pythran/pythonic/builtins/xrange.hpp | 9 +- .../pythran/pythran/pythonic/builtins/zip.hpp | 3 +- contrib/python/pythran/pythran/pythonic/core.hpp | 17 +- .../pythran/pythran/pythonic/functools/partial.hpp | 14 +- .../pythonic/include/__dispatch__/count.hpp | 3 +- .../pythran/pythonic/include/__dispatch__/pop.hpp | 3 +- .../pythran/pythonic/include/__dispatch__/sort.hpp | 6 +- .../pythonic/include/__dispatch__/tolist.hpp | 12 +- .../pythonic/include/__dispatch__/update.hpp | 3 +- .../pythran/pythonic/include/array/array.hpp | 7 +- .../pythran/pythonic/include/bisect/bisect.hpp | 15 +- .../pythran/pythonic/include/builtins/bin.hpp | 3 +- .../pythran/pythonic/include/builtins/bool_.hpp | 18 + .../pythran/pythonic/include/builtins/complex.hpp | 19 + .../pythran/pythonic/include/builtins/dict.hpp | 24 +- .../pythonic/include/builtins/dict/fromkeys.hpp | 2 +- .../pythran/pythonic/include/builtins/dict/get.hpp | 3 +- .../pythonic/include/builtins/enumerate.hpp | 11 +- .../pythran/pythonic/include/builtins/file.hpp | 3 +- .../pythran/pythonic/include/builtins/filter.hpp | 22 +- .../pythran/pythonic/include/builtins/float_.hpp | 19 + .../pythonic/include/builtins/isinstance.hpp | 16 +- .../pythran/pythonic/include/builtins/iter.hpp | 4 +- .../pythran/pythonic/include/builtins/len.hpp | 3 +- .../pythran/pythonic/include/builtins/list.hpp | 24 +- .../pythonic/include/builtins/list/extend.hpp | 8 +- .../pythran/pythonic/include/builtins/map.hpp | 68 +- .../pythran/pythonic/include/builtins/max.hpp | 3 +- .../pythran/pythonic/include/builtins/min.hpp | 3 +- .../pythran/pythonic/include/builtins/minmax.hpp | 9 +- .../pythran/pythonic/include/builtins/pow.hpp | 3 +- .../include/builtins/pythran/static_if.hpp | 8 +- .../include/builtins/pythran/static_list.hpp | 10 +- .../pythran/pythonic/include/builtins/range.hpp | 6 +- .../pythran/pythonic/include/builtins/reduce.hpp | 23 +- .../pythran/pythonic/include/builtins/set.hpp | 20 +- .../pythonic/include/builtins/set/difference.hpp | 3 +- .../include/builtins/set/difference_update.hpp | 9 +- .../pythonic/include/builtins/set/intersection.hpp | 7 +- .../include/builtins/set/intersection_update.hpp | 9 +- .../include/builtins/set/symmetric_difference.hpp | 8 +- .../builtins/set/symmetric_difference_update.hpp | 9 +- .../pythonic/include/builtins/set/union_.hpp | 8 +- .../pythran/pythonic/include/builtins/slice.hpp | 25 +- .../pythran/pythonic/include/builtins/sorted.hpp | 33 +- .../pythran/pythonic/include/builtins/str.hpp | 19 + .../pythonic/include/builtins/str/__mod__.hpp | 3 +- .../pythonic/include/builtins/str/endswith.hpp | 3 +- .../pythran/pythonic/include/builtins/str/find.hpp | 3 +- .../pythran/pythonic/include/builtins/str/join.hpp | 25 +- .../pythonic/include/builtins/str/split.hpp | 6 +- .../pythonic/include/builtins/str/splitlines.hpp | 22 - .../pythonic/include/builtins/str/startswith.hpp | 3 +- .../pythran/pythonic/include/builtins/sum.hpp | 14 +- .../pythran/pythonic/include/builtins/tuple.hpp | 55 +- .../pythran/pythonic/include/builtins/type.hpp | 7 +- .../pythran/pythonic/include/builtins/xrange.hpp | 5 +- .../pythran/pythonic/include/builtins/zip.hpp | 3 +- .../pythran/pythonic/include/functools/partial.hpp | 14 +- .../pythonic/include/itertools/combinations.hpp | 23 +- .../pythran/pythonic/include/itertools/count.hpp | 8 +- .../pythran/pythonic/include/itertools/ifilter.hpp | 6 +- .../pythran/pythonic/include/itertools/islice.hpp | 24 +- .../pythonic/include/itertools/permutations.hpp | 22 +- .../pythran/pythonic/include/itertools/product.hpp | 25 +- .../pythran/pythonic/include/itertools/repeat.hpp | 9 +- .../pythran/pythran/pythonic/include/numpy/all.hpp | 21 +- .../pythran/pythonic/include/numpy/alltrue.hpp | 3 +- .../pythonic/include/numpy/angle_in_rad.hpp | 3 +- .../pythran/pythran/pythonic/include/numpy/any.hpp | 21 +- .../pythran/pythonic/include/numpy/append.hpp | 16 +- .../pythran/pythonic/include/numpy/arange.hpp | 31 +- .../pythran/pythonic/include/numpy/argmax.hpp | 3 +- .../pythran/pythonic/include/numpy/argmin.hpp | 3 +- .../pythran/pythonic/include/numpy/argsort.hpp | 8 +- .../pythran/pythonic/include/numpy/argwhere.hpp | 3 +- .../pythran/pythonic/include/numpy/around.hpp | 32 +- .../pythran/pythonic/include/numpy/array.hpp | 48 +- .../pythran/pythonic/include/numpy/array_equiv.hpp | 9 +- .../pythran/pythonic/include/numpy/array_split.hpp | 14 +- .../pythran/pythonic/include/numpy/asarray.hpp | 10 +- .../pythran/pythonic/include/numpy/asfarray.hpp | 3 +- .../pythran/pythonic/include/numpy/asscalar.hpp | 5 +- .../pythran/pythonic/include/numpy/atleast_1d.hpp | 9 +- .../pythran/pythonic/include/numpy/atleast_2d.hpp | 29 +- .../pythran/pythonic/include/numpy/atleast_3d.hpp | 41 +- .../pythran/pythonic/include/numpy/bincount.hpp | 13 +- .../pythonic/include/numpy/broadcast_to.hpp | 5 +- .../pythran/pythonic/include/numpy/byte.hpp | 18 + .../pythran/pythonic/include/numpy/clip.hpp | 24 +- .../pythran/pythonic/include/numpy/complex128.hpp | 18 + .../pythran/pythonic/include/numpy/complex256.hpp | 18 + .../pythran/pythonic/include/numpy/complex64.hpp | 18 + .../pythran/pythonic/include/numpy/concatenate.hpp | 8 +- .../pythran/pythonic/include/numpy/conjugate.hpp | 8 +- .../pythran/pythonic/include/numpy/convolve.hpp | 7 +- .../pythran/pythonic/include/numpy/copy.hpp | 13 +- .../pythran/pythonic/include/numpy/copyto.hpp | 6 +- .../pythran/pythonic/include/numpy/correlate.hpp | 3 +- .../pythonic/include/numpy/count_nonzero.hpp | 8 +- .../pythran/pythonic/include/numpy/cross.hpp | 5 +- .../pythonic/include/numpy/ctypeslib/as_array.hpp | 3 +- .../pythran/pythonic/include/numpy/cumprod.hpp | 4 +- .../pythran/pythonic/include/numpy/cumsum.hpp | 4 +- .../pythran/pythonic/include/numpy/delete_.hpp | 8 +- .../pythran/pythonic/include/numpy/diag.hpp | 9 +- .../pythran/pythran/pythonic/include/numpy/dot.hpp | 320 ++-- .../pythran/pythonic/include/numpy/empty.hpp | 10 +- .../pythran/pythonic/include/numpy/empty_like.hpp | 6 +- .../pythran/pythran/pythonic/include/numpy/eye.hpp | 7 +- .../pythran/pythonic/include/numpy/fft/c2c.hpp | 7 +- .../pythran/pythonic/include/numpy/fft/fft.hpp | 31 +- .../pythran/pythonic/include/numpy/fft/fftn.hpp | 67 +- .../pythran/pythonic/include/numpy/fft/hfft.hpp | 48 +- .../pythran/pythonic/include/numpy/fft/ifft.hpp | 71 +- .../pythran/pythonic/include/numpy/fft/ihfft.hpp | 42 +- .../pythran/pythonic/include/numpy/fft/irfft.hpp | 48 +- .../pythran/pythonic/include/numpy/fft/rfft.hpp | 42 +- .../pythonic/include/numpy/fill_diagonal.hpp | 2 +- .../pythran/pythonic/include/numpy/flip.hpp | 6 +- .../pythran/pythonic/include/numpy/fliplr.hpp | 7 +- .../pythran/pythonic/include/numpy/flipud.hpp | 5 +- .../pythran/pythonic/include/numpy/float128.hpp | 19 + .../pythran/pythonic/include/numpy/float32.hpp | 19 + .../pythran/pythonic/include/numpy/float64.hpp | 19 + .../pythran/pythonic/include/numpy/float_.hpp | 18 + .../pythonic/include/numpy/floor_divide.hpp | 18 +- .../pythran/pythonic/include/numpy/frexp.hpp | 10 +- .../pythran/pythonic/include/numpy/frombuffer.hpp | 25 + .../pythonic/include/numpy/fromfunction.hpp | 13 +- .../pythran/pythonic/include/numpy/fromiter.hpp | 3 +- .../pythran/pythonic/include/numpy/fromstring.hpp | 24 +- .../pythran/pythonic/include/numpy/full.hpp | 13 +- .../pythran/pythonic/include/numpy/full_like.hpp | 6 +- .../pythran/pythonic/include/numpy/hstack.hpp | 3 +- .../pythran/pythonic/include/numpy/imag.hpp | 6 +- .../pythran/pythonic/include/numpy/indices.hpp | 6 +- .../pythran/pythonic/include/numpy/insert.hpp | 20 +- .../pythran/pythonic/include/numpy/int16.hpp | 18 + .../pythran/pythonic/include/numpy/int32.hpp | 18 + .../pythran/pythonic/include/numpy/int64.hpp | 18 + .../pythran/pythonic/include/numpy/int8.hpp | 18 + .../pythran/pythonic/include/numpy/int_.hpp | 19 + .../pythran/pythonic/include/numpy/intc.hpp | 18 + .../pythran/pythonic/include/numpy/interp.hpp | 67 +- .../pythran/pythonic/include/numpy/intersect1d.hpp | 5 +- .../pythran/pythonic/include/numpy/isclose.hpp | 4 +- .../pythran/pythonic/include/numpy/iscomplex.hpp | 6 +- .../pythran/pythonic/include/numpy/isnan.hpp | 12 +- .../pythran/pythonic/include/numpy/isreal.hpp | 6 +- .../pythran/pythonic/include/numpy/issctype.hpp | 12 +- .../pythonic/include/numpy/linalg/matrix_power.hpp | 3 +- .../pythran/pythonic/include/numpy/linalg/norm.hpp | 29 +- .../pythran/pythonic/include/numpy/linspace.hpp | 4 +- .../pythran/pythonic/include/numpy/logaddexp2.hpp | 3 +- .../pythran/pythonic/include/numpy/logical_xor.hpp | 3 +- .../pythran/pythonic/include/numpy/logspace.hpp | 6 +- .../pythran/pythran/pythonic/include/numpy/max.hpp | 4 +- .../pythran/pythonic/include/numpy/mean.hpp | 18 +- .../pythran/pythonic/include/numpy/median.hpp | 14 +- .../pythran/pythran/pythonic/include/numpy/min.hpp | 4 +- .../pythran/pythonic/include/numpy/ndarray.hpp | 25 +- .../pythonic/include/numpy/ndarray/flatten.hpp | 3 +- .../pythonic/include/numpy/ndarray/item.hpp | 5 +- .../pythonic/include/numpy/ndarray/reshape.hpp | 12 +- .../pythonic/include/numpy/ndarray/tolist.hpp | 8 +- .../pythran/pythonic/include/numpy/ndenumerate.hpp | 15 +- .../pythran/pythonic/include/numpy/ndindex.hpp | 11 +- .../pythran/pythonic/include/numpy/nonzero.hpp | 3 +- .../pythran/pythonic/include/numpy/ones.hpp | 10 +- .../pythran/pythonic/include/numpy/ones_like.hpp | 6 +- .../pythran/pythonic/include/numpy/outer.hpp | 12 +- .../pythran/pythonic/include/numpy/partial_sum.hpp | 21 +- .../pythran/pythonic/include/numpy/place.hpp | 7 +- .../pythran/pythonic/include/numpy/prod.hpp | 4 +- .../pythran/pythran/pythonic/include/numpy/ptp.hpp | 3 +- .../pythran/pythran/pythonic/include/numpy/put.hpp | 3 +- .../pythran/pythonic/include/numpy/putmask.hpp | 3 +- .../pythonic/include/numpy/random/choice.hpp | 20 +- .../pythran/pythonic/include/numpy/random/f.hpp | 5 +- .../pythonic/include/numpy/random/gamma.hpp | 6 +- .../pythonic/include/numpy/random/gumbel.hpp | 6 +- .../pythonic/include/numpy/random/laplace.hpp | 6 +- .../pythonic/include/numpy/random/logistic.hpp | 6 +- .../pythonic/include/numpy/random/lognormal.hpp | 9 +- .../include/numpy/random/negative_binomial.hpp | 6 +- .../pythonic/include/numpy/random/normal.hpp | 6 +- .../pythonic/include/numpy/random/pareto.hpp | 3 +- .../pythonic/include/numpy/random/power.hpp | 3 +- .../pythran/pythonic/include/numpy/random/rand.hpp | 3 +- .../pythonic/include/numpy/random/randint.hpp | 9 +- .../pythonic/include/numpy/random/randn.hpp | 3 +- .../pythonic/include/numpy/random/random.hpp | 6 +- .../pythonic/include/numpy/random/uniform.hpp | 6 +- .../pythonic/include/numpy/random/weibull.hpp | 3 +- .../pythran/pythonic/include/numpy/ravel.hpp | 3 +- .../pythran/pythonic/include/numpy/real.hpp | 6 +- .../pythran/pythonic/include/numpy/reduce.hpp | 47 +- .../pythran/pythonic/include/numpy/remainder.hpp | 3 +- .../pythran/pythonic/include/numpy/repeat.hpp | 5 +- .../pythran/pythonic/include/numpy/roll.hpp | 6 +- .../pythonic/include/numpy/searchsorted.hpp | 7 +- .../pythran/pythonic/include/numpy/select.hpp | 30 +- .../pythran/pythonic/include/numpy/short_.hpp | 18 + .../pythran/pythonic/include/numpy/sort.hpp | 8 +- .../pythran/pythonic/include/numpy/split.hpp | 11 +- .../pythran/pythonic/include/numpy/stack.hpp | 8 +- .../pythran/pythonic/include/numpy/std_.hpp | 3 +- .../pythran/pythonic/include/numpy/swapaxes.hpp | 7 +- .../pythran/pythonic/include/numpy/take.hpp | 3 +- .../pythran/pythonic/include/numpy/tile.hpp | 4 +- .../pythran/pythonic/include/numpy/transpose.hpp | 40 +- .../pythran/pythonic/include/numpy/ubyte.hpp | 18 + .../pythonic/include/numpy/ufunc_accumulate.hpp | 6 +- .../pythonic/include/numpy/ufunc_reduce.hpp | 17 +- .../pythran/pythonic/include/numpy/uint.hpp | 19 + .../pythran/pythonic/include/numpy/uint16.hpp | 19 + .../pythran/pythonic/include/numpy/uint32.hpp | 18 + .../pythran/pythonic/include/numpy/uint64.hpp | 19 + .../pythran/pythonic/include/numpy/uint8.hpp | 19 + .../pythran/pythonic/include/numpy/uintc.hpp | 18 + .../pythran/pythonic/include/numpy/union1d.hpp | 5 +- .../pythran/pythonic/include/numpy/unique.hpp | 51 +- .../pythonic/include/numpy/unravel_index.hpp | 4 +- .../pythran/pythonic/include/numpy/unwrap.hpp | 3 +- .../pythran/pythonic/include/numpy/ushort.hpp | 18 + .../pythran/pythran/pythonic/include/numpy/var.hpp | 8 +- .../pythran/pythonic/include/numpy/vdot.hpp | 3 +- .../pythran/pythonic/include/numpy/vectorize.hpp | 13 +- .../pythran/pythonic/include/numpy/vstack.hpp | 15 +- .../pythran/pythonic/include/numpy/where.hpp | 13 +- .../pythran/pythonic/include/numpy/zeros.hpp | 10 +- .../pythran/pythonic/include/numpy/zeros_like.hpp | 6 +- .../pythran/pythonic/include/operator_/concat.hpp | 3 +- .../pythonic/include/operator_/contains.hpp | 3 +- .../pythran/pythonic/include/operator_/div.hpp | 7 +- .../pythran/pythonic/include/operator_/getitem.hpp | 3 +- .../pythran/pythonic/include/operator_/icommon.hpp | 11 +- .../pythran/pythonic/include/operator_/imax.hpp | 18 +- .../pythran/pythonic/include/operator_/imin.hpp | 18 +- .../pythran/pythonic/include/operator_/is_.hpp | 4 +- .../pythran/pythonic/include/operator_/is_not.hpp | 4 +- .../pythonic/include/operator_/itemgetter.hpp | 9 +- .../pythonic/include/operator_/itruediv.hpp | 13 +- .../pythran/pythonic/include/operator_/lshift.hpp | 3 +- .../pythran/pythonic/include/operator_/matmul.hpp | 5 +- .../pythran/pythonic/include/operator_/mod.hpp | 15 +- .../pythonic/include/operator_/overloads.hpp | 27 +- .../pythran/pythonic/include/operator_/rshift.hpp | 3 +- .../pythran/pythonic/include/operator_/truediv.hpp | 3 +- .../pythran/pythonic/include/random/sample.hpp | 3 +- .../pythran/pythonic/include/scipy/special/i0.hpp | 45 +- .../pythonic/include/string/ascii_letters.hpp | 3 +- .../pythran/pythonic/include/types/NoneType.hpp | 90 +- .../pythran/pythonic/include/types/array.hpp | 71 +- .../pythran/pythonic/include/types/assignable.hpp | 3 +- .../pythran/pythonic/include/types/combined.hpp | 65 +- .../pythran/pythonic/include/types/complex.hpp | 33 +- .../pythran/pythonic/include/types/dict.hpp | 229 ++- .../pythonic/include/types/dynamic_tuple.hpp | 21 +- .../pythran/pythonic/include/types/exceptions.hpp | 66 +- .../pythran/pythonic/include/types/file.hpp | 5 +- .../pythran/pythonic/include/types/finfo.hpp | 3 +- .../pythran/pythonic/include/types/generator.hpp | 5 +- .../pythran/pythonic/include/types/immediate.hpp | 3 +- .../pythran/pythran/pythonic/include/types/int.hpp | 24 +- .../pythran/pythonic/include/types/lazy.hpp | 9 +- .../pythran/pythonic/include/types/list.hpp | 105 +- .../pythran/pythonic/include/types/ndarray.hpp | 414 ++--- .../pythran/pythonic/include/types/nditerator.hpp | 42 +- .../pythonic/include/types/numpy_binary_op.hpp | 9 +- .../pythonic/include/types/numpy_broadcast.hpp | 39 +- .../pythran/pythonic/include/types/numpy_expr.hpp | 410 ++--- .../pythran/pythonic/include/types/numpy_gexpr.hpp | 447 ++--- .../pythran/pythonic/include/types/numpy_iexpr.hpp | 141 +- .../pythonic/include/types/numpy_nary_expr.hpp | 16 +- .../pythonic/include/types/numpy_op_helper.hpp | 63 +- .../pythran/pythonic/include/types/numpy_texpr.hpp | 142 +- .../pythran/pythonic/include/types/numpy_ufunc.hpp | 17 +- .../pythonic/include/types/numpy_unary_op.hpp | 5 +- .../pythran/pythonic/include/types/numpy_vexpr.hpp | 56 +- .../pythran/pythonic/include/types/pointer.hpp | 9 +- .../pythran/pythran/pythonic/include/types/set.hpp | 39 +- .../pythran/pythonic/include/types/slice.hpp | 32 +- .../pythran/pythonic/include/types/static_if.hpp | 76 +- .../pythran/pythran/pythonic/include/types/str.hpp | 32 +- .../pythran/pythonic/include/types/traits.hpp | 51 +- .../pythran/pythonic/include/types/tuple.hpp | 439 ++--- .../pythran/pythonic/include/types/type.hpp | 17 + .../pythonic/include/types/variant_functor.hpp | 28 +- .../pythonic/include/types/vectorizable_type.hpp | 24 +- .../pythran/pythonic/include/utils/allocate.hpp | 7 +- .../pythonic/include/utils/broadcast_copy.hpp | 11 +- .../pythran/pythonic/include/utils/functor.hpp | 41 +- .../pythran/pythonic/include/utils/iterator.hpp | 8 +- .../pythonic/include/utils/nested_container.hpp | 11 +- .../pythran/pythonic/include/utils/neutral.hpp | 6 +- .../pythonic/include/utils/numpy_conversion.hpp | 24 +- .../pythonic/include/utils/numpy_traits.hpp | 20 +- .../pythran/pythran/pythonic/include/utils/seq.hpp | 63 +- .../pythran/pythonic/include/utils/tags.hpp | 4 +- .../pythran/pythonic/itertools/combinations.hpp | 20 +- .../pythran/pythran/pythonic/itertools/count.hpp | 3 +- .../pythran/pythran/pythonic/itertools/ifilter.hpp | 6 +- .../pythran/pythran/pythonic/itertools/islice.hpp | 37 +- .../pythran/pythonic/itertools/permutations.hpp | 46 +- .../pythran/pythran/pythonic/itertools/product.hpp | 41 +- .../pythran/pythran/pythonic/itertools/repeat.hpp | 15 +- .../python/pythran/pythran/pythonic/numpy/all.hpp | 47 +- .../pythran/pythran/pythonic/numpy/allclose.hpp | 13 +- .../pythran/pythonic/numpy/angle_in_rad.hpp | 3 +- .../python/pythran/pythran/pythonic/numpy/any.hpp | 44 +- .../pythran/pythran/pythonic/numpy/append.hpp | 26 +- .../pythran/pythran/pythonic/numpy/arange.hpp | 3 +- .../pythran/pythran/pythonic/numpy/argmax.hpp | 3 +- .../pythran/pythran/pythonic/numpy/argmin.hpp | 3 +- .../pythran/pythran/pythonic/numpy/argminmax.hpp | 96 +- .../pythran/pythran/pythonic/numpy/argsort.hpp | 23 +- .../pythran/pythran/pythonic/numpy/argwhere.hpp | 6 +- .../pythran/pythran/pythonic/numpy/around.hpp | 43 +- .../pythran/pythran/pythonic/numpy/array.hpp | 43 +- .../pythran/pythran/pythonic/numpy/array_equiv.hpp | 9 +- .../pythran/pythran/pythonic/numpy/array_split.hpp | 22 +- .../pythran/pythran/pythonic/numpy/asarray.hpp | 14 +- .../pythran/pythran/pythonic/numpy/asscalar.hpp | 3 +- .../pythran/pythran/pythonic/numpy/atleast_1d.hpp | 9 +- .../pythran/pythran/pythonic/numpy/atleast_2d.hpp | 38 +- .../pythran/pythran/pythonic/numpy/atleast_3d.hpp | 63 +- .../pythran/pythran/pythonic/numpy/average.hpp | 3 +- .../pythran/pythran/pythonic/numpy/base_repr.hpp | 7 +- .../pythran/pythran/pythonic/numpy/bincount.hpp | 30 +- .../pythran/pythonic/numpy/broadcast_to.hpp | 14 +- .../python/pythran/pythran/pythonic/numpy/byte.hpp | 25 + .../pythran/pythran/pythonic/numpy/complex128.hpp | 24 + .../pythran/pythran/pythonic/numpy/complex256.hpp | 25 + .../pythran/pythran/pythonic/numpy/complex64.hpp | 25 + .../pythran/pythran/pythonic/numpy/concatenate.hpp | 93 +- .../pythran/pythran/pythonic/numpy/convolve.hpp | 7 +- .../python/pythran/pythran/pythonic/numpy/copy.hpp | 16 +- .../pythran/pythran/pythonic/numpy/copyto.hpp | 24 +- .../pythran/pythran/pythonic/numpy/correlate.hpp | 22 +- .../pythran/pythonic/numpy/count_nonzero.hpp | 14 +- .../pythran/pythran/pythonic/numpy/cross.hpp | 31 +- .../pythran/pythonic/numpy/ctypeslib/as_array.hpp | 6 +- .../pythran/pythran/pythonic/numpy/cumprod.hpp | 7 +- .../pythran/pythran/pythonic/numpy/cumsum.hpp | 7 +- .../pythran/pythran/pythonic/numpy/delete_.hpp | 17 +- .../python/pythran/pythran/pythonic/numpy/diag.hpp | 15 +- .../python/pythran/pythran/pythonic/numpy/diff.hpp | 15 +- .../pythran/pythran/pythonic/numpy/digitize.hpp | 27 +- .../python/pythran/pythran/pythonic/numpy/dot.hpp | 1882 ++++++++------------ .../pythran/pythran/pythonic/numpy/ediff1d.hpp | 4 +- .../pythran/pythran/pythonic/numpy/empty.hpp | 9 +- .../pythran/pythran/pythonic/numpy/empty_like.hpp | 6 +- .../python/pythran/pythran/pythonic/numpy/eye.hpp | 8 +- .../pythran/pythran/pythonic/numpy/fft/c2c.hpp | 86 +- .../pythran/pythran/pythonic/numpy/fft/fft.hpp | 27 +- .../pythran/pythran/pythonic/numpy/fft/fftn.hpp | 58 +- .../pythran/pythran/pythonic/numpy/fft/hfft.hpp | 38 +- .../pythran/pythran/pythonic/numpy/fft/ifft.hpp | 62 +- .../pythran/pythran/pythonic/numpy/fft/ihfft.hpp | 36 +- .../pythran/pythran/pythonic/numpy/fft/irfft.hpp | 46 +- .../pythran/pythonic/numpy/fft/pocketfft.hpp | 1110 +++++------- .../pythran/pythran/pythonic/numpy/fft/rfft.hpp | 36 +- .../pythran/pythonic/numpy/fill_diagonal.hpp | 5 +- .../pythran/pythran/pythonic/numpy/flatnonzero.hpp | 3 +- .../python/pythran/pythran/pythonic/numpy/flip.hpp | 8 +- .../pythran/pythran/pythonic/numpy/fliplr.hpp | 12 +- .../pythran/pythran/pythonic/numpy/flipud.hpp | 8 +- .../pythran/pythran/pythonic/numpy/float128.hpp | 25 + .../pythran/pythran/pythonic/numpy/float32.hpp | 25 + .../pythran/pythran/pythonic/numpy/float64.hpp | 25 + .../pythran/pythran/pythonic/numpy/float_.hpp | 25 + .../pythran/pythran/pythonic/numpy/frexp.hpp | 26 +- .../pythran/pythran/pythonic/numpy/frombuffer.hpp | 33 + .../pythran/pythran/pythonic/numpy/fromfile.hpp | 10 +- .../pythran/pythonic/numpy/fromfunction.hpp | 35 +- .../pythran/pythran/pythonic/numpy/fromiter.hpp | 6 +- .../pythran/pythran/pythonic/numpy/fromstring.hpp | 9 +- .../python/pythran/pythran/pythonic/numpy/full.hpp | 22 +- .../pythran/pythran/pythonic/numpy/full_like.hpp | 6 +- .../pythran/pythran/pythonic/numpy/hstack.hpp | 6 +- .../python/pythran/pythran/pythonic/numpy/imag.hpp | 6 +- .../pythran/pythran/pythonic/numpy/indices.hpp | 11 +- .../pythran/pythran/pythonic/numpy/insert.hpp | 35 +- .../pythran/pythran/pythonic/numpy/int16.hpp | 24 + .../pythran/pythran/pythonic/numpy/int32.hpp | 24 + .../pythran/pythran/pythonic/numpy/int64.hpp | 24 + .../python/pythran/pythran/pythonic/numpy/int8.hpp | 24 + .../python/pythran/pythran/pythonic/numpy/int_.hpp | 25 + .../python/pythran/pythran/pythonic/numpy/intc.hpp | 30 + .../pythran/pythran/pythonic/numpy/interp.hpp | 107 +- .../pythran/pythran/pythonic/numpy/interp_core.hpp | 23 +- .../pythran/pythran/pythonic/numpy/intersect1d.hpp | 5 +- .../pythran/pythran/pythonic/numpy/isclose.hpp | 3 +- .../pythran/pythran/pythonic/numpy/iscomplex.hpp | 6 +- .../pythran/pythran/pythonic/numpy/isnan.hpp | 11 +- .../pythran/pythran/pythonic/numpy/isreal.hpp | 6 +- .../pythran/pythran/pythonic/numpy/issctype.hpp | 12 +- .../pythran/pythran/pythonic/numpy/lexsort.hpp | 3 +- .../pythran/pythonic/numpy/linalg/matrix_power.hpp | 3 +- .../pythran/pythran/pythonic/numpy/linalg/norm.hpp | 37 +- .../pythran/pythran/pythonic/numpy/linspace.hpp | 11 +- .../pythran/pythran/pythonic/numpy/logaddexp2.hpp | 6 +- .../pythran/pythran/pythonic/numpy/logical_xor.hpp | 3 +- .../pythran/pythran/pythonic/numpy/logspace.hpp | 6 +- .../python/pythran/pythran/pythonic/numpy/mean.hpp | 15 +- .../pythran/pythran/pythonic/numpy/median.hpp | 32 +- .../pythran/pythran/pythonic/numpy/nanargmax.hpp | 12 +- .../pythran/pythran/pythonic/numpy/nanargmin.hpp | 12 +- .../pythran/pythran/pythonic/numpy/nanmax.hpp | 3 +- .../pythran/pythran/pythonic/numpy/nanmin.hpp | 3 +- .../pythran/pythran/pythonic/numpy/ndarray.hpp | 39 +- .../pythran/pythonic/numpy/ndarray/flatten.hpp | 3 +- .../pythran/pythonic/numpy/ndarray/item.hpp | 5 +- .../pythran/pythonic/numpy/ndarray/reshape.hpp | 35 +- .../pythran/pythonic/numpy/ndarray/sort.hpp | 48 +- .../pythran/pythonic/numpy/ndarray/tofile.hpp | 3 +- .../pythran/pythonic/numpy/ndarray/tolist.hpp | 8 +- .../pythran/pythonic/numpy/ndarray/tostring.hpp | 3 +- .../pythran/pythran/pythonic/numpy/ndenumerate.hpp | 18 +- .../pythran/pythran/pythonic/numpy/ndindex.hpp | 6 +- .../pythran/pythran/pythonic/numpy/nonzero.hpp | 27 +- .../python/pythran/pythran/pythonic/numpy/ones.hpp | 9 +- .../pythran/pythran/pythonic/numpy/ones_like.hpp | 6 +- .../pythran/pythran/pythonic/numpy/outer.hpp | 24 +- .../pythran/pythran/pythonic/numpy/partial_sum.hpp | 18 +- .../pythran/pythran/pythonic/numpy/place.hpp | 10 +- .../python/pythran/pythran/pythonic/numpy/ptp.hpp | 3 +- .../python/pythran/pythran/pythonic/numpy/put.hpp | 3 +- .../pythran/pythran/pythonic/numpy/putmask.hpp | 3 +- .../pythran/pythonic/numpy/random/bytes.hpp | 5 +- .../pythran/pythonic/numpy/random/choice.hpp | 26 +- .../pythran/pythonic/numpy/random/exponential.hpp | 3 +- .../pythran/pythran/pythonic/numpy/random/f.hpp | 11 +- .../pythran/pythonic/numpy/random/gamma.hpp | 3 +- .../pythran/pythonic/numpy/random/gumbel.hpp | 6 +- .../pythran/pythonic/numpy/random/laplace.hpp | 9 +- .../pythran/pythonic/numpy/random/logistic.hpp | 9 +- .../pythran/pythonic/numpy/random/lognormal.hpp | 6 +- .../pythran/pythonic/numpy/random/logseries.hpp | 3 +- .../pythonic/numpy/random/negative_binomial.hpp | 6 +- .../pythran/pythonic/numpy/random/pareto.hpp | 8 +- .../pythran/pythonic/numpy/random/power.hpp | 4 +- .../pythran/pythran/pythonic/numpy/random/rand.hpp | 3 +- .../pythran/pythonic/numpy/random/randint.hpp | 15 +- .../pythran/pythonic/numpy/random/randn.hpp | 6 +- .../pythran/pythonic/numpy/random/random.hpp | 3 +- .../pythran/pythonic/numpy/random/rayleigh.hpp | 8 +- .../pythran/pythonic/numpy/random/uniform.hpp | 9 +- .../pythran/pythran/pythonic/numpy/ravel.hpp | 3 +- .../python/pythran/pythran/pythonic/numpy/real.hpp | 6 +- .../pythran/pythran/pythonic/numpy/reduce.hpp | 116 +- .../pythran/pythran/pythonic/numpy/repeat.hpp | 19 +- .../python/pythran/pythran/pythonic/numpy/roll.hpp | 51 +- .../pythran/pythonic/numpy/searchsorted.hpp | 31 +- .../pythran/pythran/pythonic/numpy/select.hpp | 61 +- .../pythran/pythran/pythonic/numpy/setdiff1d.hpp | 17 +- .../pythran/pythran/pythonic/numpy/short_.hpp | 24 + .../python/pythran/pythran/pythonic/numpy/sort.hpp | 8 +- .../pythran/pythran/pythonic/numpy/split.hpp | 11 +- .../pythran/pythran/pythonic/numpy/stack.hpp | 35 +- .../python/pythran/pythran/pythonic/numpy/std_.hpp | 3 +- .../pythran/pythran/pythonic/numpy/swapaxes.hpp | 8 +- .../python/pythran/pythran/pythonic/numpy/take.hpp | 3 +- .../python/pythran/pythran/pythonic/numpy/tile.hpp | 24 +- .../pythran/pythran/pythonic/numpy/trace.hpp | 3 +- .../pythran/pythran/pythonic/numpy/transpose.hpp | 35 +- .../python/pythran/pythran/pythonic/numpy/tri.hpp | 4 +- .../pythran/pythran/pythonic/numpy/trim_zeros.hpp | 10 +- .../pythran/pythran/pythonic/numpy/ubyte.hpp | 24 + .../pythran/pythonic/numpy/ufunc_accumulate.hpp | 6 +- .../python/pythran/pythran/pythonic/numpy/uint.hpp | 31 + .../pythran/pythran/pythonic/numpy/uint16.hpp | 24 + .../pythran/pythran/pythonic/numpy/uint32.hpp | 25 + .../pythran/pythran/pythonic/numpy/uint64.hpp | 25 + .../pythran/pythran/pythonic/numpy/uint8.hpp | 24 + .../pythran/pythran/pythonic/numpy/uintc.hpp | 30 + .../pythran/pythran/pythonic/numpy/union1d.hpp | 8 +- .../pythran/pythran/pythonic/numpy/unique.hpp | 165 +- .../pythran/pythonic/numpy/unravel_index.hpp | 4 +- .../pythran/pythran/pythonic/numpy/unwrap.hpp | 13 +- .../pythran/pythran/pythonic/numpy/ushort.hpp | 25 + .../python/pythran/pythran/pythonic/numpy/var.hpp | 24 +- .../python/pythran/pythran/pythonic/numpy/vdot.hpp | 6 +- .../pythran/pythran/pythonic/numpy/vectorize.hpp | 12 +- .../pythran/pythran/pythonic/numpy/vstack.hpp | 15 +- .../pythran/pythran/pythonic/numpy/where.hpp | 25 +- .../pythran/pythran/pythonic/numpy/zeros.hpp | 9 +- .../pythran/pythran/pythonic/numpy/zeros_like.hpp | 6 +- .../pythran/pythran/pythonic/operator_/add.hpp | 8 +- .../pythran/pythonic/operator_/contains.hpp | 3 +- .../pythran/pythran/pythonic/operator_/div.hpp | 7 +- .../pythran/pythran/pythonic/operator_/icommon.hpp | 5 +- .../pythran/pythran/pythonic/operator_/imax.hpp | 18 +- .../pythran/pythran/pythonic/operator_/imin.hpp | 18 +- .../pythran/pythran/pythonic/operator_/indexOf.hpp | 3 +- .../pythran/pythran/pythonic/operator_/is_.hpp | 4 +- .../pythran/pythran/pythonic/operator_/is_not.hpp | 4 +- .../pythran/pythonic/operator_/itemgetter.hpp | 22 +- .../pythran/pythonic/operator_/itruediv.hpp | 13 +- .../pythran/pythran/pythonic/operator_/lshift.hpp | 7 +- .../pythran/pythran/pythonic/operator_/mod.hpp | 15 +- .../pythran/pythran/pythonic/operator_/mul.hpp | 6 +- .../pythran/pythonic/operator_/overloads.hpp | 36 +- .../pythran/pythran/pythonic/operator_/rshift.hpp | 3 +- .../pythran/pythran/pythonic/operator_/sub.hpp | 8 +- .../pythran/pythran/pythonic/operator_/truediv.hpp | 3 +- .../pythran/pythran/pythonic/os/path/join.hpp | 3 +- .../pythran/pythran/pythonic/python/core.hpp | 88 +- .../pythran/pythonic/python/exception_handler.hpp | 138 +- .../pythran/pythran/pythonic/random/choice.hpp | 10 +- .../pythran/pythran/pythonic/random/sample.hpp | 8 +- .../pythran/pythran/pythonic/random/shuffle.hpp | 3 +- .../pythran/pythonic/scipy/special/binom.hpp | 6 +- .../pythran/pythonic/scipy/special/gammaincinv.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/iv.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/ivp.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/jv.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/jvp.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/kv.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/kvp.hpp | 3 +- .../pythonic/scipy/special/spherical_jn.hpp | 9 +- .../pythonic/scipy/special/spherical_yn.hpp | 9 +- .../pythran/pythran/pythonic/scipy/special/yv.hpp | 3 +- .../pythran/pythran/pythonic/scipy/special/yvp.hpp | 3 +- .../python/pythran/pythran/pythonic/time/time.hpp | 7 +- .../pythran/pythran/pythonic/types/NoneType.hpp | 11 +- .../pythran/pythran/pythonic/types/array.hpp | 79 +- .../python/pythran/pythran/pythonic/types/bool.hpp | 5 +- .../python/pythran/pythran/pythonic/types/cfun.hpp | 9 +- .../pythran/pythran/pythonic/types/complex.hpp | 81 +- .../python/pythran/pythran/pythonic/types/dict.hpp | 70 +- .../pythran/pythonic/types/dynamic_tuple.hpp | 27 +- .../pythran/pythran/pythonic/types/exceptions.hpp | 108 +- .../python/pythran/pythran/pythonic/types/file.hpp | 9 +- .../pythran/pythran/pythonic/types/finfo.hpp | 3 +- .../pythran/pythran/pythonic/types/float.hpp | 12 + .../pythran/pythran/pythonic/types/generator.hpp | 30 +- .../python/pythran/pythran/pythonic/types/int.hpp | 72 +- .../python/pythran/pythran/pythonic/types/list.hpp | 152 +- .../pythran/pythran/pythonic/types/ndarray.hpp | 635 +++---- .../pythran/pythran/pythonic/types/nditerator.hpp | 87 +- .../pythran/pythonic/types/numpy_binary_op.hpp | 9 +- .../pythran/pythonic/types/numpy_broadcast.hpp | 13 +- .../pythran/pythran/pythonic/types/numpy_expr.hpp | 155 +- .../pythran/pythran/pythonic/types/numpy_gexpr.hpp | 330 ++-- .../pythran/pythran/pythonic/types/numpy_iexpr.hpp | 125 +- .../pythran/pythonic/types/numpy_nary_expr.hpp | 16 +- .../pythran/pythran/pythonic/types/numpy_texpr.hpp | 153 +- .../pythran/pythonic/types/numpy_unary_op.hpp | 5 +- .../pythran/pythran/pythonic/types/numpy_vexpr.hpp | 54 +- .../pythran/pythran/pythonic/types/pointer.hpp | 9 +- .../pythran/pythran/pythonic/types/raw_array.hpp | 6 +- .../python/pythran/pythran/pythonic/types/set.hpp | 69 +- .../pythran/pythran/pythonic/types/slice.hpp | 129 +- .../python/pythran/pythran/pythonic/types/str.hpp | 82 +- .../pythran/pythran/pythonic/types/tuple.hpp | 212 ++- .../python/pythran/pythran/pythonic/types/type.hpp | 161 ++ .../pythran/pythonic/types/variant_functor.hpp | 84 +- .../pythran/pythonic/types/vectorizable_type.hpp | 11 +- .../pythran/pythonic/utils/array_helper.hpp | 3 +- .../pythran/pythonic/utils/broadcast_copy.hpp | 119 +- .../pythran/pythran/pythonic/utils/iterator.hpp | 3 +- .../python/pythran/pythran/pythonic/utils/meta.hpp | 2 +- .../pythran/pythonic/utils/nested_container.hpp | 4 +- .../pythran/pythonic/utils/numpy_conversion.hpp | 38 +- .../pythran/pythran/pythonic/utils/pdqsort.hpp | 40 +- .../pythran/pythran/pythonic/utils/shared_ref.hpp | 3 +- contrib/python/pythran/pythran/pythran-darwin.cfg | 2 +- contrib/python/pythran/pythran/pythran-default.cfg | 2 +- contrib/python/pythran/pythran/pythran-linux.cfg | 2 +- contrib/python/pythran/pythran/pythran-linux2.cfg | 2 +- contrib/python/pythran/pythran/pythran.cfg | 4 + contrib/python/pythran/pythran/spec.py | 27 +- contrib/python/pythran/pythran/tables.py | 13 +- contrib/python/pythran/pythran/toolchain.py | 11 +- .../transformations/remove_named_arguments.py | 91 +- contrib/python/pythran/pythran/types/conversion.py | 21 +- contrib/python/pythran/pythran/types/signature.py | 7 +- .../pythran/pythran/types/type_dependencies.py | 8 +- contrib/python/pythran/pythran/types/types.py | 54 +- contrib/python/pythran/pythran/typing.py | 34 +- contrib/python/pythran/pythran/utils.py | 4 +- contrib/python/pythran/pythran/version.py | 2 +- .../pythran/pythran/xsimd/arch/xsimd_avx.hpp | 2 +- contrib/python/pythran/ya.make | 2 +- 657 files changed, 8733 insertions(+), 10283 deletions(-) delete mode 100644 contrib/python/pythran/pythran/pythonic/builtins/str/splitlines.hpp delete mode 100644 contrib/python/pythran/pythran/pythonic/include/builtins/str/splitlines.hpp create mode 100644 contrib/python/pythran/pythran/pythonic/include/numpy/frombuffer.hpp create mode 100644 contrib/python/pythran/pythran/pythonic/include/types/type.hpp create mode 100644 contrib/python/pythran/pythran/pythonic/numpy/frombuffer.hpp create mode 100644 contrib/python/pythran/pythran/pythonic/types/type.hpp (limited to 'contrib/python/pythran') diff --git a/contrib/python/pythran/.dist-info/METADATA b/contrib/python/pythran/.dist-info/METADATA index 977fa455ed0..9928f1f57b1 100644 --- a/contrib/python/pythran/.dist-info/METADATA +++ b/contrib/python/pythran/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: pythran -Version: 0.18.0 +Version: 0.18.1 Summary: Ahead of Time compiler for numeric kernels Author-email: Serge Guelton License: Copyright (c) 2012, HPC Project and Serge Guelton @@ -39,7 +39,6 @@ Project-URL: Changelog, https://pythran.readthedocs.io/en/latest/Changelog.html Classifier: Development Status :: 4 - Beta Classifier: Environment :: Console Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: BSD License Classifier: Natural Language :: English Classifier: Operating System :: POSIX :: Linux Classifier: Operating System :: MacOS @@ -89,7 +88,7 @@ It is meant to efficiently compile **scientific programs**, and takes advantage of multi-cores and SIMD instruction units. Until 0.9.5 (included), Pythran was supporting Python 3 and Python 2.7. -It now only supports Python **3**. +It now only supports Python **3.7** and upward. Installation ------------ diff --git a/contrib/python/pythran/README.rst b/contrib/python/pythran/README.rst index eeb9384b2e9..004b314224c 100644 --- a/contrib/python/pythran/README.rst +++ b/contrib/python/pythran/README.rst @@ -15,7 +15,7 @@ It is meant to efficiently compile **scientific programs**, and takes advantage of multi-cores and SIMD instruction units. Until 0.9.5 (included), Pythran was supporting Python 3 and Python 2.7. -It now only supports Python **3**. +It now only supports Python **3.7** and upward. Installation ------------ diff --git a/contrib/python/pythran/pythran/analyses/aliases.py b/contrib/python/pythran/pythran/analyses/aliases.py index ff4f2a937fa..df9be140d5b 100644 --- a/contrib/python/pythran/pythran/analyses/aliases.py +++ b/contrib/python/pythran/pythran/analyses/aliases.py @@ -14,6 +14,7 @@ import gast as ast from copy import deepcopy from itertools import product import io +import numpy as np IntrinsicAliases = dict() @@ -288,7 +289,10 @@ class Aliases(ModuleAnalysis[GlobalDeclarations]): for ra in func.return_alias(args_combination): if isinstance(ra, ast.Subscript): if isinstance(ra.value, ContainerOf): - return_aliases.update(ra.value.containees) + if np.isnan(ra.value.index) or (isnum(ra.slice) and + ra.slice.value == + ra.value.index): + return_aliases.update(ra.value.containees) continue return_aliases.add(ra) return return_aliases @@ -681,7 +685,12 @@ class Aliases(ModuleAnalysis[GlobalDeclarations]): def wrap(t, aliases): if isinstance(t, ast.Subscript): alias, wrapped = wrap(t.value, aliases) - return alias, {ContainerOf(wrapped)} + if isnum(t.slice): + return alias, {ContainerOf(wrapped, t.slice.value)} + elif isinstance(t.slice, ast.Slice): + return alias, wrapped + else: + return alias, {ContainerOf(wrapped)} elif isinstance(t, ast.Name): return t, aliases else: diff --git a/contrib/python/pythran/pythran/analyses/dependencies.py b/contrib/python/pythran/pythran/analyses/dependencies.py index f153558f8c1..e0988e1038e 100644 --- a/contrib/python/pythran/pythran/analyses/dependencies.py +++ b/contrib/python/pythran/pythran/analyses/dependencies.py @@ -127,6 +127,8 @@ class Dependencies(ModuleAnalysis): def visit_Constant(self, node): if node.value is None: self.result.add(('builtins', 'None')) + elif isinstance(node.value, bytes): + self.result.add(('types', 'str')) # FIXME: using str as backend elif isinstance(node.value, str): self.result.add(('types', 'str')) elif isinstance(node.value, complex): diff --git a/contrib/python/pythran/pythran/backend.py b/contrib/python/pythran/pythran/backend.py index e5728ab3e0e..2793d52544c 100644 --- a/contrib/python/pythran/pythran/backend.py +++ b/contrib/python/pythran/pythran/backend.py @@ -298,12 +298,13 @@ class CxxFunction(ast.NodeVisitor): def prepare_types(self, node): # compute arg dump + dflt_v = [self.visit(n) for n in node.args.defaults] dflt_argv = ( [None] * (len(node.args.args) - len(node.args.defaults)) + - [self.visit(n) for n in node.args.defaults]) + dflt_v) dflt_argt = ( [None] * (len(node.args.args) - len(node.args.defaults)) + - [self.types[n].sgenerate() for n in node.args.defaults]) + ["decltype({})".format(v) for v in dflt_v]) # compute type dump result_type = self.types[node][0] @@ -1012,6 +1013,14 @@ class CxxFunction(ast.NodeVisitor): ret = 'pythonic::builtins::None' elif isinstance(node.value, bool): ret = str(node.value).lower() + elif isinstance(node.value, bytes): + quoted = "".join('\\' + hex(b)[1:] for b in node.value) + # FIXME: using str type as backend + if len(node.value) == 1: + quoted = quoted.replace("'", r"\'") + ret = 'pythonic::types::chr(\'' + quoted + '\')' + else: + ret = 'pythonic::types::str("' + quoted + '")' elif isinstance(node.value, str): quoted = quote_cxxstring(node.value) if len(node.value) == 1: diff --git a/contrib/python/pythran/pythran/config.py b/contrib/python/pythran/pythran/config.py index d24cc1fa486..43320cbff90 100644 --- a/contrib/python/pythran/pythran/config.py +++ b/contrib/python/pythran/pythran/config.py @@ -6,6 +6,7 @@ except ImportError: import io import logging import os +import re from shlex import split as shsplit import sys @@ -226,6 +227,28 @@ def make_extension(python, **extra): if ldflags is not None: extension['extra_link_args'].extend(shsplit(ldflags)) + major = minor = None + try: + limited_api = cfg.getboolean("backend", "limited_api") + if limited_api: + if sys.version_info < (3, 10): + logger.warning("Setting 'backend.limited_api' is only supported starting with Python 3.10, ignoring.") + else: + major, minor = 3, 7 + except ValueError: + limited_api = cfg.get("backend", "limited_api") + if re.match(r'^3\.[0-9]+$', limited_api): + major, minor = map(int, limited_api.split('.')) + if (major, minor) < (3, 7): + logger.warning("Invalid 'backend.limited_api' entry, expecting at least 3.7, ignoring.") + major = minor = None + else: + logger.warning("Invalid 'backend.limited_api' entry, expected boolean or '3.7+', ignoring.") + + if major is not None: + extension["define_macros"].append(f'Py_LIMITED_API={hex(major << 24 | minor << 16)}') + extension["py_limited_api"] = True + for k, w in extra.items(): extension[k].extend(w) if cfg.getboolean('pythran', 'complex_hook'): diff --git a/contrib/python/pythran/pythran/cxxgen.py b/contrib/python/pythran/pythran/cxxgen.py index 83b9432c405..a75b151858f 100644 --- a/contrib/python/pythran/pythran/cxxgen.py +++ b/contrib/python/pythran/pythran/cxxgen.py @@ -653,7 +653,7 @@ class PythonModule(object): types = [] for wrapper_name, wrapper_types, overload in overloads: funcs.append("pythonic::types::ufunc_wrapper<{}, {}>".format( - wrapper_name, ", ".join(wrapper_types))) + wrapper_name, ", ".join(wrapper_types[-1:] + wrapper_types[:-1]))) types.extend(overload) ufunc = ''' diff --git a/contrib/python/pythran/pythran/cxxtypes.py b/contrib/python/pythran/pythran/cxxtypes.py index c30cd884dc1..c3c5a2f6003 100644 --- a/contrib/python/pythran/pythran/cxxtypes.py +++ b/contrib/python/pythran/pythran/cxxtypes.py @@ -3,6 +3,7 @@ This module defines classes needed to manipulate c++ types from pythran. ''' from inspect import isclass +from pythran.utils import cxxid class ordered_set(object): @@ -47,8 +48,7 @@ class TypeBuilder(object): typename __combined::type >>> builder.ArgumentType(4) - typename std::remove_cv::\ -type>::type + std::remove_cv_t> >>> builder.Assignable(builder.NamedType("long")) typename pythonic::assignable::type @@ -59,9 +59,8 @@ type>::type >>> builder.Lazy(builder.NamedType("long")) typename pythonic::lazy::type - >>> builder.DeclType("toto") - typename std::remove_cv<\ -typename std::remove_reference::type>::type + >>> builder.FunctionType("toto") + toto >>> builder.IteratorOfType(builder.NamedType('some')) typename some::iterator @@ -69,25 +68,23 @@ typename std::remove_reference::type>::type typename some::stuff::iterator >>> builder.IteratorContentType(builder.NamedType('str')) - typename std::remove_cv::type::iterator>::value_type>::type + std::remove_cv_t::iterator>::value_type> >>> builder.GetAttr(builder.NamedType('complex'), 'real') decltype(pythonic::builtins::getattr(\ pythonic::types::attr::REAL{}, std::declval())) >>> builder.ReturnType(builder.NamedType('math::cos'), f_ty) - decltype(std::declval()(std::declval())) + std::result_of_t >>> t = builder.TupleType(i_ty, builder.NamedType('str')) >>> builder.ElementType(1, t) - typename std::tuple_element<1,typename std::remove_reference<\ -decltype(pythonic::types::make_tuple(std::declval(), \ -std::declval()))>::type>::type + std::tuple_element_t<1, std::remove_reference_t>> >>> builder.ListType(builder.NamedType('int')) - pythonic::types::list::type> + pythonic::types::list> >>> builder.NDArrayType(builder.NamedType('int'), 1) pythonic::types::ndarray> @@ -96,14 +93,13 @@ std::declval()))>::type>::type pythonic::types::set >>> builder.TupleType(i_ty, builder.NamedType('bool')) - decltype(pythonic::types::make_tuple(std::declval(), \ -std::declval())) + pythonic::types::make_tuple_t >>> builder.DictType(builder.NamedType('int'), builder.NamedType('float')) pythonic::types::dict >>> builder.ContainerType(builder.NamedType('int')) - container::type> + container> >>> builder.IndexableType(builder.NamedType('int')) indexable @@ -174,12 +170,10 @@ std::declval())) A generic parametric type """ - prefix = "__ptype{0}" - def __init__(self, fun, ptype, index): super(PType, self).__init__(fun=fun, type=ptype, - name=PType.prefix.format(index)) + name=f"__ptype{index}") def generate(self, ctx): return ctx(self.type) @@ -218,13 +212,11 @@ std::declval())) def generate(self, ctx): if self.arguments: args = ", ".join(ctx(arg) for arg in self.arguments) - template_params = "<{0}>".format(args) + template_params = f"<{args}>" else: template_params = "" - return "typename {0}::type{1}::{2}".format(self.fun.name, - template_params, - self.name) + return f"typename {self.fun.name}::type{template_params}::{self.name}" class CombinedTypes(Type): """ @@ -258,11 +250,22 @@ std::declval())) sys.setrecursionlimit(current_recursion_limit) return stypes[0] else: - stmp = 'typename __combined<{}>::type'.format( - ','.join(stypes)) + stmp = f'typename __combined<{",".join(stypes)}>::type' sys.setrecursionlimit(current_recursion_limit) return stmp + class IntegralConstant(Type): + """ + A generic type object, to hold scalar types and such + """ + + def __init__(self, of, index): + super(IntegralConstant, self).__init__(of=of, index=index) + + def generate(self, ctx): + ty = ctx(self.of) + return f"std::integral_constant<{ty}, {str(self.index).lower()}>" + class ArgumentType(Type): """ A type to hold function arguments @@ -271,10 +274,7 @@ std::declval())) super(ArgumentType, self).__init__(num=num) def generate(self, _): - argtype = "argument_type{0}".format(self.num) - noref = "typename std::remove_reference<{0}>::type".format( - argtype) - return "typename std::remove_cv<{0}>::type".format(noref) + return f'std::remove_cv_t>' class DependentType(Type): """ @@ -287,6 +287,7 @@ std::declval())) def iscombined(self): return self.of.iscombined() + class Assignable(DependentType): """ A type which can be assigned @@ -297,8 +298,7 @@ std::declval())) """ def generate(self, ctx): - return 'typename pythonic::assignable<{0}>::type'.format( - ctx(self.of)) + return f'typename pythonic::assignable<{ctx(self.of)}>::type' class AssignableNoEscape(DependentType): """ @@ -306,8 +306,7 @@ std::declval())) """ def generate(self, ctx): - return 'typename pythonic::assignable_noescape<{0}>::type'.format( - ctx(self.of)) + return f'typename pythonic::assignable_noescape<{ctx(self.of)}>::type' class Returnable(DependentType): """ @@ -321,8 +320,7 @@ std::declval())) """ def generate(self, ctx): - return 'typename pythonic::returnable<{0}>::type'.format( - ctx(self.of)) + return f'typename pythonic::returnable<{ctx(self.of)}>::type' class Lazy(DependentType): """ @@ -333,17 +331,18 @@ std::declval())) """ def generate(self, ctx): - return 'typename pythonic::lazy<{}>::type'.format(ctx(self.of)) + return f'typename pythonic::lazy<{ctx(self.of)}>::type' - class DeclType(NamedType): + class FunctionType(Type): """ - Gather the type of a variable + Gather the type of a function reference """ + def __init__(self, *path): + super(FunctionType, self).__init__(path=path) + def generate(self, _): - return ('typename std::remove_cv<' - 'typename std::remove_reference<' - 'decltype({0})>::type>::type'.format(self.srepr)) + return '::'.join(map(cxxid, self.path)) class AddConst(DependentType): @@ -352,8 +351,7 @@ std::declval())) ''' def generate(self, ctx): of_type = ctx(self.of) - return ('decltype(pythonic::types::as_const(std::declval<' - + of_type + '>()))') + return f'decltype(pythonic::types::as_const(std::declval<{of_type}>()))' class IteratorOfType(DependentType): ''' @@ -362,9 +360,9 @@ std::declval())) def generate(self, ctx): container_type = ctx(self.of) if container_type.startswith('typename'): - return container_type + '::iterator' + return f'{container_type}::iterator' else: - return 'typename ' + container_type + '::iterator' + return f'typename {container_type}::iterator' class IteratorContentType(DependentType): ''' @@ -373,12 +371,7 @@ std::declval())) def generate(self, ctx): iterator_value_type = ctx(self.of) - return 'typename std::remove_cv<{0}>::type'.format( - 'typename std::iterator_traits<{0}>::value_type'.format( - 'typename std::remove_reference<{0}>::type::iterator' - .format(iterator_value_type) - ) - ) + return f'std::remove_cv_t::iterator>::value_type>' class GetAttr(Type): ''' @@ -388,9 +381,8 @@ std::declval())) super(GetAttr, self).__init__(param=param, attr=attr) def generate(self, ctx): - return ('decltype(pythonic::builtins::getattr({}{{}}, {}))' - .format('pythonic::types::attr::' + self.attr.upper(), - 'std::declval<' + ctx(self.param) + '>()')) + attr = f'pythonic::types::attr::{self.attr.upper()}' + return f'decltype(pythonic::builtins::getattr({attr}{{}}, std::declval<{ctx(self.param)}>()))' class ReturnType(Type): ''' @@ -401,10 +393,9 @@ std::declval())) def generate(self, ctx): # the return type of a constructor is obvious - cg = 'std::declval<{0}>()'.format(ctx(self.ftype)) - args = ("std::declval<{0}>()".format(ctx(arg)) - for arg in self.args) - return 'decltype({0}({1}))'.format(cg, ", ".join(args)) + cg = ctx(self.ftype) + args = [ctx(arg) for arg in self.args] + return f'std::result_of_t<{cg}({", ".join(args)})>' class ElementType(Type): ''' @@ -418,12 +409,16 @@ std::declval())) return self.of.iscombined() def generate(self, ctx): - return 'typename std::tuple_element<{0},{1}>::type'.format( - self.index, - 'typename std::remove_reference<{0}>::type'.format( - ctx(self.of) - ) - ) + return f'std::tuple_element_t<{self.index}, std::remove_reference_t<{ctx(self.of)}>>' + + class TypeType(DependentType): + ''' + Type holding a type + ''' + + def generate(self, ctx): + return f'pythonic::types::type_t<{ctx(self.of)}>' + class ListType(DependentType): ''' @@ -431,9 +426,7 @@ std::declval())) ''' def generate(self, ctx): - return 'pythonic::types::list<{}>'.format( - 'typename std::remove_reference<{0}>::type'.format( - ctx(self.of))) + return f'pythonic::types::list>' class SetType(DependentType): ''' @@ -441,7 +434,7 @@ std::declval())) ''' def generate(self, ctx): - return 'pythonic::types::set<{0}>'.format(ctx(self.of)) + return f'pythonic::types::set<{ctx(self.of)}>' class TupleType(Type): ''' @@ -455,9 +448,7 @@ std::declval())) def generate(self, ctx): elts = (ctx(of) for of in self.ofs) - telts = ('std::declval<{0}>()'.format(elt) for elt in elts) - return 'decltype(pythonic::types::make_tuple({0}))'.format( - ", ".join(telts)) + return f'pythonic::types::make_tuple_t<{", ".join(elts)}>' class DictType(Type): ''' @@ -472,8 +463,7 @@ std::declval())) for of in (self.of_key, self.of_val))) def generate(self, ctx): - return 'pythonic::types::dict<{},{}>'.format(ctx(self.of_key), - ctx(self.of_val)) + return f'pythonic::types::dict<{ctx(self.of_key)},{ctx(self.of_val)}>' class NDArrayType(DependentType): ''' @@ -483,10 +473,7 @@ std::declval())) super(DependentType, self).__init__(of=dtype, nbdims=nbdims) def generate(self, ctx): - return 'pythonic::types::ndarray<{}, pythonic::types::pshape<{}>>'.format( - ctx(self.of), - ", ".join((['long'] * self.nbdims)) - ) + return f'pythonic::types::ndarray<{ctx(self.of)}, pythonic::types::pshape<{", ".join(["long"] * self.nbdims)}>>' class ContainerType(DependentType): @@ -495,8 +482,7 @@ std::declval())) ''' def generate(self, ctx): - return ('container::type>' - .format(ctx(self.of))) + return f'container>' class IndexableType(DependentType): ''' @@ -504,7 +490,7 @@ std::declval())) ''' def generate(self, ctx): - return 'indexable<{0}>'.format(ctx(self.of)) + return f'indexable<{ctx(self.of)}>' class IndexableContainerType(Type): ''' @@ -520,10 +506,7 @@ std::declval())) for of in (self.of_key, self.of_val))) def generate(self, ctx): - return ('indexable_container<' - '{0}, typename std::remove_reference<{1}>::type' - '>' - .format(ctx(self.of_key), ctx(self.of_val))) + return f'indexable_container<{ctx(self.of_key)}, std::remove_reference_t<{ctx(self.of_val)}>>' class ExpressionType(Type): @@ -538,9 +521,8 @@ std::declval())) return any(expr.iscombined() for expr in self.exprs) def generate(self, ctx): - gexprs = ["std::declval<{0}>()".format(ctx(expr)) - for expr in self.exprs] - return 'decltype({0})'.format(self.op(*gexprs)) + gexprs = [f"std::declval<{ctx(expr)}>()" for expr in self.exprs] + return f'decltype({self.op(*gexprs)})' builder.UnknownType = Type() diff --git a/contrib/python/pythran/pythran/dist.py b/contrib/python/pythran/pythran/dist.py index 45cf299ca0c..c2146c451f2 100644 --- a/contrib/python/pythran/pythran/dist.py +++ b/contrib/python/pythran/pythran/dist.py @@ -15,18 +15,11 @@ except ImportError: import os.path import os import re +import sys -try: - from distutils.command.build_ext import build_ext as LegacyBuildExt -except ImportError: - from setuptools.command.build_ext import build_ext as LegacyBuildExt -try: - # `numpy.distutils` is deprecated, and won't be present on Python >=3.12 - # If it is installed, we need to use it though, so try-import it: - from numpy.distutils.extension import Extension -except ImportError: - from setuptools.extension import Extension +from setuptools.command.build_ext import build_ext as LegacyBuildExt +from setuptools.extension import Extension @@ -64,6 +57,7 @@ class PythranBuildExtMixIn(object): 'compiler': None, 'linker_exe': None, 'linker_so': None, + 'linker_so_cxx': None, # Windows-like 'cc': None, } @@ -83,6 +77,8 @@ class PythranBuildExtMixIn(object): if getattr(ext, 'cc', None) is not None: try: import distutils._msvccompiler as msvc + if not hasattr(msvc, "_find_exe"): + msvc = msvc.msvc # install hook find_exe = msvc._find_exe @@ -92,7 +88,7 @@ class PythranBuildExtMixIn(object): return find_exe(exe, *args, **kwargs) msvc._find_exe = _find_exe - except (AttributeError, ImportError): + except (AttributeError, ImportError) as e: pass # In general, distutils uses -Wstrict-prototypes, but this option diff --git a/contrib/python/pythran/pythran/pythonic/__dispatch__/count.hpp b/contrib/python/pythran/pythran/pythonic/__dispatch__/count.hpp index cc566bea029..b46349788b3 100644 --- a/contrib/python/pythran/pythran/pythonic/__dispatch__/count.hpp +++ b/contrib/python/pythran/pythran/pythonic/__dispatch__/count.hpp @@ -11,8 +11,7 @@ namespace __dispatch__ { template - auto count(Any &&any, - Value &&value) -> decltype(any.count(std::forward(value))) + auto count(Any &&any, Value &&value) -> decltype(any.count(std::forward(value))) { return any.count(std::forward(value)); } diff --git a/contrib/python/pythran/pythran/pythonic/__dispatch__/pop.hpp b/contrib/python/pythran/pythran/pythonic/__dispatch__/pop.hpp index 262c82d240c..b257e10d177 100644 --- a/contrib/python/pythran/pythran/pythonic/__dispatch__/pop.hpp +++ b/contrib/python/pythran/pythran/pythonic/__dispatch__/pop.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace __dispatch__ { template - auto pop(Any &&any, - Arg0 &&...arg0) -> decltype(any.pop(std::forward(arg0)...)) + auto pop(Any &&any, Arg0 &&...arg0) -> decltype(any.pop(std::forward(arg0)...)) { return any.pop(std::forward(arg0)...); } diff --git a/contrib/python/pythran/pythran/pythonic/__dispatch__/sort.hpp b/contrib/python/pythran/pythran/pythonic/__dispatch__/sort.hpp index 3bdc0cdccb4..a14bf88cf11 100644 --- a/contrib/python/pythran/pythran/pythonic/__dispatch__/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/__dispatch__/sort.hpp @@ -13,24 +13,20 @@ namespace __dispatch__ template auto sort(types::list &l, Args &&...args) - -> decltype(pythonic::builtins::list::sort(l, - std::forward(args)...)) + -> decltype(pythonic::builtins::list::sort(l, std::forward(args)...)) { return pythonic::builtins::list::sort(l, std::forward(args)...); } template auto sort(types::list &&l, Args &&...args) - -> decltype(pythonic::builtins::list::sort(std::move(l), - std::forward(args)...)) + -> decltype(pythonic::builtins::list::sort(std::move(l), std::forward(args)...)) { - return pythonic::builtins::list::sort(std::move(l), - std::forward(args)...); + return pythonic::builtins::list::sort(std::move(l), std::forward(args)...); } template types::none_type sort(Any &&any, Args &&...args) { - return pythonic::numpy::ndarray::sort(std::forward(any), - std::forward(args)...); + return pythonic::numpy::ndarray::sort(std::forward(any), std::forward(args)...); } } // namespace __dispatch__ PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/__dispatch__/update.hpp b/contrib/python/pythran/pythran/pythonic/__dispatch__/update.hpp index 12f1acfbfe0..483302218be 100644 --- a/contrib/python/pythran/pythran/pythonic/__dispatch__/update.hpp +++ b/contrib/python/pythran/pythran/pythonic/__dispatch__/update.hpp @@ -11,8 +11,7 @@ namespace __dispatch__ { template - auto update(Any &&any, Arg0 &&...arg0) - -> decltype(any.update(std::forward(arg0)...)) + auto update(Any &&any, Arg0 &&...arg0) -> decltype(any.update(std::forward(arg0)...)) { return any.update(std::forward(arg0)...); } diff --git a/contrib/python/pythran/pythran/pythonic/array/array.hpp b/contrib/python/pythran/pythran/pythonic/array/array.hpp index 6edf437706f..41149a2f2e6 100644 --- a/contrib/python/pythran/pythran/pythonic/array/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/array/array.hpp @@ -14,15 +14,14 @@ namespace array { template - types::array::type> - array(std::integral_constant) + types::array::type> array(std::integral_constant) { return {0}; } template - types::array::type> - array(std::integral_constant, E &&elts) + types::array::type> array(std::integral_constant, + E &&elts) { return {std::forward(elts)}; } diff --git a/contrib/python/pythran/pythran/pythonic/bisect/bisect.hpp b/contrib/python/pythran/pythran/pythonic/bisect/bisect.hpp index 84258fbe367..935cfd46f31 100644 --- a/contrib/python/pythran/pythran/pythonic/bisect/bisect.hpp +++ b/contrib/python/pythran/pythran/pythonic/bisect/bisect.hpp @@ -13,8 +13,7 @@ PYTHONIC_NS_BEGIN namespace bisect { template - long bisect(X const &x, A const &a, long lo, - details::bisect_fun const &fun) + long bisect(X const &x, A const &a, long lo, details::bisect_fun const &fun) { if (lo < 0) throw types::ValueError("lo must be non-negative"); @@ -22,8 +21,7 @@ namespace bisect } template - long bisect(X const &x, A const &a, long lo, long hi, - details::bisect_fun const &fun) + long bisect(X const &x, A const &a, long lo, long hi, details::bisect_fun const &fun) { if (lo < 0) throw types::ValueError("lo must be non-negative"); diff --git a/contrib/python/pythran/pythran/pythonic/bisect/bisect_left.hpp b/contrib/python/pythran/pythran/pythonic/bisect/bisect_left.hpp index 00e7cf4ea45..b4b92ad4c80 100644 --- a/contrib/python/pythran/pythran/pythonic/bisect/bisect_left.hpp +++ b/contrib/python/pythran/pythran/pythonic/bisect/bisect_left.hpp @@ -21,8 +21,7 @@ namespace bisect template long bisect_left(X const &x, A const &a, long lo, long hi) { - return bisect(x, a, lo, hi, - std::lower_bound); + return bisect(x, a, lo, hi, std::lower_bound); } } // namespace bisect PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/builtins/bin.hpp b/contrib/python/pythran/pythran/pythonic/builtins/bin.hpp index f53fbc46192..83daaf33880 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/bin.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/bin.hpp @@ -15,8 +15,7 @@ PYTHONIC_NS_BEGIN namespace builtins { template - typename std::enable_if::value, types::str>::type - bin(T const &v) + std::enable_if_t::value, types::str> bin(T const &v) { using UT = typename std::make_unsigned::type; if (v < T{0}) diff --git a/contrib/python/pythran/pythran/pythonic/builtins/bool_.hpp b/contrib/python/pythran/pythran/pythonic/builtins/bool_.hpp index c50889b659d..d2e178d579f 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/bool_.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/bool_.hpp @@ -39,4 +39,28 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::bool_ const &c) +{ + return (PyObject *)&PyBool_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyBool_Type; +} + +inline builtins::functor::bool_ from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/complex.hpp b/contrib/python/pythran/pythran/pythonic/builtins/complex.hpp index 9629896d943..9095ee38077 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/complex.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/complex.hpp @@ -21,4 +21,29 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::complex const &c) +{ + return (PyObject *)&PyComplex_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyComplex_Type || obj == (PyObject *)&PyCDoubleArrType_Type; +} + +inline builtins::functor::complex from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/dict.hpp b/contrib/python/pythran/pythran/pythonic/builtins/dict.hpp index 6b54af33289..34a1d4a00c7 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/dict.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/dict.hpp @@ -29,13 +29,11 @@ namespace builtins template auto dict(Iterable &&iterable) - -> types::dict< - typename std::decay(*iterable.begin()))>::type, - typename std::decay(*iterable.begin()))>::type> + -> types::dict(*iterable.begin()))>, + std::decay_t(*iterable.begin()))>> { - types::dict< - typename std::decay(*iterable.begin()))>::type, - typename std::decay(*iterable.begin()))>::type> + types::dict(*iterable.begin()))>, + std::decay_t(*iterable.begin()))>> out = types::empty_dict(); for (auto const &i : iterable) out[std::get<0>(i)] = std::get<1>(i); @@ -45,4 +43,35 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::dict const &c) +{ + return (PyObject *)&PyDict_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (obj == (PyObject *)&PyDict_Type) + return true; + PyObject *Origin = PyObject_GetAttrString(obj, "__origin__"); + if (!Origin) + return false; + bool res = (Origin == (PyObject *)&PyDict_Type); + Py_DECREF(Origin); + return res; +} + +inline builtins::functor::dict from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/dict/fromkeys.hpp b/contrib/python/pythran/pythran/pythonic/builtins/dict/fromkeys.hpp index 3cfbcfb9ce9..6178eb021da 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/dict/fromkeys.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/dict/fromkeys.hpp @@ -17,10 +17,10 @@ namespace builtins { template - types::dict::type::value_type, V> - fromkeys(Iterable &&iter, V const &v) + types::dict::value_type, V> fromkeys(Iterable &&iter, + V const &v) { - types::dict::type::value_type, + types::dict::value_type, V> D = types::empty_dict(); // Allocate default capacity to dict for (auto const &i : iter) diff --git a/contrib/python/pythran/pythran/pythonic/builtins/dict/get.hpp b/contrib/python/pythran/pythran/pythonic/builtins/dict/get.hpp index f88f6f31cc3..42f97898006 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/dict/get.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/dict/get.hpp @@ -15,8 +15,7 @@ namespace builtins namespace dict { template - typename __combined::type get(types::dict const &d, W const &k, - X const &default_) + typename __combined::type get(types::dict const &d, W const &k, X const &default_) { return d.get(k, default_); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/enumerate.hpp b/contrib/python/pythran/pythran/pythonic/builtins/enumerate.hpp index faab84a4558..47dbc184b91 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/enumerate.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/enumerate.hpp @@ -22,15 +22,13 @@ namespace builtins } template - enumerate_iterator::enumerate_iterator(Iterator const &iter, - long first) + enumerate_iterator::enumerate_iterator(Iterator const &iter, long first) : value(first), iter(iter) { } template - enumerate_iterator & - enumerate_iterator::operator+=(long n) + enumerate_iterator &enumerate_iterator::operator+=(long n) { value += n, iter += n; return *this; @@ -42,29 +40,25 @@ namespace builtins // TODO : We could handle case with && without size if there is a // performances benefits template - bool enumerate_iterator::operator!=( - enumerate_iterator const &other) const + bool enumerate_iterator::operator!=(enumerate_iterator const &other) const { return !(*this == other); } template - bool enumerate_iterator::operator<( - enumerate_iterator const &other) const + bool enumerate_iterator::operator<(enumerate_iterator const &other) const { return iter < other.iter; } template - bool enumerate_iterator::operator==( - enumerate_iterator const &other) const + bool enumerate_iterator::operator==(enumerate_iterator const &other) const { return iter == other.iter; } template - long enumerate_iterator::operator-( - enumerate_iterator const &other) const + long enumerate_iterator::operator-(enumerate_iterator const &other) const { return iter - other.iter; } @@ -77,8 +71,7 @@ namespace builtins template enumerate::enumerate(Iterable seq, long first) - : Iterable(seq), iterator(Iterable::begin(), first), - end_iter(Iterable::end(), -1) + : Iterable(seq), iterator(Iterable::begin(), first), end_iter(Iterable::end(), -1) { } @@ -89,8 +82,7 @@ namespace builtins } template - typename enumerate::iterator const & - enumerate::begin() const + typename enumerate::iterator const &enumerate::begin() const { return *this; } @@ -105,9 +97,8 @@ namespace builtins /// enumerate implementation template - details::enumerate::type>::type> - enumerate(Iterable &&seq, long first) + details::enumerate>> enumerate(Iterable &&seq, + long first) { return {std::forward(seq), first}; } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/filter.hpp b/contrib/python/pythran/pythran/pythonic/builtins/filter.hpp index 8708be72122..00fe3c8b34a 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/filter.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/filter.hpp @@ -29,28 +29,24 @@ namespace builtins filter_iterator::filter_iterator(Operator _op, List0 &_seq) : op(_op), iter(_seq.begin()), iter_end(_seq.end()) { - if (iter != iter_end && - !test_filter(std::is_same())) + if (iter != iter_end && !test_filter(std::is_same())) next_value(); } template - filter_iterator::filter_iterator(itertools::npos, - Operator _op, List0 &_seq) + filter_iterator::filter_iterator(itertools::npos, Operator _op, List0 &_seq) : op(_op), iter(_seq.end()), iter_end(_seq.end()) { } template - typename List0::value_type - filter_iterator::operator*() const + typename List0::value_type filter_iterator::operator*() const { return *iter; } template - filter_iterator & - filter_iterator::operator++() + filter_iterator &filter_iterator::operator++() { next_value(); return *this; @@ -66,30 +62,26 @@ namespace builtins } template - bool filter_iterator::operator==( - filter_iterator const &other) const + bool filter_iterator::operator==(filter_iterator const &other) const { return !(iter != other.iter); } template - bool filter_iterator::operator!=( - filter_iterator const &other) const + bool filter_iterator::operator!=(filter_iterator const &other) const { return iter != other.iter; } template - bool filter_iterator::operator<( - filter_iterator const &other) const + bool filter_iterator::operator<(filter_iterator const &other) const { return iter != other.iter; } template filter::filter(Operator _op, List0 const &_seq) - : utils::iterator_reminder(_seq), - iterator(_op, this->values), + : utils::iterator_reminder(_seq), iterator(_op, this->values), end_iter(itertools::npos(), _op, this->values) { } @@ -101,25 +93,21 @@ namespace builtins } template - typename filter::iterator const & - filter::begin() const + typename filter::iterator const &filter::begin() const { return *this; } template - typename filter::iterator const & - filter::end() const + typename filter::iterator const &filter::end() const { return end_iter; } } // namespace details template - details::filter::type>::type, - typename std::remove_cv< - typename std::remove_reference::type>::type> + details::filter>, + std::remove_cv_t>> filter(Operator &&_op, List0 &&_seq) { return {std::forward(_op), std::forward(_seq)}; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/float_.hpp b/contrib/python/pythran/pythran/pythonic/builtins/float_.hpp index 52f324cce64..9f7914b7f39 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/float_.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/float_.hpp @@ -26,4 +26,29 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::float_ const &c) +{ + return (PyObject *)&PyFloat_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyFloat_Type || obj == (PyObject *)&PyDoubleArrType_Type; +} + +inline builtins::functor::float_ from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/in.hpp b/contrib/python/pythran/pythran/pythonic/builtins/in.hpp index a4f57ee1fa2..38a77829048 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/in.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/in.hpp @@ -35,8 +35,7 @@ namespace details template bool in(T &&t, V const &v) { - using RT = - typename std::remove_cv::type>::type; + using RT = std::remove_cv_t>; static bool constexpr has_contains = types::has_contains::value; return details::in()(std::forward(t), v); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/iter.hpp b/contrib/python/pythran/pythran/pythonic/builtins/iter.hpp index b2c155c136a..3f008df913b 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/iter.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/iter.hpp @@ -48,9 +48,7 @@ namespace builtins /// iter implementation template - details::iter< - typename std::remove_cv::type>::type> - iter(T &&t) + details::iter>> iter(T &&t) { return {std::forward(t)}; } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/len.hpp b/contrib/python/pythran/pythran/pythonic/builtins/len.hpp index 2c4e4f44498..76bf6fcfaed 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/len.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/len.hpp @@ -20,7 +20,7 @@ namespace builtins } template - typename std::enable_if::value, long>::type len(T const &t) + std::enable_if_t::value, long> len(T const &t) { return t.size(); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/list.hpp b/contrib/python/pythran/pythran/pythonic/builtins/list.hpp index 95d065d6f9a..9f426ae33c6 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/list.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/list.hpp @@ -28,18 +28,46 @@ namespace builtins } template - types::list::type::iterator>::value_type>:: - type> + types::list::iterator>::value_type>> list(Iterable &&t) { - return types::list::type::iterator>::value_type>::type>(t.begin(), - t.end()); + return types::list::iterator>::value_type>>(t.begin(), t.end()); } } // namespace anonymous } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::list const &c) +{ + return (PyObject *)&PyList_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (obj == (PyObject *)&PyList_Type) + return true; + PyObject *Origin = PyObject_GetAttrString(obj, "__origin__"); + if (!Origin) + return false; + bool res = (Origin == (PyObject *)&PyList_Type); + Py_DECREF(Origin); + return res; +} + +inline builtins::functor::list from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/list/extend.hpp b/contrib/python/pythran/pythran/pythonic/builtins/list/extend.hpp index e1321d79ff7..bd320f217be 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/list/extend.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/list/extend.hpp @@ -16,9 +16,7 @@ namespace builtins namespace list { template - typename std::enable_if< - !std::is_same::type, types::empty_list>::value, - types::none_type>::type + std::enable_if_t, types::empty_list>::value, types::none_type> extend(T0 &&seq, T1 const &add) { std::forward(seq) += add; @@ -26,9 +24,7 @@ namespace builtins } template - typename std::enable_if< - std::is_same::type, types::empty_list>::value, - types::none_type>::type + std::enable_if_t, types::empty_list>::value, types::none_type> extend(T0 &&seq, T1 const &add) { return {}; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/list/sort.hpp b/contrib/python/pythran/pythran/pythonic/builtins/list/sort.hpp index 913b87d4f9f..188cf1a4ab1 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/list/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/list/sort.hpp @@ -27,9 +27,8 @@ namespace builtins template types::none_type sort(types::list &seq, K key) { - pdqsort(seq.begin(), seq.end(), [&key](T const &self, T const &other) { - return key(self) < key(other); - }); + pdqsort(seq.begin(), seq.end(), + [&key](T const &self, T const &other) { return key(self) < key(other); }); return builtins::None; } } // namespace list diff --git a/contrib/python/pythran/pythran/pythonic/builtins/map.hpp b/contrib/python/pythran/pythran/pythonic/builtins/map.hpp index ac6eb0354a1..e25bacfd8bc 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/map.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/map.hpp @@ -24,19 +24,17 @@ namespace builtins template template - map_iterator::map_iterator(Operator const &op, - std::tuple &_iters, - utils::index_sequence) + map_iterator::map_iterator(Operator const &op, std::tuple &_iters, + std::index_sequence) : it(std::get(_iters).begin()...), _op(op) { } template template - map_iterator::map_iterator(itertools::npos, - Operator const &op, + map_iterator::map_iterator(itertools::npos, Operator const &op, std::tuple &_iters, - utils::index_sequence) + std::index_sequence) : it(std::get(_iters).end()...), _op(op) { } @@ -44,8 +42,7 @@ namespace builtins template template typename map_res::type - map_iterator::get_value(utils::index_sequence, - std::false_type) const + map_iterator::get_value(std::index_sequence, std::false_type) const { return _op(*std::get(it)...); } @@ -53,32 +50,29 @@ namespace builtins template template typename map_res::type - map_iterator::get_value(utils::index_sequence, - std::true_type) const + map_iterator::get_value(std::index_sequence, std::true_type) const { return types::make_tuple(*std::get(it)...); } template - typename map_res::type - map_iterator::operator*() const + typename map_res::type map_iterator::operator*() const { - return get_value(utils::make_index_sequence{}, + return get_value(std::make_index_sequence{}, std::is_same()); } template template - void map_iterator::next(utils::index_sequence) + void map_iterator::next(std::index_sequence) { utils::fwd(++std::get(it)...); } template - map_iterator & - map_iterator::operator++() + map_iterator &map_iterator::operator++() { - next(utils::make_index_sequence{}); + next(std::make_index_sequence{}); return *this; } @@ -97,16 +91,14 @@ namespace builtins } template - map_iterator & - map_iterator::operator+=(long i) + map_iterator &map_iterator::operator+=(long i) { advance(i, utils::int_()); return *this; } template - map_iterator - map_iterator::operator+(long i) const + map_iterator map_iterator::operator+(long i) const { map_iterator other(*this); other += i; @@ -115,16 +107,15 @@ namespace builtins template template - bool map_iterator::equal( - map_iterator const &other, utils::int_) const + bool map_iterator::equal(map_iterator const &other, + utils::int_) const { - return std::get(other.it) == std::get(it) || - equal(other, utils::int_()); + return std::get(other.it) == std::get(it) || equal(other, utils::int_()); } template - bool map_iterator::equal( - map_iterator const &other, utils::int_<0>) const + bool map_iterator::equal(map_iterator const &other, + utils::int_<0>) const { return std::get<0>(other.it) == std::get<0>(it); } @@ -144,31 +135,54 @@ namespace builtins } template - bool map_iterator::operator<( + template + bool map_iterator::lt(map_iterator const &other, + utils::int_) const + { + return std::get(it) < std::get(other.it) || + ((std::get(it) == std::get(other.it)) && lt(other, utils::int_())); + } + + template + bool map_iterator::lt(map_iterator const &other, + utils::int_<0>) const + { + return std::get<0>(it) < std::get<0>(other.it); + } + + template + bool + map_iterator::operator<(map_iterator const &other) const + { + return lt(other, utils::int_()); + } + + template + bool map_iterator::operator<=( map_iterator const &other) const { - return !(*this == other); + return (*this == other) || (*this < other); } template template - long map_iterator::min_len( - map_iterator const &other, utils::int_) const + long map_iterator::min_len(map_iterator const &other, + utils::int_) const { return std::min((long)(std::get(it) - std::get(other.it)), min_len(other, utils::int_())); } template - long map_iterator::min_len( - map_iterator const &other, utils::int_<0>) const + long map_iterator::min_len(map_iterator const &other, + utils::int_<0>) const { return std::get<0>(it) - std::get<0>(other.it); } template - long map_iterator::operator-( - map_iterator const &other) const + long + map_iterator::operator-(map_iterator const &other) const { return min_len(other, utils::int_()); } @@ -176,13 +190,11 @@ namespace builtins template template map::map(Operator const &_op, Types &&..._iters) - : utils::iterator_reminder( - std::forward(_iters)...), - map_iterator( - _op, this->values, - utils::make_index_sequence{}), + : utils::iterator_reminder(std::forward(_iters)...), + map_iterator(_op, this->values, + std::make_index_sequence{}), end_iter(itertools::npos(), _op, this->values, - utils::make_index_sequence{}) + std::make_index_sequence{}) { } @@ -193,27 +205,22 @@ namespace builtins } template - typename map::iterator const & - map::begin() const + typename map::iterator const &map::begin() const { return *this; } template - typename map::iterator const & - map::end() const + typename map::iterator const &map::end() const { return end_iter; } } // namespace details template - auto map(Operator &&_op, Iter &&...iters) - -> details::map< - typename std::remove_cv< - typename std::remove_reference::type>::type, - typename types::iterator::type>::type>::type...> + details::map>, + typename types::iterator>>::type...> + map(Operator &&_op, Iter &&...iters) { return {std::forward(_op), std::forward(iters)...}; } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/max.hpp b/contrib/python/pythran/pythran/pythonic/builtins/max.hpp index aeb9eb79701..2f57fbdf2ea 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/max.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/max.hpp @@ -14,11 +14,9 @@ namespace builtins template auto max(Types &&...values) - -> decltype(details::minmax(operator_::functor::lt{}, - std::forward(values)...)) + -> decltype(details::minmax(operator_::functor::lt{}, std::forward(values)...)) { - return details::minmax(operator_::functor::lt{}, - std::forward(values)...); + return details::minmax(operator_::functor::lt{}, std::forward(values)...); } } // namespace builtins PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/builtins/min.hpp b/contrib/python/pythran/pythran/pythonic/builtins/min.hpp index 915a711ce81..bad79a1d593 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/min.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/min.hpp @@ -14,11 +14,9 @@ namespace builtins template auto min(Types &&...values) - -> decltype(details::minmax(operator_::functor::gt{}, - std::forward(values)...)) + -> decltype(details::minmax(operator_::functor::gt{}, std::forward(values)...)) { - return details::minmax(operator_::functor::gt{}, - std::forward(values)...); + return details::minmax(operator_::functor::gt{}, std::forward(values)...); } } // namespace builtins PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/builtins/minmax.hpp b/contrib/python/pythran/pythran/pythonic/builtins/minmax.hpp index f74a25cdeb4..f155e3f06b0 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/minmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/minmax.hpp @@ -14,32 +14,29 @@ namespace builtins namespace details { template - typename std::decay::type::value_type minmax(Op const &op, T &&t) + typename std::decay_t::value_type minmax(Op const &op, T &&t) { return *std::max_element(t.begin(), t.end(), op); } template - typename std::decay::type::value_type minmax(Op const &op, T &&t, - types::kwonly, F key) + typename std::decay_t::value_type minmax(Op const &op, T &&t, types::kwonly, F key) { using value_type = decltype(*t.begin()); - return *std::max_element( - t.begin(), t.end(), - [op, key](value_type const &self, value_type const &other) { - return op(key(self), key(other)); - }); + return *std::max_element(t.begin(), t.end(), + [op, key](value_type const &self, value_type const &other) { + return op(key(self), key(other)); + }); } template - typename std::enable_if::value, - typename __combined::type>::type + std::enable_if_t::value, + typename __combined::type> minmax(Op const &op, T0 const &t0, T1 const &t1, Types const &...ts) { using value_type = typename __combined::type; std::initializer_list values = { - static_cast(t0), static_cast(t1), - static_cast(ts)...}; + static_cast(t0), static_cast(t1), static_cast(ts)...}; return minmax(op, values); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/builtins/ord.hpp b/contrib/python/pythran/pythran/pythonic/builtins/ord.hpp index 07f941c7f33..887fd089ebb 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/ord.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/ord.hpp @@ -15,9 +15,8 @@ namespace builtins long ord(types::str const &v) { if (v.size() != 1) - throw types::TypeError( - "ord() expected a character, but string of length " + - std::to_string(v.size()) + " found"); + throw types::TypeError("ord() expected a character, but string of length " + + std::to_string(v.size()) + " found"); return (long)v.chars()[0]; } } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/builtins/pow.hpp b/contrib/python/pythran/pythran/pythonic/builtins/pow.hpp index 80c2235236e..6cc8d8cc60c 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/pow.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/pow.hpp @@ -30,8 +30,7 @@ namespace builtins } template - auto pow(Types &&...args) - -> decltype(numpy::functor::power{}(std::forward(args)...)) + auto pow(Types &&...args) -> decltype(numpy::functor::power{}(std::forward(args)...)) { return numpy::functor::power{}(std::forward(args)...); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/pythran/len_set.hpp b/contrib/python/pythran/pythran/pythonic/builtins/pythran/len_set.hpp index 03b9f8fbd8b..40505ddae31 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/pythran/len_set.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/pythran/len_set.hpp @@ -18,8 +18,8 @@ namespace builtins template long len_set(Iterable const &s) { - return std::set::value_type>(s.begin(), s.end()) + return std::set::value_type>( + s.begin(), s.end()) .size(); } } // namespace pythran diff --git a/contrib/python/pythran/pythran/pythonic/builtins/pythran/static_if.hpp b/contrib/python/pythran/pythran/pythonic/builtins/pythran/static_if.hpp index 8e6c975cae8..4c966512bbf 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/pythran/static_if.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/pythran/static_if.hpp @@ -14,8 +14,7 @@ namespace builtins { template - auto static_if(T const &cond, F0 f0, - F1 f1) -> decltype(details::static_if{cond}(f0, f1)) + auto static_if(T const &cond, F0 f0, F1 f1) -> decltype(details::static_if{cond}(f0, f1)) { return details::static_if{cond}(f0, f1); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/range.hpp b/contrib/python/pythran/pythran/pythonic/builtins/range.hpp index 2c3f3971d4d..3d7fc54f6de 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/range.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/range.hpp @@ -18,11 +18,9 @@ namespace builtins inline long _init_last(long _begin, long _end, long _step) { if (_step > 0) - return _begin + - std::max(0L, _step * ((_end - _begin + _step - 1) / _step)); + return _begin + std::max(0L, _step * ((_end - _begin + _step - 1) / _step)); else - return _begin + - std::min(0L, _step * ((_end - _begin + _step + 1) / _step)); + return _begin + std::min(0L, _step * ((_end - _begin + _step + 1) / _step)); } } // namespace @@ -89,13 +87,18 @@ namespace builtins return sign * value_ < sign * other.value_; } + inline bool range_iterator::operator<=(range_iterator const &other) const + { + const long sign = +1 | (step_ >> (sizeof(long) * CHAR_BIT - 1)); + return sign * value_ <= sign * other.value_; + } + inline long range_iterator::operator-(range_iterator const &other) const { return (value_ - other.value_) / step_; } - inline range::range(long b, long e, long s) - : begin_(b), end_(_init_last(b, e, s)), step_(s) + inline range::range(long b, long e, long s) : begin_(b), end_(_init_last(b, e, s)), step_(s) { } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/reduce.hpp b/contrib/python/pythran/pythran/pythonic/builtins/reduce.hpp index 068dc42fbc3..14409d8ae66 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/reduce.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/reduce.hpp @@ -15,11 +15,9 @@ namespace builtins { template - auto reduce(Operator op, Iterable s) - -> decltype(op(std::declval::value_type>(), - std::declval::value_type>())) + auto reduce(Operator op, Iterable s) -> decltype(op( + std::declval::value_type>(), + std::declval::value_type>())) { auto iter = s.begin(); auto r = *iter; @@ -32,13 +30,11 @@ namespace builtins template auto reduce(Operator op, Iterable s, T const &init) - -> decltype(std::accumulate( - s.begin(), s.end(), - static_cast>(init), op)) + -> decltype(std::accumulate(s.begin(), s.end(), + static_cast>(init), op)) { - return std::accumulate( - s.begin(), s.end(), - static_cast>(init), op); + return std::accumulate(s.begin(), s.end(), + static_cast>(init), op); } } // namespace builtins PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/builtins/reversed.hpp b/contrib/python/pythran/pythran/pythonic/builtins/reversed.hpp index f765c3ac395..38d96bf9888 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/reversed.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/reversed.hpp @@ -35,8 +35,7 @@ namespace builtins } template - typename reversed::const_iterator - reversed::begin() const + typename reversed::const_iterator reversed::begin() const { return iterable.rbegin(); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set.hpp index 736c732aba5..d5f269bf620 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set.hpp @@ -21,7 +21,7 @@ namespace builtins template inline types::set::type::iterator>::value_type> + typename std::remove_reference_t::iterator>::value_type> set(Iterable &&t) { return {t.begin(), t.end()}; @@ -29,4 +29,34 @@ namespace builtins } // namespace anonymous } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::set const &c) +{ + return (PyObject *)&PySet_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (obj == (PyObject *)&PySet_Type) + return true; + PyObject *Origin = PyObject_GetAttrString(obj, "__origin__"); + if (!Origin) + return false; + bool res = (Origin == (PyObject *)&PySet_Type); + Py_DECREF(Origin); + return res; +} + +inline builtins::functor::set from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/difference.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/difference.hpp index 4edb510b67a..635ca8547a6 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/difference.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/difference.hpp @@ -28,8 +28,7 @@ namespace builtins } template - types::empty_set difference(types::empty_set const &set, - Types const &...others) + types::empty_set difference(types::empty_set const &set, Types const &...others) { return types::empty_set(); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/difference_update.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/difference_update.hpp index 9de4f8a14d6..099d1ba86aa 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/difference_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/difference_update.hpp @@ -15,24 +15,21 @@ namespace builtins { template - types::none_type difference_update(types::set &set, - Types const &...others) + types::none_type difference_update(types::set &set, Types const &...others) { set.difference_update(others...); return {}; } template - types::none_type difference_update(types::set &&set, - Types const &...others) + types::none_type difference_update(types::set &&set, Types const &...others) { // nothing to be done as we work on rvalue return {}; } template - types::none_type difference_update(types::empty_set const &set, - Types const &...others) + types::none_type difference_update(types::empty_set const &set, Types const &...others) { // nothing can be removed in set return {}; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/intersection.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/intersection.hpp index 09417a47fb1..58167699532 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/intersection.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/intersection.hpp @@ -15,8 +15,8 @@ namespace builtins { template - typename __combined, Types...>::type - intersection(types::set const &set, Types const &...others) + typename __combined, Types...>::type intersection(types::set const &set, + Types const &...others) { return set.intersection(others...); } @@ -28,8 +28,7 @@ namespace builtins * set([1.0, 2.0, 3.0]) */ template - types::empty_set intersection(types::empty_set const &set, - Types const &...others) + types::empty_set intersection(types::empty_set const &set, Types const &...others) { return types::empty_set(); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/intersection_update.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/intersection_update.hpp index 847a4d4dd6c..100cd12a9ba 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/intersection_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/intersection_update.hpp @@ -15,24 +15,21 @@ namespace builtins { template - types::none_type intersection_update(types::set &set, - Types const &...others) + types::none_type intersection_update(types::set &set, Types const &...others) { set.intersection_update(others...); return {}; } template - types::none_type intersection_update(types::set &&set, - Types const &...others) + types::none_type intersection_update(types::set &&set, Types const &...others) { // If it is an rvalue, we don't really want to update return {}; } template - types::none_type intersection_update(types::empty_set &&set, - Types const &...others) + types::none_type intersection_update(types::empty_set &&set, Types const &...others) { // If it is an empty_set, it is ! really updated otherwise we have a // typing issue diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference.hpp index 14dd6fbbdf8..3b5b753cf95 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference.hpp @@ -15,8 +15,8 @@ namespace builtins { template - typename __combined, U>::type - symmetric_difference(types::set const &set, U const &other) + typename __combined, U>::type symmetric_difference(types::set const &set, + U const &other) { return set.symmetric_difference(other); } @@ -28,8 +28,8 @@ namespace builtins * set([1.0, 4.0]) */ template - typename __combined::type - symmetric_difference(types::empty_set const &set, U const &other) + typename __combined::type symmetric_difference(types::empty_set const &set, + U const &other) { return other; } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference_update.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference_update.hpp index e9aa1675ceb..36a99635ed5 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/symmetric_difference_update.hpp @@ -15,24 +15,21 @@ namespace builtins { template - types::none_type symmetric_difference_update(types::set &set, - U const &other) + types::none_type symmetric_difference_update(types::set &set, U const &other) { set.symmetric_difference_update(other); return {}; } template - types::none_type symmetric_difference_update(types::set &&set, - U const &other) + types::none_type symmetric_difference_update(types::set &&set, U const &other) { // nothing to be done on rvalue return {}; } template - types::none_type symmetric_difference_update(types::empty_set const &set, - U const &other) + types::none_type symmetric_difference_update(types::empty_set const &set, U const &other) { // nothing otherwise empty_set have ! its correct type. return {}; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/set/union_.hpp b/contrib/python/pythran/pythran/pythonic/builtins/set/union_.hpp index 04bcaea0176..e1436a16ff8 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/set/union_.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/set/union_.hpp @@ -15,15 +15,15 @@ namespace builtins { template - typename __combined, Types...>::type - union_(types::set const &set, Types const &...others) + typename __combined, Types...>::type union_(types::set const &set, + Types const &...others) { return set.union_(others...); } template - typename __combined::type - union_(types::empty_set const &init, Types const &...others) + typename __combined::type union_(types::empty_set const &init, + Types const &...others) { return union_(others...); } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/slice.hpp b/contrib/python/pythran/pythran/pythonic/builtins/slice.hpp index 3a96dc79212..491761043a3 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/slice.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/slice.hpp @@ -15,8 +15,7 @@ namespace builtins { return {types::none(), stop}; } - inline types::cstride_slice<1> slice(types::none start, - types::none stop) + inline types::cstride_slice<1> slice(types::none start, types::none stop) { return {start, stop}; } @@ -29,4 +28,28 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::slice const &c) +{ + return (PyObject *)&PySlice_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PySlice_Type; +} + +inline builtins::functor::slice from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/sorted.hpp b/contrib/python/pythran/pythran/pythonic/builtins/sorted.hpp index c8e9e2efda2..d1764f78630 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/sorted.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/sorted.hpp @@ -15,51 +15,47 @@ namespace builtins { template - types::list::type::iterator>::value_type>::type> + types::list::iterator>::value_type>> sorted(Iterable &&seq) { - types::list::type::iterator>::value_type>::type> + types::list::iterator>::value_type>> out(seq.begin(), seq.end()); pdqsort(out.begin(), out.end()); return out; } template - types::list::type::iterator>::value_type>::type> - sorted(Iterable &&seq, Key const &key, bool reverse) + types::list::iterator>::value_type>> + sorted(Iterable &&seq, types::kwonly, Key const &key, bool reverse) { - using value_type = typename std::remove_cv::type::iterator>::value_type>::type; + using value_type = std::remove_cv_t< + typename std::iterator_traits::iterator>::value_type>; types::list out(seq.begin(), seq.end()); if (reverse) - pdqsort(out.begin(), out.end(), - [&key](value_type const &self, value_type const &other) { - return key(self) > key(other); - }); + pdqsort(out.begin(), out.end(), [&key](value_type const &self, value_type const &other) { + return key(self) > key(other); + }); else - pdqsort(out.begin(), out.end(), - [&key](value_type const &self, value_type const &other) { - return key(self) < key(other); - }); + pdqsort(out.begin(), out.end(), [&key](value_type const &self, value_type const &other) { + return key(self) < key(other); + }); return out; } template - types::list::type::iterator>::value_type>::type> - sorted(Iterable &&seq, types::none_type const &key, bool reverse) + types::list::iterator>::value_type>> + sorted(Iterable &&seq, types::kwonly, types::none_type const &key, bool reverse) { - using value_type = typename std::remove_cv::type::iterator>::value_type>::type; + using value_type = std::remove_cv_t< + typename std::iterator_traits::iterator>::value_type>; types::list out(seq.begin(), seq.end()); if (reverse) pdqsort(out.begin(), out.end(), - [](value_type const &self, value_type const &other) { - return self > other; - }); + [](value_type const &self, value_type const &other) { return self > other; }); else pdqsort(out.begin(), out.end()); return out; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str.hpp index ce0cf778ac7..91be37b3a1f 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str.hpp @@ -78,4 +78,28 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::str const &c) +{ + return (PyObject *)&PyUnicode_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUnicode_Type; +} + +inline builtins::functor::str from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/__mod__.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/__mod__.hpp index 2ea185e1f37..a3e4a0e11ff 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/__mod__.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/__mod__.hpp @@ -26,8 +26,7 @@ namespace builtins template void fmt(boost::format &f, Tuple const &a, utils::int_) { - fmt(f % std::get::value - I>(a), a, - utils::int_()); + fmt(f % std::get::value - I>(a), a, utils::int_()); } } // namespace details @@ -46,8 +45,7 @@ namespace builtins return fmter.str(); } template - types::str __mod__(types::str const &s, - types::array_tuple const &args) + types::str __mod__(types::str const &s, types::array_tuple const &args) { boost::format fmter(s.chars()); details::fmt(fmter, args, utils::int_()); diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/capitalize.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/capitalize.hpp index 743bbe8c2f4..e87c5d621ee 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/capitalize.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/capitalize.hpp @@ -21,8 +21,7 @@ namespace builtins else { types::str copy = s; copy.chars()[0] = ::toupper(s.chars()[0]); - std::transform(s.chars().begin() + 1, s.chars().end(), - copy.chars().begin() + 1, ::tolower); + std::transform(s.chars().begin() + 1, s.chars().end(), copy.chars().begin() + 1, ::tolower); return copy; } } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/endswith.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/endswith.hpp index 70fa51f46a0..3466c7def7b 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/endswith.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/endswith.hpp @@ -14,8 +14,7 @@ namespace builtins namespace str { - bool endswith(types::str const &s, types::str const &suffix, long start, - long end) + bool endswith(types::str const &s, types::str const &suffix, long start, long end) { if (end == -1) end = s.size(); diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/find.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/find.hpp index 20454838f6e..6adffdb83c3 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/find.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/find.hpp @@ -14,8 +14,7 @@ namespace builtins namespace str { - inline long find(types::str const &s, types::str const &value, long start, - long end) + inline long find(types::str const &s, types::str const &value, long start, long end) { if (end < 0) end += s.size(); diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/isalpha.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/isalpha.hpp index 4fa77567ba2..ae89a8b50fd 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/isalpha.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/isalpha.hpp @@ -16,8 +16,8 @@ namespace builtins bool isalpha(types::str const &s) { - return !s.empty() && std::all_of(s.chars().begin(), s.chars().end(), - (int (*)(int))std::isalpha); + return !s.empty() && + std::all_of(s.chars().begin(), s.chars().end(), (int (*)(int))std::isalpha); } } // namespace str } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/isdigit.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/isdigit.hpp index 43ffe5d5a7b..00384423bec 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/isdigit.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/isdigit.hpp @@ -18,8 +18,8 @@ namespace builtins bool isdigit(types::str const &s) { - return !s.empty() && std::all_of(s.chars().begin(), s.chars().end(), - (int (*)(int))std::isdigit); + return !s.empty() && + std::all_of(s.chars().begin(), s.chars().end(), (int (*)(int))std::isdigit); } } // namespace str } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/join.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/join.hpp index 38cf6fd963a..59923f893cf 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/join.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/join.hpp @@ -18,8 +18,8 @@ namespace builtins template types::str join(S const &s, types::str const &iterable) { - long ssize = std::distance(std::begin(s), std::end(s)) - - (std::is_same::value ? 0 : 1); + long ssize = + std::distance(std::begin(s), std::end(s)) - (std::is_same::value ? 0 : 1); /* first iterate over iterable to gather sizes */ size_t n = ssize * (iterable.size() - 1) + iterable.size(); @@ -42,15 +42,12 @@ namespace builtins } template - typename std::enable_if< - !std::is_same::type>::type, - types::str>::value && - std::is_same< - typename std::iterator_traits::type::iterator>::iterator_category, - std::random_access_iterator_tag>::value, - types::str>::type + std::enable_if_t< + !std::is_same>, types::str>::value && + std::is_same::iterator>::iterator_category, + std::random_access_iterator_tag>::value, + types::str> join(S const &s, Iterable &&iterable) { long ssize = builtins::functor::len{}(s); @@ -75,8 +72,7 @@ namespace builtins if (ssize) for (; iter != iterable.end(); ++iter) { auto chars = s.chars(); - oter = - std::copy(std::begin(chars), std::begin(chars) + ssize, oter); + oter = std::copy(std::begin(chars), std::begin(chars) + ssize, oter); auto tmp = *iter; auto const &stmp = tmp.chars(); oter = std::copy(stmp.begin(), stmp.end(), oter); @@ -92,12 +88,10 @@ namespace builtins } template - typename std::enable_if< - !std::is_same< - typename std::iterator_traits::type::iterator>::iterator_category, - std::random_access_iterator_tag>::value, - types::str>::type + std::enable_if_t::iterator>::iterator_category, + std::random_access_iterator_tag>::value, + types::str> join(S const &s, Iterable &&iterable) { types::str out; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/lower.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/lower.hpp index 417d01df6b3..ac0d739fda2 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/lower.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/lower.hpp @@ -17,8 +17,7 @@ namespace builtins types::str lower(types::str const &s) { types::str copy = s; - std::transform(s.chars().begin(), s.chars().end(), copy.chars().begin(), - ::tolower); + std::transform(s.chars().begin(), s.chars().end(), copy.chars().begin(), ::tolower); return copy; } } // namespace str diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/replace.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/replace.hpp index 7bd78647497..0c43ff03ba9 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/replace.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/replace.hpp @@ -27,9 +27,8 @@ namespace builtins if (!count || !haystack_next) { return {haystack}; } else { - size_t n = - 1 + std::max(self.size(), self.size() * (1 + new_pattern.size()) / - (1 + old_pattern.size())); + size_t n = 1 + std::max(self.size(), + self.size() * (1 + new_pattern.size()) / (1 + old_pattern.size())); char *buffer = utils::allocate(n); char *iter = buffer; diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/split.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/split.hpp index c7a20ee8b3a..7c5ac8cf708 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/split.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/split.hpp @@ -17,8 +17,7 @@ namespace builtins namespace str { - inline types::list split(types::str const &in, - types::str const &sep, long maxsplit) + inline types::list split(types::str const &in, types::str const &sep, long maxsplit) { types::str s = strip(in); types::list res(0); @@ -28,8 +27,7 @@ namespace builtins size_t current = 0; size_t next = 0; long numsplit = 0; - while (next != types::str::npos && - (numsplit++ < maxsplit || maxsplit == -1)) { + while (next != types::str::npos && (numsplit++ < maxsplit || maxsplit == -1)) { next = s.find_first_of(sep, current); res.push_back(s.substr(current, next - current)); current = next + 1; @@ -41,8 +39,8 @@ namespace builtins return res; } - inline types::list - split(types::str const &in, types::none_type const &, long maxsplit) + inline types::list split(types::str const &in, types::none_type const &, + long maxsplit) { types::str s = strip(in); types::list res(0); @@ -52,8 +50,7 @@ namespace builtins size_t current = 0; size_t next = 0; long numsplit = 0; - while (next != types::str::npos && - (numsplit++ < maxsplit || maxsplit == -1)) { + while (next != types::str::npos && (numsplit++ < maxsplit || maxsplit == -1)) { next = s.find_first_of(" \n\r\t", current); // from the pydoc, we skip any blank list size_t end = s.find_first_not_of(" \n\r\t", next); diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/splitlines.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/splitlines.hpp deleted file mode 100644 index 91fa344ada5..00000000000 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/splitlines.hpp +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef PYTHONIC_BUILTIN_STR_SPLITLINES_HPP -#define PYTHONIC_BUILTIN_STR_SPLITLINES_HPP - -#include "pythonic/include/builtins/str/splitlines.hpp" - -#include "pythonic/types/list.hpp" -#include "pythonic/types/str.hpp" -#include "pythonic/utils/functor.hpp" - -PYTHONIC_NS_BEGIN - -namespace builtins -{ - - namespace str - { - - inline types::list splitlines(types::str const &in, bool keepends) - { - auto const& in_ = in.chars(); - types::list res(0); - size_t current = 0; - const ssize_t adjust = keepends ? 1 : 0; - while (current < (size_t)in.size()) { - size_t next = in_.find("\n", current); - res.push_back(in_.substr(current, next - current + adjust)); - current = (next == types::str::npos) ? next : (next + 1); - } - return res; - } - - } // namespace str -} // namespace builtins -PYTHONIC_NS_END -#endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/startswith.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/startswith.hpp index 226388ca5f7..663413294fc 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/startswith.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/startswith.hpp @@ -14,13 +14,11 @@ namespace builtins namespace str { - bool startswith(types::str const &s, types::str const &prefix, long start, - long end) + bool startswith(types::str const &s, types::str const &prefix, long start, long end) { if (end < 0) end = s.size(); - return (end - start) >= prefix.size() && - s.compare(start, prefix.size(), prefix) == 0; + return (end - start) >= prefix.size() && s.compare(start, prefix.size(), prefix) == 0; } } // namespace str } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/strip.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/strip.hpp index e1cab71ee96..7d65a8ad6a9 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/strip.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/strip.hpp @@ -22,8 +22,7 @@ namespace builtins return types::str(); else return types::str(self.chars().begin() + first, - self.chars().begin() + self.find_last_not_of(to_del) + - 1); + self.chars().begin() + self.find_last_not_of(to_del) + 1); } } // namespace str } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/builtins/str/upper.hpp b/contrib/python/pythran/pythran/pythonic/builtins/str/upper.hpp index d90d583ec25..69e735aa78d 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/str/upper.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/str/upper.hpp @@ -17,8 +17,7 @@ namespace builtins types::str upper(types::str const &s) { types::str copy = s; - std::transform(s.chars().begin(), s.chars().end(), copy.chars().begin(), - ::toupper); + std::transform(s.chars().begin(), s.chars().end(), copy.chars().begin(), ::toupper); return copy; } } // namespace str diff --git a/contrib/python/pythran/pythran/pythonic/builtins/sum.hpp b/contrib/python/pythran/pythran/pythonic/builtins/sum.hpp index f583b1ae394..7d20143c1fd 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/sum.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/sum.hpp @@ -25,24 +25,20 @@ namespace builtins } template - auto - tuple_sum::operator()(Tuple const &t) -> decltype(std::get<0>(t)) + auto tuple_sum::operator()(Tuple const &t) -> decltype(std::get<0>(t)) { return std::get<0>(t); } } // namespace details template - auto sum(Iterable s, T start) - -> decltype(std::accumulate( - s.begin(), s.end(), - static_cast::type>( - start))) + auto sum(Iterable s, T start) -> decltype(std::accumulate( + s.begin(), s.end(), + static_cast::type>(start))) { return std::accumulate( s.begin(), s.end(), - static_cast::type>( - start)); + static_cast::type>(start)); } } // namespace builtins PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/builtins/tuple.hpp b/contrib/python/pythran/pythran/pythonic/builtins/tuple.hpp index 7abe56ad8f1..48b02da405d 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/tuple.hpp @@ -20,14 +20,12 @@ namespace builtins template /* this is far from perfect, but how to cope with the - difference between python tuples && c++ ones ? */ - typename std::enable_if < - types::len_of::type>::type>:: - value<0, types::dynamic_tuple::type>::type::iterator>::value_type>>::type - tuple(Iterable &&i) + difference between python tuples and c++ ones ? */ + std::enable_if_t < + types::len_of>>::value< + 0, types::dynamic_tuple>::iterator>::value_type>> + tuple(Iterable &&i) { return {i.begin(), i.end()}; } @@ -35,23 +33,18 @@ namespace builtins template /* specialization if we are capable to statically compute the size of the input */ - typename std::enable_if< - types::len_of::type>::type>::value >= 0, + std::enable_if_t< + types::len_of>>::value >= 0, types::array_tuple< - typename std::iterator_traits< - typename std::remove_cv::type>::type::iterator>::value_type, - types::len_of::type>::type>::value>>::type + typename std::iterator_traits>::iterator>::value_type, + types::len_of>>::value>> tuple(StaticIterable &&i) { types::array_tuple< - typename std::iterator_traits< - typename std::remove_cv::type>::type::iterator>::value_type, - types::len_of::type>::type>::value> + typename std::iterator_traits>::iterator>::value_type, + types::len_of>>::value> res; std::copy(i.begin(), i.end(), res.begin()); return res; @@ -59,4 +52,35 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(builtins::functor::tuple const &c) +{ + return (PyObject *)&PyTuple_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (obj == (PyObject *)&PyTuple_Type) + return true; + PyObject *Origin = PyObject_GetAttrString(obj, "__origin__"); + if (!Origin) + return false; + bool res = (Origin == (PyObject *)&PyTuple_Type); + Py_DECREF(Origin); + return res; +} + +inline builtins::functor::tuple from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/builtins/type.hpp b/contrib/python/pythran/pythran/pythonic/builtins/type.hpp index 401c566845e..6da95c0376f 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/type.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/type.hpp @@ -2,143 +2,16 @@ #define PYTHONIC_BUILTIN_TYPE_HPP #include "pythonic/include/builtins/type.hpp" +#include "pythonic/types/type.hpp" #include "pythonic/utils/functor.hpp" -#include "pythonic/builtins/bool_.hpp" -#include "pythonic/builtins/complex.hpp" -#include "pythonic/builtins/dict.hpp" -#include "pythonic/builtins/float_.hpp" -#include "pythonic/builtins/int_.hpp" -#include "pythonic/builtins/list.hpp" -#include "pythonic/builtins/set.hpp" -#include "pythonic/builtins/str.hpp" -#include "pythonic/builtins/tuple.hpp" -#include "pythonic/numpy/array.hpp" -#include "pythonic/numpy/byte.hpp" -#include "pythonic/numpy/float128.hpp" -#include "pythonic/numpy/float32.hpp" -#include "pythonic/numpy/int_.hpp" -#include "pythonic/numpy/intc.hpp" -#include "pythonic/numpy/longlong.hpp" -#include "pythonic/numpy/short_.hpp" -#include "pythonic/numpy/ubyte.hpp" -#include "pythonic/numpy/uint.hpp" -#include "pythonic/numpy/uintc.hpp" -#include "pythonic/numpy/ulonglong.hpp" -#include "pythonic/numpy/ushort.hpp" - PYTHONIC_NS_BEGIN namespace builtins { - template <> - struct type_functor { - using type = functor::bool_; - }; - template <> - struct type_functor { - using type = functor::float_; - }; - template <> - struct type_functor { - using type = functor::str; - }; - template - struct type_functor> { - using type = functor::complex; - }; - template <> - struct type_functor { - using type = functor::set; - }; - template - struct type_functor> { - using type = functor::set; - }; - template <> - struct type_functor { - using type = functor::list; - }; - template - struct type_functor> { - using type = functor::list; - }; - template - struct type_functor> { - using type = functor::list; - }; - template <> - struct type_functor { - using type = functor::dict; - }; - template - struct type_functor> { - using type = functor::dict; - }; - template - struct type_functor> { - using type = functor::tuple; - }; - template - struct type_functor> { - using type = functor::tuple; - }; - template - struct type_functor> { - using type = numpy::functor::array; - }; - template <> - struct type_functor { - using type = numpy::functor::byte; - }; - template <> - struct type_functor { - using type = numpy::functor::ubyte; - }; - template <> - struct type_functor { - using type = numpy::functor::short_; - }; - template <> - struct type_functor { - using type = numpy::functor::ushort; - }; - template <> - struct type_functor { - using type = numpy::functor::intc; - }; - template <> - struct type_functor { - using type = numpy::functor::uintc; - }; - template <> - struct type_functor { - using type = numpy::functor::int_; - }; - template <> - struct type_functor { - using type = numpy::functor::uint; - }; - template <> - struct type_functor { - using type = numpy::functor::longlong; - }; - template <> - struct type_functor { - using type = numpy::functor::ulonglong; - }; - template <> - struct type_functor { - using type = numpy::functor::float32; - }; - template <> - struct type_functor { - using type = numpy::functor::float128; - }; - template - typename type_functor::type type(T const &) + typename types::type_functor::type type(T const &) { return {}; } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/xrange.hpp b/contrib/python/pythran/pythran/pythonic/builtins/xrange.hpp index 696ac32089f..4cb7fc3cc27 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/xrange.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/xrange.hpp @@ -18,11 +18,9 @@ namespace builtins long _init_last(long _begin, long _end, long _step) { if (_step > 0) - return _begin + - std::max(0L, _step * ((_end - _begin + _step - 1) / _step)); + return _begin + std::max(0L, _step * ((_end - _begin + _step - 1) / _step)); else - return _begin + - std::min(0L, _step * ((_end - _begin + _step + 1) / _step)); + return _begin + std::min(0L, _step * ((_end - _begin + _step + 1) / _step)); } } // namespace @@ -74,8 +72,7 @@ namespace builtins return (value_ - other.value_) / step_; } - xrange::xrange(long b, long e, long s) - : begin_(b), end_(_init_last(b, e, s)), step_(s) + xrange::xrange(long b, long e, long s) : begin_(b), end_(_init_last(b, e, s)), step_(s) { } diff --git a/contrib/python/pythran/pythran/pythonic/builtins/zip.hpp b/contrib/python/pythran/pythran/pythonic/builtins/zip.hpp index 3fb8c045218..1587846698c 100644 --- a/contrib/python/pythran/pythran/pythonic/builtins/zip.hpp +++ b/contrib/python/pythran/pythran/pythonic/builtins/zip.hpp @@ -12,8 +12,7 @@ namespace builtins { template - auto zip(Iter &&...iters) -> decltype(map(builtins::None, - std::forward(iters)...)) + auto zip(Iter &&...iters) -> decltype(map(builtins::None, std::forward(iters)...)) { return map(builtins::None, std::forward(iters)...); } diff --git a/contrib/python/pythran/pythran/pythonic/core.hpp b/contrib/python/pythran/pythran/pythonic/core.hpp index 844d944cb53..bd989e18c40 100644 --- a/contrib/python/pythran/pythran/pythonic/core.hpp +++ b/contrib/python/pythran/pythran/pythonic/core.hpp @@ -2,13 +2,13 @@ #ifndef PYTHONIC_CORE_HPP #define PYTHONIC_CORE_HPP -#define PYTHONIC_NS_BEGIN \ - namespace \ - { \ - namespace pythonic \ +#define PYTHONIC_NS_BEGIN \ + namespace \ + { \ + namespace pythonic \ { -#define PYTHONIC_NS_END \ - } \ +#define PYTHONIC_NS_END \ + } \ } // mostly to flag '_' as unused in generated code @@ -29,6 +29,11 @@ // clang-format on #ifdef ENABLE_PYTHON_MODULE + +#if defined(Py_LIMITED_API) && Py_LIMITED_API < 0x03070000 +#error Pythran only supports Py_LIMITED_API from 0x03070000 upward +#endif + // Define python's visibility macros #include "pyconfig.h" diff --git a/contrib/python/pythran/pythran/pythonic/functools/partial.hpp b/contrib/python/pythran/pythran/pythonic/functools/partial.hpp index e2a2df85e75..b109267686d 100644 --- a/contrib/python/pythran/pythran/pythonic/functools/partial.hpp +++ b/contrib/python/pythran/pythran/pythonic/functools/partial.hpp @@ -22,28 +22,24 @@ namespace functools } template - task::task(ClosureTypes const &...types) - : closure(types...) + task::task(ClosureTypes const &...types) : closure(types...) { } template template auto task::operator()(Types &&...types) const - -> decltype(this->call( - utils::make_index_sequence(), - std::forward(types)...)) + -> decltype(this->call(std::make_index_sequence(), + std::forward(types)...)) { - return call(utils::make_index_sequence(), + return call(std::make_index_sequence(), std::forward(types)...); } } // namespace details template // remove references as closure capture the env by copy - details::task::type>::type...> - partial(Types &&...types) + details::task>...> partial(Types &&...types) { return {std::forward(types)...}; } diff --git a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/count.hpp b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/count.hpp index 8dcc6fcca1a..7d0b16a1015 100644 --- a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/count.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/count.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace __dispatch__ { template - auto count(Any &&any, - Value &&value) -> decltype(any.count(std::forward(value))); + auto count(Any &&any, Value &&value) -> decltype(any.count(std::forward(value))); DEFINE_FUNCTOR(pythonic::__dispatch__, count); } // namespace __dispatch__ diff --git a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/pop.hpp b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/pop.hpp index ac37c2e6533..a488c74c11c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/pop.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/pop.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace __dispatch__ { template - auto pop(Any &&any, - Arg0 &&...arg0) -> decltype(any.pop(std::forward(arg0)...)); + auto pop(Any &&any, Arg0 &&...arg0) -> decltype(any.pop(std::forward(arg0)...)); DEFINE_FUNCTOR(pythonic::__dispatch__, pop); } // namespace __dispatch__ diff --git a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/sort.hpp b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/sort.hpp index d57b8c2f38b..2ebd7e1c9b3 100644 --- a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/sort.hpp @@ -11,12 +11,10 @@ namespace __dispatch__ template auto sort(types::list &l, Args &&...args) - -> decltype(pythonic::builtins::list::sort(l, - std::forward(args)...)); + -> decltype(pythonic::builtins::list::sort(l, std::forward(args)...)); template auto sort(types::list &&l, Args &&...args) - -> decltype(pythonic::builtins::list::sort(std::move(l), - std::forward(args)...)); + -> decltype(pythonic::builtins::list::sort(std::move(l), std::forward(args)...)); template types::none_type sort(Any &&any, Args &&...args); diff --git a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/tolist.hpp b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/tolist.hpp index 199ee3fc9b4..ced21d067d9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/tolist.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/tolist.hpp @@ -15,32 +15,28 @@ namespace __dispatch__ } template - types::list< - typename std::conditional::value, long, double>::type> + types::list::value, long, double>> tolist(types::sliced_array &&a) { return {a.begin(), a.end()}; } template - types::list< - typename std::conditional::value, long, double>::type> + types::list::value, long, double>> tolist(types::sliced_array const &a) { return {a.begin(), a.end()}; } template - types::list< - typename std::conditional::value, long, double>::type> + types::list::value, long, double>> tolist(types::array &&a) { return {a.begin(), a.end()}; } template - types::list< - typename std::conditional::value, long, double>::type> + types::list::value, long, double>> tolist(types::array const &a) { return {a.begin(), a.end()}; diff --git a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/update.hpp b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/update.hpp index 258c9f6b86b..5ab229290f4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/__dispatch__/update.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/__dispatch__/update.hpp @@ -9,8 +9,7 @@ namespace __dispatch__ { template - auto update(Any &&any, Arg0 &&...arg0) - -> decltype(any.update(std::forward(arg0)...)); + auto update(Any &&any, Arg0 &&...arg0) -> decltype(any.update(std::forward(arg0)...)); DEFINE_FUNCTOR(pythonic::__dispatch__, update); } // namespace __dispatch__ diff --git a/contrib/python/pythran/pythran/pythonic/include/array/array.hpp b/contrib/python/pythran/pythran/pythonic/include/array/array.hpp index 1c076e11dd7..10e78b7b233 100644 --- a/contrib/python/pythran/pythran/pythonic/include/array/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/array/array.hpp @@ -66,12 +66,11 @@ namespace array }; template - types::array::type> - array(std::integral_constant); + types::array::type> array(std::integral_constant); template - types::array::type> - array(std::integral_constant, E &&elts); + types::array::type> array(std::integral_constant, + E &&elts); } // namespace details DEFINE_FUNCTOR(pythonic::array::details, array); diff --git a/contrib/python/pythran/pythran/pythonic/include/bisect/bisect.hpp b/contrib/python/pythran/pythran/pythonic/include/bisect/bisect.hpp index 3d54ae8a094..e0c1cb11950 100644 --- a/contrib/python/pythran/pythran/pythonic/include/bisect/bisect.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/bisect/bisect.hpp @@ -12,19 +12,18 @@ namespace bisect namespace details { template - using bisect_fun = - decltype(std::upper_bound); + using bisect_fun = decltype(std::upper_bound); } template - long bisect(X const &x, A const &a, long lo = 0, - details::bisect_fun const &fun = - std::upper_bound); + long + bisect(X const &x, A const &a, long lo = 0, + details::bisect_fun const &fun = std::upper_bound); template - long bisect(X const &x, A const &a, long lo, long hi, - details::bisect_fun const &fun = - std::upper_bound); + long + bisect(X const &x, A const &a, long lo, long hi, + details::bisect_fun const &fun = std::upper_bound); DEFINE_FUNCTOR(pythonic::bisect, bisect); } // namespace bisect diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/bin.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/bin.hpp index f507ec4b55d..a6b178966c0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/bin.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/bin.hpp @@ -12,8 +12,7 @@ PYTHONIC_NS_BEGIN namespace builtins { template - typename std::enable_if::value, types::str>::type - bin(T const &v); + std::enable_if_t::value, types::str> bin(T const &v); DEFINE_FUNCTOR(pythonic::builtins, bin); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/bool_.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/bool_.hpp index f0fdd1b52e5..7b28c833109 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/bool_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/bool_.hpp @@ -36,4 +36,22 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::bool_ const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::bool_ convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/complex.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/complex.hpp index 1ad6bc6dfee..86a1bcbb030 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/complex.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/complex.hpp @@ -25,4 +25,23 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::complex const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::complex convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/dict.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/dict.hpp index f4fdb169832..60d7ccd9cd2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/dict.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/dict.hpp @@ -21,14 +21,30 @@ namespace builtins template auto dict(Iterable &&iterable) - -> types::dict< - typename std::decay(*iterable.begin()))>::type, - typename std::decay< - decltype(std::get<1>(*iterable.begin()))>::type>; + -> types::dict(*iterable.begin()))>, + std::decay_t(*iterable.begin()))>>; } // namespace anonymous DEFINE_FUNCTOR(pythonic::builtins::anonymous, dict); } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::dict const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::dict convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/dict/fromkeys.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/dict/fromkeys.hpp index d06ff6ee574..0c84ad4799f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/dict/fromkeys.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/dict/fromkeys.hpp @@ -16,7 +16,7 @@ namespace builtins { template - types::dict::type::value_type, V> + types::dict::value_type, V> fromkeys(Iterable &&iter, V const &v = builtins::None); DEFINE_FUNCTOR(pythonic::builtins::dict, fromkeys); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/dict/get.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/dict/get.hpp index be4e976f4af..ffccb65f462 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/dict/get.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/dict/get.hpp @@ -14,8 +14,7 @@ namespace builtins { template - typename __combined::type get(types::dict const &d, W const &k, - X const &default_); + typename __combined::type get(types::dict const &d, W const &k, X const &default_); template types::none get(types::dict const &d, W const &k); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/enumerate.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/enumerate.hpp index e2e10a8e412..ed989a34c62 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/enumerate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/enumerate.hpp @@ -17,8 +17,7 @@ namespace builtins template using enumerate_iterator_base = std::iterator< typename std::iterator_traits::iterator_category, - types::make_tuple_t< - long, typename std::iterator_traits::value_type>>; + types::make_tuple_t::value_type>>; template struct enumerate_iterator : public enumerate_iterator_base { @@ -45,9 +44,8 @@ namespace builtins template struct enumerate : private Iterable, /* to hold a reference on the iterable */ - public enumerate_iterator< - typename Iterable::iterator> /* to be compatible with - builtins.next*/ + public enumerate_iterator /* to be compatible with + builtins.next*/ { using iterator = enumerate_iterator; using iterator::operator*; @@ -64,8 +62,7 @@ namespace builtins } // namespace details template - details::enumerate::type>::type> + details::enumerate>> enumerate(Iterable &&seq, long first = 0L); DEFINE_FUNCTOR(pythonic::builtins, enumerate); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/file.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/file.hpp index fbe7b70e4b1..f5618da1693 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/file.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/file.hpp @@ -12,8 +12,7 @@ namespace builtins namespace anonymous { - types::file file(types::str const &filename, - types::str const &strmode = "r"); + types::file file(types::str const &filename, types::str const &strmode = "r"); } DEFINE_FUNCTOR(pythonic::builtins::anonymous, file); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/filter.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/filter.hpp index 80081481fa7..cfc783dfca5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/filter.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/filter.hpp @@ -14,10 +14,8 @@ namespace builtins { template - struct filter_iterator - : std::iterator { - using sequence_type = typename std::remove_cv< - typename std::remove_reference::type>::type; + struct filter_iterator : std::iterator { + using sequence_type = std::remove_cv_t>; Operator op; typename List0::iterator iter; @@ -47,10 +45,9 @@ namespace builtins // and avoid a dangling reference // FIXME: It would be better to have a copy only if needed but Pythran // typing is not good enough for this as arguments have - // remove_cv/remove_ref + // remove_cv_t/remove_ref_t template - struct filter : utils::iterator_reminder, - filter_iterator { + struct filter : utils::iterator_reminder, filter_iterator { using value_type = typename List0::value_type; using iterator = filter_iterator; @@ -67,10 +64,8 @@ namespace builtins } // namespace details template - details::filter::type>::type, - typename std::remove_cv< - typename std::remove_reference::type>::type> + details::filter>, + std::remove_cv_t>> filter(Operator &&_op, List0 &&_seq); DEFINE_FUNCTOR(pythonic::builtins, filter); @@ -82,9 +77,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/float_.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/float_.hpp index 15ca376ccf2..e854e29871e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/float_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/float_.hpp @@ -28,4 +28,23 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::float_ const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::float_ convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/isinstance.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/isinstance.hpp index 806cd0ee29f..288c8482bad 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/isinstance.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/isinstance.hpp @@ -11,8 +11,7 @@ namespace types class str; template - struct isinstance - : std::conditional::value, true_type, false_type> { + struct isinstance : std::conditional::value, true_type, false_type> { }; // some specialization @@ -33,20 +32,17 @@ namespace builtins { template struct isinstance { - using type = typename types::isinstance< - Obj, - typename std::decay()())>::type>::type; + using type = + typename types::isinstance()())>>::type; }; template struct isinstance> { - using type = typename std::conditional< + using type = std::conditional_t< utils::any_of()())>::type>::type, + typename types::isinstance()())>>::type, types::true_type>::value...>::value, - types::true_type, types::false_type>::type; + types::true_type, types::false_type>; }; } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/iter.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/iter.hpp index 7c252347b7a..ec9da68560f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/iter.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/iter.hpp @@ -26,9 +26,7 @@ namespace builtins } // namespace details template - details::iter< - typename std::remove_cv::type>::type> - iter(T &&t); + details::iter>> iter(T &&t); DEFINE_FUNCTOR(pythonic::builtins, iter); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/len.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/len.hpp index d884ee5c382..376d016779c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/len.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/len.hpp @@ -16,8 +16,7 @@ namespace builtins long len(std::tuple const &); template - typename std::enable_if::value, long>::type - len(T const &t); + std::enable_if_t::value, long> len(T const &t); DEFINE_FUNCTOR(pythonic::builtins, len); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/list.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/list.hpp index aba29bc9c1f..b710bc5da62 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/list.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/list.hpp @@ -19,9 +19,8 @@ namespace builtins inline types::empty_list list(types::empty_list); template - types::list::type::iterator>::value_type>:: - type> + types::list::iterator>::value_type>> list(Iterable &&t); } // namespace anonymous @@ -29,4 +28,23 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::list const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::list convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/list/extend.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/list/extend.hpp index bac4c967049..5bc27c30313 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/list/extend.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/list/extend.hpp @@ -14,15 +14,11 @@ namespace builtins { template - typename std::enable_if< - !std::is_same::type, types::empty_list>::value, - types::none_type>::type + std::enable_if_t, types::empty_list>::value, types::none_type> extend(T0 &&seq, T1 const &add); template - typename std::enable_if< - std::is_same::type, types::empty_list>::value, - types::none_type>::type + std::enable_if_t, types::empty_list>::value, types::none_type> extend(T0 &&seq, T1 const &add); DEFINE_FUNCTOR(pythonic::builtins::list, extend); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/map.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/map.hpp index 788106712cf..9691775f17f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/map.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/map.hpp @@ -22,32 +22,28 @@ namespace builtins template struct map_res { using type = decltype(std::declval()( - std::declval::value_type>()...)); + std::declval::value_type>()...)); }; template struct map_res { using type = decltype(types::make_tuple( - std::declval::value_type>()...)); + std::declval::value_type>()...)); }; template struct map_iterator - : std::iterator< - typename utils::iterator_min::type, - typename map_res::type> { + : std::iterator::type, + typename map_res::type> { std::tuple it; Operator _op; map_iterator() = default; template - map_iterator(Operator const &_op, std::tuple &_iters, - utils::index_sequence); + map_iterator(Operator const &_op, std::tuple &_iters, std::index_sequence); template - map_iterator(itertools::npos, Operator const &_op, - std::tuple &_iters, utils::index_sequence); + map_iterator(itertools::npos, Operator const &_op, std::tuple &_iters, + std::index_sequence); typename map_res::type operator*() const; map_iterator &operator++(); @@ -56,42 +52,43 @@ namespace builtins bool operator==(map_iterator const &other) const; bool operator!=(map_iterator const &other) const; bool operator<(map_iterator const &other) const; + bool operator<=(map_iterator const &other) const; long operator-(map_iterator const &other) const; private: template - long min_len(map_iterator const &other, - utils::int_) const; - long min_len(map_iterator const &other, - utils::int_<0>) const; + long min_len(map_iterator const &other, utils::int_) const; + long min_len(map_iterator const &other, utils::int_<0>) const; template bool equal(map_iterator const &other, utils::int_) const; bool equal(map_iterator const &other, utils::int_<0>) const; + template + bool lt(map_iterator const &other, utils::int_) const; + bool lt(map_iterator const &other, utils::int_<0>) const; + template void advance(long i, utils::int_); void advance(long i, utils::int_<0>); template - void next(utils::index_sequence); + void next(std::index_sequence); template - typename map_res::type - get_value(utils::index_sequence, std::true_type) const; + typename map_res::type get_value(std::index_sequence, + std::true_type) const; template - typename map_res::type - get_value(utils::index_sequence, std::false_type) const; + typename map_res::type get_value(std::index_sequence, + std::false_type) const; }; template - struct map : utils::iterator_reminder, - map_iterator { + struct map : utils::iterator_reminder, map_iterator { using iterator = map_iterator; using value_type = typename iterator::value_type; using dtype = typename types::dtype_of::type; - static constexpr long value = - 1 + utils::nested_container_depth::value; + static constexpr long value = 1 + utils::nested_container_depth::value; iterator end_iter; @@ -107,12 +104,9 @@ namespace builtins } // namespace details template - auto map(Operator &&_op, Iter &&...iters) - -> details::map< - typename std::remove_cv< - typename std::remove_reference::type>::type, - typename types::iterator::type>::type>::type...>; + details::map>, + typename types::iterator>>::type...> + map(Operator &&_op, Iter &&...iters); DEFINE_FUNCTOR(pythonic::builtins, map); } // namespace builtins @@ -122,16 +116,13 @@ namespace types template struct len_of> { - static constexpr long value = len_of::type>::type>::value; + static constexpr long value = len_of>>::value; }; template struct len_of> { - static constexpr long _head = len_of::type>::type>::value; - static constexpr long _tail = - len_of>::value; + static constexpr long _head = len_of>>::value; + static constexpr long _tail = len_of>::value; // take the minimal value. If one is negative, it will be automatically // selected static constexpr long value = (_head < _tail ? _head : _tail); @@ -144,9 +135,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/max.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/max.hpp index 6ece9c33542..9092e07f027 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/max.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/max.hpp @@ -12,8 +12,7 @@ namespace builtins template auto max(Types &&...values) - -> decltype(details::minmax(operator_::functor::lt{}, - std::forward(values)...)); + -> decltype(details::minmax(operator_::functor::lt{}, std::forward(values)...)); DEFINE_FUNCTOR(pythonic::builtins, max); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/min.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/min.hpp index 4aabbaed453..a2676ae4d8c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/min.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/min.hpp @@ -11,8 +11,7 @@ namespace builtins { template auto min(Types &&...values) - -> decltype(details::minmax(operator_::functor::gt{}, - std::forward(values)...)); + -> decltype(details::minmax(operator_::functor::gt{}, std::forward(values)...)); DEFINE_FUNCTOR(pythonic::builtins, min); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/minmax.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/minmax.hpp index 68f894dc0fc..c248aef4194 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/minmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/minmax.hpp @@ -11,15 +11,14 @@ namespace builtins namespace details { template - typename std::decay::type::value_type minmax(Op const &, T &&t); + typename std::decay_t::value_type minmax(Op const &, T &&t); template - typename std::decay::type::value_type minmax(Op const &, T &&t, - types::kwonly, F key); + typename std::decay_t::value_type minmax(Op const &, T &&t, types::kwonly, F key); template - typename std::enable_if::value, - typename __combined::type>::type + std::enable_if_t::value, + typename __combined::type> minmax(Op const &, T0 const &, T1 const &, Types const &...); } // namespace details } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/pow.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/pow.hpp index c31526d7eb0..e077987e08a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/pow.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/pow.hpp @@ -16,8 +16,7 @@ namespace builtins long pow(long, std::integral_constant); template - auto pow(Types &&...args) - -> decltype(numpy::functor::power{}(std::forward(args)...)); + auto pow(Types &&...args) -> decltype(numpy::functor::power{}(std::forward(args)...)); DEFINE_FUNCTOR(pythonic::builtins, pow); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_if.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_if.hpp index bafed1af01a..e9d4b588de1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_if.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_if.hpp @@ -55,9 +55,8 @@ namespace builtins } template auto operator()(Args &&...args) const -> - typename __combined< - decltype(f0(std::forward(args)...)), - decltype(f1(std::forward(args)...))>::type + typename __combined(args)...)), + decltype(f1(std::forward(args)...))>::type { if (state_) return f0(std::forward(args)...); @@ -74,8 +73,7 @@ namespace builtins }; } // namespace details template - auto static_if(T const &cond, F0 f0, - F1 f1) -> decltype(details::static_if{cond}(f0, f1)); + auto static_if(T const &cond, F0 f0, F1 f1) -> decltype(details::static_if{cond}(f0, f1)); template auto static_if(int const &cond, F0 f0, F1 f1) diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_list.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_list.hpp index cc3067bc0ea..6d8e32be351 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_list.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/pythran/static_list.hpp @@ -24,16 +24,14 @@ namespace builtins types::static_list static_list(types::array_tuple &&other); template - auto static_list(T &&other) -> decltype(pythonic::builtins::functor::list{}( - std::forward(other))); + auto static_list(T &&other) + -> decltype(pythonic::builtins::functor::list{}(std::forward(other))); template - types::static_list::type, - 1 + sizeof...(Tys)> + types::static_list::type, 1 + sizeof...(Tys)> static_list(std::tuple const &other) { - return static_list( - types::to_array::type>(other)); + return static_list(types::to_array::type>(other)); } DEFINE_FUNCTOR(pythonic::builtins::pythran, static_list); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/range.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/range.hpp index 7c40b6dcd6e..65abe9a7d9f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/range.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/range.hpp @@ -10,9 +10,8 @@ namespace builtins { namespace { - struct range_iterator - : std::iterator { + struct range_iterator : std::iterator { long value_; long step_; @@ -28,6 +27,7 @@ namespace builtins bool operator!=(range_iterator const &other) const; bool operator==(range_iterator const &other) const; bool operator<(range_iterator const &other) const; + bool operator<=(range_iterator const &other) const; long operator-(range_iterator const &other) const; }; } // namespace diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/reduce.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/reduce.hpp index 75791102f44..2226a10b132 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/reduce.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/reduce.hpp @@ -12,28 +12,25 @@ namespace builtins { template - auto reduce(Operator op, Iterable s) - -> decltype(op(std::declval::value_type>(), - std::declval::value_type>())); + auto reduce(Operator op, Iterable s) -> decltype(op( + std::declval::value_type>(), + std::declval::value_type>())); // this convoluted expression computes the fixed-point type of the output // it's required because, e.g. static_list + static_list // returns array_tuple // and this widens to list template - using reduce_helper_t = typename __combined< - T, decltype(std::declval()( - std::declval(), - std::declval::value_type>()))>::type; + using reduce_helper_t = + typename __combined()( + std::declval(), + std::declval::value_type>()))>::type; template auto reduce(Operator op, Iterable s, T const &init) - -> decltype(std::accumulate( - s.begin(), s.end(), - static_cast>(init), op)); + -> decltype(std::accumulate(s.begin(), s.end(), + static_cast>(init), op)); DEFINE_FUNCTOR(pythonic::builtins, reduce); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set.hpp index 6bff4e9b7a1..c7366fa2276 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set.hpp @@ -15,11 +15,29 @@ namespace builtins template inline types::set::type::iterator>::value_type> + typename std::remove_reference_t::iterator>::value_type> set(Iterable &&t); } // namespace anonymous DEFINE_FUNCTOR(pythonic::builtins::anonymous, set); } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::set const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::set convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference.hpp index bdc34bc830a..fbb308bfc5e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference.hpp @@ -19,8 +19,7 @@ namespace builtins types::set difference(types::set &&set, Types const &...others); template - types::empty_set difference(types::empty_set const &set, - Types const &...others); + types::empty_set difference(types::empty_set const &set, Types const &...others); template types::set difference(types::set const &set); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference_update.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference_update.hpp index 7514ad93b06..836cd626d93 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/difference_update.hpp @@ -13,16 +13,13 @@ namespace builtins { template - types::none_type difference_update(types::set &set, - Types const &...others); + types::none_type difference_update(types::set &set, Types const &...others); template - types::none_type difference_update(types::set &&set, - Types const &...others); + types::none_type difference_update(types::set &&set, Types const &...others); template - types::none_type difference_update(types::empty_set const &set, - Types const &...others); + types::none_type difference_update(types::empty_set const &set, Types const &...others); DEFINE_FUNCTOR(pythonic::builtins::set, difference_update); } // namespace set diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection.hpp index 3a33b6bca59..7a2479d8066 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection.hpp @@ -13,8 +13,8 @@ namespace builtins { template - typename __combined, Types...>::type - intersection(types::set const &set, Types const &...others); + typename __combined, Types...>::type intersection(types::set const &set, + Types const &...others); /* No rvalue overload possible because of return type modification.: * >>> a = set([1,2,3]) @@ -23,8 +23,7 @@ namespace builtins * set([1.0, 2.0, 3.0]) */ template - types::empty_set intersection(types::empty_set const &set, - Types const &...others); + types::empty_set intersection(types::empty_set const &set, Types const &...others); DEFINE_FUNCTOR(pythonic::builtins::set, intersection); } // namespace set diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection_update.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection_update.hpp index a9fd1bdfc5c..2f1cb320258 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/intersection_update.hpp @@ -13,16 +13,13 @@ namespace builtins { template - types::none_type intersection_update(types::set &set, - Types const &...others); + types::none_type intersection_update(types::set &set, Types const &...others); template - types::none_type intersection_update(types::set &&set, - Types const &...others); + types::none_type intersection_update(types::set &&set, Types const &...others); template - types::none_type intersection_update(types::empty_set &&set, - Types const &...others); + types::none_type intersection_update(types::empty_set &&set, Types const &...others); DEFINE_FUNCTOR(pythonic::builtins::set, intersection_update); } // namespace set diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference.hpp index a58e3635ccc..584dacfecb5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference.hpp @@ -13,8 +13,8 @@ namespace builtins { template - typename __combined, U>::type - symmetric_difference(types::set const &set, U const &other); + typename __combined, U>::type symmetric_difference(types::set const &set, + U const &other); /* No rvalue overload possible because of return type modification.: * >>> a = set([1, 2, 3]) @@ -25,8 +25,8 @@ namespace builtins // combiner is used as other may be list but return is a set template - typename __combined::type - symmetric_difference(types::empty_set const &set, U const &other); + typename __combined::type symmetric_difference(types::empty_set const &set, + U const &other); DEFINE_FUNCTOR(pythonic::builtins::set, symmetric_difference); } // namespace set diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference_update.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference_update.hpp index 71b68679fa9..f0b32416662 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference_update.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/symmetric_difference_update.hpp @@ -13,16 +13,13 @@ namespace builtins { template - types::none_type symmetric_difference_update(types::set &set, - U const &other); + types::none_type symmetric_difference_update(types::set &set, U const &other); template - types::none_type symmetric_difference_update(types::set &&set, - U const &other); + types::none_type symmetric_difference_update(types::set &&set, U const &other); template - types::none_type symmetric_difference_update(types::empty_set const &set, - U const &other); + types::none_type symmetric_difference_update(types::empty_set const &set, U const &other); DEFINE_FUNCTOR(pythonic::builtins::set, symmetric_difference_update); } // namespace set diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/set/union_.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/set/union_.hpp index 2e561dd825b..284d6dda7f8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/set/union_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/set/union_.hpp @@ -13,12 +13,12 @@ namespace builtins { template - typename __combined, Types...>::type - union_(types::set const &set, Types const &...others); + typename __combined, Types...>::type union_(types::set const &set, + Types const &...others); template - typename __combined::type - union_(types::empty_set const &init, Types const &...others); + typename __combined::type union_(types::empty_set const &init, + Types const &...others); template types::set union_(types::set const &set); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/slice.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/slice.hpp index e8437d11a5f..f18d1c35bc5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/slice.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/slice.hpp @@ -12,14 +12,31 @@ namespace builtins namespace anonymous { types::cstride_slice<1> slice(types::none stop); - types::cstride_slice<1> slice(types::none start, - types::none stop); - types::slice slice(types::none start, types::none stop, - types::none step); + types::cstride_slice<1> slice(types::none start, types::none stop); + types::slice slice(types::none start, types::none stop, types::none step); } // namespace anonymous DEFINE_FUNCTOR(pythonic::builtins::anonymous, slice); } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::slice const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::slice convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/sorted.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/sorted.hpp index 61553dbdde5..2d89595adc5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/sorted.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/sorted.hpp @@ -1,6 +1,7 @@ #ifndef PYTHONIC_INCLUDE_BUILTIN_SORTED_HPP #define PYTHONIC_INCLUDE_BUILTIN_SORTED_HPP +#include "pythonic/include/builtins/pythran/kwonly.hpp" #include "pythonic/include/types/list.hpp" #include "pythonic/include/utils/functor.hpp" @@ -10,19 +11,35 @@ namespace builtins { template - types::list::type::iterator>::value_type>::type> + types::list::iterator>::value_type>> sorted(Iterable &&seq); template - types::list::type::iterator>::value_type>::type> - sorted(Iterable &&seq, Key const &key, bool reverse = false); + types::list::iterator>::value_type>> + sorted(Iterable &&seq, types::kwonly, Key const &key, bool reverse = false); template - types::list::type::iterator>::value_type>::type> - sorted(Iterable &&seq, types::none_type const &key, bool reverse = false); + types::list::iterator>::value_type>> + sorted(Iterable &&seq, types::kwonly, types::none_type const &key, bool reverse = false); + + template + types::list::iterator>::value_type>> + sorted(Iterable &&seq, Key const &key, bool reverse = false) + { + return sorted(std::forward(seq), types::kwonly{}, key, reverse); + } + + template + types::list::iterator>::value_type>> + sorted(Iterable &&seq, types::kwonly, bool reverse) + { + return sorted(std::forward(seq), types::kwonly{}, types::none_type{}, reverse); + } DEFINE_FUNCTOR(pythonic::builtins, sorted); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str.hpp index 4adf0379b6b..6430128ee98 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str.hpp @@ -24,4 +24,23 @@ namespace builtins } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::str const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::str convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/__mod__.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/__mod__.hpp index 5a687fd6f72..45b28b2e84b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/__mod__.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/__mod__.hpp @@ -16,8 +16,7 @@ namespace builtins template types::str __mod__(types::str const &, std::tuple const &args); template - types::str __mod__(types::str const &, - types::array_tuple const &args); + types::str __mod__(types::str const &, types::array_tuple const &args); DEFINE_FUNCTOR(pythonic::builtins::str, __mod__); } // namespace str diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/endswith.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/endswith.hpp index 4772df1d17f..c4d4b207ad6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/endswith.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/endswith.hpp @@ -13,8 +13,7 @@ namespace builtins { // TODO : Add implementation for tuple as first argument. - bool endswith(types::str const &s, types::str const &suffix, long start = 0, - long end = -1); + bool endswith(types::str const &s, types::str const &suffix, long start = 0, long end = -1); DEFINE_FUNCTOR(pythonic::builtins::str, endswith); } // namespace str diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/find.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/find.hpp index f7563e670b2..ba6dcf5fdd8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/find.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/find.hpp @@ -12,8 +12,7 @@ namespace builtins namespace str { - long find(types::str const &s, types::str const &value, long start, - long end); + long find(types::str const &s, types::str const &value, long start, long end); long find(types::str const &s, types::str const &value, long start); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/join.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/join.hpp index cac5684f615..5bef5d694ce 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/join.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/join.hpp @@ -18,25 +18,20 @@ namespace builtins /* Join for string.join(random acces iter but ! on string) */ template - typename std::enable_if< - !std::is_same::type>::type, - types::str>::value && - std::is_same< - typename std::iterator_traits::type::iterator>::iterator_category, - std::random_access_iterator_tag>::value, - types::str>::type + std::enable_if_t< + !std::is_same>, types::str>::value && + std::is_same::iterator>::iterator_category, + std::random_access_iterator_tag>::value, + types::str> join(S const &s, Iterable &&iterable); /* Join for string.join(forward iterator) */ template - typename std::enable_if< - !std::is_same< - typename std::iterator_traits::type::iterator>::iterator_category, - std::random_access_iterator_tag>::value, - types::str>::type + std::enable_if_t::iterator>::iterator_category, + std::random_access_iterator_tag>::value, + types::str> join(S const &s, Iterable &&iterable); DEFINE_FUNCTOR(pythonic::builtins::str, join); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/split.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/split.hpp index 43304c4b3e6..aa6ac1bb9d8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/split.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/split.hpp @@ -14,11 +14,9 @@ namespace builtins namespace str { - types::list split(types::str const &in, types::str const &sep, - long maxsplit = -1); + types::list split(types::str const &in, types::str const &sep, long maxsplit = -1); - types::list split(types::str const &s, - types::none_type const & = {}, + types::list split(types::str const &s, types::none_type const & = {}, long maxsplit = -1); DEFINE_FUNCTOR(pythonic::builtins::str, split); diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/splitlines.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/splitlines.hpp deleted file mode 100644 index 8bc7a3c45c0..00000000000 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/splitlines.hpp +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef PYTHONIC_INCLUDE_BUILTIN_STR_SPLITLINES_HPP -#define PYTHONIC_INCLUDE_BUILTIN_STR_SPLITLINES_HPP - -#include "pythonic/include/types/list.hpp" -#include "pythonic/include/types/str.hpp" -#include "pythonic/include/utils/functor.hpp" - -PYTHONIC_NS_BEGIN - -namespace builtins -{ - - namespace str - { - - types::list splitlines(types::str const &in, bool keepends = false); - - DEFINE_FUNCTOR(pythonic::builtins::str, splitlines); - } -} -PYTHONIC_NS_END -#endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/str/startswith.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/str/startswith.hpp index 41fe3878271..79a1d93423b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/str/startswith.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/str/startswith.hpp @@ -12,8 +12,7 @@ namespace builtins namespace str { - bool startswith(types::str const &s, types::str const &prefix, - long start = 0, long end = -1); + bool startswith(types::str const &s, types::str const &prefix, long start = 0, long end = -1); DEFINE_FUNCTOR(pythonic::builtins::str, startswith); } // namespace str diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/sum.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/sum.hpp index dd5adfce71a..d6f23419af7 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/sum.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/sum.hpp @@ -17,8 +17,7 @@ namespace builtins { template struct tuple_sum { - auto operator()(Tuple const &t) -> decltype(std::get(t) + - tuple_sum()(t)); + auto operator()(Tuple const &t) -> decltype(std::get(t) + tuple_sum()(t)); }; template @@ -28,11 +27,9 @@ namespace builtins } // namespace details template - auto sum(Iterable s, T start) - -> decltype(std::accumulate( - s.begin(), s.end(), - static_cast::type>( - start))); + auto sum(Iterable s, T start) -> decltype(std::accumulate( + s.begin(), s.end(), + static_cast::type>(start))); template auto sum(Iterable s) -> decltype(sum(s, 0L)) @@ -42,8 +39,7 @@ namespace builtins template auto sum(std::tuple const &t) - -> decltype(details::tuple_sum, - sizeof...(Types) - 1>()(t)) + -> decltype(details::tuple_sum, sizeof...(Types) - 1>()(t)) { return details::tuple_sum, sizeof...(Types) - 1>()(t); } diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/tuple.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/tuple.hpp index 1dcdcfa40df..5034178e5f0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/tuple.hpp @@ -13,33 +13,50 @@ namespace builtins template std::tuple tuple(std::tuple const &t); + inline std::tuple<> tuple() + { + return {}; + } + template /* this is far from perfect, but how to cope with the difference between python tuples && c++ ones ? */ - typename std::enable_if < - types::len_of::type>::type>:: - value<0, types::dynamic_tuple::type>::type::iterator>::value_type>>::type - tuple(Iterable &&i); - - template < - class StaticIterable> /* specialization if we are capable to statically - compute the size of the input */ - typename std::enable_if< - types::len_of::type>::type>::value >= 0, + std::enable_if_t < + types::len_of>>::value< + 0, types::dynamic_tuple>::iterator>::value_type>> + tuple(Iterable &&i); + + template /* specialization if we are capable to statically + compute the size of the input */ + std::enable_if_t< + types::len_of>>::value >= 0, types::array_tuple< - typename std::iterator_traits< - typename std::remove_cv::type>::type::iterator>::value_type, - types::len_of::type>::type>::value>>::type + typename std::iterator_traits>::iterator>::value_type, + types::len_of>>::value>> tuple(StaticIterable &&i); DEFINE_FUNCTOR(pythonic::builtins, tuple); } // namespace builtins PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(builtins::functor::tuple const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static builtins::functor::tuple convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/type.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/type.hpp index bd50e722b84..40ba8418a05 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/type.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/type.hpp @@ -1,15 +1,14 @@ #ifndef PYTHONIC_INCLUDE_BUILTIN_TYPE_HPP #define PYTHONIC_INCLUDE_BUILTIN_TYPE_HPP +#include "pythonic/include/types/type.hpp" + PYTHONIC_NS_BEGIN namespace builtins { template - struct type_functor; - - template - typename type_functor::type type(T const &t); + typename types::type_functor::type type(T const &t); DEFINE_FUNCTOR(pythonic::builtins, type); } // namespace builtins PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/xrange.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/xrange.hpp index 9b2d17d0d46..fb2dd1a6ed6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/xrange.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/xrange.hpp @@ -11,9 +11,8 @@ namespace builtins namespace { - struct xrange_iterator - : std::iterator { + struct xrange_iterator : std::iterator { long value_; long step_; diff --git a/contrib/python/pythran/pythran/pythonic/include/builtins/zip.hpp b/contrib/python/pythran/pythran/pythonic/include/builtins/zip.hpp index 731f91eecdd..47c214f7067 100644 --- a/contrib/python/pythran/pythran/pythonic/include/builtins/zip.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/builtins/zip.hpp @@ -10,8 +10,7 @@ namespace builtins { template - auto zip(Iter &&...iters) -> decltype(map(builtins::None, - std::forward(iters)...)); + auto zip(Iter &&...iters) -> decltype(map(builtins::None, std::forward(iters)...)); DEFINE_FUNCTOR(pythonic::builtins, zip); } // namespace builtins diff --git a/contrib/python/pythran/pythran/pythonic/include/functools/partial.hpp b/contrib/python/pythran/pythran/pythonic/include/functools/partial.hpp index 9fdf30ee90b..2fe16636959 100644 --- a/contrib/python/pythran/pythran/pythonic/include/functools/partial.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/functools/partial.hpp @@ -36,27 +36,23 @@ namespace functools task(ClosureTypes const &...types); template - auto call(utils::index_sequence, Types &&...types) const + auto call(std::index_sequence, Types &&...types) const -> decltype(std::get<0>(closure)(std::get(closure)..., std::forward(types)...)) { - return std::get<0>(closure)(std::get(closure)..., - std::forward(types)...); + return std::get<0>(closure)(std::get(closure)..., std::forward(types)...); } template auto operator()(Types &&...types) const - -> decltype(this->call( - utils::make_index_sequence(), - std::forward(types)...)); + -> decltype(this->call(std::make_index_sequence(), + std::forward(types)...)); }; } // namespace details template // remove references as closure capture the env by copy - details::task::type>::type...> - partial(Types &&...types); + details::task>...> partial(Types &&...types); DEFINE_FUNCTOR(pythonic::functools, partial); } // namespace functools diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/combinations.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/combinations.hpp index 9b7894033b8..8ba9375426d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/combinations.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/combinations.hpp @@ -16,20 +16,15 @@ namespace itertools { template struct combination_iterator - : std::iterator, ptrdiff_t, - types::dynamic_tuple *, + : std::iterator, + ptrdiff_t, types::dynamic_tuple *, types::dynamic_tuple /*no ref*/ > { - std::vector> - pool; + std::vector> pool; std::vector> indices; long r; bool stopped; - std::vector> - result; + std::vector> result; combination_iterator() = default; combination_iterator(bool); @@ -62,9 +57,8 @@ namespace itertools } // namespace details template - details::combination< - typename std::remove_cv::type>::type> - combinations(T0 &&iter, long num_elts); + details::combination>> combinations(T0 &&iter, + long num_elts); DEFINE_FUNCTOR(pythonic::itertools, combinations); } // namespace itertools @@ -75,9 +69,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/count.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/count.hpp index 06e93d9658a..90316b47ea1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/count.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/count.hpp @@ -41,8 +41,7 @@ namespace itertools } // namespace details template - details::count::type> count(T0 start, - T1 step = 1); + details::count::type> count(T0 start, T1 step = 1); details::count count(); @@ -55,9 +54,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/ifilter.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/ifilter.hpp index bc5c33dcf4e..692bced42af 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/ifilter.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/ifilter.hpp @@ -15,10 +15,8 @@ namespace itertools { template - details::filter::type>::type, - typename std::remove_cv< - typename std::remove_reference::type>::type> + details::filter>, + std::remove_cv_t>> ifilter(Operator &&_op, List0 &&_seq); DEFINE_FUNCTOR(pythonic::itertools, ifilter); diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/islice.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/islice.hpp index b6545a0a02b..e4075e4ac19 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/islice.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/islice.hpp @@ -13,12 +13,9 @@ namespace itertools template struct islice_iterator : std::iterator::value_type> { - typename std::remove_reference< - typename std::remove_cv::type>::type iterable_ref; - typename std::remove_reference< - typename std::remove_cv::type>::type::iterator iterable; + typename std::iterator_traits::value_type> { + std::remove_reference_t> iterable_ref; + typename std::remove_reference_t>::iterator iterable; builtins::range xr_ref; builtins::range_iterator state; @@ -26,8 +23,7 @@ namespace itertools islice_iterator(); islice_iterator(Iterable const &iterable, builtins::range const &xr); - islice_iterator(npos const &n, Iterable const &iterable, - builtins::range const &xr); + islice_iterator(npos const &n, Iterable const &iterable, builtins::range const &xr); typename Iterable::value_type operator*() const; islice_iterator &operator++(); @@ -54,14 +50,12 @@ namespace itertools }; template - _islice::type>::type> + _islice>> islice(Iterable &&iterable, long start, long stop, long step = 1); template - _islice::type>::type> - islice(Iterable &&iterable, long stop); + _islice>> islice(Iterable &&iterable, + long stop); DEFINE_FUNCTOR(pythonic::itertools, islice); } // namespace itertools @@ -72,8 +66,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = typename __combined< - E, container::value_type>>::type; + using type = + typename __combined::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/permutations.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/permutations.hpp index 7b0630622ca..bc780083d66 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/permutations.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/permutations.hpp @@ -30,13 +30,12 @@ namespace itertools * */ template - struct permutations_iterator : std::iterator { + struct permutations_iterator + : std::iterator { // Vector of inputs, contains elements to permute - using pool_type = std::vector>; + using pool_type = std::vector>; pool_type pool; // The current permutation as a dynamic_tuple of index in the pool @@ -80,12 +79,11 @@ namespace itertools }; template - _permutations> - permutations(T0 iter, long num_elts); + _permutations> permutations(T0 iter, + long num_elts); template - _permutations> - permutations(T0 iter); + _permutations> permutations(T0 iter); template _permutations> @@ -100,10 +98,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/product.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/product.hpp index 070726c630d..e0cbdfde20b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/product.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/product.hpp @@ -19,9 +19,8 @@ namespace itertools // FIXME : should be a combined_iterator_tag template - struct product_iterator - : std::iterator> { + struct product_iterator : std::iterator> { std::tuple const it_begin; std::tuple const it_end; @@ -30,11 +29,9 @@ namespace itertools product_iterator() = default; template - product_iterator(std::tuple &_iters, - utils::index_sequence const &); + product_iterator(std::tuple &_iters, std::index_sequence const &); template - product_iterator(npos, std::tuple &_iters, - utils::index_sequence const &); + product_iterator(npos, std::tuple &_iters, std::index_sequence const &); types::make_tuple_t operator*() const; product_iterator &operator++(); bool operator==(product_iterator const &other) const; @@ -47,12 +44,11 @@ namespace itertools void advance(utils::int_<0>); template types::make_tuple_t - get_value(utils::index_sequence const &) const; + get_value(std::index_sequence const &) const; }; template - struct product : utils::iterator_reminder, - product_iterator { + struct product : utils::iterator_reminder, product_iterator { using value_type = types::make_tuple_t; using iterator = product_iterator; @@ -69,9 +65,7 @@ namespace itertools } // namespace details template - details::product::type>::type...> - product(Iter &&...iters); + details::product>...> product(Iter &&...iters); DEFINE_FUNCTOR(pythonic::itertools, product); } // namespace itertools @@ -82,9 +76,8 @@ PYTHONIC_NS_END template struct __combined> { - using type = - typename __combined::value_type>>::type; + using type = typename __combined< + E, container::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/itertools/repeat.hpp b/contrib/python/pythran/pythran/pythonic/include/itertools/repeat.hpp index 477a789af5b..9c48d91c582 100644 --- a/contrib/python/pythran/pythran/pythonic/include/itertools/repeat.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/itertools/repeat.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace itertools { template - struct repeat_iterator : std::iterator { T value_; long count_; @@ -51,9 +50,9 @@ PYTHONIC_NS_END template struct __combined> { - using type = typename __combined< - E, - container::value_type>>::type; + using type = + typename __combined::value_type>>::type; }; /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/all.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/all.hpp index cfe8caf1bed..877b2c55e8f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/all.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/all.hpp @@ -10,29 +10,24 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, bool>::type + std::enable_if_t::value, bool> all(E const &expr, types::none_type _ = types::none_type()); template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, bool>::type + std::enable_if_t::value || types::is_complex::value, bool> all(E const &expr, types::none_type _ = types::none_type()); template - auto all(E const &array, long axis) -> - typename std::enable_if::value || - types::is_complex::value, - decltype(all(array))>::type; + auto all(E const &array, long axis) + -> std::enable_if_t::value || types::is_complex::value, + decltype(all(array))>; template - auto all(E const &array, long axis) -> - typename std::enable_if::type; + auto all(E const &array, long axis) -> std::enable_if_t; template - typename std::enable_if< - E::value != 1, - types::ndarray>>::type + std::enable_if_t>> all(E const &array, long axis); DEFINE_FUNCTOR(pythonic::numpy, all); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/alltrue.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/alltrue.hpp index e73ff3660ab..5e96ce5851a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/alltrue.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/alltrue.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto - alltrue(Types &&...types) -> decltype(all(std::forward(types)...)); + auto alltrue(Types &&...types) -> decltype(all(std::forward(types)...)); DEFINE_FUNCTOR(pythonic::numpy, alltrue); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/angle_in_rad.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/angle_in_rad.hpp index a0d032753a2..a292a56fe3f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/angle_in_rad.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/angle_in_rad.hpp @@ -17,8 +17,7 @@ namespace numpy namespace wrapper { template - auto angle_in_rad(T const &t) -> decltype(std::atan2(std::imag(t), - std::real(t))); + auto angle_in_rad(T const &t) -> decltype(std::atan2(std::imag(t), std::real(t))); } #define NUMPY_NARY_FUNC_NAME angle_in_rad #define NUMPY_NARY_FUNC_SYM wrapper::angle_in_rad diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/any.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/any.hpp index 044005a66a9..0c0e7c896db 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/any.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/any.hpp @@ -10,29 +10,24 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, bool>::type + std::enable_if_t::value, bool> any(E const &expr, types::none_type _ = types::none_type()); template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, bool>::type + std::enable_if_t::value || types::is_complex::value, bool> any(E const &expr, types::none_type _ = types::none_type()); template - auto any(E const &array, long axis) -> - typename std::enable_if::value || - types::is_complex::value, - decltype(any(array))>::type; + auto any(E const &array, long axis) + -> std::enable_if_t::value || types::is_complex::value, + decltype(any(array))>; template - auto any(E const &array, long axis) -> - typename std::enable_if::type; + auto any(E const &array, long axis) -> std::enable_if_t; template - typename std::enable_if< - E::value != 1, - types::ndarray>>::type + std::enable_if_t>> any(E const &array, long axis); DEFINE_FUNCTOR(pythonic::numpy, any); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/append.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/append.hpp index c78901598c4..f3ae8800d98 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/append.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/append.hpp @@ -9,19 +9,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - !types::is_dtype::value, - types::ndarray< - typename __combined::type>::type, - types::pshape>>::type + std::enable_if_t::value, + types::ndarray::type>::type, + types::pshape>> append(types::ndarray const &nto, F const &data); template - typename std::enable_if< - types::is_dtype::value, - types::ndarray< - typename __combined::type>::type, - types::pshape>>::type + std::enable_if_t::value, + types::ndarray::type>::type, + types::pshape>> append(types::ndarray const &nto, F const &data); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/arange.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/arange.hpp index 7148c517313..14e06ec3c81 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/arange.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/arange.hpp @@ -70,8 +70,7 @@ namespace numpy { return index_ < other.index_; } - arange_simd_iterator & - operator=(arange_simd_iterator const &other) = default; + arange_simd_iterator &operator=(arange_simd_iterator const &other) = default; }; #endif template @@ -120,9 +119,7 @@ namespace numpy { auto ns = s.normalize(size); arange_index r{start + s.lower * step, step * ns.step, ns.size()}; - return { - types::numpy_expr{ - r}}; + return {types::numpy_expr{r}}; } types::ndarray operator()(types::slice s) const { @@ -130,33 +127,26 @@ namespace numpy } template - types::ndarray - operator[](types::cstride_slice s) const + types::ndarray operator[](types::cstride_slice s) const { auto ns = s.normalize(size); arange_index r{start + s.lower * step, step * stride, ns.size()}; - return { - types::numpy_expr{ - r}}; + return {types::numpy_expr{r}}; } template - types::ndarray - operator()(types::cstride_slice s) const + types::ndarray operator()(types::cstride_slice s) const { return operator[](s); } template - auto operator()(S const &...s) const -> - typename std::enable_if< - (sizeof...(S) > 1), - decltype(std::declval>()( - s...))>::type + auto operator()(S const &...s) const + -> std::enable_if_t<(sizeof...(S) > 1), + decltype(std::declval>()(s...))> { return types::ndarray{ - types::numpy_expr{ - *this}}(s...); + types::numpy_expr{*this}}(s...); } const_iterator begin() const { @@ -180,8 +170,7 @@ namespace numpy template ::type>> - types::numpy_expr> + types::numpy_expr> arange(T begin, U end, S step = S(1), dtype d = dtype()); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/argmax.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/argmax.hpp index bc8de17e626..091fec0e07e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/argmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/argmax.hpp @@ -13,8 +13,7 @@ namespace numpy long argmax(E const &expr); template - types::ndarray> - argmax(E const &expr, long axis); + types::ndarray> argmax(E const &expr, long axis); DEFINE_FUNCTOR(pythonic::numpy, argmax); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/argmin.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/argmin.hpp index 126ac3bb8c0..deb9ee0552a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/argmin.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/argmin.hpp @@ -12,8 +12,7 @@ namespace numpy long argmin(E const &expr); template - types::ndarray> - argmin(E const &expr, long axis); + types::ndarray> argmin(E const &expr, long axis); DEFINE_FUNCTOR(pythonic::numpy, argmin); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/argsort.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/argsort.hpp index 6926de372e5..9240e39dc62 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/argsort.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/argsort.hpp @@ -9,12 +9,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - argsort(E const &expr, types::none_type, types::none_type = {}); + types::ndarray> argsort(E const &expr, types::none_type, + types::none_type = {}); template - types::ndarray argsort(types::ndarray const &a, - long axis = -1, types::none_type kind = {}); + types::ndarray argsort(types::ndarray const &a, long axis = -1, + types::none_type kind = {}); template types::ndarray argsort(types::ndarray const &a, long axis, diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/argwhere.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/argwhere.hpp index 90107d2f584..6d9d30acb00 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/argwhere.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/argwhere.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename types::ndarray> - argwhere(E const &expr); + typename types::ndarray> argwhere(E const &expr); DEFINE_FUNCTOR(pythonic::numpy, argwhere); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/around.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/around.hpp index 4e9ae04c522..42ebb913395 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/around.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/around.hpp @@ -17,29 +17,21 @@ namespace numpy // generic floating point version, pure numpy_expr template - auto around(E &&a, long decimals) -> - typename std::enable_if< - !std::is_integral::type>::type>::value, - decltype(functor::rint{}(functor::multiply{}( - std::forward(a), - std::declval::type>::type>())) / - std::declval::type>::type>())>::type; + auto around(E &&a, long decimals) -> std::enable_if_t< + !std::is_integral>::type>::value, + decltype(functor::rint{}(functor::multiply{}( + std::forward(a), + std::declval>::type>())) / + std::declval>::type>())>; // the integer version is only relevant when decimals < 0 template - auto around(E &&a, long decimals) -> - typename std::enable_if< - std::is_integral::type>::type>::value, - decltype(numpy::functor::floor_divide{}( - functor::float64{}(std::forward(a)), - std::declval::type>::type>()) * - std::declval::type>::type>())>::type; + auto around(E &&a, long decimals) -> std::enable_if_t< + std::is_integral>::type>::value, + decltype(numpy::functor::floor_divide{}( + functor::float64{}(std::forward(a)), + std::declval>::type>()) * + std::declval>::type>())>; DEFINE_FUNCTOR(pythonic::numpy, around); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/array.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/array.hpp index d64ec19f4cc..9b58cdcdef5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/array.hpp @@ -9,48 +9,36 @@ PYTHONIC_NS_BEGIN namespace numpy { - template ::type::dtype>> - typename std::enable_if< - types::has_size::type>::value, - types::ndarray::type::value>>>:: - type - array(T &&iterable, dtype d = dtype()); - template ::type::dtype>> - typename std::enable_if< - !types::has_size::type>::value && - !types::is_dtype::type>::value, - types::ndarray::type::value>>>:: - type - array(T &&iterable, dtype d = dtype()); - - template ::type>::type>> - typename std::enable_if< - !types::has_size::type>::value && - types::is_dtype::type>::value, - typename dtype::type>::type + template ::dtype>> + std::enable_if_t< + types::has_size>::value, + types::ndarray::value>>> + array(T &&iterable, dtype d = dtype()); + template ::dtype>> + std::enable_if_t< + !types::has_size>::value && !types::is_dtype>::value, + types::ndarray::value>>> + array(T &&iterable, dtype d = dtype()); + + template >::type>> + std::enable_if_t>::value && + types::is_dtype>::value, + typename dtype::type> array(T &&non_iterable, dtype d = dtype()); template - types::ndarray>> + types::ndarray>> array(std::tuple<>, dtype); template types::ndarray array(types::ndarray const &arr); template > - types::ndarray::shape_t> + types::ndarray::shape_t> array(types::array_base const &, dtype d = dtype()); template > - types::ndarray::shape_t> + types::ndarray::shape_t> array(types::array_base &&, dtype d = dtype()); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/array_equiv.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/array_equiv.hpp index d79c84c6a56..c0e2c053053 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/array_equiv.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/array_equiv.hpp @@ -10,16 +10,13 @@ namespace numpy { template - typename std::enable_if::type - array_equiv(U const &u, V const &v); + std::enable_if_t array_equiv(U const &u, V const &v); template - typename std::enable_if < - U::value::type array_equiv(U const &u, V const &v); + std::enable_if_t < U::value array_equiv(U const &u, V const &v); template - typename std::enable_if<(U::value > V::value), bool>::type - array_equiv(U const &u, V const &v); + std::enable_if_t<(U::value > V::value), bool> array_equiv(U const &u, V const &v); DEFINE_FUNCTOR(pythonic::numpy, array_equiv); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/array_split.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/array_split.hpp index d425c02e2e0..4ccbd69358d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/array_split.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/array_split.hpp @@ -9,17 +9,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::list()[types::fast_contiguous_slice()])>::type> + types::list< + typename assignable()[types::fast_contiguous_slice()])>::type> array_split(E const &a, long nb_split); template - typename std::enable_if< - types::is_iterable::value, - types::list()[types::fast_contiguous_slice()])>::type>>:: - type - array_split(E const &a, I const &split_mask); + std::enable_if_t::value, + types::list()[types::fast_contiguous_slice()])>::type>> + array_split(E const &a, I const &split_mask); NUMPY_EXPR_TO_NDARRAY0_DECL(array_split); DEFINE_FUNCTOR(pythonic::numpy, array_split); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/asarray.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/asarray.hpp index 40377c3ea2f..1d3552a459f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/asarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/asarray.hpp @@ -12,8 +12,7 @@ namespace numpy template struct _asarray { template - auto operator()(Types &&...args) - -> decltype(array(std::forward(args)...)); + auto operator()(Types &&...args) -> decltype(array(std::forward(args)...)); }; template @@ -24,15 +23,12 @@ namespace numpy template auto asarray(E &&e, types::none_type d = types::none_type()) - -> decltype(_asarray::type, - typename types::dtype_of< - typename std::decay::type>::type>{}( + -> decltype(_asarray, typename types::dtype_of>::type>{}( std::forward(e))); template auto asarray(E &&e, dtype d) - -> decltype(_asarray::type, - typename dtype::type>{}(std::forward(e), d)); + -> decltype(_asarray, typename dtype::type>{}(std::forward(e), d)); DEFINE_FUNCTOR(pythonic::numpy, asarray); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/asfarray.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/asfarray.hpp index 114543d279b..eb14f4a1698 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/asfarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/asfarray.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto asfarray(E &&e, - dtype d = dtype()) -> decltype(asarray(std::forward(e), d)); + auto asfarray(E &&e, dtype d = dtype()) -> decltype(asarray(std::forward(e), d)); DEFINE_FUNCTOR(pythonic::numpy, asfarray); } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/asscalar.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/asscalar.hpp index ef2c5f6cba2..8ef3a758362 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/asscalar.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/asscalar.hpp @@ -10,10 +10,9 @@ PYTHONIC_NS_BEGIN namespace numpy { template - using asscalar_result_type = typename std::conditional< + using asscalar_result_type = std::conditional_t< std::is_integral::value, long, - typename std::conditional::value, double, - std::complex>::type>::type; + std::conditional_t::value, double, std::complex>>; template asscalar_result_type asscalar(E const &expr); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_1d.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_1d.hpp index f6a43e51281..19ccb5643b2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_1d.hpp @@ -8,15 +8,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray>>>::type + std::enable_if_t::value, + types::ndarray>>> atleast_1d(T t); template - auto atleast_1d(T const &t) -> - typename std::enable_if::value), - decltype(asarray(t))>::type; + auto atleast_1d(T const &t) -> std::enable_if_t::value, decltype(asarray(t))>; DEFINE_FUNCTOR(pythonic::numpy, atleast_1d); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_2d.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_2d.hpp index b882ae747a0..d48675a4729 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_2d.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_2d.hpp @@ -8,29 +8,22 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray, - std::integral_constant>>>::type + std::enable_if_t::value, + types::ndarray, + std::integral_constant>>> atleast_2d(T t); template - auto atleast_2d(T const &t) -> - typename std::enable_if < (!types::is_dtype::value) && - T::value<2, - types::ndarray< - typename T::dtype, - types::pshape, - typename std::tuple_element< - 0, typename T::shape_t>::type>>>::type; + auto atleast_2d(T const &t) -> std::enable_if_t < (!types::is_dtype::value) && + T::value<2, types::ndarray, + std::tuple_element_t<0, typename T::shape_t>>>>; template - auto atleast_2d(T &&t) -> - typename std::enable_if< - (!types::is_dtype::type>::type>::value) && - std::decay::type::value >= 2, - decltype(std::forward(t))>::type; + auto atleast_2d(T &&t) + -> std::enable_if_t<(!types::is_dtype>>::value) && + std::decay_t::value >= 2, + decltype(std::forward(t))>; DEFINE_FUNCTOR(pythonic::numpy, atleast_2d); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_3d.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_3d.hpp index b7720c10228..fae16ec7a80 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_3d.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/atleast_3d.hpp @@ -8,37 +8,28 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray, - std::integral_constant, - std::integral_constant>>>::type + std::enable_if_t::value, + types::ndarray, + std::integral_constant, + std::integral_constant>>> atleast_3d(T t); template - auto atleast_3d(T const &t) -> - typename std::enable_if< - (!types::is_dtype::value) && (T::value == 1), - types::ndarray, - typename std::tuple_element< - 0, typename T::shape_t>::type, - std::integral_constant>>>::type; + auto atleast_3d(T const &t) -> std::enable_if_t< + (!types::is_dtype::value) && (T::value == 1), + types::ndarray, + std::tuple_element_t<0, typename T::shape_t>, + std::integral_constant>>>; template - auto atleast_3d(T const &t) -> - typename std::enable_if< - (!types::is_dtype::value) && (T::value == 2), - types::ndarray< - typename T::dtype, - types::pshape< - typename std::tuple_element<0, typename T::shape_t>::type, - typename std::tuple_element<1, typename T::shape_t>::type, - std::integral_constant>>>::type; + auto atleast_3d(T const &t) -> std::enable_if_t< + (!types::is_dtype::value) && (T::value == 2), + types::ndarray, + std::tuple_element_t<1, typename T::shape_t>, + std::integral_constant>>>; template - auto atleast_3d(T const &t) -> - typename std::enable_if<(!types::is_dtype::value) && T::value >= 3, - decltype(asarray(t))>::type; + auto atleast_3d(T const &t) + -> std::enable_if_t<(!types::is_dtype::value) && T::value >= 3, decltype(asarray(t))>; DEFINE_FUNCTOR(pythonic::numpy, atleast_3d); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/bincount.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/bincount.hpp index 087b41f5503..774dd8b4c0f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/bincount.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/bincount.hpp @@ -9,18 +9,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value == 1, - types::ndarray>>::type - bincount(types::ndarray const &expr, - types::none_type weights = builtins::None, + std::enable_if_t::value == 1, types::ndarray>> + bincount(types::ndarray const &expr, types::none_type weights = builtins::None, types::none minlength = builtins::None); template - typename std::enable_if< + std::enable_if_t< std::tuple_size::value == 1, - types::ndarray() * - std::declval()), - types::pshape>>::type + types::ndarray() * std::declval()), + types::pshape>> bincount(types::ndarray const &expr, E const &weights, types::none minlength = builtins::None); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/broadcast_to.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/broadcast_to.hpp index cc3f14b825c..623633651c4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/broadcast_to.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/broadcast_to.hpp @@ -10,9 +10,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto broadcast_to(E const &expr, pS shape) - -> decltype(numpy::functor::empty{}( - shape, typename types::dtype_t::type>{})); + auto broadcast_to(E const &expr, pS shape) -> decltype(numpy::functor::empty{}( + shape, typename types::dtype_t::type>{})); DEFINE_FUNCTOR(pythonic::numpy, broadcast_to); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/byte.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/byte.hpp index c7478f393f7..c17ad8dd038 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/byte.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/byte.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::byte const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::byte convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/clip.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/clip.hpp index 3d5e11ab6e3..8f4988667e0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/clip.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/clip.hpp @@ -30,18 +30,18 @@ namespace numpy #define NUMPY_NARY_FUNC_NAME clip #define NUMPY_NARY_FUNC_SYM wrapper::clip -#define NUMPY_NARY_EXTRA_METHOD \ - template \ - auto operator()(T &&v, Mi &&a_min, types::none_type) \ - ->decltype((*this)(std::forward(v), std::forward(a_min))) \ - { \ - return (*this)(std::forward(v), std::forward(a_min)); \ - } \ - template \ - auto operator()(T &&v, types::none_type, Ma &&a_max) \ - ->decltype(_clip_max{}(std::forward(v), std::forward(a_max))) \ - { \ - return _clip_max{}(std::forward(v), std::forward(a_max)); \ +#define NUMPY_NARY_EXTRA_METHOD \ + template \ + auto operator()(T &&v, Mi &&a_min, types::none_type) \ + ->decltype((*this)(std::forward(v), std::forward(a_min))) \ + { \ + return (*this)(std::forward(v), std::forward(a_min)); \ + } \ + template \ + auto operator()(T &&v, types::none_type, Ma &&a_max) \ + ->decltype(_clip_max{}(std::forward(v), std::forward(a_max))) \ + { \ + return _clip_max{}(std::forward(v), std::forward(a_max)); \ } #include "pythonic/include/types/numpy_nary_expr.hpp" diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/complex128.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/complex128.hpp index cc7a4730131..b45cf434824 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/complex128.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/complex128.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::complex128 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::complex128 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/complex256.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/complex256.hpp index caed53d6376..4fc49a5e803 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/complex256.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/complex256.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::complex256 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::complex256 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/complex64.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/complex64.hpp index f09026f40d7..a4f46f2f6da 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/complex64.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/complex64.hpp @@ -26,5 +26,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::complex64 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::complex64 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/concatenate.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/concatenate.hpp index a5033900ecf..c4e1d6b9a30 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/concatenate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/concatenate.hpp @@ -13,11 +13,9 @@ namespace numpy concatenate(types::array_base const &args, long axis = 0); template - auto concatenate(std::tuple const &args, long axis = 0) - -> types::ndarray< - typename __combined::type::dtype...>::type, - types::array_tuple< - long, std::tuple_element<0, std::tuple>::type::value>>; + auto concatenate(std::tuple const &args, long axis = 0) -> types::ndarray< + typename __combined::dtype...>::type, + types::array_tuple>::value>>; template types::ndarray> diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/conjugate.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/conjugate.hpp index 442d2ccb08d..28399d6da8e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/conjugate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/conjugate.hpp @@ -8,9 +8,8 @@ #include // Inject some extra symbol in xsimd namespace, until that's fixed upstream -#if XSIMD_VERSION_MAJOR < 8 || \ - (XSIMD_VERSION_MAJOR == 8 && XSIMD_VERSION_MINOR == 0 && \ - XSIMD_VERSION_PATCH <= 5) +#if XSIMD_VERSION_MAJOR < 8 || \ + (XSIMD_VERSION_MAJOR == 8 && XSIMD_VERSION_MINOR == 0 && XSIMD_VERSION_PATCH <= 5) namespace xsimd { using std::conj; @@ -29,8 +28,7 @@ namespace numpy return std::conj(v); } template - xsimd::batch, A> - conjugate(xsimd::batch, A> const &v) + xsimd::batch, A> conjugate(xsimd::batch, A> const &v) { return xsimd::conj(v); } diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/convolve.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/convolve.hpp index dd63f4ec2d9..09859ad40a1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/convolve.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/convolve.hpp @@ -9,12 +9,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - convolve(A const &inA, B const &inB, U renorm = types::str("full")); + types::ndarray> convolve(A const &inA, B const &inB, + U renorm = types::str("full")); template - types::ndarray> convolve(A const &inA, - B const &inB); + types::ndarray> convolve(A const &inA, B const &inB); NUMPY_EXPR_TO_NDARRAY0_DECL(convolve) DEFINE_FUNCTOR(pythonic::numpy, convolve) diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/copy.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/copy.hpp index 952f0407354..c53a836f63b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/copy.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/copy.hpp @@ -11,22 +11,17 @@ namespace numpy { // list case template - typename std::enable_if< - !types::is_array::value && !types::is_dtype::value, - types::ndarray>>::type + std::enable_if_t::value && !types::is_dtype::value, + types::ndarray>> copy(E const &v); // scalar / complex case template - auto copy(E const &v) -> - typename std::enable_if::value, E>::type; + auto copy(E const &v) -> std::enable_if_t::value, E>; // No copy is required for numpy_expr template - auto copy(E &&v) -> - typename std::enable_if::value, - decltype(std::forward(v))>::type; + auto copy(E &&v) -> std::enable_if_t::value, decltype(std::forward(v))>; // ndarray case template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/copyto.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/copyto.hpp index 07854fec2e5..e15d9bbb9b5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/copyto.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/copyto.hpp @@ -14,12 +14,10 @@ namespace numpy types::none_type copyto(types::ndarray &&out, E const &expr); template - types::none_type copyto(types::numpy_texpr> &out, - E const &expr); + types::none_type copyto(types::numpy_texpr> &out, E const &expr); template - types::none_type copyto(types::numpy_texpr> &&out, - E const &expr); + types::none_type copyto(types::numpy_texpr> &&out, E const &expr); // pythran extensions template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/correlate.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/correlate.hpp index 6e6216b78a4..69c10b6c789 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/correlate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/correlate.hpp @@ -10,8 +10,7 @@ namespace numpy { template types::ndarray> - correlate(A const &inA, B const &inB, - types::str const &renorm = types::str("valid")); + correlate(A const &inA, B const &inB, types::str const &renorm = types::str("valid")); NUMPY_EXPR_TO_NDARRAY0_DECL(correlate) DEFINE_FUNCTOR(pythonic::numpy, correlate) diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/count_nonzero.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/count_nonzero.hpp index 3a140881bf2..5b915814dac 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/count_nonzero.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/count_nonzero.hpp @@ -10,12 +10,12 @@ namespace numpy { template - auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) -> - typename std::enable_if::value>::type; + auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) + -> std::enable_if_t::value>; template - auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) -> - typename std::enable_if::value>::type; + auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) + -> std::enable_if_t::value>; template void _count_nonzero(E begin, E end, long &count, utils::int_); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/cross.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/cross.hpp index 139d0874a65..40fb48b7386 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/cross.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/cross.hpp @@ -9,9 +9,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename __combined::type, - types::array_tuple> + types::ndarray::type, + types::array_tuple> cross(E const &e, F const &f); DEFINE_FUNCTOR(pythonic::numpy, cross); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ctypeslib/as_array.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ctypeslib/as_array.hpp index c6184dc998a..737205b1963 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ctypeslib/as_array.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ctypeslib/as_array.hpp @@ -10,8 +10,7 @@ namespace numpy namespace ctypeslib { template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> as_array(types::pointer, pS); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/cumprod.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/cumprod.hpp index b2e3b583547..a963cafb62b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/cumprod.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/cumprod.hpp @@ -12,8 +12,8 @@ namespace numpy template auto cumprod(E &&e, Opts &&...opts) - -> decltype(partial_sum( - std::forward(e), std::forward(opts)...)); + -> decltype(partial_sum(std::forward(e), + std::forward(opts)...)); NUMPY_EXPR_TO_NDARRAY0_DECL(cumprod); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/cumsum.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/cumsum.hpp index cd37a1e657b..2b38a317c4a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/cumsum.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/cumsum.hpp @@ -12,8 +12,8 @@ namespace numpy template auto cumsum(E &&e, Opts &&...opts) - -> decltype(partial_sum( - std::forward(e), std::forward(opts)...)); + -> decltype(partial_sum(std::forward(e), + std::forward(opts)...)); DEFINE_FUNCTOR(pythonic::numpy, cumsum); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/delete_.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/delete_.hpp index d8cc67c48d8..656bb3b5e3f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/delete_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/delete_.hpp @@ -9,13 +9,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - delete_(types::ndarray const &a, long index, - types::none_type axis = builtins::None); + types::ndarray> delete_(types::ndarray const &a, long index, + types::none_type axis = builtins::None); template - typename std::enable_if::value, - types::ndarray>>::type + std::enable_if_t::value, types::ndarray>> delete_(types::ndarray const &in, I const &indices, types::none_type axis = builtins::None); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/diag.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/diag.hpp index c0813ccc99c..f4778d00a73 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/diag.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/diag.hpp @@ -11,18 +11,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value == 2, - types::ndarray>>::type + std::enable_if_t::value == 2, types::ndarray>> diag(types::ndarray const &a, long k = 0); template - typename std::enable_if::value == 1, - types::ndarray>>::type + std::enable_if_t::value == 1, types::ndarray>> diag(types::ndarray const &a, long k = 0); template - auto diag(types::list const &a, - long k = 0) -> decltype(diag(asarray(a), k)); + auto diag(types::list const &a, long k = 0) -> decltype(diag(asarray(a), k)); NUMPY_EXPR_TO_NDARRAY0_DECL(diag); DEFINE_FUNCTOR(pythonic::numpy, diag); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/dot.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/dot.hpp index 41aab6226c4..47f5ffc52aa 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/dot.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/dot.hpp @@ -28,17 +28,15 @@ struct is_strided { template struct is_blas_array { - static constexpr bool value = - pythonic::types::has_buffer::value && - is_blas_type::type>::value && - !is_strided::value; + static constexpr bool value = pythonic::types::has_buffer::value && + is_blas_type::type>::value && + !is_strided::value; }; template struct is_blas_view { - static constexpr bool value = - pythonic::types::has_buffer::value && - is_blas_type::type>::value; + static constexpr bool value = pythonic::types::has_buffer::value && + is_blas_type::type>::value; }; PYTHONIC_NS_BEGIN @@ -46,187 +44,163 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value && - types::is_dtype::value, - decltype(std::declval() * std::declval())>::type + std::enable_if_t::value && types::is_dtype::value, + decltype(std::declval() * std::declval())> dot(E const &e, F const &f); /// Vector / Vector multiplication template - typename std::enable_if< - types::is_numexpr_arg::value && types::is_numexpr_arg::value && - E::value == 1 && F::value == 1 && - (!is_blas_view::value || !is_blas_view::value || - !std::is_same::value), - typename __combined::type>::type + std::enable_if_t::value && types::is_numexpr_arg::value && + E::value == 1 && F::value == 1 && + (!is_blas_view::value || !is_blas_view::value || + !std::is_same::value), + typename __combined::type> dot(E const &e, F const &f); template - typename std::enable_if::value && - std::is_same::value && - is_blas_array::value && - is_blas_array::value, - float>::type + std::enable_if_t::value && + std::is_same::value && is_blas_array::value && + is_blas_array::value, + float> dot(E const &e, F const &f); template - typename std::enable_if::value && - std::is_same::value && - is_blas_array::value && - is_blas_array::value, - double>::type + std::enable_if_t::value && + std::is_same::value && is_blas_array::value && + is_blas_array::value, + double> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - is_blas_array::value && is_blas_array::value, - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + is_blas_array::value && is_blas_array::value, + std::complex> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - is_blas_array::value && is_blas_array::value, - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + is_blas_array::value && is_blas_array::value, + std::complex> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same::value && - std::is_same::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - float>::type + std::enable_if_t::value && + std::is_same::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + float> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same::value && - std::is_same::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - double>::type + std::enable_if_t::value && + std::is_same::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + double> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + std::complex> dot(E const &e, F const &f); template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + std::complex> dot(E const &e, F const &f); /// Matrix / Vector multiplication // We transpose the matrix to reflect our C order template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 1, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 1, + types::ndarray>> dot(types::ndarray const &f, types::ndarray const &e); template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 1, - types::ndarray>>::type - dot(types::numpy_texpr> const &f, - types::ndarray const &e); + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 1, + types::ndarray>> + dot(types::numpy_texpr> const &f, types::ndarray const &e); // The trick is to not transpose the matrix so that MV become VM template - typename std::enable_if::value && - std::tuple_size::value == 1 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 1 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::ndarray const &e, types::ndarray const &f); template - typename std::enable_if::value && - std::tuple_size::value == 1 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::ndarray const &e, - types::numpy_texpr> const &f); + std::enable_if_t::value && std::tuple_size::value == 1 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::ndarray const &e, types::numpy_texpr> const &f); // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 2 && F::value == 1, // And it is matrix / vect - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 2 && F::value == 1, // And it is matrix / vect + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f); // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 1 && F::value == 2, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 1 && F::value == 2, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f); // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix vector multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 1 && F::value == 2, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 1 && F::value == 2, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f); // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix vector multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 2 && F::value == 1, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 2 && F::value == 1, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f); /// Matrix / Matrix multiplication @@ -236,88 +210,72 @@ namespace numpy // So we compute B'A' == (AB)'. As this equality is perform with F order // We doesn't have to return a texpr because we want a C order matrice!! template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::ndarray const &a, types::ndarray const &b); template - typename std::enable_if< - is_blas_type::value && std::tuple_size::value == 2 && - std::tuple_size::value == 2 && std::tuple_size::value == 2, - types::ndarray>::type & - dot(types::ndarray const &a, types::ndarray const &b, - types::ndarray &c); + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2 && std::tuple_size::value == 2, + types::ndarray> & + dot(types::ndarray const &a, types::ndarray const &b, types::ndarray &c); // texpr variants: MT, TM, TT template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::numpy_texpr> const &a, - types::ndarray const &b); + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::numpy_texpr> const &a, types::ndarray const &b); template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::ndarray const &a, - types::numpy_texpr> const &b); + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::ndarray const &a, types::numpy_texpr> const &b); template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::numpy_texpr> const &a, types::numpy_texpr> const &b); // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 2 && F::value == 2, // And both are matrix - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 2 && F::value == 2, // And both are matrix + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f); // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 2 && F::value == 2, // And it is matrix / matrix - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 2 && F::value == 2, // And it is matrix / matrix + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f); // N x M where N >= 3 and M == 1 template - typename std::enable_if< - (E::value >= 3 && F::value == 1), - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(E::value >= 3 && F::value == 1), + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f); // N x M where N >= 3 and M >= 2 template - typename std::enable_if< - (E::value >= 3 && F::value >= 2), - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(E::value >= 3 && F::value >= 2), + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f); DEFINE_FUNCTOR(pythonic::numpy, dot); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/empty.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/empty.hpp index 77047e4c998..568baed4e77 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/empty.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/empty.hpp @@ -13,16 +13,14 @@ namespace numpy typename dtype::type empty(types::pshape<> const &shape, dtype d = dtype()); template - types::ndarray> - empty(pS const &shape, dtype d = dtype()); + types::ndarray> empty(pS const &shape, + dtype d = dtype()); template - types::ndarray> - empty(long size, dtype d = dtype()); + types::ndarray> empty(long size, dtype d = dtype()); template - types::ndarray>> + types::ndarray>> empty(std::integral_constant, dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, empty); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/empty_like.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/empty_like.hpp index 28baea1b086..54e11908449 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/empty_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/empty_like.hpp @@ -9,13 +9,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto empty_like(E const &expr, dtype d = dtype()) - -> decltype(empty(sutils::getshape(expr), d)); + auto empty_like(E const &expr, dtype d = dtype()) -> decltype(empty(sutils::getshape(expr), d)); template auto empty_like(E const &expr, types::none_type d = builtins::None) - -> decltype(empty(sutils::getshape(expr), - types::dtype_t())); + -> decltype(empty(sutils::getshape(expr), types::dtype_t())); DEFINE_FUNCTOR(pythonic::numpy, empty_like) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/eye.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/eye.hpp index 62033463c1c..806cd65016f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/eye.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/eye.hpp @@ -11,13 +11,12 @@ namespace numpy { template - types::ndarray> - eye(long N, long M, long k = 0, dtype d = dtype()); + types::ndarray> eye(long N, long M, long k = 0, + dtype d = dtype()); template types::ndarray> - eye(long N, types::none_type M = builtins::None, long k = 0, - dtype d = dtype()); + eye(long N, types::none_type M = builtins::None, long k = 0, dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, eye); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/c2c.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/c2c.hpp index 9ea27559aee..a7b63bbf1cf 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/c2c.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/c2c.hpp @@ -12,10 +12,9 @@ namespace numpy { template - types::ndarray, - types::array_tuple::value>> - c2c(types::ndarray, pS> const &a, long n = -1, - long axis = -1, types::str const &norm = {}, bool const forward = true); + types::ndarray, types::array_tuple::value>> + c2c(types::ndarray, pS> const &a, long n = -1, long axis = -1, + types::str const &norm = {}, bool const forward = true); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fft.hpp index 512ac55d8e7..3d470d46f8a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fft.hpp @@ -25,29 +25,20 @@ namespace numpy namespace fft { - template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fft(types::ndarray const &a, N const &n = {}, long axis = -1, - Norm const &norm = {}); - - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, T>, types::array_tuple::value>> - fft(types::ndarray const &a, N const &n = {}, long axis = -1, - Norm const &norm = {}); + fft(types::ndarray const &a, N const &n = {}, long axis = -1, Norm const &norm = {}); - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fft(types::ndarray const &a, N const &n = {}, long axis = -1, - Norm const &norm = {}); + fft(types::ndarray const &a, N const &n = {}, long axis = -1, Norm const &norm = {}); + + template + types::ndarray::value, std::complex>, + types::array_tuple::value>> + fft(types::ndarray const &a, N const &n = {}, long axis = -1, Norm const &norm = {}); NUMPY_EXPR_TO_NDARRAY0_DECL(fft); DEFINE_FUNCTOR(pythonic::numpy::fft, fft); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fftn.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fftn.hpp index 8f7d78b17bc..91eb793b4ac 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fftn.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/fftn.hpp @@ -11,54 +11,45 @@ namespace numpy namespace fft { // without shape - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::none_type s = {}, - Axes const &axes = {}, Norm const &norm = {}); + fftn(types::ndarray const &a, types::none_type s = {}, Axes const &axes = {}, + Norm const &norm = {}); - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::none_type s = {}, - Axes const &axes = {}, Norm const &norm = {}); + fftn(types::ndarray const &a, types::none_type s = {}, Axes const &axes = {}, + Norm const &norm = {}); - template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fftn(types::ndarray const &a, types::none_type s = {}, - Axes const &axes = {}, Norm const &norm = {}); + template + types::ndarray::value, T>, + types::array_tuple::value>> + fftn(types::ndarray const &a, types::none_type s = {}, Axes const &axes = {}, + Norm const &norm = {}); // with shape - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes = {}, Norm const &norm = {}); + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes = {}, + Norm const &norm = {}); - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes = {}, Norm const &norm = {}); + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes = {}, + Norm const &norm = {}); - template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes = {}, Norm const &norm = {}); + template + types::ndarray::value, T>, + types::array_tuple::value>> + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes = {}, + Norm const &norm = {}); NUMPY_EXPR_TO_NDARRAY0_DECL(fftn); DEFINE_FUNCTOR(pythonic::numpy::fft, fftn); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/hfft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/hfft.hpp index 6337bd991f5..1177f0549db 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/hfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/hfft.hpp @@ -27,56 +27,44 @@ namespace numpy template types::ndarray::value>> - hfft(types::ndarray, pS> const &a, long n = -1, - long axis = -1, types::str const &norm = {}); + hfft(types::ndarray, pS> const &a, long n = -1, long axis = -1, + types::str const &norm = {}); template types::ndarray::value>> - hfft(types::ndarray, pS> const &a, types::none_type n, - long axis, types::str const &norm); + hfft(types::ndarray, pS> const &a, types::none_type n, long axis, + types::str const &norm); template types::ndarray::value>> - hfft(types::ndarray, pS> const &a, long n, long axis, - types::none_type norm); + hfft(types::ndarray, pS> const &a, long n, long axis, types::none_type norm); template types::ndarray::value>> - hfft(types::ndarray, pS> const &a, types::none_type n, - long axis = -1, types::none_type norm = types::none_type{}); + hfft(types::ndarray, pS> const &a, types::none_type n, long axis = -1, + types::none_type norm = types::none_type{}); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - hfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + hfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - hfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + hfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - hfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + hfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> hfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ifft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ifft.hpp index cb15442fd77..384dcbef765 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ifft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ifft.hpp @@ -26,85 +26,64 @@ namespace numpy { template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - ifft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + types::ndarray::value, T>, + types::array_tuple::value>> + ifft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - ifft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + types::ndarray::value, T>, + types::array_tuple::value>> + ifft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - ifft(types::ndarray const &a, long n, long axis, - types::none_type norm); + types::ndarray::value, T>, + types::array_tuple::value>> + ifft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> + types::ndarray::value, T>, + types::array_tuple::value>> ifft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + ifft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + ifft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, long n, long axis, - types::none_type norm); + ifft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + ifft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + ifft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &a, long n, long axis, - types::none_type norm); + ifft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ihfft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ihfft.hpp index e1e2af123da..803c8ca89c4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ihfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/ihfft.hpp @@ -26,57 +26,43 @@ namespace numpy { template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + ihfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + ihfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + ihfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + ihfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + ihfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + ihfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/irfft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/irfft.hpp index b10c977bdee..5e3f83d5ac0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/irfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/irfft.hpp @@ -27,56 +27,44 @@ namespace numpy template types::ndarray::value>> - irfft(types::ndarray, pS> const &a, long n = -1, - long axis = -1, types::str const &norm = {}); + irfft(types::ndarray, pS> const &a, long n = -1, long axis = -1, + types::str const &norm = {}); template types::ndarray::value>> - irfft(types::ndarray, pS> const &a, types::none_type n, - long axis, types::str const &norm); + irfft(types::ndarray, pS> const &a, types::none_type n, long axis, + types::str const &norm); template types::ndarray::value>> - irfft(types::ndarray, pS> const &a, long n, long axis, - types::none_type norm); + irfft(types::ndarray, pS> const &a, long n, long axis, types::none_type norm); template types::ndarray::value>> - irfft(types::ndarray, pS> const &a, types::none_type n, - long axis = -1, types::none_type norm = types::none_type{}); + irfft(types::ndarray, pS> const &a, types::none_type n, long axis = -1, + types::none_type norm = types::none_type{}); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - irfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + irfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - irfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + irfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - irfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + irfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> irfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/rfft.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/rfft.hpp index e8b410ff425..680ad84cc7f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fft/rfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fft/rfft.hpp @@ -26,57 +26,43 @@ namespace numpy { template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + rfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + rfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + rfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, long n = -1, long axis = -1, - types::str const &norm = {}); + rfft(types::ndarray const &a, long n = -1, long axis = -1, types::str const &norm = {}); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, types::none_type n, long axis, - types::str const &norm); + rfft(types::ndarray const &a, types::none_type n, long axis, types::str const &norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &a, long n, long axis, - types::none_type norm); + rfft(types::ndarray const &a, long n, long axis, types::none_type norm); template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &a, types::none_type n, long axis = -1, types::none_type norm = types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fill_diagonal.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fill_diagonal.hpp index ef8a05cf98b..3bc658a4f91 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fill_diagonal.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fill_diagonal.hpp @@ -9,7 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type fill_diagonal(E &&, typename std::decay::type::dtype); + types::none_type fill_diagonal(E &&, typename std::decay_t::dtype); DEFINE_FUNCTOR(pythonic::numpy, fill_diagonal) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/flip.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/flip.hpp index ab2705cf0d6..94764eb1587 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/flip.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/flip.hpp @@ -12,14 +12,14 @@ namespace numpy namespace details { template - auto flip(E const &expr, S const &slices, - utils::index_sequence) -> decltype(expr(slices[I]...)); + auto flip(E const &expr, S const &slices, std::index_sequence) + -> decltype(expr(slices[I]...)); } template auto flip(E const &expr, long axis) -> decltype(details::flip(expr, std::array{}, - utils::make_index_sequence{})); + std::make_index_sequence{})); DEFINE_FUNCTOR(pythonic::numpy, flip); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fliplr.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fliplr.hpp index 605d2677ac0..a9e365e478d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fliplr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fliplr.hpp @@ -9,10 +9,9 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto - fliplr(E &&expr) -> decltype(std::forward(expr)( - types::cstride_slice<1>{builtins::None, builtins::None}, - types::slice{builtins::None, builtins::None, -1})); + auto fliplr(E &&expr) + -> decltype(std::forward(expr)(types::cstride_slice<1>{builtins::None, builtins::None}, + types::slice{builtins::None, builtins::None, -1})); DEFINE_FUNCTOR(pythonic::numpy, fliplr); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/flipud.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/flipud.hpp index a4b5f241a6a..2a8daf252ff 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/flipud.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/flipud.hpp @@ -9,9 +9,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto - flipud(E &&expr) -> decltype(std::forward( - expr)[types::slice{builtins::None, builtins::None, -1}]); + auto flipud(E &&expr) + -> decltype(std::forward(expr)[types::slice{builtins::None, builtins::None, -1}]); DEFINE_FUNCTOR(pythonic::numpy, flipud); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/float128.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/float128.hpp index 8f4819e2b10..f8155857272 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/float128.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/float128.hpp @@ -28,4 +28,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::float128 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::float128 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/float32.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/float32.hpp index a88b5b3d883..32981a18395 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/float32.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/float32.hpp @@ -26,4 +26,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::float32 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::float32 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/float64.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/float64.hpp index 0494e3303e3..dae2a3505cc 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/float64.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/float64.hpp @@ -24,4 +24,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::float64 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::float64 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/float_.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/float_.hpp index b4e25d97ad5..5c3491eb17d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/float_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/float_.hpp @@ -14,4 +14,22 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::float_ const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::float_ convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/floor_divide.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/floor_divide.hpp index 85de7c53122..2228b24cca6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/floor_divide.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/floor_divide.hpp @@ -14,27 +14,25 @@ namespace numpy namespace wrapper { template - std::complex::type> - divfloor(std::complex const &arg0, std::complex const &arg1) + std::complex> divfloor(std::complex const &arg0, + std::complex const &arg1) { return {functor::floor{}(std::real(arg0 / arg1)), 0}; } template - auto divfloor(Arg0 const &arg0, Arg1 const &arg1) -> - typename std::enable_if<(std::is_integral::value && - std::is_integral::value), - decltype(arg0 / arg1)>::type + auto divfloor(Arg0 const &arg0, Arg1 const &arg1) + -> std::enable_if_t<(std::is_integral::value && std::is_integral::value), + decltype(arg0 / arg1)> { bool opposite_sign = (arg0 >= 0 && arg1 < 0) || (arg0 < 0 && arg1 >= 0); return (arg0 + opposite_sign * (-arg1 + 1)) / arg1; } template - auto divfloor(Arg0 const &arg0, Arg1 const &arg1) -> - typename std::enable_if::value || - !std::is_integral::value, - decltype(functor::floor{}(arg0 / arg1))>::type + auto divfloor(Arg0 const &arg0, Arg1 const &arg1) + -> std::enable_if_t::value || !std::is_integral::value, + decltype(functor::floor{}(arg0 / arg1))> { return functor::floor{}(arg0 / arg1); } diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/frexp.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/frexp.hpp index e9a2b202afc..fb80f1ae119 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/frexp.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/frexp.hpp @@ -11,14 +11,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, std::tuple>::type - frexp(T val); + std::enable_if_t::value, std::tuple> frexp(T val); template - typename std::enable_if< - !types::is_dtype::value, - std::tuple, - types::ndarray>>::type + std::enable_if_t::value, + std::tuple, + types::ndarray>> frexp(E const &arr); DEFINE_FUNCTOR(pythonic::numpy, frexp); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/frombuffer.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/frombuffer.hpp new file mode 100644 index 00000000000..5868e9a73d7 --- /dev/null +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/frombuffer.hpp @@ -0,0 +1,25 @@ +#ifndef PYTHONIC_INCLUDE_NUMPY_FROMBUFFER_HPP +#define PYTHONIC_INCLUDE_NUMPY_FROMBUFFER_HPP + +#include "pythonic/include/numpy/float64.hpp" +#include "pythonic/include/types/list.hpp" +#include "pythonic/include/types/ndarray.hpp" +#include "pythonic/include/types/str.hpp" +#include "pythonic/include/utils/functor.hpp" + +#include +#include + +PYTHONIC_NS_BEGIN + +namespace numpy +{ + template + types::ndarray> + frombuffer(types::str const &string, dtype d = dtype(), long count = -1, long offset = 0); + + DEFINE_FUNCTOR(pythonic::numpy, frombuffer); +} // namespace numpy +PYTHONIC_NS_END + +#endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fromfunction.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fromfunction.hpp index ade065d1469..a17be5a8c06 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fromfunction.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fromfunction.hpp @@ -17,27 +17,22 @@ namespace numpy template struct fromfunction_helper { template - types::ndarray::type>::type>::type, - pS> + types::ndarray>>, pS> operator()(F &&f, pS const &shape, dtype d = dtype()); }; template struct fromfunction_helper { template - types::ndarray< - typename std::remove_cv::type>::type>::type, - pS> + types::ndarray>>, pS> operator()(F &&f, pS const &shape, dtype d = dtype()); }; template auto fromfunction(F &&f, pS const &shape, dtype d = dtype()) -> decltype(fromfunction_helper::value, dtype, - typename pythonic::purity_of::type>()( - std::forward(f), shape)); + typename pythonic::purity_of::type>()(std::forward(f), + shape)); /* TODO: must specialize for higher order */ DEFINE_FUNCTOR(pythonic::numpy, fromfunction); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fromiter.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fromiter.hpp index 077c4de534c..efc8e293e8f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fromiter.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fromiter.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray::type>::type::value_type, + types::ndarray>::value_type, types::pshape> fromiter(Iterable &&iterable, dtype d = dtype(), long count = -1); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/fromstring.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/fromstring.hpp index 545a053b170..8c68dc13b3f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/fromstring.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/fromstring.hpp @@ -1,6 +1,7 @@ #ifndef PYTHONIC_INCLUDE_NUMPY_FROMSTRING_HPP #define PYTHONIC_INCLUDE_NUMPY_FROMSTRING_HPP +#include "pythonic/include/builtins/pythran/kwonly.hpp" #include "pythonic/include/numpy/float64.hpp" #include "pythonic/include/types/list.hpp" #include "pythonic/include/types/ndarray.hpp" @@ -16,9 +17,30 @@ namespace numpy { template types::ndarray> - fromstring(types::str const &string, dtype d = dtype(), long count = -1, + fromstring(types::str const &string, dtype d = dtype(), long count = -1, types::kwonly = {}, types::str const &sep = {}); + template + types::ndarray> + fromstring(types::str const &string, dtype d = dtype(), long count = -1, + types::str const &sep = {}) + { + return fromstring(string, d, count, types::kwonly{}, sep); + } + + types::ndarray> inline fromstring( + types::str const &string, types::kwonly, types::str const &sep = {}) + { + return fromstring(string, functor::float64{}, -1, types::kwonly{}, sep); + } + + template + types::ndarray> + fromstring(types::str const &string, dtype d, types::kwonly, types::str const &sep) + { + return fromstring(string, d, -1, types::kwonly{}, sep); + } + DEFINE_FUNCTOR(pythonic::numpy, fromstring); } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/full.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/full.hpp index 4c945f6dfb0..663a6199d07 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/full.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/full.hpp @@ -11,16 +11,14 @@ namespace numpy { template - types::ndarray> - full(pS const &shape, F fill_value, dtype d); + types::ndarray> full(pS const &shape, F fill_value, + dtype d); template - types::ndarray> - full(long size, F fill_value, dtype d); + types::ndarray> full(long size, F fill_value, dtype d); template - types::ndarray>> + types::ndarray>> full(std::integral_constant, F fill_value, dtype d); template @@ -28,8 +26,7 @@ namespace numpy types::none_type _ = {}); template - types::ndarray> full(long size, F fill_value, - types::none_type _ = {}); + types::ndarray> full(long size, F fill_value, types::none_type _ = {}); template types::ndarray>> diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/full_like.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/full_like.hpp index 61cac42cf13..68f43d0d85d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/full_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/full_like.hpp @@ -14,10 +14,8 @@ namespace numpy -> decltype(full(sutils::getshape(expr), fill_value, d)); template - auto full_like(E const &expr, F fill_value, - types::none_type d = builtins::None) - -> decltype(full(sutils::getshape(expr), fill_value, - types::dtype_t())); + auto full_like(E const &expr, F fill_value, types::none_type d = builtins::None) + -> decltype(full(sutils::getshape(expr), fill_value, types::dtype_t())); DEFINE_FUNCTOR(pythonic::numpy, full_like) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/hstack.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/hstack.hpp index 13caae7529b..9a1559ce315 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/hstack.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/hstack.hpp @@ -9,8 +9,7 @@ namespace numpy { template - auto hstack(ArraySequence &&seq) - -> decltype(concatenate(std::forward(seq), 1)); + auto hstack(ArraySequence &&seq) -> decltype(concatenate(std::forward(seq), 1)); DEFINE_FUNCTOR(pythonic::numpy, hstack); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/imag.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/imag.hpp index 086b3b6f802..20ae73cbbc8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/imag.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/imag.hpp @@ -11,12 +11,10 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto imag(E &&expr) -> decltype(builtins::getattr(types::attr::IMAG{}, - std::forward(expr))); + auto imag(E &&expr) -> decltype(builtins::getattr(types::attr::IMAG{}, std::forward(expr))); template - auto imag(types::list const &expr) - -> decltype(imag(numpy::functor::asarray{}(expr))); + auto imag(types::list const &expr) -> decltype(imag(numpy::functor::asarray{}(expr))); DEFINE_FUNCTOR(pythonic::numpy, imag); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/indices.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/indices.hpp index 544d96760ee..5ec3699355b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/indices.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/indices.hpp @@ -10,10 +10,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename dtype::type, - sutils::push_front_t< - pS, std::integral_constant::value>>> + types::ndarray::value>>> indices(pS const &shape, dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, indices); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/insert.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/insert.hpp index 5b8b94363fa..d91d57c4fab 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/insert.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/insert.hpp @@ -14,30 +14,26 @@ namespace numpy { template - typename std::enable_if::value && - types::is_iterable::value, - types::ndarray>>::type + std::enable_if_t::value && types::is_iterable::value, + types::ndarray>> insert(types::ndarray in, I const &indices, F const &data, types::none_type axis = builtins::None); template - typename std::enable_if::value && - !types::is_iterable::value, - types::ndarray>>::type + std::enable_if_t::value && !types::is_iterable::value, + types::ndarray>> insert(types::ndarray in, I const &indices, F const &data, types::none_type axis = builtins::None); template - typename std::enable_if::value && - types::is_iterable::value, - types::ndarray>>::type + std::enable_if_t::value && types::is_iterable::value, + types::ndarray>> insert(types::ndarray in, I const &indices, F const &data, types::none_type axis = builtins::None); template - typename std::enable_if::value && - !types::is_iterable::value, - types::ndarray>>::type + std::enable_if_t::value && !types::is_iterable::value, + types::ndarray>> insert(types::ndarray in, I const &indices, F const &data, types::none_type axis = builtins::None); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/int16.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/int16.hpp index fa3e9f34bb0..ecbc2113d60 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/int16.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/int16.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::int16 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::int16 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/int32.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/int32.hpp index 5bc35e04d6d..24bf809a9df 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/int32.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/int32.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::int32 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::int32 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/int64.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/int64.hpp index 5e0bca6ed55..97615e34a01 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/int64.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/int64.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::int64 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::int64 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/int8.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/int8.hpp index 9021c0972ad..083704595b8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/int8.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/int8.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::int8 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::int8 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/int_.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/int_.hpp index efc448dc794..fb5edc97623 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/int_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/int_.hpp @@ -25,4 +25,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::int_ const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::int_ convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/intc.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/intc.hpp index a340dee7e69..5f753150c68 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/intc.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/intc.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::intc const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::intc convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/interp.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/interp.hpp index 320bff15c2c..f87ed543f58 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/interp.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/interp.hpp @@ -11,86 +11,67 @@ namespace numpy { template using interp_out_type = - typename std::conditional::value, - std::complex, double>::type; + std::conditional_t::value, std::complex, double>; // None,None,None template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type + std::enable_if_t::value, + types::ndarray, types::pshape>> interp(T1 x, T2 xp, T3 fp, types::none_type left = types::none_type{}, - types::none_type right = types::none_type{}, - types::none_type period = types::none_type{}); + types::none_type right = types::none_type{}, types::none_type period = types::none_type{}); // left None None template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, t1 left, - types::none_type right = types::none_type{}, + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right = types::none_type{}, types::none_type period = types::none_type{}); // None right None template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type + std::enable_if_t::value, + types::ndarray, types::pshape>> interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, types::none_type period = types::none_type{}); // None None period template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - t1 period); + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, t1 period); // left right None template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, - types::none_type period = types::none_type{}); + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, types::none_type period = types::none_type{}); ////////////////////////// NUMERIC TYPES for x. template - typename std::enable_if::value, - interp_out_type>::type + std::enable_if_t::value, interp_out_type> interp(T1 x, T2 xp, T3 fp, types::none_type left = types::none_type{}, - types::none_type right = types::none_type{}, - types::none_type period = types::none_type{}); + types::none_type right = types::none_type{}, types::none_type period = types::none_type{}); // left None None template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, t1 left, - types::none_type right = types::none_type{}, + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right = types::none_type{}, types::none_type period = types::none_type{}); // None right None template - typename std::enable_if::value, - interp_out_type>::type + std::enable_if_t::value, interp_out_type> interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, types::none_type period = types::none_type{}); // None None period template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - t1 period); + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, t1 period); // left right None template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, - types::none_type period = types::none_type{}); + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, types::none_type period = types::none_type{}); NUMPY_EXPR_TO_NDARRAY0_DECL(interp); DEFINE_FUNCTOR(pythonic::numpy, interp); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/intersect1d.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/intersect1d.hpp index e07cb2c91bd..e899a3cea8c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/intersect1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/intersect1d.hpp @@ -13,9 +13,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> intersect1d(E const &e, F const &f); DEFINE_FUNCTOR(pythonic::numpy, intersect1d); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/isclose.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/isclose.hpp index 922f1c64591..680c23a0fd2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/isclose.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/isclose.hpp @@ -14,8 +14,8 @@ namespace numpy namespace wrapper { template - bool isclose(T0 const &u, T1 const &v, double rtol = 1e-5, - double atol = 1e-8, bool equal_nan = false); + bool isclose(T0 const &u, T1 const &v, double rtol = 1e-5, double atol = 1e-8, + bool equal_nan = false); } #define NUMPY_NARY_FUNC_NAME isclose #define NUMPY_NARY_FUNC_SYM wrapper::isclose diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/iscomplex.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/iscomplex.hpp index c64d8170dc9..9fbb15c2578 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/iscomplex.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/iscomplex.hpp @@ -14,12 +14,10 @@ namespace numpy namespace wrapper { template - typename std::enable_if::value, bool>::type - iscomplex(I const &a); + std::enable_if_t::value, bool> iscomplex(I const &a); template - constexpr typename std::enable_if::value, bool>::type - iscomplex(I const &a); + constexpr std::enable_if_t::value, bool> iscomplex(I const &a); } // namespace wrapper #define NUMPY_NARY_FUNC_NAME iscomplex diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/isnan.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/isnan.hpp index d471777df7d..98fe289aebe 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/isnan.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/isnan.hpp @@ -14,15 +14,11 @@ namespace numpy template bool isnan(std::complex const &v); template - auto isnan(T const &v) -> - typename std::enable_if< - std::is_floating_point::type>::value, - bool>::type; + auto isnan(T const &v) + -> std::enable_if_t>::value, bool>; template - auto isnan(T const &v) -> - typename std::enable_if< - !std::is_floating_point::type>::value, - bool>::type; + auto isnan(T const &v) + -> std::enable_if_t>::value, bool>; } // namespace wrapper #define NUMPY_NARY_FUNC_NAME isnan diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/isreal.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/isreal.hpp index a43a129b4c2..eb6bc23a650 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/isreal.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/isreal.hpp @@ -14,12 +14,10 @@ namespace numpy namespace wrapper { template - typename std::enable_if::value, bool>::type - isreal(I const &a); + std::enable_if_t::value, bool> isreal(I const &a); template - typename std::enable_if::value, bool>::type - isreal(I const &a); + std::enable_if_t::value, bool> isreal(I const &a); } // namespace wrapper #define NUMPY_NARY_FUNC_NAME isreal diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/issctype.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/issctype.hpp index e38e2647534..e8e4d6e23b2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/issctype.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/issctype.hpp @@ -12,16 +12,12 @@ namespace types namespace numpy { template - constexpr auto issctype(E const &expr) -> - typename std::enable_if::value && - !std::is_same::value, - bool>::type; + constexpr auto issctype(E const &expr) + -> std::enable_if_t::value && !std::is_same::value, bool>; template - constexpr auto issctype(E const &expr) -> - typename std::enable_if::value || - std::is_same::value, - bool>::type; + constexpr auto issctype(E const &expr) + -> std::enable_if_t::value || std::is_same::value, bool>; DEFINE_FUNCTOR(pythonic::numpy, issctype); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/matrix_power.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/matrix_power.hpp index adb1af5d9c7..c5bb0fe3914 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/matrix_power.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/matrix_power.hpp @@ -9,8 +9,7 @@ namespace numpy namespace linalg { template - auto matrix_power(E const &expr, - long n) -> decltype(numpy::functor::array{}(expr)); + auto matrix_power(E const &expr, long n) -> decltype(numpy::functor::array{}(expr)); DEFINE_FUNCTOR(pythonic::numpy::linalg, matrix_power); } // namespace linalg diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/norm.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/norm.hpp index 42ab8dcaa01..8023c603c7f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/norm.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/linalg/norm.hpp @@ -12,25 +12,20 @@ namespace numpy namespace linalg { template - auto norm(Array &&array, types::none_type ord = {}, - types::none_type axis = {}) - -> decltype(pythonic::numpy::functor::sqrt{}( - pythonic::numpy::functor::sum{}( - pythonic::builtins::pythran::functor::abssqr{}( - std::forward(array))))); + auto norm(Array &&array, types::none_type ord = {}, types::none_type axis = {}) + -> decltype(pythonic::numpy::functor::sqrt{}(pythonic::numpy::functor::sum{}( + pythonic::builtins::pythran::functor::abssqr{}(std::forward(array))))); template - using norm_dtype_t = typename std::conditional< - std::is_floating_point< - typename std::decay::type::dtype()>::value, - typename std::decay::type::dtype(), double>::type; + using norm_dtype_t = + std::conditional_t::dtype()>::value, + typename std::decay_t::dtype(), double>; template - using norm_t = typename std::conditional< - std::decay::type::value == 1, norm_dtype_t, + using norm_t = std::conditional_t< + std::decay_t::value == 1, norm_dtype_t, types::ndarray, - types::array_tuple::type::value - - 1>>>::type; + types::array_tuple::value - 1>>>; template norm_t norm(Array &&array, double ord, types::none_type axis = {}); @@ -42,12 +37,10 @@ namespace numpy norm_t norm(Array &&array, double ord, long axis); template - norm_t norm(Array &&array, double ord, - types::array_tuple axis); + norm_t norm(Array &&array, double ord, types::array_tuple axis); template - norm_t norm(Array &&array, double ord, - types::array_tuple axis); + norm_t norm(Array &&array, double ord, types::array_tuple axis); DEFINE_FUNCTOR(pythonic::numpy::linalg, norm); } // namespace linalg } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/linspace.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/linspace.hpp index 71d009c457d..dc0d6b31361 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/linspace.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/linspace.hpp @@ -10,8 +10,8 @@ namespace numpy template > types::ndarray> - linspace(double start, double stop, long num = 50, bool endpoint = true, - bool retstep = false, dtype d = dtype()); + linspace(double start, double stop, long num = 50, bool endpoint = true, bool retstep = false, + dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, linspace); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/logaddexp2.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/logaddexp2.hpp index 9fafebe1c72..a6e1bc8e36c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/logaddexp2.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/logaddexp2.hpp @@ -17,8 +17,7 @@ namespace numpy { template auto logaddexp2(T0 const &t0, T1 const &t1) - -> decltype(functor::log2{}(functor::power{}(T0(2), t0) + - functor::power{}(T1(2), t1))); + -> decltype(functor::log2{}(functor::power{}(T0(2), t0) + functor::power{}(T1(2), t1))); } #define NUMPY_NARY_FUNC_NAME logaddexp2 diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/logical_xor.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/logical_xor.hpp index 1075eaef8b4..ccee551d095 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/logical_xor.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/logical_xor.hpp @@ -13,8 +13,7 @@ namespace numpy namespace wrapper { template - auto logical_xor(T0 const &t0, - T1 const &t1) -> decltype((t0 && !t1) || (t1 && !t0)); + auto logical_xor(T0 const &t0, T1 const &t1) -> decltype((t0 && !t1) || (t1 && !t0)); template bool logical_xor(std::complex const &t0, std::complex const &t1) { diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/logspace.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/logspace.hpp index 478e497a92d..f29c16695c7 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/logspace.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/logspace.hpp @@ -8,10 +8,8 @@ PYTHONIC_NS_BEGIN namespace numpy { - auto logspace(double start, double stop, long num = 50, bool endpoint = true, - double base = 10.0) - -> decltype(functor::power()(base, functor::linspace()(start, stop, num, - endpoint))); + auto logspace(double start, double stop, long num = 50, bool endpoint = true, double base = 10.0) + -> decltype(functor::power()(base, functor::linspace()(start, stop, num, endpoint))); DEFINE_FUNCTOR(pythonic::numpy, logspace); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/max.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/max.hpp index 3120f92c94a..6861265d063 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/max.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/max.hpp @@ -10,8 +10,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto max(Args &&...args) -> decltype(reduce( - std::forward(args)...)); + auto max(Args &&...args) + -> decltype(reduce(std::forward(args)...)); DEFINE_FUNCTOR(pythonic::numpy, max); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/mean.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/mean.hpp index 0aa0e9a5b9e..757d7dcce4b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/mean.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/mean.hpp @@ -13,9 +13,8 @@ namespace numpy namespace details { template - struct make_scalar_pshape - : sutils::concat>, - typename make_scalar_pshape::type> { + struct make_scalar_pshape : sutils::concat>, + typename make_scalar_pshape::type> { }; template <> @@ -36,15 +35,13 @@ namespace numpy } // namespace details template - auto mean(E const &expr, types::none_type axis = {}, dtype d = {}, - types::none_type out = {}, types::false_immediate keep_dims = {}) - -> decltype(sum(expr, axis, d) / - details::dtype_or_double(expr.flat_size())); + auto mean(E const &expr, types::none_type axis = {}, dtype d = {}, types::none_type out = {}, + types::false_immediate keep_dims = {}) + -> decltype(sum(expr, axis, d) / details::dtype_or_double(expr.flat_size())); template auto mean(E const &expr, long axis, dtype d = {}, types::none_type out = {}, - types::false_immediate keep_dims = {}) -> decltype(sum(expr, axis, - d)); + types::false_immediate keep_dims = {}) -> decltype(sum(expr, axis, d)); template types::ndarray, @@ -54,8 +51,7 @@ namespace numpy template auto mean(E const &expr, long axis, dtype d, types::none_type out, - types::true_immediate keep_dims) - -> decltype(expand_dims(mean(expr, axis, d), axis)); + types::true_immediate keep_dims) -> decltype(expand_dims(mean(expr, axis, d), axis)); DEFINE_FUNCTOR(pythonic::numpy, mean); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/median.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/median.hpp index af1f229a871..550d193e81c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/median.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/median.hpp @@ -11,20 +11,16 @@ PYTHONIC_NS_BEGIN namespace numpy { template - decltype(std::declval() + 1.) median(types::ndarray const &arr, - types::none_type = {}); + decltype(std::declval() + 1.) median(types::ndarray const &arr, types::none_type = {}); template - typename std::enable_if< - std::tuple_size::value != 1, - types::ndarray< - decltype(std::declval() + 1.), - types::array_tuple::value - 1>>>::type + std::enable_if_t::value != 1, + types::ndarray() + 1.), + types::array_tuple::value - 1>>> median(types::ndarray const &arr, long axis); template - typename std::enable_if::value == 1, - decltype(std::declval() + 1.)>::type + std::enable_if_t::value == 1, decltype(std::declval() + 1.)> median(types::ndarray const &arr, long axis); NUMPY_EXPR_TO_NDARRAY0_DECL(median); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/min.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/min.hpp index 4e5137d9f19..c639da029d2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/min.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/min.hpp @@ -11,8 +11,8 @@ namespace numpy { template - auto min(Args &&...args) -> decltype(reduce( - std::forward(args)...)); + auto min(Args &&...args) + -> decltype(reduce(std::forward(args)...)); DEFINE_FUNCTOR(pythonic::numpy, min); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray.hpp index 293b0467a24..0339564367e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray.hpp @@ -10,20 +10,23 @@ PYTHONIC_NS_BEGIN namespace numpy { - template - types::ndarray> - ndarray(pS const &shape, dtype d = dtype()); + namespace anonymous + { - template - types::ndarray> - ndarray(long size, dtype d = dtype()); + template + types::ndarray> ndarray(pS const &shape, + dtype d = dtype()); - template - types::ndarray>> - ndarray(std::integral_constant, dtype d = dtype()); + template + types::ndarray> ndarray(long size, dtype d = dtype()); - DEFINE_FUNCTOR(pythonic::numpy, ndarray); + template + types::ndarray>> + ndarray(std::integral_constant, dtype d = dtype()); + + } // namespace anonymous + + DEFINE_FUNCTOR(pythonic::numpy::anonymous, ndarray); } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/flatten.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/flatten.hpp index ab81081b71d..55cc2e32aee 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/flatten.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/flatten.hpp @@ -12,8 +12,7 @@ namespace numpy namespace ndarray { template - types::ndarray> - flatten(types::ndarray const &a); + types::ndarray> flatten(types::ndarray const &a); NUMPY_EXPR_TO_NDARRAY0_DECL(flatten); DEFINE_FUNCTOR(pythonic::numpy::ndarray, flatten); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/item.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/item.hpp index 2391263fb60..988cdf1ddd2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/item.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/item.hpp @@ -16,12 +16,11 @@ namespace numpy T item(types::ndarray const &expr, long i); template - auto item(E &&expr, - types::array_tuple const &i) -> decltype(expr[i]); + auto item(E &&expr, types::array_tuple const &i) -> decltype(expr[i]); // only for compatibility purpose, very bad impl template - typename std::decay::type::dtype item(E &&expr, long i); + typename std::decay_t::dtype item(E &&expr, long i); DEFINE_FUNCTOR(pythonic::numpy::ndarray, item); } // namespace ndarray diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/reshape.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/reshape.hpp index db3aad1d217..87bcb0722ae 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/reshape.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/reshape.hpp @@ -12,19 +12,15 @@ namespace numpy namespace ndarray { template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> reshape(types::ndarray const &expr, NpS const &new_shape); template - typename std::enable_if::value, - types::ndarray>>::type + std::enable_if_t::value, types::ndarray>> reshape(types::ndarray const &expr, NpS const &new_shape); template - auto reshape(types::ndarray const &expr, S0 i0, S1 i1, - S const &...indices) - -> decltype(reshape(expr, - types::pshape{i0, i1, indices...})); + auto reshape(types::ndarray const &expr, S0 i0, S1 i1, S const &...indices) + -> decltype(reshape(expr, types::pshape{i0, i1, indices...})); NUMPY_EXPR_TO_NDARRAY0_DECL(reshape); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/tolist.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/tolist.hpp index e45630bb2e0..318caa79d9d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/tolist.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndarray/tolist.hpp @@ -23,14 +23,12 @@ namespace numpy }; template - typename std::enable_if::value == 1, - types::list>::type + std::enable_if_t::value == 1, types::list> tolist(types::ndarray const &expr); template - typename std::enable_if< - std::tuple_size::value != 1, - typename tolist_type::value>::type>::type + std::enable_if_t::value != 1, + typename tolist_type::value>::type> tolist(types::ndarray const &expr); NUMPY_EXPR_TO_NDARRAY0_DECL(tolist); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndenumerate.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndenumerate.hpp index 18d78f2ef5f..4b0934c7edd 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndenumerate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndenumerate.hpp @@ -9,9 +9,8 @@ namespace numpy { template struct ndenumerate_iterator - : std::iterator< - std::random_access_iterator_tag, - std::tuple, typename E::dtype>> { + : std::iterator, typename E::dtype>> { long index; E const &expr; typename E::dtype *iter; @@ -19,12 +18,15 @@ namespace numpy ndenumerate_iterator(); ndenumerate_iterator(E const &expr, long first); - std::tuple, typename E::dtype> - operator*() const; + std::tuple, typename E::dtype> operator*() const; ndenumerate_iterator &operator++(); ndenumerate_iterator &operator+=(long n); bool operator!=(ndenumerate_iterator const &other) const; + bool operator==(ndenumerate_iterator const &other) const + { + return !(*this != other); + } bool operator<(ndenumerate_iterator const &other) const; long operator-(ndenumerate_iterator const &other) const; }; @@ -43,8 +45,7 @@ namespace numpy }; template - _ndenumerate> - ndenumerate(types::ndarray const &expr); + _ndenumerate> ndenumerate(types::ndarray const &expr); NUMPY_EXPR_TO_NDARRAY0_DECL(ndenumerate); DEFINE_FUNCTOR(pythonic::numpy, ndenumerate); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ndindex.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ndindex.hpp index 387665cdbf9..b4a40661526 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ndindex.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ndindex.hpp @@ -13,10 +13,9 @@ namespace numpy template struct ndindex_iterator : std::iterator< - std::random_access_iterator_tag, types::array_tuple, - ptrdiff_t, types::array_tuple *, - types::array_tuple< - long, N> /* reference_type, but no reference is possible*/> { + std::random_access_iterator_tag, types::array_tuple, ptrdiff_t, + types::array_tuple *, + types::array_tuple /* reference_type, but no reference is possible*/> { long index; types::array_tuple shape; ndindex_iterator(); @@ -25,6 +24,10 @@ namespace numpy ndindex_iterator &operator++(); ndindex_iterator &operator+=(long n); bool operator!=(ndindex_iterator const &other) const; + bool operator==(ndindex_iterator const &other) const + { + return !(*this != other); + } bool operator<(ndindex_iterator const &other) const; long operator-(ndindex_iterator const &other) const; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/nonzero.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/nonzero.hpp index add55d20ea8..d09edac13f7 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/nonzero.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/nonzero.hpp @@ -11,8 +11,7 @@ namespace numpy template auto nonzero(E const &expr) - -> types::array_tuple>, - E::value>; + -> types::array_tuple>, E::value>; DEFINE_FUNCTOR(pythonic::numpy, nonzero) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ones.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ones.hpp index 8ce8d3f505a..276e2531ad1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ones.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ones.hpp @@ -14,16 +14,14 @@ namespace numpy typename dtype::type ones(std::tuple<> const &shape, dtype d = dtype()); template - types::ndarray> - ones(pS const &shape, dtype d = dtype()); + types::ndarray> ones(pS const &shape, + dtype d = dtype()); template - types::ndarray> - ones(long size, dtype d = dtype()); + types::ndarray> ones(long size, dtype d = dtype()); template - types::ndarray>> + types::ndarray>> ones(std::integral_constant, dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, ones); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ones_like.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ones_like.hpp index 784b017d7e3..e121ca3a91e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ones_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ones_like.hpp @@ -10,13 +10,11 @@ namespace numpy { template - auto ones_like(E const &expr, dtype d = dtype()) - -> decltype(ones(sutils::getshape(expr), d)); + auto ones_like(E const &expr, dtype d = dtype()) -> decltype(ones(sutils::getshape(expr), d)); template auto ones_like(E const &expr, types::none_type d = builtins::None) - -> decltype(ones(sutils::getshape(expr), - types::dtype_t())); + -> decltype(ones(sutils::getshape(expr), types::dtype_t())); DEFINE_FUNCTOR(pythonic::numpy, ones_like) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/outer.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/outer.hpp index c125edba2e6..ab0ded6c449 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/outer.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/outer.hpp @@ -11,21 +11,17 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray() + std::declval()), - types::pshape> + types::ndarray() + std::declval()), types::pshape> outer(types::ndarray const &a, types::ndarray const &b); template - auto outer(types::ndarray const &a, - E1 const &b) -> decltype(outer(a, asarray(b))); + auto outer(types::ndarray const &a, E1 const &b) -> decltype(outer(a, asarray(b))); template - auto outer(E0 const &a, types::ndarray const &b) - -> decltype(outer(asarray(a), b)); + auto outer(E0 const &a, types::ndarray const &b) -> decltype(outer(asarray(a), b)); template - auto outer(E0 const &a, - E1 const &b) -> decltype(outer(asarray(a), asarray(b))); + auto outer(E0 const &a, E1 const &b) -> decltype(outer(asarray(a), asarray(b))); DEFINE_FUNCTOR(pythonic::numpy, outer); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/partial_sum.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/partial_sum.hpp index 968ae7ee2c7..59eb4d6be2f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/partial_sum.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/partial_sum.hpp @@ -10,28 +10,25 @@ namespace numpy template using result_dtype = types::dtype_t()( - std::declval::type::dtype>(), - std::declval::type::dtype>()))>; + std::declval::dtype>(), + std::declval::dtype>()))>; template > - types::ndarray> - partial_sum(E const &expr, dtype d = dtype()); + types::ndarray> partial_sum(E const &expr, + dtype d = dtype()); template > - auto partial_sum(E const &expr, long axis, dtype d = dtype()) -> - typename std::enable_if(expr))>::type; + auto partial_sum(E const &expr, long axis, dtype d = dtype()) + -> std::enable_if_t(expr))>; template > - using partial_sum_type = - types::ndarray>; + using partial_sum_type = types::ndarray>; template > using partial_sum_type2 = - types::ndarray>; + types::ndarray>; template > - typename std::enable_if>::type + std::enable_if_t> partial_sum(E const &expr, long axis, dtype d = dtype()); } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/place.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/place.hpp index 86e0094b91c..b084ee2d53d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/place.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/place.hpp @@ -11,12 +11,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type place(types::ndarray &expr, - types::ndarray const &mask, F const &values); + types::none_type place(types::ndarray &expr, types::ndarray const &mask, + F const &values); template - types::none_type place(types::ndarray &expr, M const &mask, - F const &values); + types::none_type place(types::ndarray &expr, M const &mask, F const &values); template types::none_type place(E &, M const &, F const &); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/prod.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/prod.hpp index 459108a512d..c0f735c8f85 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/prod.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/prod.hpp @@ -11,8 +11,8 @@ namespace numpy { template - auto prod(Args &&...args) -> decltype(reduce( - std::forward(args)...)); + auto prod(Args &&...args) + -> decltype(reduce(std::forward(args)...)); DEFINE_FUNCTOR(pythonic::numpy, prod); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ptp.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ptp.hpp index 6ee15eaaabd..8f069744e74 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ptp.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ptp.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto ptp(E const &expr, - long axis) -> decltype(max(expr, axis) - min(expr, axis)); + auto ptp(E const &expr, long axis) -> decltype(max(expr, axis) - min(expr, axis)); template auto ptp(E const &expr) -> decltype(max(expr) - min(expr)); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/put.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/put.hpp index fad2c56efe2..cf9043166b5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/put.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/put.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, - types::none_type>::type + std::enable_if_t::value, types::none_type> put(types::ndarray &expr, F const &ind, E const &v); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/putmask.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/putmask.hpp index c10c896432d..132ac3942f9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/putmask.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/putmask.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type putmask(types::ndarray &expr, E const &mask, - F const &values); + types::none_type putmask(types::ndarray &expr, E const &mask, F const &values); template types::none_type putmask(E &, M const &, F const &); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/choice.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/choice.hpp index 38234fdbe39..081ba79a304 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/choice.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/choice.hpp @@ -12,16 +12,13 @@ namespace numpy namespace random { template - types::ndarray choice(long max, pS const &shape, bool replace, - P const &p); + types::ndarray choice(long max, pS const &shape, bool replace, P const &p); template - types::ndarray> choice(long max, long size, - bool replace, P &&p); + types::ndarray> choice(long max, long size, bool replace, P &&p); template - auto choice(long max, - T &&size) -> decltype(randint(0, max, std::forward(size))); + auto choice(long max, T &&size) -> decltype(randint(0, max, std::forward(size))); long choice(long max); @@ -32,16 +29,15 @@ namespace numpy types::ndarray choice(T const &a, pS const &shape); template - types::ndarray> choice(T &&a, - long size); + types::ndarray> choice(T &&a, long size); template - types::ndarray choice(T const &a, pS const &shape, - bool replace, P const &p); + types::ndarray choice(T const &a, pS const &shape, bool replace, + P const &p); template - types::ndarray> - choice(T &&a, long size, bool replace, P &&p); + types::ndarray> choice(T &&a, long size, bool replace, + P &&p); DEFINE_FUNCTOR(pythonic::numpy::random, choice); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/f.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/f.hpp index 32e9ae53994..e4e6f7685b3 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/f.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/f.hpp @@ -14,9 +14,8 @@ namespace numpy template types::ndarray f(double dfnum, double dfden, pS const &shape); - auto f(double dfnum, double dfden, - long size) -> decltype(f(dfnum, dfden, - types::array_tuple{{size}})); + auto f(double dfnum, double dfden, long size) + -> decltype(f(dfnum, dfden, types::array_tuple{{size}})); double f(double dfnum, double dfden, types::none_type size = {}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/gamma.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/gamma.hpp index 336e10eb729..a5a740187d6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/gamma.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/gamma.hpp @@ -12,14 +12,12 @@ namespace numpy namespace random { template - types::ndarray gamma(double shape, double scale, - pS const &array_shape); + types::ndarray gamma(double shape, double scale, pS const &array_shape); auto gamma(double shape, double scale, long size) -> decltype(gamma(shape, scale, types::array_tuple{{size}})); - double gamma(double shape = 0.0, double scale = 1.0, - types::none_type size = {}); + double gamma(double shape = 0.0, double scale = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, gamma); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/gumbel.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/gumbel.hpp index 0dd5481d500..6a45541a333 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/gumbel.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/gumbel.hpp @@ -12,14 +12,12 @@ namespace numpy namespace random { template - types::ndarray gumbel(double loc, double scale, - pS const &shape); + types::ndarray gumbel(double loc, double scale, pS const &shape); auto gumbel(double loc, double scale, long size) -> decltype(gumbel(loc, scale, types::array_tuple{{size}})); - double gumbel(double loc = 0.0, double scale = 1.0, - types::none_type size = {}); + double gumbel(double loc = 0.0, double scale = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, gumbel); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/laplace.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/laplace.hpp index f0a5fab81a8..fc6bb940180 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/laplace.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/laplace.hpp @@ -12,14 +12,12 @@ namespace numpy namespace random { template - types::ndarray laplace(double loc, double scale, - pS const &shape); + types::ndarray laplace(double loc, double scale, pS const &shape); auto laplace(double loc, double scale, long size) -> decltype(laplace(loc, scale, types::array_tuple{{size}})); - double laplace(double loc = 0.0, double scale = 1.0, - types::none_type size = {}); + double laplace(double loc = 0.0, double scale = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, laplace); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/logistic.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/logistic.hpp index 938ce930ca3..13dcd527ba0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/logistic.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/logistic.hpp @@ -12,14 +12,12 @@ namespace numpy namespace random { template - types::ndarray logistic(double loc, double scale, - pS const &shape); + types::ndarray logistic(double loc, double scale, pS const &shape); auto logistic(double loc, double scale, long size) -> decltype(logistic(loc, scale, types::array_tuple{{size}})); - double logistic(double loc = 0.0, double scale = 1.0, - types::none_type size = {}); + double logistic(double loc = 0.0, double scale = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, logistic); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/lognormal.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/lognormal.hpp index 5c1ee965f9c..19b6d51087c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/lognormal.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/lognormal.hpp @@ -12,15 +12,12 @@ namespace numpy namespace random { template - types::ndarray lognormal(double mean, double sigma, - pS const &shape); + types::ndarray lognormal(double mean, double sigma, pS const &shape); auto lognormal(double mean, double sigma, long size) - -> decltype(lognormal(mean, sigma, - types::array_tuple{{size}})); + -> decltype(lognormal(mean, sigma, types::array_tuple{{size}})); - double lognormal(double mean = 0.0, double sigma = 1.0, - types::none_type size = {}); + double lognormal(double mean = 0.0, double sigma = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, lognormal); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/negative_binomial.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/negative_binomial.hpp index 1b70ef5082b..7188ada2998 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/negative_binomial.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/negative_binomial.hpp @@ -12,12 +12,10 @@ namespace numpy namespace random { template - types::ndarray negative_binomial(long n, double p, - pS const &shape); + types::ndarray negative_binomial(long n, double p, pS const &shape); auto negative_binomial(long n, double p, long size) - -> decltype(negative_binomial(n, p, - types::array_tuple{{size}})); + -> decltype(negative_binomial(n, p, types::array_tuple{{size}})); long negative_binomial(long n, double p, types::none_type size = {}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/normal.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/normal.hpp index bc69b5ff004..f2e8aa00e06 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/normal.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/normal.hpp @@ -12,14 +12,12 @@ namespace numpy namespace random { template - types::ndarray normal(double loc, double scale, - pS const &shape); + types::ndarray normal(double loc, double scale, pS const &shape); auto normal(double loc, double scale, long size) -> decltype(normal(loc, scale, types::array_tuple{{size}})); - double normal(double loc = 0.0, double scale = 1.0, - types::none_type size = {}); + double normal(double loc = 0.0, double scale = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, normal); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/pareto.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/pareto.hpp index a98eb234815..72987148c58 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/pareto.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/pareto.hpp @@ -15,8 +15,7 @@ namespace numpy template types::ndarray pareto(double a, pS const &shape); - auto pareto(double a, long size) - -> decltype(pareto(a, types::array_tuple{{size}})); + auto pareto(double a, long size) -> decltype(pareto(a, types::array_tuple{{size}})); double pareto(double a, types::none_type size = {}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/power.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/power.hpp index f10fdc7553a..b5ad6dafd9a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/power.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/power.hpp @@ -14,8 +14,7 @@ namespace numpy { template types::ndarray power(double a, pS const &shape); - auto power(double a, long size) - -> decltype(power(a, types::array_tuple{{size}})); + auto power(double a, long size) -> decltype(power(a, types::array_tuple{{size}})); double power(double a, types::none_type size = {}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/rand.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/rand.hpp index 5e10ebecc51..cd37233bdb9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/rand.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/rand.hpp @@ -10,8 +10,7 @@ namespace numpy namespace random { template - types::ndarray> - rand(T... shape); + types::ndarray> rand(T... shape); double rand(); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/randint.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/randint.hpp index bcc8ebbdeb2..60de4b4388b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/randint.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/randint.hpp @@ -11,18 +11,15 @@ namespace numpy namespace random { template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> randint(long min, long max, pS const &shape); template - typename std::enable_if::value, - types::ndarray>>::type + std::enable_if_t::value, types::ndarray>> randint(long min, long max, pS const &shape); template - auto randint(long max, types::none_type, - pS const &shape) -> decltype(randint(0, max, shape)); + auto randint(long max, types::none_type, pS const &shape) -> decltype(randint(0, max, shape)); long randint(long min, long max); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/randn.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/randn.hpp index 1a9cdd1c649..5c1b6083fc4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/randn.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/randn.hpp @@ -11,8 +11,7 @@ namespace numpy namespace random { template - types::ndarray> - randn(T... shape); + types::ndarray> randn(T... shape); double randn(); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/random.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/random.hpp index 084c57b6843..fb10a2cfef1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/random.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/random.hpp @@ -14,13 +14,11 @@ namespace numpy template types::ndarray random(pS const &shape); - auto - random(long size) -> decltype(random(types::array_tuple{{size}})); + auto random(long size) -> decltype(random(types::array_tuple{{size}})); template auto random(std::integral_constant) - -> decltype(random( - types::array_tuple, 1>{})) + -> decltype(random(types::array_tuple, 1>{})) { return random(types::array_tuple, 1>{}); } diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/uniform.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/uniform.hpp index da81018b81d..7b297850a5b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/uniform.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/uniform.hpp @@ -13,14 +13,12 @@ namespace numpy namespace random { template - types::ndarray uniform(double low, double high, - pS const &array_shape); + types::ndarray uniform(double low, double high, pS const &array_shape); auto uniform(double low, double high, long size) -> decltype(uniform(low, high, types::array_tuple{{size}})); - double uniform(double low = 0.0, double high = 1.0, - types::none_type size = {}); + double uniform(double low = 0.0, double high = 1.0, types::none_type size = {}); DEFINE_FUNCTOR(pythonic::numpy::random, uniform); } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/random/weibull.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/random/weibull.hpp index 2f96e7d0b9e..aa640a87dd8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/random/weibull.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/random/weibull.hpp @@ -14,8 +14,7 @@ namespace numpy template types::ndarray weibull(double a, pS const &shape); - auto weibull(double a, long size) - -> decltype(weibull(a, types::array_tuple{{size}})); + auto weibull(double a, long size) -> decltype(weibull(a, types::array_tuple{{size}})); double weibull(double a, types::none_type size = {}); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ravel.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ravel.hpp index 9fd9e8e51ef..73902ffa921 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ravel.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ravel.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - ravel(types::ndarray const &expr); + types::ndarray> ravel(types::ndarray const &expr); NUMPY_EXPR_TO_NDARRAY0_DECL(ravel); DEFINE_FUNCTOR(pythonic::numpy, ravel); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/real.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/real.hpp index 900733f5f8c..ce46770c0f9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/real.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/real.hpp @@ -11,11 +11,9 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto real(E &&expr) -> decltype(builtins::getattr(types::attr::REAL{}, - std::forward(expr))); + auto real(E &&expr) -> decltype(builtins::getattr(types::attr::REAL{}, std::forward(expr))); template - auto real(types::list const &expr) - -> decltype(real(numpy::functor::asarray{}(expr))); + auto real(types::list const &expr) -> decltype(real(numpy::functor::asarray{}(expr))); DEFINE_FUNCTOR(pythonic::numpy, real); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/reduce.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/reduce.hpp index 6923590ca56..5b37b1fbeff 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/reduce.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/reduce.hpp @@ -27,65 +27,58 @@ namespace numpy }; template struct reduce_result_type_helper { - using type = typename std::conditional< + using type = std::conditional_t< std::is_integral::type>::value && (sizeof(typename types::dtype_of::type) < sizeof(long)) && !std::is_same::value && !std::is_same::value, - typename std::conditional< - std::is_same::type, bool>::value, - long, - typename std::conditional< - std::is_signed::type>::value, - long, unsigned long>::type>::type, - typename types::dtype_of::type>::type; + std::conditional_t< + std::is_same::type, bool>::value, long, + std::conditional_t::type>::value, long, + unsigned long>>, + typename types::dtype_of::type>; }; template - using reduce_result_type = - typename reduce_result_type_helper::type; + using reduce_result_type = typename reduce_result_type_helper::type; } // namespace template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, E>::type + std::enable_if_t::value || types::is_complex::value, E> reduce(E const &expr, types::none_type _ = types::none_type()); template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, E>::type + std::enable_if_t::value || types::is_complex::value, E> reduce(E const &array, long axis); template - typename std::enable_if::value, - reduce_result_type>::type + std::enable_if_t::value, reduce_result_type> reduce(E const &expr, types::none_type axis = {}, dtype d = {}); template - reduce_result_type reduce(types::numpy_texpr const &expr, - types::none_type axis = {}, dtype d = {}) + reduce_result_type reduce(types::numpy_texpr const &expr, types::none_type axis = {}, + dtype d = {}) { return reduce(expr.arg, axis, d); } template - typename std::enable_if>::type + std::enable_if_t> reduce(E const &array, long axis, dtype d = {}, types::none_type out = {}); template - typename std::enable_if>::type + std::enable_if_t> reduce(E const &array, long axis, types::none_type dtype, Out &&out); namespace { template - using reduced_type = types::ndarray, - types::array_tuple>; + using reduced_type = + types::ndarray, types::array_tuple>; } template - typename std::enable_if>::type - reduce(E const &array, long axis, dtype d = {}, - types::none_type out = types::none_type()); + std::enable_if_t> + reduce(E const &array, long axis, dtype d = {}, types::none_type out = types::none_type()); template reduced_type reduce(types::numpy_texpr const &array, long axis, @@ -96,8 +89,8 @@ namespace numpy } template - typename std::enable_if>::type - reduce(E const &array, long axis, types::none_type dtype, Out &&out); + std::enable_if_t> reduce(E const &array, long axis, + types::none_type dtype, Out &&out); } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/remainder.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/remainder.hpp index 691687ff80b..1ac9d83fe19 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/remainder.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/remainder.hpp @@ -15,8 +15,7 @@ namespace numpy namespace wrapper { template - auto remainder(T0 const &x, - T1 const &y) -> decltype(x - y * xsimd::floor(x / y)) + auto remainder(T0 const &x, T1 const &y) -> decltype(x - y * xsimd::floor(x / y)) { return x - y * xsimd::floor(x / y); } diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/repeat.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/repeat.hpp index 39dba3a7c0c..42efc350b38 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/repeat.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/repeat.hpp @@ -15,9 +15,8 @@ namespace numpy repeat(types::ndarray const &expr, long repeats, long axis); template - types::ndarray> - repeat(types::ndarray const &expr, long repeats, - types::none_type axis = types::none_type{}); + types::ndarray> repeat(types::ndarray const &expr, long repeats, + types::none_type axis = types::none_type{}); NUMPY_EXPR_TO_NDARRAY0_DECL(repeat); DEFINE_FUNCTOR(pythonic::numpy, repeat); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/roll.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/roll.hpp index cf8e122e52f..e5c9d22c1f7 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/roll.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/roll.hpp @@ -13,12 +13,10 @@ namespace numpy types::ndarray roll(types::ndarray const &expr, long shift); template - types::ndarray roll(types::ndarray const &expr, long shift, - long axis); + types::ndarray roll(types::ndarray const &expr, long shift, long axis); template - types::ndarray roll(types::ndarray const &expr, - types::array_tuple shift, + types::ndarray roll(types::ndarray const &expr, types::array_tuple shift, types::array_tuple axis); NUMPY_EXPR_TO_NDARRAY0_DECL(roll); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/searchsorted.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/searchsorted.hpp index 378b30d021d..53165832fee 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/searchsorted.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/searchsorted.hpp @@ -15,13 +15,12 @@ namespace numpy { template - typename std::enable_if::value, long>::type + std::enable_if_t::value, long> searchsorted(U const &a, T const &v, types::str const &side = "left"); template - typename std::enable_if< - types::is_numexpr_arg::value, - types::ndarray>>::type + std::enable_if_t::value, + types::ndarray>> searchsorted(T const &a, E const &v, types::str const &side = "left"); DEFINE_FUNCTOR(pythonic::numpy, searchsorted); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/select.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/select.hpp index c8040d7a3a7..d946749210e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/select.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/select.hpp @@ -11,39 +11,31 @@ namespace numpy template types::ndarray> - select(C const &condlist, L const &choicelist, - typename L::dtype _default = 0); + select(C const &condlist, L const &choicelist, typename L::dtype _default = 0); template - typename std::enable_if< - std::tuple_size::value == std::tuple_size::value, - types::ndarray< - T, types::array_tuple::value>>>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray::value>>> select(types::list> const &condlist, types::list> const &choicelist, T _default = 0); template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::static_list, M> const &condlist, - types::static_list, M> const &choicelist, - T _default = 0); + types::static_list, M> const &choicelist, T _default = 0); template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::static_list, M> const &condlist, types::list> const &choicelist, T _default = 0); template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::list> const &condlist, - types::static_list, M> const &choicelist, - T _default = 0); + types::static_list, M> const &choicelist, T _default = 0); DEFINE_FUNCTOR(pythonic::numpy, select); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/short_.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/short_.hpp index df740d99f85..a43b68b49e2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/short_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/short_.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::short_ const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::short_ convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/sort.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/sort.hpp index 97c40568135..80096c645ed 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/sort.hpp @@ -11,12 +11,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - sort(E const &expr, types::none_type); + types::ndarray> sort(E const &expr, + types::none_type); template - types::ndarray> - sort(E const &expr, long axis = -1); + types::ndarray> sort(E const &expr, + long axis = -1); template types::ndarray> diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/split.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/split.hpp index dfc51673471..a5e9a60028c 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/split.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/split.hpp @@ -8,20 +8,17 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::list< - types::ndarray::value>>> + types::list::value>>> split(types::ndarray const &a, long nb_split); template - typename std::enable_if< + std::enable_if_t< types::is_iterable::value, - types::list::value>>>>::type + types::list::value>>>> split(types::ndarray const &a, I const &split_mask); template - types::list< - types::ndarray>> + types::list>> split(E const &a, I const &); DEFINE_FUNCTOR(pythonic::numpy, split); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/stack.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/stack.hpp index 94cbfcc5dd7..f9f1142b270 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/stack.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/stack.hpp @@ -15,14 +15,12 @@ namespace numpy namespace details { template - using stack_helper_t = - typename __combined::type...>::type; + using stack_helper_t = typename __combined::type...>::type; } template - types::ndarray< - typename details::stack_helper_t::dtype, - types::array_tuple::value + 1>> + types::ndarray::dtype, + types::array_tuple::value + 1>> stack(std::tuple const &args, long axis = 0); DEFINE_FUNCTOR(pythonic::numpy, stack); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/std_.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/std_.hpp index 0e403bf214c..cd28fd2192b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/std_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/std_.hpp @@ -10,8 +10,7 @@ namespace numpy { template - auto std_(Args &&...args) - -> decltype(functor::sqrt{}(var(std::forward(args)...))); + auto std_(Args &&...args) -> decltype(functor::sqrt{}(var(std::forward(args)...))); DEFINE_FUNCTOR(pythonic::numpy, std_); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/swapaxes.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/swapaxes.hpp index 13552f2cd3e..32d50646393 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/swapaxes.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/swapaxes.hpp @@ -8,11 +8,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto swapaxes(T &&a, int axis1, int axis2) - -> decltype(functor::transpose{}( - std::forward(a), - std::declval< - types::array_tuple::type::value>>())); + auto swapaxes(T &&a, int axis1, int axis2) -> decltype(functor::transpose{}( + std::forward(a), std::declval::value>>())); DEFINE_FUNCTOR(pythonic::numpy, swapaxes); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/take.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/take.hpp index 47c311c86df..286fb9d1502 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/take.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/take.hpp @@ -6,8 +6,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto take(T &&expr, F &&indices) - -> decltype(std::forward(expr)[std::forward(indices)]); + auto take(T &&expr, F &&indices) -> decltype(std::forward(expr)[std::forward(indices)]); DEFINE_FUNCTOR(pythonic::numpy, take); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/tile.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/tile.hpp index 6c844eeceee..04ac0e475f6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/tile.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/tile.hpp @@ -9,8 +9,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - tile(E const &expr, long reps); + types::ndarray> tile(E const &expr, + long reps); template types::ndarray> diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/transpose.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/transpose.hpp index 0eb9ade8b3e..c5a98f8a8eb 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/transpose.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/transpose.hpp @@ -13,8 +13,7 @@ namespace numpy { template - types::numpy_texpr> - transpose(types::broadcasted const &arr) + types::numpy_texpr> transpose(types::broadcasted const &arr) { return {arr}; } @@ -26,36 +25,31 @@ namespace numpy } template - typename std::enable_if>::type - transpose(E const &arr) + std::enable_if_t> transpose(E const &arr) { return {arr}; } template - typename std::enable_if::type transpose(E const &arr) + std::enable_if_t transpose(E const &arr) { return arr; } template - typename std::enable_if< - (std::tuple_size::value > 2), - types::ndarray::value>>>:: - type - transpose(types::ndarray const &a); + std::enable_if_t<(std::tuple_size::value > 2), + types::ndarray::value>>> + transpose(types::ndarray const &a); template types::ndarray::value>> - transpose(types::ndarray const &a, - types::array_tuple const &t); + transpose(types::ndarray const &a, types::array_tuple const &t); template types::ndarray> transpose(types::ndarray const &a, long index, Args const &...indices) { - return transpose(a, types::array_tuple{ - {index, (long)indices...}}); + return transpose(a, types::array_tuple{{index, (long)indices...}}); } template @@ -64,16 +58,15 @@ namespace numpy template auto transpose(types::numpy_expr const &expr) -> decltype(_transpose>{}( - expr, utils::make_index_sequence())) + expr, std::make_index_sequence())) { return _transpose>{}( - expr, utils::make_index_sequence()); + expr, std::make_index_sequence()); } template struct _transpose> { template - auto operator()(types::numpy_expr const &expr, - utils::index_sequence) + auto operator()(types::numpy_expr const &expr, std::index_sequence) -> decltype(Op{}(transpose(std::get(expr.args))...)) { return Op{}(transpose(std::get(expr.args))...); @@ -81,14 +74,11 @@ namespace numpy }; template - auto transpose(E const &expr) -> - typename std::enable_if< - (E::value > 2), - decltype(transpose(types::ndarray{expr}))>::type + auto transpose(E const &expr) -> std::enable_if_t< + (E::value > 2), + decltype(transpose(types::ndarray{expr}))> { - return transpose( - types::ndarray{expr}); + return transpose(types::ndarray{expr}); } DEFINE_FUNCTOR(pythonic::numpy, transpose); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ubyte.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ubyte.hpp index e95fd990dea..e99d72a3dbe 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ubyte.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ubyte.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::ubyte const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::ubyte convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_accumulate.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_accumulate.hpp index be76448d59e..3e64b889b8e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_accumulate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_accumulate.hpp @@ -15,11 +15,9 @@ namespace numpy { namespace UFUNC_NAME { - template > + template > auto accumulate(T &&a, long axis = 0, dtype d = dtype()) - -> decltype(partial_sum(std::forward(a), - axis, d)); + -> decltype(partial_sum(std::forward(a), axis, d)); DEFINE_FUNCTOR(pythonic::numpy::UFUNC_NAME, accumulate); } // namespace UFUNC_NAME } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_reduce.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_reduce.hpp index 8f8b19f5999..de63f457131 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_reduce.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ufunc_reduce.hpp @@ -20,21 +20,16 @@ namespace numpy template auto reduce(Arg &&arg) - -> decltype(numpy::reduce( - std::forward(arg), 0L)) + -> decltype(numpy::reduce(std::forward(arg), 0L)) { - return numpy::reduce( - std::forward(arg), 0L); + return numpy::reduce(std::forward(arg), 0L); } template - auto reduce(Args &&...args) -> - typename std::enable_if< - sizeof...(Args) != 1, - decltype(numpy::reduce( - std::forward(args)...))>::type + auto reduce(Args &&...args) -> std::enable_if_t< + sizeof...(Args) != 1, + decltype(numpy::reduce(std::forward(args)...))> { - return numpy::reduce( - std::forward(args)...); + return numpy::reduce(std::forward(args)...); } DEFINE_FUNCTOR(pythonic::numpy::UFUNC_NAME, reduce); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uint.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uint.hpp index dd6242f7759..bc13cf6e2e2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uint.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uint.hpp @@ -25,4 +25,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uint const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uint convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uint16.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uint16.hpp index 0d1f6c33533..924a732a56b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uint16.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uint16.hpp @@ -26,4 +26,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uint16 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uint16 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uint32.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uint32.hpp index 0d0bfcb17b4..d0f6e29a473 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uint32.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uint32.hpp @@ -24,5 +24,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uint32 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uint32 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uint64.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uint64.hpp index 85264f209c8..ca718acc098 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uint64.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uint64.hpp @@ -25,4 +25,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uint64 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uint64 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uint8.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uint8.hpp index 8eef53ba882..78d3d491fd2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uint8.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uint8.hpp @@ -26,4 +26,23 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uint8 const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uint8 convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/uintc.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/uintc.hpp index dc9a6e25c77..0d65b7067fd 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/uintc.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/uintc.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::uintc const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::uintc convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/union1d.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/union1d.hpp index 241fd221ecc..d03e5cf50c2 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/union1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/union1d.hpp @@ -9,9 +9,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> union1d(E const &e, F const &f); DEFINE_FUNCTOR(pythonic::numpy, union1d) diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/unique.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/unique.hpp index e353f4de2a8..293c811fcb0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/unique.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/unique.hpp @@ -25,85 +25,68 @@ namespace numpy template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse); + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse); template types::ndarray> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse); + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse); template std::tuple>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse); + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse); template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse); + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse); template std::tuple>, - types::ndarray>, - types::ndarray>, + types::ndarray>, types::ndarray>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse, + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse, types::true_immediate return_counts); template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse, types::false_immediate return_counts); template std::tuple>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse, types::false_immediate return_counts); template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse, types::true_immediate return_counts); template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse, types::false_immediate return_counts); template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse, types::true_immediate return_counts); template types::ndarray> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse, types::false_immediate return_counts); template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse, types::true_immediate return_counts); DEFINE_FUNCTOR(pythonic::numpy, unique) diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/unravel_index.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/unravel_index.hpp index fcab8025b35..9705a57bdb4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/unravel_index.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/unravel_index.hpp @@ -9,9 +9,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - std::is_scalar::value, - types::array_tuple::value>>::type + std::enable_if_t::value, types::array_tuple::value>> unravel_index(E const &expr, S const &shape, types::str const &order = "C"); DEFINE_FUNCTOR(pythonic::numpy, unravel_index); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/unwrap.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/unwrap.hpp index e0928a5001f..0a906d03312 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/unwrap.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/unwrap.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray unwrap(E const &expr, - double discont = pi); + types::ndarray unwrap(E const &expr, double discont = pi); DEFINE_FUNCTOR(pythonic::numpy, unwrap) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/ushort.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/ushort.hpp index de2018e7957..a7ec888e757 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/ushort.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/ushort.hpp @@ -25,5 +25,23 @@ namespace numpy #include "pythonic/include/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +template <> +struct to_python { + static PyObject *convert(numpy::functor::ushort const &c); +}; + +template <> +struct from_python { + static bool is_convertible(PyObject *obj); + static numpy::functor::ushort convert(PyObject *obj); +}; +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/var.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/var.hpp index f6a74f69b1c..8486b142e8a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/var.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/var.hpp @@ -15,14 +15,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - using var_type = typename std::conditional< - std::is_integral::value, double, - decltype(std::real(std::declval()))>::type; + using var_type = std::conditional_t::value, double, + decltype(std::real(std::declval()))>; template auto var(E const &expr, types::none_type axis = builtins::None, - types::none_type dtype = builtins::None, - types::none_type out = builtins::None, + types::none_type dtype = builtins::None, types::none_type out = builtins::None, long ddof = 0) -> decltype(var_type(std::real(mean(expr)))); template diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/vdot.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/vdot.hpp index db4cdcd64d7..c5228c440dc 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/vdot.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/vdot.hpp @@ -12,8 +12,7 @@ namespace numpy { template auto vdot(U const &u, V const &v) - -> decltype(functor::dot{}(functor::asarray{}(u).flat(), - functor::asarray{}(v).flat())); + -> decltype(functor::dot{}(functor::asarray{}(u).flat(), functor::asarray{}(v).flat())); DEFINE_FUNCTOR(pythonic::numpy, vdot); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/vectorize.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/vectorize.hpp index 14e1fead586..e38e50a5f65 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/vectorize.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/vectorize.hpp @@ -12,16 +12,13 @@ namespace numpy struct vectorized { using callable = void; template - auto operator()(T &&...args) const -> - typename std::enable_if::type...>::value, - decltype(F{}(std::forward(args)...))>::type; + auto operator()(T &&...args) const + -> std::enable_if_t...>::value, + decltype(F{}(std::forward(args)...))>; template - typename std::enable_if< - types::valid_numexpr_parameters::type...>::value, - types::numpy_expr::type...>>::type + std::enable_if_t...>::value, + types::numpy_expr::type...>> operator()(E &&...args) const; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/vstack.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/vstack.hpp index 9742af5e880..46dbf5b56f3 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/vstack.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/vstack.hpp @@ -14,9 +14,9 @@ namespace numpy } template - auto vstack(ArraySequence &&seq) -> - typename std::enable_if<(impl::vstack_helper::value > 1), - impl::vstack_helper>::type; + auto vstack(ArraySequence &&seq) + -> std::enable_if_t<(impl::vstack_helper::value > 1), + impl::vstack_helper>; // according to the numpy.vstack doc: // Equivalent to ``np.concatenate(tup, axis=0)`` if `tup` contains arrays @@ -25,11 +25,10 @@ namespace numpy // // the enable if is there to match this behavior template - auto vstack(ArraySequence &&seq) -> - typename std::enable_if< - (impl::vstack_helper::value == 1), - decltype(std::declval>().reshape( - std::declval>()))>::type; + auto vstack(ArraySequence &&seq) + -> std::enable_if_t<(impl::vstack_helper::value == 1), + decltype(std::declval>().reshape( + std::declval>()))>; DEFINE_FUNCTOR(pythonic::numpy, vstack); } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/where.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/where.hpp index 559c9aca5be..3bf9482dfbe 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/where.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/where.hpp @@ -12,15 +12,14 @@ namespace numpy namespace impl { template - typename __combined::type where(E const &cond, F const &true_, - G const &false_); + typename __combined::type where(E const &cond, F const &true_, G const &false_); } -#define NUMPY_NARY_EXTRA_METHOD \ - template \ - auto operator()(E &&expr)->decltype(nonzero{}(std::forward(expr))) \ - { \ - return nonzero{}(std::forward(expr)); \ +#define NUMPY_NARY_EXTRA_METHOD \ + template \ + auto operator()(E &&expr)->decltype(nonzero{}(std::forward(expr))) \ + { \ + return nonzero{}(std::forward(expr)); \ } #define NUMPY_NARY_FUNC_NAME where diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/zeros.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/zeros.hpp index d716de5d1bf..7747118c011 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/zeros.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/zeros.hpp @@ -13,16 +13,14 @@ namespace numpy typename dtype::type zeros(std::tuple<> const &shape, dtype d = dtype()); template - types::ndarray> - zeros(pS const &shape, dtype d = dtype()); + types::ndarray> zeros(pS const &shape, + dtype d = dtype()); template - types::ndarray> - zeros(long size, dtype d = dtype()); + types::ndarray> zeros(long size, dtype d = dtype()); template - types::ndarray>> + types::ndarray>> zeros(std::integral_constant, dtype d = dtype()); DEFINE_FUNCTOR(pythonic::numpy, zeros); diff --git a/contrib/python/pythran/pythran/pythonic/include/numpy/zeros_like.hpp b/contrib/python/pythran/pythran/pythonic/include/numpy/zeros_like.hpp index c593ddbad11..78cac6e2677 100644 --- a/contrib/python/pythran/pythran/pythonic/include/numpy/zeros_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/numpy/zeros_like.hpp @@ -10,13 +10,11 @@ namespace numpy { template - auto zeros_like(E const &expr, dtype d = dtype()) - -> decltype(zeros(sutils::getshape(expr), d)); + auto zeros_like(E const &expr, dtype d = dtype()) -> decltype(zeros(sutils::getshape(expr), d)); template auto zeros_like(E const &expr, types::none_type d = builtins::None) - -> decltype(zeros(sutils::getshape(expr), - types::dtype_t())); + -> decltype(zeros(sutils::getshape(expr), types::dtype_t())); DEFINE_FUNCTOR(pythonic::numpy, zeros_like) } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/concat.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/concat.hpp index beba5e98f77..fa2a59c0a54 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/concat.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/concat.hpp @@ -9,8 +9,7 @@ namespace operator_ { template - auto concat(A &&a, - B &&b) -> decltype(std::forward(a) + std::forward(b)); + auto concat(A &&a, B &&b) -> decltype(std::forward(a) + std::forward(b)); DEFINE_FUNCTOR(pythonic::operator_, concat); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/contains.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/contains.hpp index ce741d860ed..2bb08e23d10 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/contains.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/contains.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto contains(A &&a, - B &&b) -> decltype(in(std::forward(a), std::forward(b))); + auto contains(A &&a, B &&b) -> decltype(in(std::forward(a), std::forward(b))); DEFINE_FUNCTOR(pythonic::operator_, contains); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/div.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/div.hpp index 3d8d44f6a4b..ecddd2e1712 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/div.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/div.hpp @@ -10,10 +10,9 @@ namespace operator_ { template auto div(A &&a, B &&b) // for ndarrays - -> typename std::enable_if< - !std::is_fundamental::type>::value || - !std::is_fundamental::type>::value, - decltype(std::forward(a) / std::forward(b))>::type; + -> std::enable_if_t>::value || + !std::is_fundamental>::value, + decltype(std::forward(a) / std::forward(b))>; double div(double a, double b); diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/getitem.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/getitem.hpp index 78697dec48b..c136097769f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/getitem.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/getitem.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto getitem(A &&a, - B &&b) -> decltype(std::forward(a)[std::forward(b)]); + auto getitem(A &&a, B &&b) -> decltype(std::forward(a)[std::forward(b)]); DEFINE_FUNCTOR(pythonic::operator_, getitem); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/icommon.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/icommon.hpp index 2d5c6a17452..a45d1008e18 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/icommon.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/icommon.hpp @@ -22,19 +22,16 @@ namespace operator_ { template - auto OPERATOR_NAME(bool, A &&a, B &&b, - ...) -> decltype(std::forward(a) - OPERATOR_SYMBOL std::forward(b)); + auto OPERATOR_NAME(bool, A &&a, B &&b, ...) + -> decltype(std::forward(a) OPERATOR_SYMBOL std::forward(b)); template auto OPERATOR_NAME(bool, A &&a, B &&b, std::nullptr_t) -> decltype(std::forward(a) OPERATOR_ISYMBOL std::forward(b)); template - auto OPERATOR_NAME(A &&a, - B &&b) -> decltype(OPERATOR_NAME(true, std::forward(a), - std::forward(b), - nullptr)) + auto OPERATOR_NAME(A &&a, B &&b) + -> decltype(OPERATOR_NAME(true, std::forward(a), std::forward(b), nullptr)) { return OPERATOR_NAME(true, std::forward(a), std::forward(b), nullptr); } diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/imax.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/imax.hpp index c57935e245a..7edbf76f35f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/imax.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/imax.hpp @@ -9,18 +9,16 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto imax(A &&a, B &&b) -> - typename std::enable_if< - std::is_const::value || !std::is_assignable::value, - decltype(numpy::functor::maximum{}(std::forward(a), - std::forward(b)))>::type; + auto imax(A &&a, B &&b) + -> std::enable_if_t::value || !std::is_assignable::value, + decltype(numpy::functor::maximum{}(std::forward(a), + std::forward(b)))>; template - auto imax(A &&a, B &&b) -> - typename std::enable_if< - !std::is_const::value && std::is_assignable::value, - decltype(a = numpy::functor::maximum{}(std::forward(a), - std::forward(b)))>::type; + auto imax(A &&a, B &&b) + -> std::enable_if_t::value && std::is_assignable::value, + decltype(a = numpy::functor::maximum{}(std::forward(a), + std::forward(b)))>; DEFINE_FUNCTOR(pythonic::operator_, imax); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/imin.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/imin.hpp index 6036ff10dbd..82f5f2d747a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/imin.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/imin.hpp @@ -9,18 +9,16 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto imin(A &&a, B &&b) -> - typename std::enable_if< - std::is_const::value || !std::is_assignable::value, - decltype(numpy::functor::minimum{}(std::forward(a), - std::forward(b)))>::type; + auto imin(A &&a, B &&b) + -> std::enable_if_t::value || !std::is_assignable::value, + decltype(numpy::functor::minimum{}(std::forward(a), + std::forward(b)))>; template - auto imin(A &&a, B &&b) -> - typename std::enable_if< - !std::is_const::value && std::is_assignable::value, - decltype(a = numpy::functor::minimum{}(std::forward(a), - std::forward(b)))>::type; + auto imin(A &&a, B &&b) + -> std::enable_if_t::value && std::is_assignable::value, + decltype(a = numpy::functor::minimum{}(std::forward(a), + std::forward(b)))>; DEFINE_FUNCTOR(pythonic::operator_, imin); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/is_.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/is_.hpp index 2426ff1db0d..3d03634f131 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/is_.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/is_.hpp @@ -10,8 +10,8 @@ namespace operator_ { template - auto is_(A &&a, B &&b) -> decltype(builtins::id(std::forward(a)) == - builtins::id(std::forward(b))); + auto is_(A &&a, B &&b) + -> decltype(builtins::id(std::forward(a)) == builtins::id(std::forward(b))); DEFINE_FUNCTOR(pythonic::operator_, is_); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/is_not.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/is_not.hpp index 46b51a1d830..dceb3cca24d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/is_not.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/is_not.hpp @@ -9,8 +9,8 @@ namespace operator_ { template - auto is_not(A &&a, B &&b) -> decltype(builtins::id(std::forward(a)) != - builtins::id(std::forward(b))); + auto is_not(A &&a, B &&b) + -> decltype(builtins::id(std::forward(a)) != builtins::id(std::forward(b))); DEFINE_FUNCTOR(pythonic::operator_, is_not); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/itemgetter.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/itemgetter.hpp index 7fd8943fcfa..344c7cfa4fc 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/itemgetter.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/itemgetter.hpp @@ -34,14 +34,13 @@ namespace operator_ void helper(T &t, A const &a, utils::int_<0>) const; template - auto operator()(A const &a) const - -> std::tuple()])>::type>::type...>; + auto operator()(A const &a) const -> std::tuple< + std::remove_cv_t()])>>...>; }; template - itemgetter_tuple_return - itemgetter(long const &item1, long const &item2, L... items); + itemgetter_tuple_return itemgetter(long const &item1, long const &item2, + L... items); DEFINE_FUNCTOR(pythonic::operator_, itemgetter); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/itruediv.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/itruediv.hpp index 75b058e449c..bd5cf12c479 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/itruediv.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/itruediv.hpp @@ -12,16 +12,13 @@ namespace operator_ auto itruediv(A const &a, B &&b) -> decltype(truediv(a, std::forward(b))); template - auto itruediv(A &a, B &&b) -> - typename std::enable_if< - std::is_same(b)))>::value, - A &>::type; + auto itruediv(A &a, B &&b) + -> std::enable_if_t(b)))>::value, A &>; template - auto itruediv(A &a, B &&b) -> - typename std::enable_if< - !std::is_same(b)))>::value, - decltype(truediv(a, std::forward(b)))>::type; + auto itruediv(A &a, B &&b) + -> std::enable_if_t(b)))>::value, + decltype(truediv(a, std::forward(b)))>; DEFINE_FUNCTOR(pythonic::operator_, itruediv); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/lshift.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/lshift.hpp index 0de91c72922..bcd82dacf95 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/lshift.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/lshift.hpp @@ -10,8 +10,7 @@ namespace operator_ { template - auto lshift(A &&a, B &&b) -> decltype(std::forward(a) - << std::forward(b)); + auto lshift(A &&a, B &&b) -> decltype(std::forward(a) << std::forward(b)); DEFINE_ALL_OPERATOR_OVERLOADS_DECL(lshift, <<) diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/matmul.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/matmul.hpp index e0733b7d2bf..51f8abe4715 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/matmul.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/matmul.hpp @@ -10,9 +10,8 @@ namespace operator_ { template - auto matmul(A &&a, - B &&b) -> decltype(numpy::functor::dot{}(std::forward(a), - std::forward(b))); + auto matmul(A &&a, B &&b) + -> decltype(numpy::functor::dot{}(std::forward(a), std::forward(b))); DEFINE_FUNCTOR(pythonic::operator_, matmul); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/mod.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/mod.hpp index 3fecdec3d1f..294e6184a20 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/mod.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/mod.hpp @@ -9,11 +9,9 @@ namespace operator_ { template - auto mod(A &&a, B &&b) -> - typename std::enable_if< - std::is_fundamental::type>::value && - std::is_fundamental::type>::value, - decltype(std::forward(a) % std::forward(b))>::type; + auto mod(A &&a, B &&b) -> std::enable_if_t>::value && + std::is_fundamental>::value, + decltype(std::forward(a) % std::forward(b))>; inline double mod(double a, long b); @@ -21,10 +19,9 @@ namespace operator_ template auto mod(A &&a, B &&b) // for ndarrays - -> typename std::enable_if< - !std::is_fundamental::type>::value || - !std::is_fundamental::type>::value, - decltype(std::forward(a) % std::forward(b))>::type; + -> std::enable_if_t>::value || + !std::is_fundamental>::value, + decltype(std::forward(a) % std::forward(b))>; DEFINE_FUNCTOR(pythonic::operator_, mod); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/overloads.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/overloads.hpp index f4753f9b317..27d38b07c08 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/overloads.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/overloads.hpp @@ -1,23 +1,22 @@ #ifndef PYTHONIC_INCLUDE_OPERATOR_OVERLOADS_HPP #define PYTHONIC_INCLUDE_OPERATOR_OVERLOADS_HPP -#define PYTHONIC_OPERATOR_OVERLOAD_DECL(type, opname, op) \ - type opname(type a, type b); +#define PYTHONIC_OPERATOR_OVERLOAD_DECL(type, opname, op) type opname(type a, type b); // workaround the fact that char and short computations are done using int in C, // while they are done at their respective type in numpy -#define DEFINE_ALL_OPERATOR_OVERLOADS_DECL(opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(bool, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned char, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(char, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(signed char, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned short, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(signed short, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned int, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(signed int, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned long, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(signed long, opname, op) \ - PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned long long, opname, op) \ +#define DEFINE_ALL_OPERATOR_OVERLOADS_DECL(opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(bool, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned char, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(char, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(signed char, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned short, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(signed short, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned int, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(signed int, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned long, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(signed long, opname, op) \ + PYTHONIC_OPERATOR_OVERLOAD_DECL(unsigned long long, opname, op) \ PYTHONIC_OPERATOR_OVERLOAD_DECL(signed long long, opname, op) #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/rshift.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/rshift.hpp index cc64a33a52b..612e1523692 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/rshift.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/rshift.hpp @@ -9,8 +9,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto rshift(A &&a, - B &&b) -> decltype(std::forward(a) >> std::forward(b)); + auto rshift(A &&a, B &&b) -> decltype(std::forward(a) >> std::forward(b)); DEFINE_ALL_OPERATOR_OVERLOADS_DECL(rshift, >>) diff --git a/contrib/python/pythran/pythran/pythonic/include/operator_/truediv.hpp b/contrib/python/pythran/pythran/pythonic/include/operator_/truediv.hpp index b6df765b478..e9e5dcbae2b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/operator_/truediv.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/operator_/truediv.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto truediv(A &&a, B &&b) -> decltype(std::forward(a) / - (double)std::forward(b)); + auto truediv(A &&a, B &&b) -> decltype(std::forward(a) / (double)std::forward(b)); DEFINE_FUNCTOR(pythonic::operator_, truediv); } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/include/random/sample.hpp b/contrib/python/pythran/pythran/pythonic/include/random/sample.hpp index df2cfc2382d..a6b75e510c8 100644 --- a/contrib/python/pythran/pythran/pythonic/include/random/sample.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/random/sample.hpp @@ -12,8 +12,7 @@ namespace random { template types::list::type>:: - type::iterator>::value_type> + typename std::remove_cv_t>::iterator>::value_type> sample(Iterable &&s, size_t k); DEFINE_FUNCTOR(pythonic::random, sample); diff --git a/contrib/python/pythran/pythran/pythonic/include/scipy/special/i0.hpp b/contrib/python/pythran/pythran/pythonic/include/scipy/special/i0.hpp index fd7d18d33a2..fa772fae2c4 100644 --- a/contrib/python/pythran/pythran/pythonic/include/scipy/special/i0.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/scipy/special/i0.hpp @@ -24,39 +24,30 @@ namespace scipy * lim(x->0){ exp(-x) I0(x) } = 1. */ static constexpr double A[] = { - -4.41534164647933937950E-18, 3.33079451882223809783E-17, - -2.43127984654795469359E-16, 1.71539128555513303061E-15, - -1.16853328779934516808E-14, 7.67618549860493561688E-14, - -4.85644678311192946090E-13, 2.95505266312963983461E-12, - -1.72682629144155570723E-11, 9.67580903537323691224E-11, - -5.18979560163526290666E-10, 2.65982372468238665035E-9, - -1.30002500998624804212E-8, 6.04699502254191894932E-8, - -2.67079385394061173391E-7, 1.11738753912010371815E-6, - -4.41673835845875056359E-6, 1.64484480707288970893E-5, - -5.75419501008210370398E-5, 1.88502885095841655729E-4, - -5.76375574538582365885E-4, 1.63947561694133579842E-3, - -4.32430999505057594430E-3, 1.05464603945949983183E-2, - -2.37374148058994688156E-2, 4.93052842396707084878E-2, - -9.49010970480476444210E-2, 1.71620901522208775349E-1, - -3.04682672343198398683E-1, 6.76795274409476084995E-1}; + -4.41534164647933937950E-18, 3.33079451882223809783E-17, -2.43127984654795469359E-16, + 1.71539128555513303061E-15, -1.16853328779934516808E-14, 7.67618549860493561688E-14, + -4.85644678311192946090E-13, 2.95505266312963983461E-12, -1.72682629144155570723E-11, + 9.67580903537323691224E-11, -5.18979560163526290666E-10, 2.65982372468238665035E-9, + -1.30002500998624804212E-8, 6.04699502254191894932E-8, -2.67079385394061173391E-7, + 1.11738753912010371815E-6, -4.41673835845875056359E-6, 1.64484480707288970893E-5, + -5.75419501008210370398E-5, 1.88502885095841655729E-4, -5.76375574538582365885E-4, + 1.63947561694133579842E-3, -4.32430999505057594430E-3, 1.05464603945949983183E-2, + -2.37374148058994688156E-2, 4.93052842396707084878E-2, -9.49010970480476444210E-2, + 1.71620901522208775349E-1, -3.04682672343198398683E-1, 6.76795274409476084995E-1}; /* Chebyshev coefficients for exp(-x) sqrt(x) I0(x) * in the inverted interval [8,infinity]. * * lim(x->inf){ exp(-x) sqrt(x) I0(x) } = 1/sqrt(2pi). */ static constexpr double B[] = { - -7.23318048787475395456E-18, -4.83050448594418207126E-18, - 4.46562142029675999901E-17, 3.46122286769746109310E-17, - -2.82762398051658348494E-16, -3.42548561967721913462E-16, - 1.77256013305652638360E-15, 3.81168066935262242075E-15, - -9.55484669882830764870E-15, -4.15056934728722208663E-14, - 1.54008621752140982691E-14, 3.85277838274214270114E-13, - 7.18012445138366623367E-13, -1.79417853150680611778E-12, - -1.32158118404477131188E-11, -3.14991652796324136454E-11, - 1.18891471078464383424E-11, 4.94060238822496958910E-10, - 3.39623202570838634515E-9, 2.26666899049817806459E-8, - 2.04891858946906374183E-7, 2.89137052083475648297E-6, - 6.88975834691682398426E-5, 3.36911647825569408990E-3, + -7.23318048787475395456E-18, -4.83050448594418207126E-18, 4.46562142029675999901E-17, + 3.46122286769746109310E-17, -2.82762398051658348494E-16, -3.42548561967721913462E-16, + 1.77256013305652638360E-15, 3.81168066935262242075E-15, -9.55484669882830764870E-15, + -4.15056934728722208663E-14, 1.54008621752140982691E-14, 3.85277838274214270114E-13, + 7.18012445138366623367E-13, -1.79417853150680611778E-12, -1.32158118404477131188E-11, + -3.14991652796324136454E-11, 1.18891471078464383424E-11, 4.94060238822496958910E-10, + 3.39623202570838634515E-9, 2.26666899049817806459E-8, 2.04891858946906374183E-7, + 2.89137052083475648297E-6, 6.88975834691682398426E-5, 3.36911647825569408990E-3, 8.04490411014108831608E-1}; template diff --git a/contrib/python/pythran/pythran/pythonic/include/string/ascii_letters.hpp b/contrib/python/pythran/pythran/pythonic/include/string/ascii_letters.hpp index cbfefa9d67f..52d21f1b106 100644 --- a/contrib/python/pythran/pythran/pythonic/include/string/ascii_letters.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/string/ascii_letters.hpp @@ -7,8 +7,7 @@ PYTHONIC_NS_BEGIN namespace string { - static types::str const - ascii_letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + static types::str const ascii_letters("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/types/NoneType.hpp b/contrib/python/pythran/pythran/pythonic/include/types/NoneType.hpp index 9dfdbd77bc9..a47fc0415d1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/NoneType.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/NoneType.hpp @@ -83,8 +83,7 @@ namespace types struct none_data { explicit operator bool() const { - return !static_cast

(this)->is_none && - static_cast

(this)->data; + return !static_cast

(this)->is_none && static_cast

(this)->data; } operator T const &() const { @@ -95,8 +94,7 @@ namespace types struct none_data { operator bool() const { - return !static_cast

(this)->is_none && - static_cast

(this)->data; + return !static_cast

(this)->is_none && static_cast

(this)->data; } }; template @@ -134,31 +132,28 @@ namespace types } }; -#define NONE_OPERATOR_OVERLOAD(op) \ - template \ - auto operator op(none const &t0, T const &t1) \ - ->decltype(static_cast(t0) op t1) \ - { \ - return static_cast(t0) op t1; \ - } \ - \ - template \ - auto operator op(T const &t0, none const &t1) \ - ->decltype(t0 op static_cast(t1)) \ - { \ - return t0 op static_cast(t1); \ - } \ - \ - template \ - auto operator op(none const &t0, none const &t1) \ - ->none(t0) \ - op static_cast(t1))> \ - { \ - if (t0.is_none && t1.is_none) \ - return none_type{}; \ - else { \ - return {static_cast(t0) op static_cast(t1)}; \ - } \ +#define NONE_OPERATOR_OVERLOAD(op) \ + template \ + auto operator op(none const &t0, T const &t1)->decltype(static_cast(t0) op t1) \ + { \ + return static_cast(t0) op t1; \ + } \ + \ + template \ + auto operator op(T const &t0, none const &t1)->decltype(t0 op static_cast(t1)) \ + { \ + return t0 op static_cast(t1); \ + } \ + \ + template \ + auto operator op(none const &t0, none const &t1) \ + ->none(t0) op static_cast(t1))> \ + { \ + if (t0.is_none && t1.is_none) \ + return none_type{}; \ + else { \ + return {static_cast(t0) op static_cast(t1)}; \ + } \ } NONE_OPERATOR_OVERLOAD(+) @@ -172,12 +167,12 @@ namespace types NONE_OPERATOR_OVERLOAD(<=) template - decltype(operator_::mod(std::declval(), std::declval())) - operator%(none const &t0, T1 const &t1); + decltype(operator_::mod(std::declval(), std::declval())) operator%(none const &t0, + T1 const &t1); template - decltype(operator_::mod(std::declval(), std::declval())) - operator%(T0 const &t0, none const &t1); + decltype(operator_::mod(std::declval(), std::declval())) operator%(T0 const &t0, + none const &t1); template none(), std::declval()))> @@ -213,12 +208,11 @@ namespace std { /* std::get overload */ template - auto get(pythonic::types::none const &t) - -> decltype(std::get((T0 const &)t)); + auto get(pythonic::types::none const &t) -> decltype(std::get((T0 const &)t)); template struct tuple_element> { - using type = typename std::tuple_element::type; + using type = std::tuple_element_t; }; template <> @@ -235,51 +229,43 @@ namespace std template struct __combined, T1> { - static_assert(!pythonic::types::is_none::value, - "none of none should'nt exist"); + static_assert(!pythonic::types::is_none::value, "none of none should'nt exist"); using type = pythonic::types::none::type>; }; template struct __combined> { - static_assert(!pythonic::types::is_none::value, - "none of none should'nt exist"); + static_assert(!pythonic::types::is_none::value, "none of none should'nt exist"); using type = pythonic::types::none::type>; }; template struct __combined, pythonic::types::none> { - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); using type = pythonic::types::none::type>; }; template struct __combined { - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); using type = pythonic::types::none; }; template struct __combined> { - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); using type = pythonic::types::none; }; template struct __combined { - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); using type = pythonic::types::none; }; template struct __combined, pythonic::types::none_type> { - static_assert(!pythonic::types::is_none::value, - "none of none shouldn't exist"); + static_assert(!pythonic::types::is_none::value, "none of none shouldn't exist"); using type = pythonic::types::none; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/array.hpp b/contrib/python/pythran/pythran/pythonic/include/types/array.hpp index d4e6c1e06ec..0826c948565 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/array.hpp @@ -65,8 +65,7 @@ namespace types }; template - struct array_iterator - : std::iterator { + struct array_iterator : std::iterator { E data; long index; array_iterator(E data, long index) : data(data), index(index) @@ -129,6 +128,10 @@ namespace types { return index < other.index; } + bool operator<=(array_iterator const &other) const + { + return index <= other.index; + } array_iterator &operator=(array_iterator const &other) { index = other.index; @@ -142,9 +145,7 @@ namespace types { // data holder - typedef - typename std::remove_cv::type>::type - _type; + using _type = std::remove_cv_t>; typedef container<_type> container_type; utils::shared_ref _data; @@ -156,8 +157,7 @@ namespace types public: // types typedef T data_type; - typedef typename std::conditional::value, long, - double>::type value_type; + typedef std::conditional_t::value, long, double> value_type; typedef array_reference reference; typedef value_type const_reference; typedef array_iterator iterator; @@ -174,15 +174,13 @@ namespace types typedef data_type dtype; static const size_t value = 1; static const bool is_vectorizable = - types::is_vectorizable_dtype::value && - !std::is_same::value; + types::is_vectorizable_dtype::value && !std::is_same::value; static const bool is_flat = std::is_same::value; static const bool is_strided = std::is_same::value; using shape_t = types::array_tuple; template - auto shape() const -> decltype(details::extract_shape(*this, - utils::int_{})) + auto shape() const -> decltype(details::extract_shape(*this, utils::int_{})) { return details::extract_shape(*this, utils::int_{}); } @@ -201,8 +199,7 @@ namespace types template array operator+(array_base const &) const; template - array::type> - operator+(sliced_array const &) const; + array::type> operator+(sliced_array const &) const; // iterators iterator begin(); @@ -236,9 +233,8 @@ namespace types const_reference operator[](long i) const; reference operator[](long i); template - typename std::enable_if< - is_slice::value, - sliced_array() * std::declval())>>::type + std::enable_if_t::value, + sliced_array() * std::declval())>> operator[](Sp s) const; template @@ -276,8 +272,7 @@ namespace types long count(T const &x) const; template - friend std::ostream &operator<<(std::ostream &os, - sliced_array const &v); + friend std::ostream &operator<<(std::ostream &os, sliced_array const &v); }; /* array */ @@ -288,9 +283,7 @@ namespace types static const size_t DEFAULT_CAPACITY = 16; // data holder - typedef - typename std::remove_cv::type>::type - _type; + using _type = std::remove_cv_t>; typedef container<_type> container_type; utils::shared_ref _data; @@ -303,8 +296,7 @@ namespace types public: // types typedef T data_type; - typedef typename std::conditional::value, long, - double>::type value_type; + typedef std::conditional_t::value, long, double> value_type; typedef array_reference reference; typedef value_type const_reference; typedef array_iterator iterator; @@ -353,8 +345,7 @@ namespace types array &operator=(sliced_array const &other); template - array & - operator=(ndarray> const &); // implemented in ndarray.hpp + array &operator=(ndarray> const &); // implemented in ndarray.hpp template array &operator+=(sliced_array const &other); @@ -417,8 +408,7 @@ namespace types const_reference operator[](long n) const; template - typename std::enable_if::value, sliced_array>::type - operator[](Sp const &s) const; + std::enable_if_t::value, sliced_array> operator[](Sp const &s) const; template dtype load(long index0, long index1, Indices... indices) const @@ -467,8 +457,7 @@ namespace types array::type> operator+(array const &s) const; template - array() + - std::declval::value_type>())> + array() + std::declval::value_type>())> operator+(sliced_array const &s) const; array operator*(long t) const; @@ -520,8 +509,7 @@ namespace utils * const_iterator type. */ template - void reserve(types::array &l, From const &f, - typename From::const_iterator *p = nullptr); + void reserve(types::array &l, From const &f, typename From::const_iterator *p = nullptr); } // namespace utils template @@ -545,16 +533,13 @@ PYTHONIC_NS_END namespace std { template - typename pythonic::types::array::reference - get(pythonic::types::array &t); + typename pythonic::types::array::reference get(pythonic::types::array &t); template - typename pythonic::types::array::const_reference - get(pythonic::types::array const &t); + typename pythonic::types::array::const_reference get(pythonic::types::array const &t); template - typename pythonic::types::array::value_type - get(pythonic::types::array &&t); + typename pythonic::types::array::value_type get(pythonic::types::array &&t); template typename pythonic::types::sliced_array::reference @@ -617,24 +602,20 @@ struct __combined, pythonic::types::array> { }; template -struct __combined, - pythonic::types::array> { +struct __combined, pythonic::types::array> { typedef pythonic::types::array::type> type; }; template -struct __combined, - pythonic::types::sliced_array> { +struct __combined, pythonic::types::sliced_array> { typedef pythonic::types::array::type> type; }; template -struct __combined, - pythonic::types::array> { +struct __combined, pythonic::types::array> { typedef pythonic::types::array::type> type; }; template -struct __combined, - pythonic::types::array_base> { +struct __combined, pythonic::types::array_base> { typedef pythonic::types::array::type> type; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/assignable.hpp b/contrib/python/pythran/pythran/pythonic/include/types/assignable.hpp index 888fcc408ef..17747061543 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/assignable.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/assignable.hpp @@ -34,8 +34,7 @@ namespace types }; template - using by_val_t = typename by_val< - T, std::is_integral::type>::value>::type; + using by_val_t = typename by_val>::value>::type; template static inline auto call(F &&f, Args &&...args) diff --git a/contrib/python/pythran/pythran/pythonic/include/types/combined.hpp b/contrib/python/pythran/pythran/pythonic/include/types/combined.hpp index 4e2179f4848..74098791ad6 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/combined.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/combined.hpp @@ -32,13 +32,11 @@ template struct __combined { // callable -> functor template - static pythonic::types::variant_functor - get(std::integral_constant); + static pythonic::types::variant_functor get(std::integral_constant); // operator+ exists -> deduce type template - static decltype(std::declval() + - std::declval()) get(std::integral_constant); + static decltype(std::declval() + std::declval()) get(std::integral_constant); // operator+ does not exists -> pick first one, better than error // note that this is needed because broadcasting is too complex to be modeled @@ -51,12 +49,11 @@ struct __combined { template static F0 get(...); - using type = typename std::conditional< + using type = std::conditional_t< std::is_same::value, T0, - decltype(get(std::integral_constant < bool, - pythonic::types::is_callable::value - &&pythonic::types::is_callable::value > - ()))>::type; + decltype(get( + std::integral_constant::value && + pythonic::types::is_callable::value>()))>; }; template @@ -68,7 +65,7 @@ struct __combined : std::add_const::ty }; template -struct __combined : __combined { +struct __combined : __combined { }; template @@ -144,71 +141,70 @@ struct __combined : std::add_const -struct __combined : std::add_lvalue_reference::type>::type> { +struct __combined + : std::add_lvalue_reference::type>::type> { }; template class container { public: - using value_type = - typename std::remove_cv::type>::type; + using value_type = std::remove_cv_t>; private: container(); }; -namespace std { +namespace std +{ template struct tuple_element> { using type = typename container::value_type; }; -} +} // namespace std template class indexable_container { public: - using key_type = - typename std::remove_cv::type>::type; - using value_type = - typename std::remove_cv::type>::type; + using key_type = std::remove_cv_t>; + using value_type = std::remove_cv_t>; private: indexable_container(); }; -namespace std { +namespace std +{ template struct tuple_element> { using type = typename indexable_container::value_type; }; -} +} // namespace std template class dict_container { public: - using value_type = - typename std::remove_cv::type>::type; + using value_type = std::remove_cv_t>; private: dict_container(); }; -namespace std { +namespace std +{ template struct tuple_element> { using type = typename dict_container::value_type; }; -} +} // namespace std template class indexable { public: - using type = - typename std::remove_cv::type>::type; + using type = std::remove_cv_t>; private: indexable(); @@ -218,8 +214,7 @@ template class indexable_dict { public: - using type = - typename std::remove_cv::type>::type; + using type = std::remove_cv_t>; private: indexable_dict(); @@ -227,8 +222,8 @@ private: template struct __combined, indexable_container> { - using type = indexable_container::type, - typename __combined::type>; + using type = + indexable_container::type, typename __combined::type>; }; template @@ -294,10 +289,10 @@ struct __combined, /* } */ /* mimic numpy behavior { */ -#define SCALAR_COMBINER(Type) \ - template <> \ - struct __combined { \ - using type = Type; \ +#define SCALAR_COMBINER(Type) \ + template <> \ + struct __combined { \ + using type = Type; \ }; SCALAR_COMBINER(bool) SCALAR_COMBINER(uint8_t) diff --git a/contrib/python/pythran/pythran/pythonic/include/types/complex.hpp b/contrib/python/pythran/pythran/pythonic/include/types/complex.hpp index 19ae86680ae..6662f2075bf 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/complex.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/complex.hpp @@ -29,12 +29,12 @@ namespace std { template - using complex_broadcast_t = typename std::enable_if< - std::is_scalar::value && !std::is_same::value, - std::complex::type>>::type; + using complex_broadcast_t = + std::enable_if_t::value && !std::is_same::value, + std::complex>>; template - using complex_bool_t = typename std::enable_if< - std::is_scalar::value && !std::is_same::value, bool>::type; + using complex_bool_t = + std::enable_if_t::value && !std::is_same::value, bool>; template complex_broadcast_t operator+(std::complex self, S other); @@ -91,12 +91,9 @@ namespace builtins T getattr(types::attr::REAL, std::complex const &self); template T getattr(types::attr::IMAG, std::complex const &self); - numpy::functor::complex64 getattr(types::attr::DTYPE, - std::complex const &self); - numpy::functor::complex128 getattr(types::attr::DTYPE, - std::complex const &self); - numpy::functor::complex256 getattr(types::attr::DTYPE, - std::complex const &self); + numpy::functor::complex64 getattr(types::attr::DTYPE, std::complex const &self); + numpy::functor::complex128 getattr(types::attr::DTYPE, std::complex const &self); + numpy::functor::complex256 getattr(types::attr::DTYPE, std::complex const &self); } // namespace builtins PYTHONIC_NS_END @@ -119,13 +116,13 @@ struct __combined, std::complex> { /* } */ -#define STD_COMPLEX_IMPLICT_OPERATOR_CAST(op) \ - template \ - auto operator op(std::complex const &lhs, std::complex const &rhs) \ - ->std::complex::type> \ - { \ - using ctype = std::complex::type>; \ - return ctype{lhs} op ctype{rhs}; \ +#define STD_COMPLEX_IMPLICT_OPERATOR_CAST(op) \ + template \ + auto operator op(std::complex const &lhs, std::complex const &rhs) \ + ->std::complex> \ + { \ + using ctype = std::complex>; \ + return ctype{lhs} op ctype{rhs}; \ } STD_COMPLEX_IMPLICT_OPERATOR_CAST(+) diff --git a/contrib/python/pythran/pythran/pythonic/include/types/dict.hpp b/contrib/python/pythran/pythran/pythonic/include/types/dict.hpp index 7772a2641e5..7b38bf8418e 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/dict.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/dict.hpp @@ -31,19 +31,32 @@ namespace types struct item_iterator_adaptator { I base; using difference_type = typename std::iterator_traits::difference_type; - using value_type = make_tuple_t< - typename std::remove_cv::value_type::first_type>::type, - typename std::iterator_traits::value_type::second_type>; + using value_type = + make_tuple_t::value_type::first_type>, + typename std::iterator_traits::value_type::second_type>; using pointer = value_type *; using reference = value_type &; using iterator_category = typename std::iterator_traits::iterator_category; item_iterator_adaptator() = default; item_iterator_adaptator(I const &i); value_type operator*() const; - bool operator==(item_iterator_adaptator const& other) const { return base == other.base;} - bool operator!=(item_iterator_adaptator const& other) const { return base != other.base;} - item_iterator_adaptator& operator++() { ++base; return *this;} - auto operator->() ->decltype( &*base) { return &*base;} + bool operator==(item_iterator_adaptator const &other) const + { + return base == other.base; + } + bool operator!=(item_iterator_adaptator const &other) const + { + return base != other.base; + } + item_iterator_adaptator &operator++() + { + ++base; + return *this; + } + auto operator->() -> decltype(&*base) + { + return &*base; + } }; template @@ -57,10 +70,23 @@ namespace types key_iterator_adaptator() = default; key_iterator_adaptator(I const &i); value_type operator*() const; - bool operator==(key_iterator_adaptator const& other) const { return base == other.base;} - bool operator!=(key_iterator_adaptator const& other) const { return base != other.base;} - key_iterator_adaptator& operator++() { ++base; return *this;} - auto operator->() ->decltype( &*base) { return &*base;} + bool operator==(key_iterator_adaptator const &other) const + { + return base == other.base; + } + bool operator!=(key_iterator_adaptator const &other) const + { + return base != other.base; + } + key_iterator_adaptator &operator++() + { + ++base; + return *this; + } + auto operator->() -> decltype(&*base) + { + return &*base; + } }; template @@ -74,10 +100,23 @@ namespace types value_iterator_adaptator() = default; value_iterator_adaptator(I const &i); value_type operator*() const; - bool operator==(value_iterator_adaptator const& other) const { return base == other.base;} - bool operator!=(value_iterator_adaptator const& other) const { return base != other.base;} - value_iterator_adaptator& operator++() { ++base; return *this;} - auto operator->() ->decltype( &*base) { return &*base;} + bool operator==(value_iterator_adaptator const &other) const + { + return base == other.base; + } + bool operator!=(value_iterator_adaptator const &other) const + { + return base != other.base; + } + value_iterator_adaptator &operator++() + { + ++base; + return *this; + } + auto operator->() -> decltype(&*base) + { + return &*base; + } }; template @@ -134,35 +173,73 @@ namespace types value_type data_[1]; bool empty_; - none_type_map(size_type) : data_(), empty_(true) {} + none_type_map(size_type) : data_(), empty_(true) + { + } template - none_type_map(B begin, E end) : data_{begin == end ? value_type() : *begin}, empty_(begin == end) { + none_type_map(B begin, E end) + : data_{begin == end ? value_type() : *begin}, empty_(begin == end) + { } - mapped_type& operator[](none_type) { + mapped_type &operator[](none_type) + { empty_ = false; return data_[0].second; } - iterator find(none_type) { + iterator find(none_type) + { return data_ + empty_; } - const_iterator find(none_type) const { + const_iterator find(none_type) const + { return data_ + empty_; } - iterator begin() { return data_ + empty_; } - const_iterator begin() const { return data_ + empty_; } - iterator end() { return data_ + 1; } - const_iterator end() const { return data_ + 1; } + iterator begin() + { + return data_ + empty_; + } + const_iterator begin() const + { + return data_ + empty_; + } + iterator end() + { + return data_ + 1; + } + const_iterator end() const + { + return data_ + 1; + } - bool empty() const { return empty_;} - void clear() { empty_ = true; data_[0].second = {}; } - const_iterator erase(const_iterator pos) { clear(); return end();} - bool erase(none_type) { bool res = empty_; clear(); return !res;} + bool empty() const + { + return empty_; + } + void clear() + { + empty_ = true; + data_[0].second = {}; + } + const_iterator erase(const_iterator pos) + { + clear(); + return end(); + } + bool erase(none_type) + { + bool res = empty_; + clear(); + return !res; + } - size_t size() const { return empty_?0:1;} + size_t size() const + { + return empty_ ? 0 : 1; + } }; template @@ -170,15 +247,12 @@ namespace types { // data holder - using _key_type = - typename std::remove_cv::type>::type; - using _value_type = - typename std::remove_cv::type>::type; - using container_type = typename std::conditional::value, - none_type_map<_value_type>, - std::unordered_map< - _key_type, _value_type, std::hash<_key_type>, std::equal_to<_key_type>, - utils::allocator>>>::type; + using _key_type = std::remove_cv_t>; + using _value_type = std::remove_cv_t>; + using container_type = std::conditional_t< + std::is_same::value, none_type_map<_value_type>, + std::unordered_map<_key_type, _value_type, std::hash<_key_type>, std::equal_to<_key_type>, + utils::allocator>>>; utils::shared_ref data; template @@ -188,20 +262,20 @@ namespace types // types using reference = typename container_type::reference; using const_reference = typename container_type::const_reference; - using iterator = utils::comparable_iterator< - key_iterator_adaptator>; - using const_iterator = utils::comparable_iterator< - key_iterator_adaptator>; - using item_iterator = utils::comparable_iterator< - item_iterator_adaptator>; + using iterator = + utils::comparable_iterator>; + using const_iterator = + utils::comparable_iterator>; + using item_iterator = + utils::comparable_iterator>; using item_const_iterator = utils::comparable_iterator< item_iterator_adaptator>; - using key_iterator = utils::comparable_iterator< - key_iterator_adaptator>; - using key_const_iterator = utils::comparable_iterator< - key_iterator_adaptator>; - using value_iterator = utils::comparable_iterator< - value_iterator_adaptator>; + using key_iterator = + utils::comparable_iterator>; + using key_const_iterator = + utils::comparable_iterator>; + using value_iterator = + utils::comparable_iterator>; using value_const_iterator = utils::comparable_iterator< value_iterator_adaptator>; using size_type = typename container_type::size_type; @@ -334,8 +408,7 @@ namespace types template struct assignable> { - using type = - types::dict::type, typename assignable::type>; + using type = types::dict::type, typename assignable::type>; }; std::ostream &operator<<(std::ostream &os, types::empty_dict const &); @@ -388,57 +461,45 @@ struct __combined, container> { template struct __combined> { - using type = pythonic::types::dict::type, - typename std::tuple_element<1, T>::type>; + using type = pythonic::types::dict, std::tuple_element_t<1, T>>; }; template -struct __combined> { - using type = pythonic::types::dict::type, - typename std::tuple_element<1, T>::type>; +struct __combined> { + using type = pythonic::types::dict, std::tuple_element_t<1, T>>; }; template struct __combined, pythonic::types::empty_dict> { - using type = pythonic::types::dict::type, - typename std::tuple_element<1, T>::type>; + using type = pythonic::types::dict, std::tuple_element_t<1, T>>; }; template -struct __combined, - pythonic::types::empty_dict> { - using type = pythonic::types::dict::type, - typename std::tuple_element<1, T>::type>; +struct __combined, pythonic::types::empty_dict> { + using type = pythonic::types::dict, std::tuple_element_t<1, T>>; }; template struct __combined, pythonic::types::list> { - using type = pythonic::types::dict< - typename __combined::type>::type, - typename __combined::type>::type>; + using type = pythonic::types::dict>::type, + typename __combined>::type>; }; template -struct __combined, - pythonic::types::static_list> { - using type = pythonic::types::dict< - typename __combined::type>::type, - typename __combined::type>::type>; +struct __combined, pythonic::types::static_list> { + using type = pythonic::types::dict>::type, + typename __combined>::type>; }; template struct __combined, pythonic::types::dict> { - using type = pythonic::types::dict< - typename __combined::type>::type, - typename __combined::type>::type>; + using type = pythonic::types::dict>::type, + typename __combined>::type>; }; template -struct __combined, - pythonic::types::dict> { - using type = pythonic::types::dict< - typename __combined::type>::type, - typename __combined::type>::type>; +struct __combined, pythonic::types::dict> { + using type = pythonic::types::dict>::type, + typename __combined>::type>; }; template @@ -488,14 +549,14 @@ struct __combined> { template struct __combined, indexable_container> { - using type = pythonic::types::dict::type, - typename __combined::type>; + using type = + pythonic::types::dict::type, typename __combined::type>; }; template struct __combined, pythonic::types::dict> { - using type = pythonic::types::dict::type, - typename __combined::type>; + using type = + pythonic::types::dict::type, typename __combined::type>; }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/types/dynamic_tuple.hpp b/contrib/python/pythran/pythran/pythonic/include/types/dynamic_tuple.hpp index 0db63dcff6f..72de31be8b5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/dynamic_tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/dynamic_tuple.hpp @@ -33,14 +33,11 @@ namespace types using size_type = std::size_t; using difference_type = std::ptrdiff_t; using reverse_iterator = typename container_type::reverse_iterator; - using const_reverse_iterator = - typename container_type::const_reverse_iterator; + using const_reverse_iterator = typename container_type::const_reverse_iterator; // minimal ndarray interface - using dtype = - typename utils::nested_container_value_type::type; - static const size_t value = - utils::nested_container_depth::value; + using dtype = typename utils::nested_container_value_type::type; + static const size_t value = utils::nested_container_depth::value; static const bool is_vectorizable = true; static const bool is_strided = false; @@ -157,8 +154,7 @@ namespace types else { dynamic_tuple res; res.data->reserve(ns.size()); - for (auto i = ns.lower, step = ns.step, n = ns.upper; i != n; - i += step) { + for (auto i = ns.lower, step = ns.step, n = ns.upper; i != n; i += step) { res.data->emplace_back(fast(i)); } return res; @@ -173,8 +169,7 @@ namespace types using shape_t = typename shape_builder::type; template - auto shape() const -> decltype(details::extract_shape(*this, - utils::int_{})) + auto shape() const -> decltype(details::extract_shape(*this, utils::int_{})) { return details::extract_shape(*this, utils::int_{}); } @@ -217,15 +212,13 @@ namespace std } template - typename pythonic::types::dynamic_tuple::reference - get(pythonic::types::dynamic_tuple &t) + typename pythonic::types::dynamic_tuple::reference get(pythonic::types::dynamic_tuple &t) { return t[I]; } template - typename pythonic::types::dynamic_tuple::reference - get(pythonic::types::dynamic_tuple &&t) + typename pythonic::types::dynamic_tuple::reference get(pythonic::types::dynamic_tuple &&t) { return t[I]; } diff --git a/contrib/python/pythran/pythran/pythonic/include/types/exceptions.hpp b/contrib/python/pythran/pythran/pythonic/include/types/exceptions.hpp index 3cdb832ece1..5c168fd3e1f 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/exceptions.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/exceptions.hpp @@ -24,17 +24,17 @@ namespace types }; // Use this to create a python exception class -#define CLASS_EXCEPTION_DECL(name, parent) \ - class name : public parent \ - { \ - public: \ - name() = default; \ - name(const name &e) = default; \ - template \ - name(Types const &...types) : parent(types...) \ - { \ - } \ - virtual ~name() noexcept = default; \ +#define CLASS_EXCEPTION_DECL(name, parent) \ + class name : public parent \ + { \ + public: \ + name() = default; \ + name(const name &e) = default; \ + template \ + name(Types const &...types) : parent(types...) \ + { \ + } \ + virtual ~name() noexcept = default; \ }; CLASS_EXCEPTION_DECL(SystemExit, BaseException); @@ -88,34 +88,32 @@ namespace types PYTHONIC_NS_END #include "pythonic/include/utils/functor.hpp" -#define PYTHONIC_EXCEPTION_DECL(name) \ - template \ - types::name name(Types const &...args); \ - \ +#define PYTHONIC_EXCEPTION_DECL(name) \ + template \ + types::name name(Types const &...args); \ + \ DEFINE_FUNCTOR(pythonic::builtins, name); /* pythran attribute system { */ -#define DECLARE_EXCEPTION_GETATTR(name) \ - PYTHONIC_NS_BEGIN \ - namespace builtins \ - { \ - types::none> \ - getattr(types::attr::ARGS, types::name const &f); \ - } \ +#define DECLARE_EXCEPTION_GETATTR(name) \ + PYTHONIC_NS_BEGIN \ + namespace builtins \ + { \ + types::none> getattr(types::attr::ARGS, \ + types::name const &f); \ + } \ PYTHONIC_NS_END -#define DECLARE_EXCEPTION_GETATTR_FULL(name) \ - PYTHONIC_NS_BEGIN \ - namespace builtins \ - { \ - types::none> \ - getattr(types::attr::ARGS, types::name const &e); \ - types::none getattr(types::attr::ERRNO, types::name const &e); \ - types::none getattr(types::attr::STRERROR, \ - types::name const &e); \ - types::none getattr(types::attr::FILENAME, \ - types::name const &e); \ - } \ +#define DECLARE_EXCEPTION_GETATTR_FULL(name) \ + PYTHONIC_NS_BEGIN \ + namespace builtins \ + { \ + types::none> getattr(types::attr::ARGS, \ + types::name const &e); \ + types::none getattr(types::attr::ERRNO, types::name const &e); \ + types::none getattr(types::attr::STRERROR, types::name const &e); \ + types::none getattr(types::attr::FILENAME, types::name const &e); \ + } \ PYTHONIC_NS_END DECLARE_EXCEPTION_GETATTR(BaseException); diff --git a/contrib/python/pythran/pythran/pythonic/include/types/file.hpp b/contrib/python/pythran/pythran/pythonic/include/types/file.hpp index 7d192c9a9de..8e50d50aa59 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/file.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/file.hpp @@ -18,9 +18,8 @@ namespace types { class file; - struct file_iterator - : std::iterator { + struct file_iterator : std::iterator { private: file *f; mutable bool set; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/finfo.hpp b/contrib/python/pythran/pythran/pythonic/include/types/finfo.hpp index f15b2acc577..7f14333027d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/finfo.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/finfo.hpp @@ -26,8 +26,7 @@ PYTHONIC_NS_BEGIN namespace builtins { template - auto getattr(types::attr::EPS, - pythonic::types::finfo const &f) -> decltype(f.eps()); + auto getattr(types::attr::EPS, pythonic::types::finfo const &f) -> decltype(f.eps()); } PYTHONIC_NS_END /* } */ diff --git a/contrib/python/pythran/pythran/pythonic/include/types/generator.hpp b/contrib/python/pythran/pythran/pythonic/include/types/generator.hpp index 85998cccb52..3870b3254fe 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/generator.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/generator.hpp @@ -10,9 +10,8 @@ namespace types { template struct generator_iterator - : std::iterator { + : std::iterator { T the_generator; generator_iterator(); diff --git a/contrib/python/pythran/pythran/pythonic/include/types/immediate.hpp b/contrib/python/pythran/pythran/pythonic/include/types/immediate.hpp index 7b8de529d4c..f3960f92343 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/immediate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/immediate.hpp @@ -17,8 +17,7 @@ namespace types return Val; } - template ::type> + template > immediate(std::integral_constant) { } diff --git a/contrib/python/pythran/pythran/pythonic/include/types/int.hpp b/contrib/python/pythran/pythran/pythonic/include/types/int.hpp index 40a53da2146..228644477db 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/int.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/int.hpp @@ -7,11 +7,9 @@ PYTHONIC_NS_BEGIN namespace builtins { template - typename std::enable_if::value, T>::value - getattr(types::attr::REAL, T self); + typename std::enable_if::value, T>::value getattr(types::attr::REAL, T self); template - typename std::enable_if::value, T>::value - getattr(types::attr::IMAG, T self); + typename std::enable_if::value, T>::value getattr(types::attr::IMAG, T self); } // namespace builtins PYTHONIC_NS_END #ifdef ENABLE_PYTHON_MODULE @@ -20,10 +18,10 @@ PYTHONIC_NS_END PYTHONIC_NS_BEGIN -#define PYTHONIC_INT_TO_PYTHON(TYPE) \ - template <> \ - struct to_python { \ - static PyObject *convert(TYPE l); \ +#define PYTHONIC_INT_TO_PYTHON(TYPE) \ + template <> \ + struct to_python { \ + static PyObject *convert(TYPE l); \ } PYTHONIC_INT_TO_PYTHON(char); @@ -40,11 +38,11 @@ PYTHONIC_INT_TO_PYTHON(signed long long); #undef PYTHONIC_INT_TO_PYTHON -#define PYTHONIC_INT_FROM_PYTHON(TYPE) \ - template <> \ - struct from_python { \ - static bool is_convertible(PyObject *obj); \ - static TYPE convert(PyObject *obj); \ +#define PYTHONIC_INT_FROM_PYTHON(TYPE) \ + template <> \ + struct from_python { \ + static bool is_convertible(PyObject *obj); \ + static TYPE convert(PyObject *obj); \ } PYTHONIC_INT_FROM_PYTHON(unsigned char); diff --git a/contrib/python/pythran/pythran/pythonic/include/types/lazy.hpp b/contrib/python/pythran/pythran/pythonic/include/types/lazy.hpp index 13680b0c1a2..b6cb4644c91 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/lazy.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/lazy.hpp @@ -8,13 +8,12 @@ namespace types template using lazy_res_t = decltype((std::declval()())); template - using lazy_res_decay_t = typename std::decay>::type; + using lazy_res_decay_t = std::decay_t>; template - using lazy_combined_t = typename std::conditional< - std::is_same, lazy_res_t>::value, lazy_res_t, - typename __combined, - lazy_res_decay_t>::type>::type; + using lazy_combined_t = + std::conditional_t, lazy_res_t>::value, lazy_res_t, + typename __combined, lazy_res_decay_t>::type>; } // namespace types PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/types/list.hpp b/contrib/python/pythran/pythran/pythonic/include/types/list.hpp index 5d5d939aaab..61e304452ae 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/list.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/list.hpp @@ -43,9 +43,7 @@ namespace types { // data holder - typedef - typename std::remove_cv::type>::type - _type; + using _type = std::remove_cv_t>; typedef container<_type> container_type; utils::shared_ref _data; @@ -67,25 +65,20 @@ namespace types typedef typename container_type::pointer pointer; typedef typename container_type::const_pointer const_pointer; typedef typename container_type::reverse_iterator reverse_iterator; - typedef - typename container_type::const_reverse_iterator const_reverse_iterator; + typedef typename container_type::const_reverse_iterator const_reverse_iterator; // minimal ndarray interface - typedef - typename utils::nested_container_value_type::type dtype; - static const size_t value = - utils::nested_container_depth::value; + typedef typename utils::nested_container_value_type::type dtype; + static const size_t value = utils::nested_container_depth::value; static_assert(value != 0, "valid shape"); static const bool is_vectorizable = - types::is_vectorizable_dtype::value && - !std::is_same::value; + types::is_vectorizable_dtype::value && !std::is_same::value; static const bool is_flat = std::is_same::value; static const bool is_strided = std::is_same::value; using shape_t = types::array_tuple; template - auto shape() const -> decltype(details::extract_shape(*this, - utils::int_{})) + auto shape() const -> decltype(details::extract_shape(*this, utils::int_{})) { return details::extract_shape(*this, utils::int_{}); } @@ -104,8 +97,7 @@ namespace types template list operator+(array_base const &) const; template - list::type> - operator+(sliced_list const &) const; + list::type> operator+(sliced_list const &) const; // iterators iterator begin(); @@ -122,9 +114,8 @@ namespace types const_reference operator[](long i) const; reference operator[](long i); template - typename std::enable_if< - is_slice::value, - sliced_list() * std::declval())>>::type + std::enable_if_t::value, + sliced_list() * std::declval())>> operator[](Sp s) const; template @@ -163,8 +154,7 @@ namespace types long count(T const &x) const; template - friend std::ostream &operator<<(std::ostream &os, - sliced_list const &v); + friend std::ostream &operator<<(std::ostream &os, sliced_list const &v); }; /* list */ @@ -174,9 +164,7 @@ namespace types static constexpr size_t DEFAULT_CAPACITY = 16; // data holder - typedef - typename std::remove_cv::type>::type - _type; + using _type = std::remove_cv_t>; typedef container<_type> container_type; utils::shared_ref _data; @@ -199,8 +187,7 @@ namespace types typedef typename container_type::pointer pointer; typedef typename container_type::const_pointer const_pointer; typedef typename container_type::reverse_iterator reverse_iterator; - typedef - typename container_type::const_reverse_iterator const_reverse_iterator; + typedef typename container_type::const_reverse_iterator const_reverse_iterator; // minimal ndarray interface typedef typename utils::nested_container_value_type::type dtype; @@ -227,8 +214,7 @@ namespace types { } template - list(numpy_gexpr, S...> const &other) - : list(other.begin(), other.end()) + list(numpy_gexpr, S...> const &other) : list(other.begin(), other.end()) { } list &operator=(list &&other); @@ -242,8 +228,7 @@ namespace types list &operator=(sliced_list const &other); template - list & - operator=(ndarray> const &); // implemented in ndarray.hpp + list &operator=(ndarray> const &); // implemented in ndarray.hpp template list &operator+=(sliced_list const &other); @@ -296,8 +281,7 @@ namespace types const_reference operator[](long n) const; template - typename std::enable_if::value, sliced_list>::type - operator[](Sp const &s) const; + std::enable_if_t::value, sliced_list> operator[](Sp const &s) const; template dtype load(long index0, long index1, Indices... indices) const @@ -346,8 +330,7 @@ namespace types list::type> operator+(list const &s) const; template - list() + - std::declval::value_type>())> + list() + std::declval::value_type>())> operator+(sliced_list const &s) const; list operator+(empty_list const &) const; @@ -403,8 +386,8 @@ namespace types } template - list::type> - operator+(static_list const &l0, list const &l1) + list::type> operator+(static_list const &l0, + list const &l1) { list::type> out(l0.begin(), l0.end()); return out += l1; @@ -434,9 +417,7 @@ namespace types static_list operator+(array_base const &s) const; empty_list operator+(empty_list const &) const; template - typename std::enable_if::value, - list>::type - operator+(F s) const; + std::enable_if_t::value, list> operator+(F s) const; explicit operator bool() const; template operator list() const; @@ -457,8 +438,7 @@ namespace types return {}; } template - typename std::enable_if::value, empty_list>::type - operator[](S) const + std::enable_if_t::value, empty_list> operator[](S) const { return {}; } @@ -491,8 +471,7 @@ namespace utils * const_iterator type. */ template - void reserve(types::list &l, From const &f, - typename From::const_iterator *p = nullptr); + void reserve(types::list &l, From const &f, typename From::const_iterator *p = nullptr); } // namespace utils template @@ -519,16 +498,13 @@ namespace std typename pythonic::types::list::reference get(pythonic::types::list &t); template - typename pythonic::types::list::const_reference - get(pythonic::types::list const &t); + typename pythonic::types::list::const_reference get(pythonic::types::list const &t); template - typename pythonic::types::list::value_type - get(pythonic::types::list &&t); + typename pythonic::types::list::value_type get(pythonic::types::list &&t); template - typename pythonic::types::sliced_list::reference - get(pythonic::types::sliced_list &t); + typename pythonic::types::sliced_list::reference get(pythonic::types::sliced_list &t); template typename pythonic::types::sliced_list::const_reference @@ -607,45 +583,37 @@ struct __combined, pythonic::types::list> { }; template -struct __combined, - pythonic::types::empty_list> { +struct __combined, pythonic::types::empty_list> { typedef pythonic::types::list type; }; template -struct __combined> { +struct __combined> { typedef pythonic::types::list type; }; template -struct __combined, - pythonic::types::list> { +struct __combined, pythonic::types::list> { typedef pythonic::types::list::type> type; }; template -struct __combined, - pythonic::types::sliced_list> { +struct __combined, pythonic::types::sliced_list> { typedef pythonic::types::list::type> type; }; template -struct __combined, - pythonic::types::empty_list> { +struct __combined, pythonic::types::empty_list> { typedef pythonic::types::list type; }; template -struct __combined> { +struct __combined> { typedef pythonic::types::list type; }; template -struct __combined, - pythonic::types::list> { +struct __combined, pythonic::types::list> { typedef pythonic::types::list::type> type; }; template -struct __combined, - pythonic::types::array_base> { +struct __combined, pythonic::types::array_base> { typedef pythonic::types::list::type> type; }; @@ -662,11 +630,10 @@ struct to_python::reference> { struct phantom_type; // ghost don't exist template <> -struct to_python::const_reference>::value, - phantom_type, typename std::vector::const_reference>::type> { - static PyObject * - convert(typename std::vector::const_reference const &v); +struct to_python< + std::conditional_t::const_reference>::value, + phantom_type, typename std::vector::const_reference>> { + static PyObject *convert(typename std::vector::const_reference const &v); }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/types/ndarray.hpp b/contrib/python/pythran/pythran/pythonic/include/types/ndarray.hpp index fff23b7522d..7b3f4759a51 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/ndarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/ndarray.hpp @@ -17,12 +17,12 @@ #include "pythonic/include/types/tuple.hpp" #include "pythonic/include/numpy/bool_.hpp" -#include "pythonic/include/numpy/complex256.hpp" #include "pythonic/include/numpy/complex128.hpp" +#include "pythonic/include/numpy/complex256.hpp" #include "pythonic/include/numpy/complex64.hpp" +#include "pythonic/include/numpy/float128.hpp" #include "pythonic/include/numpy/float32.hpp" #include "pythonic/include/numpy/float64.hpp" -#include "pythonic/include/numpy/float128.hpp" #include "pythonic/include/numpy/int16.hpp" #include "pythonic/include/numpy/int32.hpp" #include "pythonic/include/numpy/int64.hpp" @@ -128,8 +128,7 @@ namespace types template static T *initialize_from_iterable(S &shape, T *from, Iter &&iter); - static numpy_iexpr const &> get(ndarray const &self, - long i); + static numpy_iexpr const &> get(ndarray const &self, long i); }; template @@ -142,8 +141,7 @@ namespace types type_helper() = delete; // Not intended to be instantiated static iterator make_iterator(ndarray> &n, long i); - static const_iterator make_iterator(ndarray> const &n, - long i); + static const_iterator make_iterator(ndarray> const &n, long i); template static T *initialize_from_iterable(S &shape, T *from, Iter &&iter); @@ -161,8 +159,7 @@ namespace types type_helper() = delete; // Not intended to be instantiated static iterator make_iterator(ndarray> &n, long i); - static const_iterator make_iterator(ndarray> const &n, - long i); + static const_iterator make_iterator(ndarray> const &n, long i); template static T *initialize_from_iterable(S &shape, T *from, Iter &&iter); @@ -179,8 +176,7 @@ namespace types type_helper() = delete; // Not intended to be instantiated static iterator make_iterator(ndarray> &n, long i); - static const_iterator make_iterator(ndarray> const &n, - long i); + static const_iterator make_iterator(ndarray> const &n, long i); template static T *initialize_from_iterable(S &shape, T *from, Iter &&iter); @@ -198,8 +194,7 @@ namespace types type_helper() = delete; // Not intended to be instantiated static iterator make_iterator(ndarray> &n, long i); - static const_iterator make_iterator(ndarray> const &n, - long i); + static const_iterator make_iterator(ndarray> const &n, long i); template static T *initialize_from_iterable(S &shape, T *from, Iter &&iter); @@ -234,16 +229,14 @@ namespace types using const_flat_iterator = T const *; using shape_t = pS; - static_assert(std::tuple_size::value == value, - "consistent shape size"); + static_assert(std::tuple_size::value == value, "consistent shape size"); /* members */ utils::shared_ref> mem; // shared data pointer - T *buffer; // pointer to the first data stored in the equivalent flat - // array - shape_t _shape; // shape of the multidimensional array - sutils::concat_t, - pshape>> + T *buffer; // pointer to the first data stored in the equivalent flat + // array + shape_t _shape; // shape of the multidimensional array + sutils::concat_t, pshape>> _strides; // strides /* mem management */ @@ -286,15 +279,11 @@ namespace types ndarray(T *data, pS const &pshape, PyObject *obj); #endif - template < - class Iterable, - class = typename std::enable_if< - !is_array::type>::type>::value && - is_iterable::type>::type>:: - value, - void>::type> + template >>::value && + is_iterable>>::value, + void>> ndarray(Iterable &&iterable); /* from a numpy expression */ @@ -348,8 +337,7 @@ namespace types { static_assert(is_dtype::value, "valid store"); *(buffer + noffset::value>{}( - *this, array_tuple{{indices...}})) = - static_cast(elt); + *this, array_tuple{{indices...}})) = static_cast(elt); } template dtype load(Indices... indices) const @@ -362,44 +350,37 @@ namespace types void update(E elt, Indices... indices) const { static_assert(is_dtype::value, "valid store"); - Op{}(*(buffer + noffset::value>{}( - *this, array_tuple{{indices...}})), + Op{}(*(buffer + + noffset::value>{}(*this, array_tuple{{indices...}})), static_cast(elt)); } /* element indexing * differentiate const from non const, && r-value from l-value * */ - auto fast( - long i) const & -> decltype(type_helper::get(*this, i)) + auto fast(long i) const & -> decltype(type_helper::get(*this, i)) { return type_helper::get(*this, i); } - auto fast(long i) && -> decltype(type_helper::get(std::move(*this), - i)) + auto fast(long i) && -> decltype(type_helper::get(std::move(*this), i)) { return type_helper::get(std::move(*this), i); } template - typename std::enable_if::value, T &>::type - fast(array_tuple const &indices); + std::enable_if_t::value, T &> fast(array_tuple const &indices); template - typename std::enable_if::value, T>::type + std::enable_if_t::value, T> fast(array_tuple const &indices) const; template - auto fast(array_tuple const &indices) const & -> - typename std::enable_if::value, - decltype(nget().fast(*this, - indices))>::type; + auto fast(array_tuple const &indices) const & -> std::enable_if_t< + std::is_integral::value, decltype(nget().fast(*this, indices))>; template - auto fast(array_tuple const &indices) && -> - typename std::enable_if::value, - decltype(nget().fast(std::move(*this), - indices))>::type; + auto fast(array_tuple const &indices) && -> std::enable_if_t< + std::is_integral::value, decltype(nget().fast(std::move(*this), indices))>; #ifdef USE_XSIMD using simd_iterator = const_simd_nditerator; @@ -430,89 +411,71 @@ namespace types operator[](none_type) const; template - typename std::enable_if::value, - numpy_gexpr>>::type + std::enable_if_t::value, numpy_gexpr>> operator[](S const &s) const &; template - typename std::enable_if::value, - numpy_gexpr>>::type + std::enable_if_t::value, numpy_gexpr>> operator[](S const &s) &&; long size() const; /* extended slice indexing */ template - auto operator()(Ty s) const -> - typename std::enable_if::value, - decltype((*this)[s])>::type + auto operator()(Ty s) const + -> std::enable_if_t::value, decltype((*this)[s])> { return (*this)[s]; } template auto operator()(S0 const &s0, S const &...s) - const & -> decltype(extended_slice::value>{}( - (*this), s0, s...)); + const & -> decltype(extended_slice::value>{}((*this), s0, s...)); template auto operator()(S0 const &s0, S const &...s) - & -> decltype(extended_slice::value>{}((*this), - s0, - s...)); + & -> decltype(extended_slice::value>{}((*this), s0, s...)); template auto operator()(S0 const &s0, S const &...s) - && -> decltype(extended_slice::value>{}( - std::move(*this), s0, s...)); + && -> decltype(extended_slice::value>{}(std::move(*this), s0, + s...)); /* element filtering */ template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr>>> fast(F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr>>> operator[](F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if::value && - std::is_same::value && - F::value != 1 && !is_pod_array::value, - numpy_vexpr>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> fast(F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if::value && - std::is_same::value && - F::value != 1 && !is_pod_array::value, - numpy_vexpr>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> operator[](F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> operator[](F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> fast(F const &filter) const; auto operator[](long i) const & -> decltype(this->fast(i)) @@ -532,112 +495,93 @@ namespace types } template - typename std::enable_if::value, T const &>::type + std::enable_if_t::value, T const &> operator[](array_tuple const &indices) const; template - typename std::enable_if::value, T &>::type + std::enable_if_t::value, T &> operator[](array_tuple const &indices); template - auto operator[](array_tuple const &indices) const & -> - typename std::enable_if::value, - decltype(nget()(*this, indices))>::type; + auto operator[](array_tuple const &indices) const + & -> std::enable_if_t::value, decltype(nget()(*this, indices))>; template - auto operator[](array_tuple const &indices) && -> - typename std::enable_if::value, - decltype(nget()(std::move(*this), - indices))>::type; + auto operator[](array_tuple const &indices) && -> std::enable_if_t< + std::is_integral::value, decltype(nget()(std::move(*this), indices))>; template - auto _fwdlongindex(std::tuple const &indices, - utils::index_sequence) const + auto _fwdlongindex(std::tuple const &indices, std::index_sequence) const -> decltype((*this)(static_cast(Is)...)) { return (*this)(static_cast(std::get(indices))...); } template - auto operator[](std::tuple const &indices) const -> - typename std::enable_if< - utils::all_of::value...>::value, - decltype(this->_fwdlongindex( - indices, utils::make_index_sequence()))>::type + auto operator[](std::tuple const &indices) const -> std::enable_if_t< + utils::all_of::value...>::value, + decltype(this->_fwdlongindex(indices, std::make_index_sequence()))> { - return _fwdlongindex(indices, - utils::make_index_sequence()); + return _fwdlongindex(indices, std::make_index_sequence()); } template - auto _fwdlongindex(std::tuple const &indices, - utils::index_sequence) + auto _fwdlongindex(std::tuple const &indices, std::index_sequence) -> decltype((*this)(static_cast(Is)...)) { return (*this)(static_cast(std::get(indices))...); } template - auto operator[](std::tuple const &indices) -> - typename std::enable_if< - utils::all_of::value...>::value, - decltype(this->_fwdlongindex( - indices, utils::make_index_sequence()))>::type + auto operator[](std::tuple const &indices) -> std::enable_if_t< + utils::all_of::value...>::value, + decltype(this->_fwdlongindex(indices, std::make_index_sequence()))> { - return _fwdlongindex(indices, - utils::make_index_sequence()); + return _fwdlongindex(indices, std::make_index_sequence()); } template - auto operator[](std::tuple const &indices) const -> - typename std::enable_if< - std::is_integral::value && - !utils::all_of::value, - std::is_integral::value...>::value, - decltype((*this)[std::get<0>(indices)][tuple_tail(indices)])>::type + auto operator[](std::tuple const &indices) const -> std::enable_if_t< + std::is_integral::value && + !utils::all_of::value, std::is_integral::value...>::value, + decltype((*this)[std::get<0>(indices)][tuple_tail(indices)])> { return (*this)[std::get<0>(indices)][tuple_tail(indices)]; } template - auto _fwdindex(Slices const &indices, utils::index_sequence) - const & -> decltype((*this)(std::get(indices)...)) + auto + _fwdindex(Slices const &indices, + std::index_sequence) const & -> decltype((*this)(std::get(indices)...)) { return (*this)(std::get(indices)...); } template - auto _fwdindex(dynamic_tuple const &indices, - utils::index_sequence) - const & -> decltype((*this)(std::get(indices)...)) + auto + _fwdindex(dynamic_tuple const &indices, + std::index_sequence) const & -> decltype((*this)(std::get(indices)...)) { - return (*this)((indices.size() > Is ? std::get(indices) - : cstride_slice<1>())...); + return (*this)((indices.size() > Is ? std::get(indices) : cstride_slice<1>())...); } template ::value, - void>::type> - auto operator[](std::tuple const &indices) const -> - typename std::enable_if::value, - decltype(this->_fwdindex( - indices, utils::make_index_sequence< - 2 + sizeof...(Tys)>()))>::type; - - template ::value, - void>::type> - auto operator[](array_tuple const &indices) const - & -> decltype(this->_fwdindex(indices, utils::make_index_sequence())) + class _ = std::enable_if_t::value, void>> + auto operator[](std::tuple const &indices) const -> std::enable_if_t< + is_numexpr_arg::value, + decltype(this->_fwdindex(indices, std::make_index_sequence<2 + sizeof...(Tys)>()))>; + + template ::value, void>> + auto operator[](array_tuple const &indices) + const & -> decltype(this->_fwdindex(indices, std::make_index_sequence())) { - return _fwdindex(indices, utils::make_index_sequence()); + return _fwdindex(indices, std::make_index_sequence()); } template auto operator[](dynamic_tuple const &indices) const - -> decltype(this->_fwdindex(indices, - utils::make_index_sequence())) + -> decltype(this->_fwdindex(indices, std::make_index_sequence())) { - return _fwdindex(indices, utils::make_index_sequence()); + return _fwdindex(indices, std::make_index_sequence()); } /* through iterators */ @@ -709,8 +653,7 @@ namespace types std::ostream &operator<<(std::ostream &os, ndarray const &e); template - typename std::enable_if::value, std::ostream &>::type - operator<<(std::ostream &os, E const &e); + std::enable_if_t::value, std::ostream &> operator<<(std::ostream &os, E const &e); /* } */ } // namespace types PYTHONIC_NS_END @@ -720,11 +663,9 @@ namespace std { template - auto get(E &&a) -> - typename std::enable_if< - pythonic::types::is_array::type>::type>::value, - decltype(std::forward(a)[I])>::type; + auto get(E &&a) -> std::enable_if_t< + pythonic::types::is_array>>::value, + decltype(std::forward(a)[I])>; template struct tuple_element> { @@ -748,14 +689,12 @@ namespace std template struct tuple_element> { - using type = - decltype(std::declval>()[0]); + using type = decltype(std::declval>()[0]); }; template struct tuple_element> { - using type = - decltype(std::declval>()[0]); + using type = decltype(std::declval>()[0]); }; } // namespace std @@ -769,23 +708,20 @@ namespace types namespace details { - using dtype_table = std::tuple; + using dtype_table = + std::tuple; using dtype_utable = - std::tuple; template struct dtype_helper { - using table = typename std::conditional::value, - dtype_table, dtype_utable>::type; - using type = typename std::tuple_element< - (sizeof(T) < std::tuple_size::value) ? sizeof(T) : 0, - table>::type; + using table = std::conditional_t::value, dtype_table, dtype_utable>; + using type = + std::tuple_element_t<(sizeof(T) < std::tuple_size
::value) ? sizeof(T) : 0, table>; }; template <> @@ -829,44 +765,39 @@ namespace builtins struct _build_gexpr { template auto operator()(E const &a, S const &...slices) - -> decltype(_build_gexpr{}(a, types::cstride_slice<1>(), - slices...)); + -> decltype(_build_gexpr{}(a, types::cstride_slice<1>(), slices...)); }; template <> struct _build_gexpr<1> { template - auto operator()(E const &a, - S const &...slices) -> decltype(E(a)(slices...)); + auto operator()(E const &a, S const &...slices) -> decltype(E(a)(slices...)); }; template E _make_real(E const &a, utils::int_<0>); template - auto _make_real(E const &a, utils::int_<1>) - -> decltype(_build_gexpr{}( - types::ndarray::type, - types::array_tuple>{}, - types::slice())); + auto _make_real(E const &a, utils::int_<1>) -> decltype(_build_gexpr{}( + types::ndarray::type, + types::array_tuple>{}, + types::slice())); template - auto real_get(T &&expr, Ss const &indices, utils::index_sequence) + auto real_get(T &&expr, Ss const &indices, std::index_sequence) -> decltype(std::forward(expr)(std::get(indices)...)) { return std::forward(expr)(std::get(indices)...); } template - types::ndarray - _make_imag(E const &a, utils::int_<0>); + types::ndarray _make_imag(E const &a, utils::int_<0>); template - auto _make_imag(E const &a, utils::int_<1>) - -> decltype(_build_gexpr{}( - types::ndarray::type, - types::array_tuple>{}, - types::slice())); + auto _make_imag(E const &a, utils::int_<1>) -> decltype(_build_gexpr{}( + types::ndarray::type, + types::array_tuple>{}, + types::slice())); template - auto imag_get(T &&expr, Ss const &indices, utils::index_sequence) + auto imag_get(T &&expr, Ss const &indices, std::index_sequence) -> decltype(std::forward(expr)(std::get(indices)...)) { return std::forward(expr)(std::get(indices)...); @@ -885,8 +816,7 @@ namespace builtins constexpr decltype(long(E::value)) getattr(types::attr::NDIM, E const &a); template - std::integral_constant getattr(types::attr::NDIM, - E *const &a); + std::integral_constant getattr(types::attr::NDIM, E *const &a); inline long getattr(types::attr::NDIM, ...) { @@ -908,8 +838,8 @@ namespace builtins constexpr long getattr(types::attr::ITEMSIZE, E const &a); template - std::integral_constant - getattr(types::attr::ITEMSIZE, E *const &a); + std::integral_constant getattr(types::attr::ITEMSIZE, + E *const &a); template long getattr(types::attr::NBYTES, E const &a); @@ -925,25 +855,22 @@ namespace builtins template auto getattr(types::attr::REAL, types::ndarray const &a) - -> decltype(details::_make_real( - a, utils::int_::value>{})); + -> decltype(details::_make_real(a, utils::int_::value>{})); template auto getattr(types::attr::REAL, types::numpy_expr const &a) -> decltype(details::_make_real( - a, utils::int_::dtype>::value>{})); + a, + utils::int_::dtype>::value>{})); template auto getattr(types::attr::REAL, types::numpy_texpr const &a) - -> decltype(types::numpy_texpr{ + -> decltype(types::numpy_texpr{ getattr(types::attr::REAL{}, a.arg)}); template auto getattr(types::attr::REAL, types::numpy_iexpr const &a) - -> decltype(types::numpy_iexpr{ + -> decltype(types::numpy_iexpr{ getattr(types::attr::REAL{}, a.arg)}) { return {getattr(types::attr::REAL{}, a.arg)}; @@ -951,8 +878,7 @@ namespace builtins template auto getattr(types::attr::REAL, types::numpy_vexpr const &a) - -> decltype(types::numpy_vexpr< - decltype(getattr(types::attr::REAL{}, a.data_)), F>{ + -> decltype(types::numpy_vexpr{ getattr(types::attr::REAL{}, a.data_), a.view_}) { return {getattr(types::attr::REAL{}, a.data_), a.view_}; @@ -962,35 +888,31 @@ namespace builtins auto getattr(types::attr::REAL, types::numpy_gexpr const &a) -> decltype(details::real_get( getattr(types::attr::REAL{}, a.arg), a.slices, - utils::make_index_sequence< - std::tuple_size::value>())) + std::make_index_sequence::value>())) { - return details::real_get(getattr(types::attr::REAL{}, a.arg), a.slices, - utils::make_index_sequence< - std::tuple_size::value>()); + return details::real_get( + getattr(types::attr::REAL{}, a.arg), a.slices, + std::make_index_sequence::value>()); } template auto getattr(types::attr::IMAG, types::ndarray const &a) - -> decltype(details::_make_imag( - a, utils::int_::value>{})); + -> decltype(details::_make_imag(a, utils::int_::value>{})); template auto getattr(types::attr::IMAG, types::numpy_expr const &a) -> decltype(details::_make_imag( - a, utils::int_::dtype>::value>{})); + a, + utils::int_::dtype>::value>{})); template auto getattr(types::attr::IMAG, types::numpy_texpr const &a) - -> decltype(types::numpy_texpr{ + -> decltype(types::numpy_texpr{ getattr(types::attr::IMAG{}, a.arg)}); template auto geatttr(types::attr::IMAG, types::numpy_iexpr const &a) - -> decltype(types::numpy_iexpr{ + -> decltype(types::numpy_iexpr{ getattr(types::attr::IMAG{}, a.arg)}) { return {getattr(types::attr::IMAG{}, a.arg)}; @@ -998,8 +920,7 @@ namespace builtins template auto getattr(types::attr::IMAG, types::numpy_vexpr const &a) - -> decltype(types::numpy_vexpr< - decltype(getattr(types::attr::IMAG{}, a.data_)), F>{ + -> decltype(types::numpy_vexpr{ getattr(types::attr::IMAG{}, a.data_), a.view_}) { return {getattr(types::attr::IMAG{}, a.data_), a.view_}; @@ -1009,17 +930,15 @@ namespace builtins auto getattr(types::attr::IMAG, types::numpy_gexpr const &a) -> decltype(details::imag_get( getattr(types::attr::IMAG{}, a.arg), a.slices, - utils::make_index_sequence< - std::tuple_size::value>())) + std::make_index_sequence::value>())) { - return details::imag_get(getattr(types::attr::IMAG{}, a.arg), a.slices, - utils::make_index_sequence< - std::tuple_size::value>()); + return details::imag_get( + getattr(types::attr::IMAG{}, a.arg), a.slices, + std::make_index_sequence::value>()); } template - types::dtype_t::type> getattr(types::attr::DTYPE, - E const &); + types::dtype_t::type> getattr(types::attr::DTYPE, E const &); } // namespace builtins PYTHONIC_NS_END @@ -1029,21 +948,19 @@ PYTHONIC_NS_END #include "pythonic/include/types/combined.hpp" template -struct __combined, - pythonic::types::ndarray> { +struct __combined, pythonic::types::ndarray> { using type = pythonic::types::ndarray< typename __combined::type, pythonic::sutils::common_shapes_t::value, pS1, pS2>>; }; template -struct __combined, - pythonic::types::numpy_expr> { +struct __combined, pythonic::types::numpy_expr> { using expr_type = pythonic::types::numpy_expr; - using type = pythonic::types::ndarray< - typename __combined::type, - pythonic::sutils::common_shapes_t::value, pS, - typename expr_type::shape_t>>; + using type = + pythonic::types::ndarray::type, + pythonic::sutils::common_shapes_t::value, pS, + typename expr_type::shape_t>>; }; template @@ -1053,14 +970,12 @@ struct __combined, O> { template struct __combined, pythonic::types::none> { - using type = pythonic::types::none< - typename __combined, O>::type>; + using type = pythonic::types::none, O>::type>; }; template struct __combined, pythonic::types::ndarray> { - using type = pythonic::types::none< - typename __combined>::type>; + using type = pythonic::types::none>::type>; }; template @@ -1099,26 +1014,22 @@ PYTHONIC_NS_BEGIN template struct to_python> { - static PyObject *convert(types::ndarray const &n, - bool transpose = false); + static PyObject *convert(types::ndarray const &n, bool transpose = false); }; template struct to_python> { - static PyObject *convert(types::numpy_iexpr const &v, - bool transpose = false); + static PyObject *convert(types::numpy_iexpr const &v, bool transpose = false); }; template struct to_python> { - static PyObject *convert(types::numpy_gexpr const &v, - bool transpose = false); + static PyObject *convert(types::numpy_gexpr const &v, bool transpose = false); }; template struct to_python> { - static PyObject *convert(types::numpy_texpr const &t, - bool transpose = false) + static PyObject *convert(types::numpy_texpr const &t, bool transpose = false) { auto const &n = t.arg; PyObject *result = to_python::convert(n, !transpose); @@ -1157,18 +1068,13 @@ PYTHONIC_NS_END namespace std { template - typename pythonic::types::nditerator> copy( - typename pythonic::types::const_nditerator< - pythonic::types::ndarray> - begin, - typename pythonic::types::const_nditerator< - pythonic::types::ndarray> - end, - typename pythonic::types::nditerator> out) + typename pythonic::types::nditerator> + copy(typename pythonic::types::const_nditerator> begin, + typename pythonic::types::const_nditerator> end, + typename pythonic::types::nditerator> out) { const long offset = pythonic::sutils::prod_tail(begin.data); - std::copy(begin.data.buffer + begin.index * offset, - end.data.buffer + end.index * offset, + std::copy(begin.data.buffer + begin.index * offset, end.data.buffer + end.index * offset, out.data.buffer + out.index * offset); return out + (end - begin); } diff --git a/contrib/python/pythran/pythran/pythonic/include/types/nditerator.hpp b/contrib/python/pythran/pythran/pythonic/include/types/nditerator.hpp index 0d1f8281adf..d37e29288a0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/nditerator.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/nditerator.hpp @@ -15,30 +15,24 @@ namespace types }; template - auto fast_begin(T const &e) -> - typename std::enable_if::value, - decltype(e.begin(fast{}))>::type + auto fast_begin(T const &e) + -> std::enable_if_t::value, decltype(e.begin(fast{}))> { return e.begin(fast{}); } template - auto fast_begin(T const &e) -> - typename std::enable_if::value, - decltype(e.begin())>::type + auto fast_begin(T const &e) -> std::enable_if_t::value, decltype(e.begin())> { return e.begin(); } template - auto fast_end(T const &e) -> - typename std::enable_if::value, - decltype(e.end(fast{}))>::type + auto fast_end(T const &e) + -> std::enable_if_t::value, decltype(e.end(fast{}))> { return e.end(fast{}); } template - auto fast_end(T const &e) -> - typename std::enable_if::value, - decltype(e.end())>::type + auto fast_end(T const &e) -> std::enable_if_t::value, decltype(e.end())> { return e.end(); } @@ -48,8 +42,7 @@ namespace types template struct nditerator : public std::iterator().fast(0))>::type> { + std::remove_reference_t().fast(0))>> { E &data; long index; nditerator(E &data, long index); @@ -66,6 +59,9 @@ namespace types bool operator!=(nditerator const &other) const; bool operator==(nditerator const &other) const; bool operator<(nditerator const &other) const; + bool operator>(nditerator const &other) const; + bool operator<=(nditerator const &other) const; + bool operator>=(nditerator const &other) const; nditerator &operator=(nditerator const &other); }; @@ -75,8 +71,7 @@ namespace types template struct const_nditerator : public std::iterator().fast(0))>::type> { + std::remove_reference_t().fast(0))>> { E const &data; long index; const_nditerator(E const &data, long index); @@ -92,13 +87,15 @@ namespace types bool operator!=(const_nditerator const &other) const; bool operator==(const_nditerator const &other) const; bool operator<(const_nditerator const &other) const; + bool operator>(const_nditerator const &other) const; + bool operator<=(const_nditerator const &other) const; + bool operator>=(const_nditerator const &other) const; const_nditerator &operator=(const_nditerator const &other); }; #ifdef USE_XSIMD template struct const_simd_nditerator - : public std::iterator> { + : public std::iterator> { using vector_type = typename xsimd::batch; typename E::dtype const *data; @@ -115,6 +112,9 @@ namespace types bool operator!=(const_simd_nditerator const &other) const; bool operator==(const_simd_nditerator const &other) const; bool operator<(const_simd_nditerator const &other) const; + bool operator>(const_simd_nditerator const &other) const; + bool operator<=(const_simd_nditerator const &other) const; + bool operator>=(const_simd_nditerator const &other) const; const_simd_nditerator &operator=(const_simd_nditerator const &other); void store(xsimd::batch const &); }; @@ -132,8 +132,7 @@ namespace types { return *this; } - const_simd_nditerator_nostep & - operator=(const_simd_nditerator_nostep const &other) = default; + const_simd_nditerator_nostep &operator=(const_simd_nditerator_nostep const &other) = default; }; #endif @@ -153,8 +152,7 @@ namespace types template struct make_const_nditerator { template - auto operator()(T const &self, - long i) -> decltype(const_nditerator(self, i)) const; + auto operator()(T const &self, long i) -> decltype(const_nditerator(self, i)) const; }; template <> diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_binary_op.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_binary_op.hpp index 5aec8888b53..998c27ca8d9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_binary_op.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_binary_op.hpp @@ -6,12 +6,9 @@ #endif template -typename std::enable_if< - types::valid_numop_parameters::type, - typename std::decay::type>::value, - types::numpy_expr::type, - typename types::adapt_type::type>>::type +std::enable_if_t, std::decay_t>::value, + types::numpy_expr::type, + typename types::adapt_type::type>> NUMPY_BINARY_FUNC_NAME(E0 &&self, E1 &&other); #undef NUMPY_BINARY_FUNC_NAME diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_broadcast.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_broadcast.hpp index f86dc628fe0..34cb4dc9743 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_broadcast.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_broadcast.hpp @@ -16,8 +16,7 @@ namespace types { template struct broadcasted_iterator - : std::iterator::type> { + : std::iterator> { T value_; broadcasted_iterator(T const &value) : value_(value) @@ -80,9 +79,9 @@ namespace types static const bool is_vectorizable = true; static const bool is_flat = false; static const bool is_strided = false; - using dtype = typename std::remove_reference::type::dtype; - using value_type = typename std::remove_reference::type::value_type; - static constexpr size_t value = std::remove_reference::type::value + 1; + using dtype = typename std::remove_reference_t::dtype; + using value_type = typename std::remove_reference_t::value_type; + static constexpr size_t value = std::remove_reference_t::value + 1; using const_iterator = broadcasted_iterator; using iterator = const_iterator; @@ -92,8 +91,7 @@ namespace types template long shape() const { - return I == 0 ? 1 - : (long)(ref.template shape < I == 0 ? 0 : (I - 1) > ()); + return I == 0 ? 1 : (long)(ref.template shape()); } broadcasted() = default; @@ -115,8 +113,7 @@ namespace types T const &operator[](long i) const; template - typename std::enable_if::value, broadcasted const &>::type - operator[](S s) const + std::enable_if_t::value, broadcasted const &> operator[](S s) const { return *this; } @@ -137,8 +134,7 @@ namespace types #endif template - typename std::enable_if::value, broadcasted const &>::type - operator()(S s) const + std::enable_if_t::value, broadcasted const &> operator()(S s) const { return *this; } @@ -153,9 +149,8 @@ namespace types -> decltype(ref(std::forward(arg1), std::forward(args)...)); template - auto operator()(S arg0, Arg1 &&arg1, Args &&...args) const - -> broadcast_or_broadcasted_t(arg1), std::forward(args)...))>::type>; + auto operator()(S arg0, Arg1 &&arg1, Args &&...args) const -> broadcast_or_broadcasted_t< + std::decay_t(arg1), std::forward(args)...))>>; long flat_size() const; }; @@ -199,8 +194,7 @@ namespace types #endif template - struct const_broadcast_iterator - : public std::iterator { + struct const_broadcast_iterator : public std::iterator { T value; const_broadcast_iterator(T data) : value{data} { @@ -258,12 +252,10 @@ namespace types template struct broadcast_dtype { - using type = - typename std::conditional<(std::is_integral::value && - std::is_integral::value) || - (std::is_floating_point::value && - std::is_floating_point::value), - T, typename __combined::type>::type; + using type = std::conditional_t<(std::is_integral::value && std::is_integral::value) || + (std::is_floating_point::value && + std::is_floating_point::value), + T, typename __combined::type>; }; #ifndef USE_XSIMD template @@ -304,8 +296,7 @@ namespace types dtype operator[](array_tuple) const; template - typename std::enable_if::value, broadcast const &>::type - operator[](S) const + std::enable_if_t::value, broadcast const &> operator[](S) const { return *this; } diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_expr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_expr.hpp index 0d13801a6bf..a6b59610364 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_expr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_expr.hpp @@ -11,10 +11,9 @@ namespace types template bool is_trivial_broadcast() { - return std::is_same::type>::type::shape_t>::type, - std::integral_constant>::value; + return std::is_same< + std::tuple_element_t<0, typename std::decay_t>::shape_t>, + std::integral_constant>::value; } template @@ -27,9 +26,8 @@ namespace types }; template struct count_non_integral - : std::integral_constant::value + - count_non_integral::value> { + : std::integral_constant::value + + count_non_integral::value> { }; template struct is_perfect_stepping; @@ -42,21 +40,18 @@ namespace types template struct all_valid_indices { - using type = utils::index_sequence; + using type = std::index_sequence; }; template struct all_valid_indices - : std::conditional<(value <= - std::remove_reference::type>::type::value), - all_valid_indices, - all_valid_indices>::type { + : std::conditional_t<(value <= + std::remove_reference_t>::value), + all_valid_indices, + all_valid_indices> { }; template - using valid_indices = - typename all_valid_indices::value>::type; + using valid_indices = typename all_valid_indices::value>::type; template struct is_numexpr_arg; @@ -67,7 +62,7 @@ namespace types template struct Dereferencer { template - auto operator()(Ts const &iters, utils::index_sequence) + auto operator()(Ts const &iters, std::index_sequence) -> decltype(Op{}(*std::get(iters)...)) { return Op{}(*std::get(iters)...); @@ -80,20 +75,18 @@ namespace types namespace details { template - long init_shape_element(Args const &args, utils::index_sequence); + long init_shape_element(Args const &args, std::index_sequence); } template struct numpy_expr_iterator : std::iterator< std::random_access_iterator_tag, - typename std::remove_reference()( - *std::declval()...))>::type> { + std::remove_reference_t()(*std::declval()...))>> { Steps steps_; std::tuple iters_; - numpy_expr_iterator(Steps steps, Iters... iters) - : steps_(steps), iters_(iters...) + numpy_expr_iterator(Steps steps, Iters... iters) : steps_(steps), iters_(iters...) { } @@ -109,16 +102,15 @@ namespace types } template - auto _dereference(utils::index_sequence s) const - -> decltype(Dereferencer{}(iters_, s)) + auto _dereference(std::index_sequence s) const -> decltype(Dereferencer{}(iters_, s)) { return Dereferencer{}(iters_, s); } - auto operator*() const -> decltype(this->_dereference( - utils::make_index_sequence{})) + auto operator*() const + -> decltype(this->_dereference(std::make_index_sequence{})) { - return _dereference(utils::make_index_sequence{}); + return _dereference(std::make_index_sequence{}); } template @@ -134,22 +126,21 @@ namespace types template bool _incr_opt(std::integral_constant long_step) { - if (std::tuple_element::type::value) + if (std::tuple_element_t::value) ++std::get(iters_); return true; } template - void _incr(utils::index_sequence) + void _incr(std::index_sequence) { (void)std::initializer_list{_incr_opt( - std::integral_constant< - bool, std::is_same::type>::value>{})...}; + std::integral_constant>::value>{})...}; } numpy_expr_iterator &operator++() { - _incr(utils::make_index_sequence{}); + _incr(std::make_index_sequence{}); return *this; } @@ -160,29 +151,27 @@ namespace types } template - void _update(long i, utils::index_sequence) + void _update(long i, std::index_sequence) { - (void)std::initializer_list{ - (std::get(iters_) += std::get(steps_) * i, true)...}; + (void)std::initializer_list{(std::get(iters_) += std::get(steps_) * i, true)...}; } numpy_expr_iterator &operator+=(long i) { - _update(i, utils::make_index_sequence{}); + _update(i, std::make_index_sequence{}); return *this; } template - long _difference(numpy_expr_iterator const &other, - utils::index_sequence) const + long _difference(numpy_expr_iterator const &other, std::index_sequence) const { - std::initializer_list distances{(static_cast( - std::get(iters_) - std::get(other.iters_)))...}; + std::initializer_list distances{ + (static_cast(std::get(iters_) - std::get(other.iters_)))...}; return *std::max_element(distances.begin(), distances.end()); } long operator-(numpy_expr_iterator const &other) const { - return _difference(other, utils::make_index_sequence{}); + return _difference(other, std::make_index_sequence{}); } bool _neq(numpy_expr_iterator const &other, utils::int_<0u>) const @@ -228,32 +217,34 @@ namespace types template bool _lt(numpy_expr_iterator const &other, utils::int_) const { - if (!std::get(steps_) || - (std::get(iters_) == std::get(other.iters_))) + if (!std::get(steps_) || (std::get(iters_) == std::get(other.iters_))) return _lt(other, utils::int_{}); else - return std::get(steps_) && - (std::get(iters_) < std::get(other.iters_)); + return std::get(steps_) && (std::get(iters_) < std::get(other.iters_)); } bool operator<(numpy_expr_iterator const &other) const { return _lt(other, utils::int_{}); } + + bool operator<=(numpy_expr_iterator const &other) const + { + return *this < other || *this == other; + } }; #ifdef USE_XSIMD template struct numpy_expr_simd_iterator : std::iterator< std::random_access_iterator_tag, - typename std::remove_reference()( - *std::declval()...))>::type> { + std::remove_reference_t()(*std::declval()...))>> { Steps steps_; std::tuple iters_; SIters siters_; - numpy_expr_simd_iterator(array_tuple steps, - SIters const &siters, Iters... iters) + numpy_expr_simd_iterator(array_tuple steps, SIters const &siters, + Iters... iters) : steps_(steps), iters_(iters...), siters_(siters) { } @@ -271,17 +262,15 @@ namespace types } template - auto _dereference(utils::index_sequence) const - -> decltype(Op{}(*std::get(iters_)...)) + auto _dereference(std::index_sequence) const -> decltype(Op{}(*std::get(iters_)...)) { - return Op{}(((std::get(steps_)) ? (*std::get(iters_)) - : (std::get(siters_)))...); + return Op{}(((std::get(steps_)) ? (*std::get(iters_)) : (std::get(siters_)))...); } - auto operator*() const -> decltype(this->_dereference( - utils::make_index_sequence{})) + auto operator*() const + -> decltype(this->_dereference(std::make_index_sequence{})) { - return _dereference(utils::make_index_sequence{}); + return _dereference(std::make_index_sequence{}); } template @@ -297,22 +286,21 @@ namespace types template bool _incr_opt(std::integral_constant long_step) { - if (std::tuple_element::type::value) + if (std::tuple_element_t::value) ++std::get(iters_); return true; } template - void _incr(utils::index_sequence) + void _incr(std::index_sequence) { (void)std::initializer_list{_incr_opt( - std::integral_constant< - bool, std::is_same::type>::value>{})...}; + std::integral_constant>::value>{})...}; } numpy_expr_simd_iterator &operator++() { - _incr(utils::make_index_sequence{}); + _incr(std::make_index_sequence{}); return *this; } @@ -323,29 +311,26 @@ namespace types } template - void _update(long i, utils::index_sequence) + void _update(long i, std::index_sequence) { - (void)std::initializer_list{ - (std::get(iters_) += std::get(steps_) * i, true)...}; + (void)std::initializer_list{(std::get(iters_) += std::get(steps_) * i, true)...}; } numpy_expr_simd_iterator &operator+=(long i) { - _update(i, utils::make_index_sequence{}); + _update(i, std::make_index_sequence{}); return *this; } template - long _difference(numpy_expr_simd_iterator const &other, - utils::index_sequence) const + long _difference(numpy_expr_simd_iterator const &other, std::index_sequence) const { - std::initializer_list distances{ - (std::get(iters_) - std::get(other.iters_))...}; + std::initializer_list distances{(std::get(iters_) - std::get(other.iters_))...}; return *std::max_element(distances.begin(), distances.end()); } long operator-(numpy_expr_simd_iterator const &other) const { - return _difference(other, utils::make_index_sequence{}); + return _difference(other, std::make_index_sequence{}); } bool _neq(numpy_expr_simd_iterator const &other, utils::int_<0u>) const @@ -392,12 +377,10 @@ namespace types template bool _lt(numpy_expr_simd_iterator const &other, utils::int_) const { - if (std::get(steps_) && - (std::get(iters_) == std::get(other.iters_))) + if (std::get(steps_) && (std::get(iters_) == std::get(other.iters_))) return _lt(other, utils::int_{}); else - return std::get(steps_) && - (std::get(iters_) < std::get(other.iters_)); + return std::get(steps_) && (std::get(iters_) < std::get(other.iters_)); } bool operator<(numpy_expr_simd_iterator const &other) const @@ -410,16 +393,14 @@ namespace types struct numpy_expr_simd_iterator_nobroadcast : std::iterator< std::random_access_iterator_tag, - typename std::remove_reference()( - *std::declval()...))>::type> { + std::remove_reference_t()(*std::declval()...))>> { std::tuple iters_; numpy_expr_simd_iterator_nobroadcast(Iters... iters) : iters_(iters...) { } - numpy_expr_simd_iterator_nobroadcast( - numpy_expr_simd_iterator_nobroadcast const &other) + numpy_expr_simd_iterator_nobroadcast(numpy_expr_simd_iterator_nobroadcast const &other) : iters_(other.iters_) { } @@ -432,41 +413,39 @@ namespace types } template - auto _dereference(utils::index_sequence) const - -> decltype(Op{}(*std::get(iters_)...)) + auto _dereference(std::index_sequence) const -> decltype(Op{}(*std::get(iters_)...)) { return Op{}((*std::get(iters_))...); } - auto operator*() const -> decltype(this->_dereference( - utils::make_index_sequence{})) + auto operator*() const + -> decltype(this->_dereference(std::make_index_sequence{})) { - return _dereference(utils::make_index_sequence{}); + return _dereference(std::make_index_sequence{}); } template - void _incr(utils::index_sequence) + void _incr(std::index_sequence) { (void)std::initializer_list{(++std::get(iters_), true)...}; } numpy_expr_simd_iterator_nobroadcast &operator++() { - _incr(utils::make_index_sequence{}); + _incr(std::make_index_sequence{}); return *this; } template long _difference(numpy_expr_simd_iterator_nobroadcast const &other, - utils::index_sequence) const + std::index_sequence) const { - std::initializer_list distances{ - (std::get(iters_) - std::get(other.iters_))...}; + std::initializer_list distances{(std::get(iters_) - std::get(other.iters_))...}; return *std::max_element(distances.begin(), distances.end()); } long operator-(numpy_expr_simd_iterator_nobroadcast const &other) const { - return _difference(other, utils::make_index_sequence{}); + return _difference(other, std::make_index_sequence{}); } numpy_expr_simd_iterator_nobroadcast operator+(long i) const @@ -476,25 +455,23 @@ namespace types } template - void _update(long i, utils::index_sequence) + void _update(long i, std::index_sequence) { (void)std::initializer_list{(std::get(iters_) += i, true)...}; } numpy_expr_simd_iterator_nobroadcast &operator+=(long i) { - _update(i, utils::make_index_sequence{}); + _update(i, std::make_index_sequence{}); return *this; } - bool _neq(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_<0u>) const + bool _neq(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_<0u>) const { return false; } template - bool _neq(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_) const + bool _neq(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_) const { return (std::get(iters_) != std::get(other.iters_)) || _neq(other, utils::int_{}); @@ -505,15 +482,13 @@ namespace types return _neq(other, utils::int_{}); } - bool _eq(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_<0u>) const + bool _eq(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_<0u>) const { return true; } template - bool _eq(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_) const + bool _eq(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_) const { return (std::get(iters_) == std::get(other.iters_)) && _eq(other, utils::int_{}); @@ -524,15 +499,13 @@ namespace types return _eq(other, utils::int_{}); } - bool _lt(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_<0u>) const + bool _lt(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_<0u>) const { return false; } template - bool _lt(numpy_expr_simd_iterator_nobroadcast const &other, - utils::int_) const + bool _lt(numpy_expr_simd_iterator_nobroadcast const &other, utils::int_) const { if (std::get(iters_) == std::get(other.iters_)) return _lt(other, utils::int_{}); @@ -548,8 +521,8 @@ namespace types #endif template - std::integral_constant - make_step(std::integral_constant, std::integral_constant) + std::integral_constant make_step(std::integral_constant, + std::integral_constant) { return {}; } @@ -568,14 +541,12 @@ namespace types template constexpr size_t count_none(size_t I) { - return I == 0 ? 0 - : (std::is_same::value + - count_none(I - 1)); + return I == 0 ? 0 : (std::is_same::value + count_none(I - 1)); } template - using step_type_t = decltype(make_step(std::get<0>(std::declval()), - std::get<0>(std::declval()))); + using step_type_t = + decltype(make_step(std::get<0>(std::declval()), std::get<0>(std::declval()))); constexpr size_t clamp(size_t i, size_t j) { @@ -583,16 +554,13 @@ namespace types } template - auto - make_subslice(utils::index_sequence, Arg const &arg, Shp const &shp, - std::tuple const &ss) -> decltype(arg(std::get(ss)...)) + auto make_subslice(std::index_sequence, Arg const &arg, Shp const &shp, + std::tuple const &ss) -> decltype(arg(std::get(ss)...)) { // we need to adapt_slice to take broadcasting into account return arg(adapt_slice( - std::get(ss), - shp.template shape(J), Shp::value - 1)>(), - arg.template shape(J), - Arg::value - 1)>())...); + std::get(ss), shp.template shape(J), Shp::value - 1)>(), + arg.template shape(J), Arg::value - 1)>())...); } /* Expression template for numpy expressions - binary operators @@ -601,90 +569,79 @@ namespace types struct numpy_expr { using first_arg = typename utils::front::type; static const bool is_vectorizable = - utils::all_of< - std::remove_reference::type::is_vectorizable...>::value && - utils::all_of< - std::is_same::type>::type::dtype, - typename std::remove_cv::type>::type::dtype>::value...>::value && - types::is_vector_op< - Op, typename std::remove_reference::type::dtype...>::value; + utils::all_of::is_vectorizable...>::value && + utils::all_of>::dtype, + typename std::remove_cv_t>::dtype>::value...>::value && + types::is_vector_op::dtype...>::value; static const bool is_flat = false; static const bool is_strided = - utils::any_of::type::is_strided...>::value; + utils::any_of::is_strided...>::value; static constexpr size_t value = - utils::max_element::type::value...>::value; - using value_type = decltype(Op()( - std::declval< - typename std::remove_reference::type::value_type>()...)); - using dtype = decltype(Op()( - std::declval::type::dtype>()...)); + utils::max_element::value...>::value; + using value_type = + decltype(Op()(std::declval::value_type>()...)); + using dtype = decltype(Op()(std::declval::dtype>()...)); #ifdef CYTHON_ABI - std::tuple::type...> args; + std::tuple...> args; #else std::tuple args; #endif - using shape_t = sutils::merged_shapes_t< - value, typename std::remove_reference::type::shape_t...>; - using steps_t = pshape::type::shape_t>...>; - static_assert(value == std::tuple_size::value, - "consistent shape and size"); - using const_iterator = numpy_expr_iterator< - Op, steps_t, - typename std::remove_reference::type::const_iterator...>; - using iterator = numpy_expr_iterator< - Op, steps_t, typename std::remove_reference::type::iterator...>; + using shape_t = + sutils::merged_shapes_t::shape_t...>; + using steps_t = + pshape::shape_t>...>; + static_assert(value == std::tuple_size::value, "consistent shape and size"); + using const_iterator = + numpy_expr_iterator::const_iterator...>; + using iterator = + numpy_expr_iterator::iterator...>; using const_fast_iterator = const_nditerator; numpy_expr() = default; numpy_expr(numpy_expr const &) = default; numpy_expr(numpy_expr &&) = default; -#ifdef CYTHON_ABI template numpy_expr(numpy_expr const &other) : args(other.args) { } -#endif numpy_expr(Args const &...args); template - const_iterator _begin(utils::index_sequence) const; + const_iterator _begin(std::index_sequence) const; const_iterator begin() const; template - const_iterator _end(utils::index_sequence) const; + const_iterator _end(std::index_sequence) const; const_iterator end() const; const_fast_iterator begin(types::fast) const; const_fast_iterator end(types::fast) const; template - iterator _begin(utils::index_sequence); + iterator _begin(std::index_sequence); iterator begin(); template - iterator _end(utils::index_sequence); + iterator _end(std::index_sequence); iterator end(); template - auto _fast(long i, utils::index_sequence) const + auto _fast(long i, std::index_sequence) const -> decltype(Op()(std::get(args).fast(i)...)) { return Op()(std::get(args).fast(i)...); } auto fast(long i) const - -> decltype(this->_fast(i, - utils::make_index_sequence{})); + -> decltype(this->_fast(i, std::make_index_sequence{})); template - auto _load(utils::index_sequence, Indices... indices) const + auto _load(std::index_sequence, Indices... indices) const -> decltype(Op()(std::get(args).load(indices...)...)) { return Op()(std::get(args).load(indices...)...); @@ -692,16 +649,13 @@ namespace types template auto load(Indices... indices) const - -> decltype(this->_load(utils::make_index_sequence{}, - indices...)) + -> decltype(this->_load(std::make_index_sequence{}, indices...)) { - return this->_load(utils::make_index_sequence{}, - indices...); + return this->_load(std::make_index_sequence{}, indices...); } template - auto _map_fast(array_tuple const &indices, - utils::index_sequence) const + auto _map_fast(array_tuple const &indices, std::index_sequence) const -> decltype(Op()(std::get(args).fast(std::get(indices))...)) { return Op()(std::get(args).fast(std::get(indices))...); @@ -709,126 +663,107 @@ namespace types template auto map_fast(Indices... indices) const - -> decltype(this->_map_fast( - array_tuple{{indices...}}, - utils::make_index_sequence{})); + -> decltype(this->_map_fast(array_tuple{{indices...}}, + std::make_index_sequence{})); public: template - auto shape() const -> decltype(details::init_shape_element( - args, valid_indices>{})) + auto shape() const + -> decltype(details::init_shape_element(args, + valid_indices>{})) { - return details::init_shape_element( - args, valid_indices>{}); + return details::init_shape_element(args, valid_indices>{}); } template - bool _no_broadcast(utils::index_sequence) const; + bool _no_broadcast(std::index_sequence) const; bool no_broadcast() const; template - bool _no_broadcast_vectorize(utils::index_sequence) const; + bool _no_broadcast_vectorize(std::index_sequence) const; bool no_broadcast_vectorize() const; template - bool _no_broadcast_ex(utils::index_sequence) const; + bool _no_broadcast_ex(std::index_sequence) const; bool no_broadcast_ex() const; #ifdef USE_XSIMD using simd_iterator = numpy_expr_simd_iterator< numpy_expr, Op, - pshape::type::shape_t>...>, - std::tuple::type::value_type>...>, - typename std::remove_reference::type::simd_iterator...>; + pshape::shape_t>...>, + std::tuple::value_type>...>, + typename std::remove_reference_t::simd_iterator...>; using simd_iterator_nobroadcast = numpy_expr_simd_iterator_nobroadcast< - numpy_expr, Op, - typename std::remove_reference< - Args>::type::simd_iterator_nobroadcast...>; + numpy_expr, Op, typename std::remove_reference_t::simd_iterator_nobroadcast...>; template - simd_iterator _vbegin(types::vectorize, utils::index_sequence) const; + simd_iterator _vbegin(types::vectorize, std::index_sequence) const; simd_iterator vbegin(types::vectorize) const; template - simd_iterator _vend(types::vectorize, utils::index_sequence) const; + simd_iterator _vend(types::vectorize, std::index_sequence) const; simd_iterator vend(types::vectorize) const; template simd_iterator_nobroadcast _vbegin(types::vectorize_nobroadcast, - utils::index_sequence) const; + std::index_sequence) const; simd_iterator_nobroadcast vbegin(types::vectorize_nobroadcast) const; template - simd_iterator_nobroadcast _vend(types::vectorize_nobroadcast, - utils::index_sequence) const; + simd_iterator_nobroadcast _vend(types::vectorize_nobroadcast, std::index_sequence) const; simd_iterator_nobroadcast vend(types::vectorize_nobroadcast) const; #endif template - auto _get(utils::index_sequence is, S const &...s) const - -> decltype(Op{}( - make_subslice(utils::make_index_sequence{}, - std::get(args), *this, std::make_tuple(s...))...)) + auto _get(std::index_sequence is, S const &...s) const + -> decltype(Op{}(make_subslice(std::make_index_sequence{}, std::get(args), + *this, std::make_tuple(s...))...)) { - return Op{}(make_subslice(utils::make_index_sequence{}, - std::get(args), *this, + return Op{}(make_subslice(std::make_index_sequence{}, std::get(args), *this, std::make_tuple(s...))...); } template auto operator()(S const &...s) const - -> decltype(this->_get(utils::make_index_sequence{}, - s...)); + -> decltype(this->_get(std::make_index_sequence{}, s...)); template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr>>> fast(F const &filter) const; template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr>>> operator[](F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> operator[](F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> fast(F const &filter) const; // FIXME: this does not take into account bounds and broadcasting auto operator[](long i) const -> decltype(this->fast(i)); template - auto _index(S s, utils::index_sequence) const - -> decltype(Op{}(std::get(args)[s]...)) + auto _index(S s, std::index_sequence) const -> decltype(Op{}(std::get(args)[s]...)) { return Op{}(std::get(args)[s]...); } template auto operator[](S s) const - -> decltype((*this)._index( - (s.lower, s), utils::make_index_sequence{})) + -> decltype((*this)._index((s.lower, s), std::make_index_sequence{})) { - return _index(s, utils::make_index_sequence{}); + return _index(s, std::make_index_sequence{}); } dtype operator[](array_tuple const &indices) const { - return _index(indices, utils::make_index_sequence{}); + return _index(indices, std::make_index_sequence{}); } explicit operator bool() const; @@ -841,9 +776,8 @@ namespace types template struct assignable> { - using type = types::ndarray< - typename pythonic::types::numpy_expr::dtype, - typename pythonic::types::numpy_expr::shape_t>; + using type = types::ndarray::dtype, + typename pythonic::types::numpy_expr::shape_t>; }; template @@ -864,14 +798,12 @@ struct __combined, pythonic::types::numpy_expr> { }; template -struct __combined, - indexable_container> { +struct __combined, indexable_container> { using type = pythonic::types::numpy_expr; }; template -struct __combined, - pythonic::types::numpy_expr> { +struct __combined, pythonic::types::numpy_expr> { using type = pythonic::types::numpy_expr; }; @@ -890,42 +822,34 @@ struct __combined, pythonic::types::numpy_expr> { using type = pythonic::types::ndarray< typename pythonic::types::numpy_expr::dtype, - pythonic::types::array_tuple< - long, pythonic::types::numpy_expr::value>>; + pythonic::types::array_tuple::value>>; }; template -struct __combined, - pythonic::types::numpy_expr> { +struct __combined, pythonic::types::numpy_expr> { using type = pythonic::types::numpy_iexpr; }; template -struct __combined, - pythonic::types::numpy_iexpr> { +struct __combined, pythonic::types::numpy_iexpr> { using type = pythonic::types::numpy_iexpr; }; template -struct __combined, - pythonic::types::ndarray> { +struct __combined, pythonic::types::ndarray> { using type = pythonic::types::ndarray; }; template -struct __combined, - pythonic::types::numpy_texpr> { +struct __combined, pythonic::types::numpy_texpr> { using type = pythonic::types::ndarray< typename pythonic::types::numpy_expr::dtype, - pythonic::types::array_tuple< - long, pythonic::types::numpy_expr::value>>; + pythonic::types::array_tuple::value>>; }; template -struct __combined, - pythonic::types::numpy_expr> { +struct __combined, pythonic::types::numpy_expr> { using type = pythonic::types::ndarray< typename pythonic::types::numpy_expr::dtype, - pythonic::types::array_tuple< - long, pythonic::types::numpy_expr::value>>; + pythonic::types::array_tuple::value>>; }; /*}*/ diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_gexpr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_gexpr.hpp index b56aeba3bc1..8b9f1acd5d9 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_gexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_gexpr.hpp @@ -31,8 +31,7 @@ namespace types template struct count_new_axis { - static constexpr size_t value = - count_new_axis::value + count_new_axis::value; + static constexpr size_t value = count_new_axis::value + count_new_axis::value; }; /* helper to cast slices @@ -96,16 +95,12 @@ namespace types template auto operator()(E &&expr, S const &...s) -> decltype(std::forward(expr).reshape(make_reshape( - expr, - std::tuple< - std::integral_constant::is_new_axis>...>()))( + expr, std::tuple::is_new_axis>...>()))( to_slice{}(s)...)) { return std::forward(expr).reshape(make_reshape( - expr, - std::tuple< - std::integral_constant::is_new_axis>...>()))( + expr, std::tuple::is_new_axis>...>()))( to_slice{}(s)...); } }; @@ -113,51 +108,44 @@ namespace types template <> struct extended_slice<0> { template - auto operator()(E &&expr, long const &s0, S const &...s) -> - typename std::enable_if< - utils::all_of::value...>::value, - decltype(std::forward(expr)[types::make_tuple(s0, s...)])>::type + auto operator()(E &&expr, long const &s0, S const &...s) + -> std::enable_if_t::value...>::value, + decltype(std::forward(expr)[types::make_tuple(s0, s...)])> { return std::forward(expr)[types::make_tuple(s0, s...)]; } template - auto operator()(E &&expr, long const &s0, S const &...s) -> - typename std::enable_if< - !utils::all_of::value...>::value, - decltype(std::forward(expr)[s0](s...))>::type + auto operator()(E &&expr, long const &s0, S const &...s) + -> std::enable_if_t::value...>::value, + decltype(std::forward(expr)[s0](s...))> { return std::forward(expr)[s0](s...); } template - numpy_gexpr::type, normalize_t...> - fwd(E &&expr, std::tuple const &s, utils::index_sequence) + numpy_gexpr, normalize_t...> fwd(E &&expr, std::tuple const &s, + std::index_sequence) { - return {std::forward(expr), - std::get(s).normalize(expr.template shape())...}; + return {std::forward(expr), std::get(s).normalize(expr.template shape())...}; } template - typename std::enable_if< - is_slice::value, - numpy_gexpr, normalize_t...>>::type + std::enable_if_t::value, numpy_gexpr, normalize_t...>> operator()(E &&expr, Sp const &s0, S const &...s) { return make_gexpr(std::forward(expr), s0, s...); } template - typename std::enable_if< - !is_slice::value, - numpy_gexpr::type::dtype, - array_tuple::type::value>>, - cstride_normalized_slice<1>, normalize_t...>>::type + std::enable_if_t::value, + numpy_gexpr::dtype, + array_tuple::value>>, + cstride_normalized_slice<1>, normalize_t...>> operator()(E &&expr, F const &s0, S const &...s) { - return numpy_vexpr::type::dtype, - array_tuple::type::value>>, - F>{std::forward(expr), s0}( - fast_contiguous_slice(none_type{}, none_type{}), s...); + return numpy_vexpr< + ndarray::dtype, array_tuple::value>>, F>{ + std::forward(expr), s0}(fast_contiguous_slice(none_type{}, none_type{}), s...); } }; @@ -183,8 +171,7 @@ namespace types template struct count_long { - static constexpr size_t value = - count_long::value + count_long::value; + static constexpr size_t value = count_long::value + count_long::value; }; template <> @@ -226,21 +213,18 @@ namespace types { template - std::tuple::type...> - tuple_push_head(T const &val, Ts const &vals, utils::index_sequence) + std::tuple...> tuple_push_head(T const &val, Ts const &vals, + std::index_sequence) { - return std::tuple::type...>{ - val, std::get(vals)...}; + return std::tuple...>{val, std::get(vals)...}; } template auto tuple_push_head(T const &val, Ts const &vals) - -> decltype(tuple_push_head( - val, vals, - utils::make_index_sequence::value>())) + -> decltype(tuple_push_head(val, vals, + std::make_index_sequence::value>())) { - return tuple_push_head( - val, vals, utils::make_index_sequence::value>()); + return tuple_push_head(val, vals, std::make_index_sequence::value>()); } // this struct is specialized for every type combination && takes care of @@ -257,89 +241,77 @@ namespace types template struct merge_gexpr, std::tuple<>> { template - std::tuple run(S const &, std::tuple const &t0, - std::tuple<>); - static_assert( - utils::all_of>::value...>::value, - "all slices are normalized"); + std::tuple run(S const &, std::tuple const &t0, std::tuple<>); + static_assert(utils::all_of>::value...>::value, + "all slices are normalized"); }; template struct merge_gexpr, std::tuple> { template - std::tuple...> run(S const &, std::tuple<>, - std::tuple const &t1); + std::tuple...> run(S const &, std::tuple<>, std::tuple const &t1); }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t0) * std::get<0>(t1), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), tuple_tail(t1)))) + auto run(S const &s, std::tuple const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t0) * std::get<0>(t1), + merge_gexpr, std::tuple>{} + .template run(s, tuple_tail(t0), tuple_tail(t1)))) { return tuple_push_head( std::get<0>(t0) * std::get<0>(t1), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), tuple_tail(t1))); + merge_gexpr, std::tuple>{}.template run( + s, tuple_tail(t0), tuple_tail(t1))); } static_assert( std::is_same() * std::declval()), - normalize_t() * - std::declval())>>::value, + normalize_t() * std::declval())>>::value, "all slices are normalized"); }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple<> const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t1), merge_gexpr, std::tuple>{} - .template run(s, t0, tuple_tail(t1)))) + auto run(S const &s, std::tuple<> const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t1), + merge_gexpr, std::tuple>{} + .template run(s, t0, tuple_tail(t1)))) { - return tuple_push_head( - std::get<0>(t1), - merge_gexpr, std::tuple>{}.template run( - s, t0, tuple_tail(t1))); + return tuple_push_head(std::get<0>(t1), + merge_gexpr, std::tuple>{}.template run( + s, t0, tuple_tail(t1))); } }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t1), - merge_gexpr, std::tuple>{} - .template run(s, t0, tuple_tail(t1)))) + auto run(S const &s, std::tuple const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t1), + merge_gexpr, std::tuple>{} + .template run(s, t0, tuple_tail(t1)))) { return tuple_push_head( std::get<0>(t1), - merge_gexpr, std::tuple>{} - .template run(s, t0, tuple_tail(t1))); + merge_gexpr, std::tuple>{}.template run( + s, t0, tuple_tail(t1))); } }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1))) + auto run(S const &s, std::tuple const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t0), + merge_gexpr, std::tuple>{} + .template run(s, tuple_tail(t0), t1))) { return tuple_push_head( std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1)); + merge_gexpr, std::tuple>{}.template run( + s, tuple_tail(t0), t1)); } }; template @@ -347,102 +319,88 @@ namespace types template auto run(S const &s, std::tuple const &t0, std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1))) + -> decltype(tuple_push_head(std::get<0>(t0), + merge_gexpr, std::tuple>{} + .template run(s, tuple_tail(t0), t1))) { return tuple_push_head( std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1)); + merge_gexpr, std::tuple>{}.template run( + s, tuple_tail(t0), t1)); } }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t1), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), tuple_tail(t1)))) + auto run(S const &s, std::tuple const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t1), + merge_gexpr, std::tuple>{} + .template run(s, tuple_tail(t0), tuple_tail(t1)))) { return tuple_push_head( std::get<0>(t1) * std::get<0>(t0).step + std::get<0>(t0).lower, - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), tuple_tail(t1))); + merge_gexpr, std::tuple>{}.template run( + s, tuple_tail(t0), tuple_tail(t1))); } }; template struct merge_gexpr, std::tuple> { template - auto run(S const &s, std::tuple const &t0, - std::tuple const &t1) - -> decltype(tuple_push_head( - std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1))) + auto run(S const &s, std::tuple const &t0, std::tuple const &t1) + -> decltype(tuple_push_head(std::get<0>(t0), + merge_gexpr, std::tuple>{} + .template run(s, tuple_tail(t0), t1))) { return tuple_push_head( std::get<0>(t0), - merge_gexpr, std::tuple>{} - .template run(s, tuple_tail(t0), t1)); + merge_gexpr, std::tuple>{}.template run( + s, tuple_tail(t0), t1)); } }; template - typename std::enable_if::value == 0, - numpy_gexpr>::type + std::enable_if_t::value == 0, numpy_gexpr> _make_gexpr(Arg arg, std::tuple const &t); template - numpy_gexpr::type>::type...> - _make_gexpr_helper(Arg arg, S const &s, utils::index_sequence); + numpy_gexpr>::type...> + _make_gexpr_helper(Arg arg, S const &s, std::index_sequence); template - auto _make_gexpr(Arg arg, std::tuple const &s) -> - typename std::enable_if< - count_new_axis::value != 0, - decltype(_make_gexpr_helper( - arg.reshape(make_reshape::value>( - arg, std::tuple::is_new_axis>...>())), - s, utils::make_index_sequence()))>::type; + auto _make_gexpr(Arg arg, std::tuple const &s) -> std::enable_if_t< + count_new_axis::value != 0, + decltype(_make_gexpr_helper( + arg.reshape(make_reshape::value>( + arg, std::tuple::is_new_axis>...>())), + s, std::make_index_sequence()))>; template struct make_gexpr { template - numpy_gexpr...> - operator()(Arg arg, std::tuple, utils::index_sequence); + numpy_gexpr...> operator()(Arg arg, std::tuple, + std::index_sequence); numpy_gexpr...> operator()(Arg arg, S const &...s); }; // this specialization is in charge of merging gexpr template struct make_gexpr const &, Sp...> { - auto operator()(numpy_gexpr const &arg, Sp const &...s) - -> decltype(_make_gexpr( - std::declval(), - merge_gexpr, std::tuple>{} - .template run<0>(arg, std::tuple(), - std::tuple()))) + auto operator()(numpy_gexpr const &arg, Sp const &...s) -> decltype(_make_gexpr( + std::declval(), merge_gexpr, std::tuple>{}.template run<0>( + arg, std::tuple(), std::tuple()))) { - return _make_gexpr( - arg.arg, - merge_gexpr, std::tuple>{}.template run<0>( - arg, arg.slices, std::make_tuple(s...))); + return _make_gexpr(arg.arg, + merge_gexpr, std::tuple>{}.template run<0>( + arg, arg.slices, std::make_tuple(s...))); } }; } // namespace details template auto make_gexpr(Arg &&arg, S const &...s) - -> decltype(details::make_gexpr{}(std::forward(arg), - s...)); + -> decltype(details::make_gexpr{}(std::forward(arg), s...)); /* type-based compile time overlapping detection: detect if a type may *overlap with another @@ -494,8 +452,7 @@ namespace types }; template - struct may_overlap_gexpr> - : std::integral_constant::value> { + struct may_overlap_gexpr> : std::integral_constant::value> { }; template @@ -526,18 +483,14 @@ namespace types }; template - struct gexpr_shape, - pshape, oTys...>, + struct gexpr_shape, pshape, oTys...>, cstride_normalized_slice, S...> - : gexpr_shape>, - pshape, S...> { + : gexpr_shape>, pshape, S...> { }; template - struct gexpr_shape, - pshape, oTys...>, + struct gexpr_shape, pshape, oTys...>, normalized_slice, S...> - : gexpr_shape>, - pshape, S...> { + : gexpr_shape>, pshape, S...> { }; template @@ -564,14 +517,12 @@ namespace types */ template struct numpy_gexpr { + static_assert(utils::all_of>::value...>::value, + "all slices are normalized"); static_assert( - utils::all_of>::value...>::value, - "all slices are normalized"); - static_assert(utils::all_of<(std::is_same::value || - is_normalized_slice::value)...>::value, - "all slices are valid"); - static_assert(std::decay::type::value >= sizeof...(S), - "slicing respects array shape"); + utils::all_of<(std::is_same::value || is_normalized_slice::value)...>::value, + "all slices are valid"); + static_assert(std::decay_t::value >= sizeof...(S), "slicing respects array shape"); // numpy_gexpr is a wrapper for extended sliced array around a numpy // expression. @@ -582,19 +533,14 @@ namespace types // through the S... template // && compacted values as we know that first S is a slice. - static_assert( - utils::all_of< - std::is_same::type>::value...>::value, - "no modifiers on slices"); + static_assert(utils::all_of>::value...>::value, + "no modifiers on slices"); - using dtype = typename std::remove_reference::type::dtype; - static constexpr size_t value = - std::remove_reference::type::value - count_long::value; + using dtype = typename std::remove_reference_t::dtype; + static constexpr size_t value = std::remove_reference_t::value - count_long::value; - using last_arg_stride_t = - decltype(std::declval().template strides()); - using last_slice_t = - typename std::tuple_element>::type; + using last_arg_stride_t = decltype(std::declval().template strides()); + using last_slice_t = std::tuple_element_t>; // It is not possible to vectorize everything. We only vectorize if the // last dimension is contiguous, which happens if @@ -602,36 +548,29 @@ namespace types // 2. the size of the gexpr is lower than the dim of arg, || it's the // same, but the last slice is contiguous static const bool is_vectorizable = - std::remove_reference::type::is_vectorizable && - (sizeof...(S) < std::remove_reference::type::value || + std::remove_reference_t::is_vectorizable && + (sizeof...(S) < std::remove_reference_t::value || std::is_same, last_slice_t>::value); static const bool is_flat = - std::remove_reference::type::is_flat && value == 1 && - utils::all_of< - std::is_same, S>::value...>::value; + std::remove_reference_t::is_flat && value == 1 && + utils::all_of, S>::value...>::value; static const bool is_strided = - std::remove_reference::type::is_strided || + std::remove_reference_t::is_strided || (((sizeof...(S) - count_long::value) == value) && !std::is_same, last_slice_t>::value); using value_type = - typename std::decay::get( - std::declval(), 1))>::type; + std::decay_t::get(std::declval(), 1))>; - using iterator = - typename std::conditional, dtype *>::type; + using iterator = std::conditional_t, dtype *>; using const_iterator = - typename std::conditional, - dtype const *>::type; + std::conditional_t, dtype const *>; - typename std::remove_cv::type arg; + std::remove_cv_t arg; std::tuple slices; - using shape_t = - gexpr_shape_t::type::shape_t, S...>; + using shape_t = gexpr_shape_t::shape_t, S...>; shape_t _shape; dtype *buffer; @@ -644,10 +583,9 @@ namespace types static constexpr types::array_tuple last_stride(...); sutils::concat_t, - typename std::conditional< - sizeof...(S) == std::decay::type::value, - decltype(last_stride(std::declval())), - types::array_tuple>::type> + std::conditional_t::value, + decltype(last_stride(std::declval())), + types::array_tuple>> _strides; // strides template @@ -671,11 +609,11 @@ namespace types numpy_gexpr(numpy_gexpr const &other); template - typename std::enable_if::value, void>::type + std::enable_if_t::value, void> init_shape(Slice const &s, utils::int_<1>, utils::int_); template - typename std::enable_if::value, void>::type + std::enable_if_t::value, void> init_shape(Slice const &s, utils::int_, utils::int_); template @@ -691,16 +629,13 @@ namespace types friend struct array_base_slicer; template - friend - typename std::enable_if::value == 0, - numpy_gexpr<_Arg, _other_classes...>>::type - details::_make_gexpr(_Arg arg, std::tuple<_other_classes...> const &t); + friend std::enable_if_t::value == 0, + numpy_gexpr<_Arg, _other_classes...>> + details::_make_gexpr(_Arg arg, std::tuple<_other_classes...> const &t); template - friend numpy_gexpr<_Arg, - typename to_normalized_slice::type>::type...> - details::_make_gexpr_helper(_Arg arg, _other_classes const &s, - utils::index_sequence); + friend numpy_gexpr< + _Arg, typename to_normalized_slice>::type...> + details::_make_gexpr_helper(_Arg arg, _other_classes const &s, std::index_sequence); template friend struct extended_slice; @@ -736,12 +671,10 @@ namespace types } template - typename std::enable_if::value, numpy_gexpr &>::type - _copy(E const &expr); + std::enable_if_t::value, numpy_gexpr &> _copy(E const &expr); template - typename std::enable_if::value, numpy_gexpr &>::type - _copy(E const &expr); + std::enable_if_t::value, numpy_gexpr &> _copy(E const &expr); template numpy_gexpr &_copy_restrict(E const &expr); @@ -755,12 +688,10 @@ namespace types numpy_gexpr &operator=(numpy_gexpr const &expr); template - typename std::enable_if::value, numpy_gexpr &>::type - update_(E const &expr); + std::enable_if_t::value, numpy_gexpr &> update_(E const &expr); template - typename std::enable_if::value, numpy_gexpr &>::type - update_(E const &expr); + std::enable_if_t::value, numpy_gexpr &> update_(E const &expr); template numpy_gexpr &operator+=(E const &expr); @@ -803,8 +734,7 @@ namespace types iterator begin(); iterator end(); - auto fast(long i) const & -> decltype(numpy_iexpr_helper::get(*this, - i)) + auto fast(long i) const & -> decltype(numpy_iexpr_helper::get(*this, i)) { return numpy_iexpr_helper::get(*this, i); } @@ -818,22 +748,19 @@ namespace types void store(E elt, Indices... indices) { static_assert(is_dtype::value, "valid store"); - *(buffer + - noffset{}(*this, array_tuple{{indices...}})) = + *(buffer + noffset{}(*this, array_tuple{{indices...}})) = static_cast(elt); } template dtype load(Indices... indices) const { - return *(buffer + - noffset{}(*this, array_tuple{{indices...}})); + return *(buffer + noffset{}(*this, array_tuple{{indices...}})); } template void update(E elt, Indices... indices) const { static_assert(is_dtype::value, "valid store"); - Op{}(*(buffer + - noffset{}(*this, array_tuple{{indices...}})), + Op{}(*(buffer + noffset{}(*this, array_tuple{{indices...}})), static_cast(elt)); } @@ -850,58 +777,52 @@ namespace types auto operator()(Sp const &...s) const -> decltype(make_gexpr(*this, s...)); template - auto operator[](Sp const &s) const -> - typename std::enable_if::value, - decltype(make_gexpr(*this, - (s.lower, s)))>::type; + auto operator[](Sp const &s) const + -> std::enable_if_t::value, decltype(make_gexpr(*this, (s.lower, s)))>; template - auto fast(array_tuple const &indices) - const & -> decltype(nget().fast(*this, indices)); + auto fast(array_tuple const &indices) const & -> decltype(nget().fast(*this, + indices)); template - auto fast(array_tuple const &indices) - && -> decltype(nget().fast(std::move(*this), indices)); + auto + fast(array_tuple const &indices) && -> decltype(nget().fast(std::move(*this), + indices)); template - auto operator[](array_tuple const &indices) - const & -> decltype(nget()(*this, indices)); + auto operator[]( + array_tuple const &indices) const & -> decltype(nget()(*this, indices)); template - auto operator[](array_tuple const &indices) - && -> decltype(nget()(std::move(*this), indices)); + auto + operator[](array_tuple const &indices) && -> decltype(nget()(std::move(*this), + indices)); template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value, + numpy_vexpr> operator[](F const &filter) const { return {*this, filter}; } template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value, + numpy_vexpr> fast(F const &filter) const { return {*this, filter}; } template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr>>> fast(F const &filter) const; template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr>>> operator[](F const &filter) const; auto operator[](long i) const -> decltype(this->fast(i)); auto operator[](long i) -> decltype(this->fast(i)); @@ -934,21 +855,16 @@ namespace types } template - auto recast(utils::index_sequence) - -> decltype(make_gexpr( - arg.template recast(), - recast_slice(std::get(slices))...)) + auto recast(std::index_sequence) { - return make_gexpr( - arg.template recast(), - recast_slice(std::get(slices))...); + return make_gexpr(arg.template recast(), + recast_slice(std::get(slices))...); } template - auto - recast() -> decltype(recast(utils::make_index_sequence())) + auto recast() { - return recast(utils::make_index_sequence()); + return recast(std::make_index_sequence()); } }; } // namespace types @@ -974,8 +890,7 @@ struct assignable> { }; template -struct lazy> - : assignable> { +struct lazy> : assignable> { }; PYTHONIC_NS_END @@ -994,10 +909,8 @@ struct __combined, using t0 = pythonic::types::numpy_gexpr; using t1 = pythonic::types::numpy_gexpr; using type = - pythonic::types::ndarray < - typename __combined::type, - pythonic::types::array_tuple< - long, t0::value>; + pythonic::types::ndarray < typename __combined::type, + pythonic::types::array_tuple>; }; template @@ -1005,20 +918,17 @@ struct __combined, O> { using type = pythonic::types::numpy_gexpr; }; template -struct __combined, - pythonic::types::numpy_gexpr> { - using type = pythonic::types::list::value_type, T>::type>; +struct __combined, pythonic::types::numpy_gexpr> { + using type = pythonic::types::list< + typename __combined::value_type, T>::type>; }; template -struct __combined, - pythonic::types::list> { - using type = pythonic::types::list::value_type, T>::type>; +struct __combined, pythonic::types::list> { + using type = pythonic::types::list< + typename __combined::value_type, T>::type>; }; template -struct __combined, - pythonic::types::none_type> { +struct __combined, pythonic::types::none_type> { using type = pythonic::types::none>; }; @@ -1033,21 +943,18 @@ struct __combined> { }; template -struct __combined> { +struct __combined> { using type = pythonic::types::none>; }; /* combined are sorted such that the assigned type comes first */ template -struct __combined, - pythonic::types::ndarray> { +struct __combined, pythonic::types::ndarray> { using type = pythonic::types::ndarray; }; template -struct __combined, - pythonic::types::numpy_gexpr> { +struct __combined, pythonic::types::numpy_gexpr> { using type = pythonic::types::ndarray; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_iexpr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_iexpr.hpp index 99f19d12bdf..c956b5e8806 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_iexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_iexpr.hpp @@ -16,8 +16,7 @@ namespace types template long operator()(S const &strides, array_tuple const &indices) const; template - long operator()(S const &strides, array_tuple const &indices, - pS const &shape) const; + long operator()(S const &strides, array_tuple const &indices, pS const &shape) const; }; template @@ -33,30 +32,22 @@ namespace types struct numpy_iexpr { // wrapper around another numpy expression to skip first dimension using a // given value. - static constexpr size_t value = std::remove_reference::type::value - 1; - static const bool is_vectorizable = - std::remove_reference::type::is_vectorizable; - static const bool is_flat = std::remove_reference::type::is_flat; - using dtype = typename std::remove_reference::type::dtype; - using value_type = - typename std::remove_reference::get( - std::declval(), 0L))>::type; - - static constexpr bool is_strided = - std::remove_reference::type::is_strided; - - using iterator = - typename std::conditional, dtype *>::type; + static constexpr size_t value = std::remove_reference_t::value - 1; + static const bool is_vectorizable = std::remove_reference_t::is_vectorizable; + static const bool is_flat = std::remove_reference_t::is_flat; + using dtype = typename std::remove_reference_t::dtype; + using value_type = std::remove_reference_t::get( + std::declval(), 0L))>; + + static constexpr bool is_strided = std::remove_reference_t::is_strided; + + using iterator = std::conditional_t, dtype *>; using const_iterator = - typename std::conditional, - dtype const *>::type; + std::conditional_t, dtype const *>; Arg arg; dtype *buffer; - using shape_t = - sutils::pop_head_t::type::shape_t>; + using shape_t = sutils::pop_head_t::shape_t>; numpy_iexpr(); numpy_iexpr(numpy_iexpr const &) = default; @@ -73,22 +64,21 @@ namespace types long size() const; template - struct is_almost_same : std::is_same::type, typename std::decay::type> { + struct is_almost_same : std::is_same, std::decay_t> { }; template struct is_almost_same, numpy_iexpr> : is_almost_same { }; template - struct is_almost_same, ndarray> : std::integral_constant::value == std::tuple_size::value)> { + struct is_almost_same, ndarray> + : std::integral_constant::value == std::tuple_size::value)> { }; - template ::value, void>::type> + template ::value, void>> numpy_iexpr &operator=(E const &expr); - template ::value, void>::type> + template ::value, void>> numpy_iexpr &operator=(numpy_iexpr const &expr); numpy_iexpr &operator=(numpy_iexpr const &expr); @@ -157,8 +147,7 @@ namespace types *reference is bound to * the buffer of ``a`` that is ! temp. */ - auto fast(long i) const & -> decltype(numpy_iexpr_helper::get(*this, - i)) + auto fast(long i) const & -> decltype(numpy_iexpr_helper::get(*this, i)) { return numpy_iexpr_helper::get(*this, i); } @@ -168,9 +157,7 @@ namespace types return numpy_iexpr_helper::get(*this, i); } - auto - fast(long i) && -> decltype(numpy_iexpr_helper::get(std::move(*this), - i)) + auto fast(long i) && -> decltype(numpy_iexpr_helper::get(std::move(*this), i)) { return numpy_iexpr_helper::get(std::move(*this), i); } @@ -179,17 +166,14 @@ namespace types dtype &fast(array_tuple const &indices); template - auto fast(array_tuple const &indices) const - -> decltype(nget()(*this, indices)) + auto fast(array_tuple const &indices) const -> decltype(nget()(*this, indices)) { return nget()(*this, indices); } template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr>>> fast(F const &filter) const; template @@ -197,24 +181,21 @@ namespace types { static_assert(is_dtype::value, "valid store"); assert(buffer); - *(buffer + - noffset{}(*this, array_tuple{{indices...}})) = + *(buffer + noffset{}(*this, array_tuple{{indices...}})) = static_cast(elt); } template dtype load(Indices... indices) const { assert(buffer); - return *(buffer + - noffset{}(*this, array_tuple{{indices...}})); + return *(buffer + noffset{}(*this, array_tuple{{indices...}})); } template void update(E elt, Indices... indices) const { static_assert(is_dtype::value, "valid store"); assert(buffer); - Op{}(*(buffer + - noffset{}(*this, array_tuple{{indices...}})), + Op{}(*(buffer + noffset{}(*this, array_tuple{{indices...}})), static_cast(elt)); } @@ -228,9 +209,8 @@ namespace types #endif template - typename std::enable_if< - is_slice::value, - numpy_gexpr, normalize_t...>>::type + std::enable_if_t::value, + numpy_gexpr, normalize_t...>> operator()(Sp const &s0, S const &...s) const; template @@ -246,24 +226,21 @@ namespace types } template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr>>> operator[](F const &filter) const; auto operator[](long i) const & -> decltype(this->fast(i)); auto operator[](long i) & -> decltype(this->fast(i)); auto operator[](long i) && -> decltype(std::move(*this).fast(i)); template - typename std::enable_if::value, - numpy_gexpr>>::type + std::enable_if_t::value, numpy_gexpr>> operator[](Sp const &s0) const; dtype const &operator[](array_tuple const &indices) const; dtype &operator[](array_tuple const &indices); template - auto operator[](array_tuple const &indices) - const & -> decltype(nget()(*this, indices)) + auto operator[](array_tuple const &indices) const & -> decltype(nget()(*this, + indices)) { return nget()(*this, indices); } @@ -282,24 +259,18 @@ namespace types } template - auto reshape(pS const &new_shape) const - -> numpy_iexpr().reshape( - std::declval::type::shape_t>::type>>()))> + auto reshape(pS const &new_shape) const -> numpy_iexpr().reshape( + std::declval::shape_t>>>()))> { assert(buffer); - sutils::push_front_t< - pS, typename std::tuple_element< - 0, typename std::decay::type::shape_t>::type> + sutils::push_front_t::shape_t>> fixed_new_shape; - sutils::scopy_shape<1, -1>( - fixed_new_shape, new_shape, - utils::make_index_sequence::value>{}); + sutils::scopy_shape<1, -1>(fixed_new_shape, new_shape, + std::make_index_sequence::value>{}); sutils::assign(std::get<0>(fixed_new_shape), arg.template shape<0>()); return numpy_iexpr( - arg.reshape(fixed_new_shape), - (buffer - arg.buffer) / arg.template strides<0>()); + arg.reshape(fixed_new_shape), (buffer - arg.buffer) / arg.template strides<0>()); } ndarray copy() const @@ -316,35 +287,29 @@ namespace types auto recast() -> decltype(arg.template recast().fast(0)) { long former_index = (buffer - arg.buffer) / arg.template strides<0>(); - return arg.template recast().fast(former_index * sizeof(dtype) / - sizeof(Tp)); + return arg.template recast().fast(former_index * sizeof(dtype) / sizeof(Tp)); } template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> operator[](F const &filter) const { return {*this, filter}; } template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> operator[](F const &filter) { return {*this, filter}; } template - auto operator[](std::tuple const &index) const - -> decltype((*this)[std::get<0>(index)]) + auto operator[](std::tuple const &index) const -> decltype((*this)[std::get<0>(index)]) { return (*this)[std::get<0>(index)]; } @@ -462,18 +427,16 @@ struct __combined, container> { using type = pythonic::types::numpy_iexpr; }; -template +template struct __combined, pythonic::types::numpy_gexpr> { using type = pythonic::types::numpy_iexpr; }; template -struct __combined, - pythonic::types::numpy_iexpr> { +struct __combined, pythonic::types::numpy_iexpr> { using type = pythonic::types::numpy_iexpr::type>; }; template -struct __combined, - pythonic::types::ndarray> { +struct __combined, pythonic::types::ndarray> { using type = pythonic::types::ndarray; }; /*}*/ diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_nary_expr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_nary_expr.hpp index dd42278b3ba..2e307efe941 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_nary_expr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_nary_expr.hpp @@ -26,18 +26,14 @@ namespace functor NUMPY_NARY_EXTRA_METHOD template - auto operator()(T &&...args) const -> - typename std::enable_if< - !types::valid_numexpr_parameters< - typename std::decay::type...>::value, - decltype(NUMPY_NARY_FUNC_SYM(std::forward(args)...))>::type; + auto operator()(T &&...args) const + -> std::enable_if_t...>::value, + decltype(NUMPY_NARY_FUNC_SYM(std::forward(args)...))>; template - typename std::enable_if< - types::valid_numexpr_parameters::type...>::value, - types::numpy_expr< - NUMPY_NARY_FUNC_NAME, - typename types::NUMPY_NARY_RESHAPE_MODE::type...>>::type + std::enable_if_t...>::value, + types::numpy_expr::type...>> operator()(E &&...args) const; friend std::ostream &operator<<(std::ostream &os, NUMPY_NARY_FUNC_NAME) diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_op_helper.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_op_helper.hpp index d61e0b875bf..1f556c1f4bd 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_op_helper.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_op_helper.hpp @@ -11,21 +11,18 @@ namespace types template struct all_valid_arg { - static constexpr bool value = - all_valid_arg::value && all_valid_arg::value; + static constexpr bool value = all_valid_arg::value && all_valid_arg::value; }; template struct all_valid_arg { static constexpr bool value = - (is_numexpr_arg::value || is_complex::value || - std::is_scalar::value); + (is_numexpr_arg::value || is_complex::value || std::is_scalar::value); }; template struct any_numexpr_arg { - static constexpr bool value = - any_numexpr_arg::value || any_numexpr_arg::value; + static constexpr bool value = any_numexpr_arg::value || any_numexpr_arg::value; }; template @@ -44,8 +41,7 @@ namespace types template struct any_numop_arg { - static constexpr bool value = - any_numop_arg::value || any_numop_arg::value; + static constexpr bool value = any_numop_arg::value || any_numop_arg::value; }; template @@ -75,22 +71,17 @@ namespace types template struct valid_numop_parameters { - static constexpr bool value = - any_numop_arg::value && all_valid_arg::value; + static constexpr bool value = any_numop_arg::value && all_valid_arg::value; }; template <> struct valid_numop_parameters<> : std::false_type { }; - template ::value, - bool T0_number = is_dtype::value, - bool T1_number = is_dtype::value> + template ::value, + bool T0_number = is_dtype::value, bool T1_number = is_dtype::value> struct the_common_type { - using type = - typename std::conditional < - std::decay::type::value::type::value, T1, T0>::type; + using type = std::conditional_t < std::decay_t::value::value, T1, T0>; }; template @@ -124,9 +115,8 @@ namespace types template struct common_type { - using type = - typename common_type::type, - typename common_type::type>::type; + using type = typename common_type::type, + typename common_type::type>::type; }; /* An adapted type creates a type that has the same shape as C and the same @@ -144,8 +134,7 @@ namespace types template struct adapted_type { - using type = broadcast::type::dtype, - typename std::decay::type>; + using type = broadcast::dtype, std::decay_t>; }; template @@ -166,20 +155,16 @@ namespace types template struct adapted_type { - using type = typename broadcasted_n< - T, absdiff(std::remove_reference::type::value, - std::remove_reference::type::value)>::type; + using type = typename broadcasted_n::value, + std::remove_reference_t::value)>::type; }; template struct adapt_type { - using ctype = - typename common_type::type, OtherTypes...>::type; - static constexpr bool isdtype = - is_dtype::type>::value; - using type = typename adapted_type< - T, ctype, std::is_same::type, ctype>::value, - isdtype>::type; + using ctype = typename common_type, OtherTypes...>::type; + static constexpr bool isdtype = is_dtype>::value; + using type = + typename adapted_type, ctype>::value, isdtype>::type; }; template struct adapt_type, OtherTypes...> { @@ -200,8 +185,7 @@ namespace types template struct reshaped_type { - using type = - broadcast::type, typename std::decay::type>; + using type = broadcast, std::decay_t>; }; template @@ -211,13 +195,10 @@ namespace types template struct reshape_type { - using ctype = - typename common_type::type, OtherTypes...>::type; - static constexpr bool isdtype = - is_dtype::type>::value; - using type = typename reshaped_type< - T, ctype, std::is_same::type, ctype>::value, - isdtype>::type; + using ctype = typename common_type, OtherTypes...>::type; + static constexpr bool isdtype = is_dtype>::value; + using type = typename reshaped_type, ctype>::value, + isdtype>::type; }; template struct is_array_index : std::false_type { diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_texpr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_texpr.hpp index 592bbaf76e7..83b70ff91c0 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_texpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_texpr.hpp @@ -42,9 +42,9 @@ namespace types Arg arg; using shape_t = sutils::transpose_t; template - auto shape() const -> decltype(arg.template shape < I == 0 ? 1 : 0 > ()) + auto shape() const -> decltype(arg.template shape()) { - return arg.template shape < I == 0 ? 1 : 0 > (); + return arg.template shape(); } numpy_texpr_2(); @@ -64,15 +64,13 @@ namespace types return this->template shape<0>(); } - auto fast(long i) const - -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - i)); + auto fast(long i) const -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, + pythonic::builtins::None), + i)); - auto fast(long i) - -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - i)); + auto fast(long i) -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, + pythonic::builtins::None), + i)); auto fast(array_tuple const &indices) -> decltype(arg.fast(array_tuple{{indices[1], indices[0]}})) { @@ -110,49 +108,37 @@ namespace types /* element filtering */ template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr>>> fast(F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if::value && - std::is_same::value && - F::value != 1 && !is_pod_array::value, - numpy_vexpr>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> fast(F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if< - is_numexpr_arg::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && !std::is_same::value && + !is_pod_array::value, + numpy_vexpr>>> fast(F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr>>> operator[](F const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if::value && - std::is_same::value && - F::value != 1 && !is_pod_array::value, - numpy_vexpr>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> operator[](F const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if< - is_numexpr_arg::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && !std::is_same::value && + !is_pod_array::value, + numpy_vexpr>>> operator[](F const &filter) const; auto operator[](long i) const -> decltype(this->fast(i)); auto operator[](long i) -> decltype(this->fast(i)); @@ -170,40 +156,29 @@ namespace types } template auto operator[](std::tuple const &indices) - -> decltype(arg[std::tuple{std::get<1>(indices), - std::get<0>(indices)}]) + -> decltype(arg[std::tuple{std::get<1>(indices), std::get<0>(indices)}]) { - return arg[std::tuple{std::get<1>(indices), - std::get<0>(indices)}]; + return arg[std::tuple{std::get<1>(indices), std::get<0>(indices)}]; } template auto operator[](std::tuple const &indices) const - -> decltype(arg[std::tuple{std::get<1>(indices), - std::get<0>(indices)}]) + -> decltype(arg[std::tuple{std::get<1>(indices), std::get<0>(indices)}]) { - return arg[std::tuple{std::get<1>(indices), - std::get<0>(indices)}]; + return arg[std::tuple{std::get<1>(indices), std::get<0>(indices)}]; } template - auto operator[](S const &s0) const - -> numpy_texpr< - decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - (s0.step, s0)))>; + auto operator[](S const &s0) const -> numpy_texprarg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), (s0.step, s0)))>; template - auto - operator[](S const &s0) -> numpy_texprarg( - fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - (s0.step, s0)))>; + auto operator[](S const &s0) -> numpy_texprarg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), (s0.step, s0)))>; template - auto _reverse_index(S const &indices, utils::index_sequence) const - -> decltype(numpy::functor::transpose{}( - this->arg(std::get(indices)...))) + auto _reverse_index(S const &indices, std::index_sequence) const + -> decltype(numpy::functor::transpose{}(this->arg(std::get(indices)...))) { return numpy::functor::transpose{}(arg(std::get(indices)...)); } @@ -213,25 +188,20 @@ namespace types } template - auto - recast() -> decltype(numpy::functor::transpose{}(arg.template recast())) + auto recast() -> decltype(numpy::functor::transpose{}(arg.template recast())) { return numpy::functor::transpose{}(arg.template recast()); } template - auto operator()(S0 const &s0, S const &...s) const -> - typename std::enable_if< - !is_numexpr_arg::value, - decltype(this->_reverse_index( - std::tuple{s0, s...}, - utils::make_reversed_index_sequence<1 + sizeof...(S)>()))>:: - type; + auto operator()(S0 const &s0, S const &...s) const -> std::enable_if_t< + !is_numexpr_arg::value, + decltype(this->_reverse_index(std::tuple{s0, s...}, + utils::make_reversed_index_sequence<1 + sizeof...(S)>()))>; template - auto operator()(S0 const &s0, S const &...s) const -> - typename std::enable_if::value, - decltype(this->copy()(s0, s...))>::type; + auto operator()(S0 const &s0, S const &...s) const + -> std::enable_if_t::value, decltype(this->copy()(s0, s...))>; explicit operator bool() const; long flat_size() const; @@ -271,8 +241,7 @@ namespace types // only implemented for N = 2 template - struct numpy_texpr>> - : numpy_texpr_2>> { + struct numpy_texpr>> : numpy_texpr_2>> { numpy_texpr() = default; numpy_texpr(numpy_texpr const &) = default; numpy_texpr(numpy_texpr &&) = default; @@ -296,15 +265,13 @@ namespace types }; template - struct numpy_texpr> - : numpy_texpr_2> { + struct numpy_texpr> : numpy_texpr_2> { numpy_texpr() = default; numpy_texpr(numpy_texpr const &) = default; numpy_texpr(numpy_texpr &&) = default; numpy_texpr(numpy_gexpr const &arg); template - numpy_texpr(numpy_texpr const &other) - : numpy_texpr(numpy_gexpr(other.arg)) + numpy_texpr(numpy_texpr const &other) : numpy_texpr(numpy_gexpr(other.arg)) { } @@ -353,7 +320,7 @@ namespace types template long shape() const { - return arg.template shape < I == 0 ? 1 : 0 > (); + return arg.template shape(); } auto load(long i, long j) const -> decltype(arg.ref.load(i)) { @@ -408,13 +375,11 @@ PYTHONIC_NS_END /* type inference stuff {*/ #include "pythonic/include/types/combined.hpp" template -struct __combined, - pythonic::types::numpy_texpr> { +struct __combined, pythonic::types::numpy_texpr> { using type = pythonic::types::numpy_texpr; }; template -struct __combined, - pythonic::types::numpy_texpr> { +struct __combined, pythonic::types::numpy_texpr> { using type = pythonic::types::numpy_texpr::type>; }; @@ -424,21 +389,18 @@ struct __combined, K> { }; template -struct __combined, - pythonic::types::numpy_gexpr> { +struct __combined, pythonic::types::numpy_gexpr> { using type = pythonic::types::numpy_texpr; }; template struct __combined, pythonic::types::none> { - using type = pythonic::types::none< - typename __combined, O>::type>; + using type = pythonic::types::none, O>::type>; }; template struct __combined, pythonic::types::numpy_texpr> { - using type = pythonic::types::none< - typename __combined>::type>; + using type = pythonic::types::none>::type>; }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_ufunc.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_ufunc.hpp index 6c97ea92c1c..298a0622831 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_ufunc.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_ufunc.hpp @@ -10,28 +10,25 @@ namespace types namespace detail { template - void ufunc_wrapper(char *output, char **inputs, npy_intp n, - npy_intp output_step, const npy_intp *inputs_steps, - utils::index_sequence) + void ufunc_wrapper(char *output, char **inputs, npy_intp n, npy_intp output_step, + const npy_intp *inputs_steps, std::index_sequence) { for (npy_intp i = 0; i < n; ++i) { *(ResType *)output = - F{}(*(typename std::tuple_element>::type - *)(inputs[Is])...); + F{}(*(std::tuple_element_t> *)(inputs[Is])...); output += output_step; - (void)std::initializer_list{ - ((inputs[Is] += inputs_steps[Is]), 0)...}; + (void)std::initializer_list{((inputs[Is] += inputs_steps[Is]), 0)...}; } } } // namespace detail template - void ufunc_wrapper(char **args, npy_intp const *dimensions, - npy_intp const *steps, void * /*extra*/) + void ufunc_wrapper(char **args, npy_intp const *dimensions, npy_intp const *steps, + void * /*extra*/) { npy_intp output_step = steps[sizeof...(ArgTypes)]; return detail::ufunc_wrapper( args[sizeof...(ArgTypes)], args, dimensions[0], output_step, steps, - utils::make_index_sequence()); + std::make_index_sequence()); } } // namespace types PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_unary_op.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_unary_op.hpp index 544c05eb1e7..b14e73495fc 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_unary_op.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_unary_op.hpp @@ -6,9 +6,8 @@ #endif template -typename std::enable_if< - types::valid_numop_parameters::type>::value, - types::numpy_expr>::type +std::enable_if_t>::value, + types::numpy_expr> NUMPY_UNARY_FUNC_NAME(E &&self); #undef NUMPY_UNARY_FUNC_NAME diff --git a/contrib/python/pythran/pythran/pythonic/include/types/numpy_vexpr.hpp b/contrib/python/pythran/pythran/pythonic/include/types/numpy_vexpr.hpp index a58d796f910..7f6f945308d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/numpy_vexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/numpy_vexpr.hpp @@ -40,11 +40,9 @@ namespace types } template - typename std::enable_if::value, numpy_vexpr &>::type - operator=(E const &); + std::enable_if_t::value, numpy_vexpr &> operator=(E const &); template - typename std::enable_if::value, numpy_vexpr &>::type - operator=(E const &expr); + std::enable_if_t::value, numpy_vexpr &> operator=(E const &expr); numpy_vexpr &operator=(numpy_vexpr const &); @@ -106,9 +104,8 @@ namespace types } template - typename std::enable_if< - is_slice::value, - numpy_gexpr().normalize(1))>> + std::enable_if_t::value, + numpy_gexpr().normalize(1))>> operator[](S s) const { return {*this, s.normalize(size())}; @@ -116,35 +113,27 @@ namespace types /* element filtering */ template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr>>> fast(E const &filter) const; template // indexing through an array of boolean -- a mask - typename std::enable_if< - !is_slice::value && is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr>>>::type + std::enable_if_t::value && is_numexpr_arg::value && + std::is_same::value && !is_pod_array::value, + numpy_vexpr>>> operator[](E const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> operator[](E const &filter) const; template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr> fast(E const &filter) const; template @@ -175,28 +164,25 @@ namespace types template struct assignable> { - using type = types::ndarray::type, - typename types::numpy_vexpr::shape_t>; + using type = + types::ndarray::type, typename types::numpy_vexpr::shape_t>; }; template struct lazy> { - using type = - types::numpy_vexpr::type, typename lazy::type>; + using type = types::numpy_vexpr::type, typename lazy::type>; }; PYTHONIC_NS_END /* combined are sorted such that the assigned type comes first */ template -struct __combined, - pythonic::types::ndarray> { +struct __combined, pythonic::types::ndarray> { using type = pythonic::types::ndarray; }; template -struct __combined, - pythonic::types::numpy_vexpr> { +struct __combined, pythonic::types::numpy_vexpr> { using type = pythonic::types::ndarray; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/pointer.hpp b/contrib/python/pythran/pythran/pythonic/include/types/pointer.hpp index ee6fddb21cf..727922539f1 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/pointer.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/pointer.hpp @@ -25,16 +25,13 @@ PYTHONIC_NS_END namespace std { template - typename pythonic::types::pointer::reference - get(pythonic::types::pointer &t); + typename pythonic::types::pointer::reference get(pythonic::types::pointer &t); template - typename pythonic::types::pointer::value_type - get(pythonic::types::pointer const &t); + typename pythonic::types::pointer::value_type get(pythonic::types::pointer const &t); template - typename pythonic::types::pointer::value_type - get(pythonic::types::pointer &&t); + typename pythonic::types::pointer::value_type get(pythonic::types::pointer &&t); template struct tuple_element> { diff --git a/contrib/python/pythran/pythran/pythonic/include/types/set.hpp b/contrib/python/pythran/pythran/pythonic/include/types/set.hpp index cb07955def3..ffa346d1b67 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/set.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/set.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include PYTHONIC_NS_BEGIN @@ -106,14 +106,12 @@ struct __combined, indexable> { template struct __combined, pythonic::types::set> { - using type = - pythonic::types::set() + std::declval())>; + using type = pythonic::types::set() + std::declval())>; }; template struct __combined, indexable_container> { - using type = - pythonic::types::set() + std::declval())>; + using type = pythonic::types::set() + std::declval())>; }; template @@ -133,10 +131,9 @@ namespace types { // data holder - using _type = - typename std::remove_cv::type>::type; + using _type = std::remove_cv_t>; using container_type = - std::set<_type, std::less<_type>, utils::allocator<_type>>; + std::unordered_set<_type, std::hash<_type>, std::equal_to<_type>, utils::allocator<_type>>; utils::shared_ref data; public: @@ -146,19 +143,14 @@ namespace types // types using reference = typename container_type::reference; using const_reference = typename container_type::const_reference; - using iterator = - utils::comparable_iterator; - using const_iterator = - utils::comparable_iterator; + using iterator = typename container_type::iterator; + using const_iterator = typename container_type::const_iterator; using size_type = typename container_type::size_type; using difference_type = typename container_type::difference_type; using value_type = typename container_type::value_type; using allocator_type = typename container_type::allocator_type; using pointer = typename container_type::pointer; using const_pointer = typename container_type::const_pointer; - using reverse_iterator = typename container_type::reverse_iterator; - using const_reverse_iterator = - typename container_type::const_reverse_iterator; // constructors set(); @@ -175,10 +167,6 @@ namespace types const_iterator begin() const; iterator end(); const_iterator end() const; - reverse_iterator rbegin(); - const_reverse_iterator rbegin() const; - reverse_iterator rend(); - const_reverse_iterator rend() const; // modifiers T pop(); @@ -213,8 +201,7 @@ namespace types set union_() const; template - typename __combined, U, Types...>::type - union_(U &&other, Types &&...others) const; + typename __combined, U, Types...>::type union_(U &&other, Types &&...others) const; template none_type update(Types &&...others); @@ -222,8 +209,8 @@ namespace types set intersection() const; template - typename __combined, U, Types...>::type - intersection(U const &other, Types const &...others) const; + typename __combined, U, Types...>::type intersection(U const &other, + Types const &...others) const; template void intersection_update(Types const &...others); @@ -240,12 +227,10 @@ namespace types void difference_update(Types const &...others); template - set::type> - symmetric_difference(set const &other) const; + set::type> symmetric_difference(set const &other) const; template - typename __combined>::type - symmetric_difference(U const &other) const; + typename __combined>::type symmetric_difference(U const &other) const; template void symmetric_difference_update(U const &other); diff --git a/contrib/python/pythran/pythran/pythonic/include/types/slice.hpp b/contrib/python/pythran/pythran/pythonic/include/types/slice.hpp index 75de78d4fce..22e077afa17 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/slice.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/slice.hpp @@ -62,8 +62,7 @@ namespace types normalized_slice operator*(normalized_slice const &other) const; template - normalized_slice - operator*(cstride_normalized_slice const &other) const; + normalized_slice operator*(cstride_normalized_slice const &other) const; normalized_slice operator*(slice const &other) const; template normalized_slice operator*(cstride_slice const &other) const; @@ -112,19 +111,16 @@ namespace types normalized_slice operator*(normalized_slice const &other) const; template - typename std::conditional<(stride < 256 && other_stride < 256), - cstride_normalized_slice, - normalized_slice>::type + std::conditional_t<(stride < 256 && other_stride < 256), + cstride_normalized_slice, normalized_slice> operator*(cstride_normalized_slice const &other) const; normalized_slice operator*(slice const &other) const; template - typename std::conditional<(stride < 256 && other_stride < 256), - cstride_normalized_slice, - normalized_slice>::type + std::conditional_t<(stride < 256 && other_stride < 256), + cstride_normalized_slice, normalized_slice> operator*(cstride_slice const &other) const; - cstride_normalized_slice - operator*(fast_contiguous_slice const &other) const; + cstride_normalized_slice operator*(fast_contiguous_slice const &other) const; long size() const; inline long get(long i) const; @@ -146,8 +142,8 @@ namespace types slice operator*(slice const &other) const; template - typename std::conditional<(stride < 256 && other_stride < 256), - cstride_slice, slice>::type + std::conditional_t<(stride < 256 && other_stride < 256), cstride_slice, + slice> operator*(cstride_slice const &other) const; cstride_slice operator*(fast_contiguous_slice const &other) const; @@ -231,15 +227,14 @@ namespace types struct is_normalized_slice : std::true_type { }; template - struct is_normalized_slice> - : std::true_type { + struct is_normalized_slice> : std::true_type { }; template using normalize_t = typename normalized::type; template - typename std::enable_if::value, S>::type normalize(S s, long n) + std::enable_if_t::value, S> normalize(S s, long n) { if (s < 0) s += n; @@ -286,8 +281,8 @@ namespace types return s; } template - fast_contiguous_slice adapt_slice(fast_contiguous_slice const &s, - I0 const &index0, I1 const &index1) + fast_contiguous_slice adapt_slice(fast_contiguous_slice const &s, I0 const &index0, + I1 const &index1) { if ((long)index0 != (long)index1) return {0, 1}; @@ -296,8 +291,7 @@ namespace types } template - typename std::enable_if::value, std::ostream &>::type - operator<<(std::ostream &os, S const &s); + std::enable_if_t::value, std::ostream &> operator<<(std::ostream &os, S const &s); } // namespace types namespace builtins { diff --git a/contrib/python/pythran/pythran/pythonic/include/types/static_if.hpp b/contrib/python/pythran/pythran/pythonic/include/types/static_if.hpp index f5cb1f7038a..66db7ff81cf 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/static_if.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/static_if.hpp @@ -103,18 +103,15 @@ namespace types StaticIfReturnHolder(StaticIfReturnHolder const &) = default; template - StaticIfReturnHolder(StaticIfReturnHolder const &other) - : args(other.args) + StaticIfReturnHolder(StaticIfReturnHolder const &other) : args(other.args) { } template - StaticIfReturnHolder(StaticIfReturn const &arg) - : args(1, arg.arg, T1()) + StaticIfReturnHolder(StaticIfReturn const &arg) : args(1, arg.arg, T1()) { } - StaticIfReturnHolder(StaticIfNoReturn const &arg) - : args(0, T0(), arg.arg) + StaticIfReturnHolder(StaticIfNoReturn const &arg) : args(0, T0(), arg.arg) { } StaticIfReturnHolder(StaticIfBreak const &arg) : args(2, T0(), arg.arg) @@ -132,21 +129,18 @@ namespace std { template struct tuple_element> { - using type = typename std::conditional< - I == 0, bool, typename std::conditional::type>::type; + using type = std::conditional_t>; }; template - auto get(pythonic::types::StaticIfReturnHolder &t) - -> decltype(std::get(t.args)) + auto get(pythonic::types::StaticIfReturnHolder &t) -> decltype(std::get(t.args)) { return std::get(t.args); } template struct tuple_element> { - using type = - decltype(std::declval>().get( - std::integral_constant{})); + using type = decltype(std::declval>().get( + std::integral_constant{})); }; template @@ -187,104 +181,82 @@ namespace std #include "pythonic/include/types/combined.hpp" template -struct __combined, - pythonic::types::StaticIfNoReturn> { +struct __combined, pythonic::types::StaticIfNoReturn> { using type = pythonic::types::StaticIfReturnHolder; }; template -struct __combined, - pythonic::types::StaticIfBreak> { +struct __combined, pythonic::types::StaticIfBreak> { using type = pythonic::types::StaticIfReturnHolder; }; template -struct __combined, - pythonic::types::StaticIfCont> { +struct __combined, pythonic::types::StaticIfCont> { using type = pythonic::types::StaticIfReturnHolder; }; template -struct __combined, - pythonic::types::StaticIfReturn> { +struct __combined, pythonic::types::StaticIfReturn> { using type = pythonic::types::StaticIfReturnHolder; }; template -struct __combined &, - pythonic::types::none_type> { +struct __combined &, pythonic::types::none_type> { using type = pythonic::types::none_type; }; template -struct __combined, - pythonic::types::none_type> { +struct __combined, pythonic::types::none_type> { using type = pythonic::types::none_type; }; template -struct __combined> { +struct __combined> { using type = pythonic::types::none_type; }; template -struct __combined, - pythonic::types::StaticIfReturn> { +struct __combined, pythonic::types::StaticIfReturn> { using type = pythonic::types::StaticIfReturnHolder; }; template -struct __combined, - pythonic::types::StaticIfReturn> { +struct __combined, pythonic::types::StaticIfReturn> { using type = pythonic::types::StaticIfReturnHolder; }; template struct __combined, pythonic::types::StaticIfReturnHolder> { - using type = - pythonic::types::StaticIfReturnHolder::type, - typename __combined::type>; + using type = pythonic::types::StaticIfReturnHolder::type, + typename __combined::type>; }; template struct __combined, pythonic::types::StaticIfCont> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template struct __combined, pythonic::types::StaticIfBreak> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template struct __combined, pythonic::types::StaticIfReturn> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template struct __combined, pythonic::types::StaticIfReturnHolder> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template struct __combined, pythonic::types::StaticIfReturnHolder> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template struct __combined, pythonic::types::StaticIfReturnHolder> { - using type = - pythonic::types::StaticIfReturnHolder::type, - T1>; + using type = pythonic::types::StaticIfReturnHolder::type, T1>; }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/types/str.hpp b/contrib/python/pythran/pythran/pythonic/include/types/str.hpp index ca373c734fc..20514af0417 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/str.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/str.hpp @@ -105,8 +105,7 @@ namespace types chr operator[](long i) const; chr fast(long i) const; template - typename std::enable_if::value, sliced_str>::type - operator[](Sp const &s) const; + std::enable_if_t::value, sliced_str> operator[](Sp const &s) const; // conversion operator long() const; @@ -119,8 +118,7 @@ namespace types // io template - friend std::ostream &operator<<(std::ostream &os, - types::sliced_str const &v); + friend std::ostream &operator<<(std::ostream &os, types::sliced_str const &v); }; struct string_iterator; @@ -209,15 +207,13 @@ namespace types bool operator==(chr other) const; template - typename std::enable_if::value, sliced_str>::type - operator()(S const &s) const; + std::enable_if_t::value, sliced_str> operator()(S const &s) const; chr operator[](long i) const; chr fast(long i) const; template - typename std::enable_if::value, sliced_str>::type - operator[](S const &s) const; + std::enable_if_t::value, sliced_str> operator[](S const &s) const; explicit operator bool() const; long count(types::str const &sub) const; @@ -228,8 +224,8 @@ namespace types } }; - struct string_iterator : std::iterator { + struct string_iterator + : std::iterator { std::string::const_iterator curr; string_iterator() = default; string_iterator(std::string::const_iterator iter) : curr(iter) @@ -275,14 +271,21 @@ namespace types { return curr != other.curr; } + bool operator<(string_iterator const &other) const + { + return curr < other.curr; + } + bool operator<=(string_iterator const &other) const + { + return curr <= other.curr; + } std::ptrdiff_t operator-(string_iterator const &other) const { return curr - other.curr; } }; struct const_sliced_str_iterator - : std::iterator { + : std::iterator { const char *data; long step; const_sliced_str_iterator(char const *data, long step); @@ -328,9 +331,8 @@ namespace operator_ { template - auto mod(const char (&fmt)[N], - Arg &&arg) -> decltype(pythonic::types::str(fmt) % - std::forward(arg)); + auto mod(const char (&fmt)[N], Arg &&arg) + -> decltype(pythonic::types::str(fmt) % std::forward(arg)); pythonic::types::str add(char const *self, char const *other); diff --git a/contrib/python/pythran/pythran/pythonic/include/types/traits.hpp b/contrib/python/pythran/pythran/pythonic/include/types/traits.hpp index c14ca8fce6f..d3e3a4b2487 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/traits.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/traits.hpp @@ -20,36 +20,31 @@ namespace types template struct is_dtype { - static constexpr bool value = - std::is_scalar::value || is_complex::value; + static constexpr bool value = std::is_scalar::value || is_complex::value; }; -#define MEMBER_TYPE_TRAIT(check_struct, member) \ - template \ - struct check_struct { \ - using yes = char; \ - using no = struct { \ - char _[2]; \ - }; \ - template \ - static yes _test(typename C::member *); \ - template \ - static no _test(...); \ - static const bool value = \ - sizeof(_test::type>(nullptr)) == \ - sizeof(yes); \ +#define MEMBER_TYPE_TRAIT(check_struct, member) \ + template \ + struct check_struct { \ + using yes = char; \ + using no = struct { \ + char _[2]; \ + }; \ + template \ + static yes _test(typename C::member *); \ + template \ + static no _test(...); \ + static const bool value = sizeof(_test>(nullptr)) == sizeof(yes); \ }; -#define MEMBER_ATTR_TRAIT(check_struct, member) \ - template \ - struct check_struct { \ - template \ - static std::integral_constant _test(decltype(&C::member)); \ - template \ - static std::integral_constant _test(...); \ - static const bool value = \ - decltype(_test::type>( \ - nullptr))::value; \ +#define MEMBER_ATTR_TRAIT(check_struct, member) \ + template \ + struct check_struct { \ + template \ + static std::integral_constant _test(decltype(&C::member)); \ + template \ + static std::integral_constant _test(...); \ + static const bool value = decltype(_test>(nullptr))::value; \ }; /* trait to check if a type is iterable*/ @@ -74,8 +69,8 @@ namespace types template struct has_contains { template - static auto _test(C *t) -> decltype(t->contains(std::declval()), - std::integral_constant()); + static auto _test(C *t) + -> decltype(t->contains(std::declval()), std::integral_constant()); static std::integral_constant _test(...); static const bool value = decltype(_test((T *)nullptr))::value; }; diff --git a/contrib/python/pythran/pythran/pythonic/include/types/tuple.hpp b/contrib/python/pythran/pythran/pythonic/include/types/tuple.hpp index a8f072cafba..33b8ef6894b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/tuple.hpp @@ -42,8 +42,7 @@ std::tuple operator+(std::tuple const &t0, std::tuple &&t1); template -std::tuple operator+(std::tuple &&t0, - std::tuple &&t1); +std::tuple operator+(std::tuple &&t0, std::tuple &&t1); PYTHONIC_NS_BEGIN @@ -92,7 +91,7 @@ namespace types /* helper to extract the tail of a tuple, && pop the head */ template - auto make_tuple_tail(T const &t, utils::index_sequence) + auto make_tuple_tail(T const &t, std::index_sequence) -> decltype(std::make_tuple(std::get(t)...)) { return std::make_tuple(std::get(t)...); @@ -113,17 +112,14 @@ namespace types template auto tuple_pop(std::tuple const &t) -> decltype(make_tuple_tail::value>( - t, - utils::make_index_sequence::value>{})) + t, std::make_index_sequence::value>{})) { return make_tuple_tail::value>( - t, utils::make_index_sequence::value>{}); + t, std::make_index_sequence::value>{}); } template - std::tuple array_to_tuple(A const &a, utils::index_sequence, + std::tuple array_to_tuple(A const &a, std::index_sequence, utils::type_sequence) { return std::tuple(a[I]...); @@ -155,8 +151,7 @@ namespace types return {}; } template - std::integral_constant check_type(std::integral_constant, - long v) + std::integral_constant check_type(std::integral_constant, long v) { assert(N == v && "consistent init"); return {}; @@ -171,55 +166,49 @@ namespace types template struct pshape { - static_assert(utils::all_of::value...>::value, - "valid pshape"); + static_assert(utils::all_of::value...>::value, "valid pshape"); std::tuple values; template - pshape(std::tuple const &v, utils::index_sequence) + pshape(std::tuple const &v, std::index_sequence) : values{check_type(std::get(values), std::get(v))...} { } template - pshape(std::tuple const &v) - : pshape(v, utils::make_index_sequence()) + pshape(std::tuple const &v) : pshape(v, std::make_index_sequence()) { } template pshape(long arg, Args... args) - : pshape(std::make_tuple(arg, args...), - utils::make_index_sequence<1 + sizeof...(args)>()) + : pshape(std::make_tuple(arg, args...), std::make_index_sequence<1 + sizeof...(args)>()) { } template pshape(std::integral_constant arg, Args... args) - : pshape(std::make_tuple(arg, args...), - utils::make_index_sequence<1 + sizeof...(args)>()) + : pshape(std::make_tuple(arg, args...), std::make_index_sequence<1 + sizeof...(args)>()) { } template - pshape(S const *buffer, utils::index_sequence) + pshape(S const *buffer, std::index_sequence) : values{check_type(std::get(values), buffer[Is])...} { } template - pshape(S const *buffer) - : pshape(buffer, utils::make_index_sequence()) + pshape(S const *buffer) : pshape(buffer, std::make_index_sequence()) { } template pshape(pshape other) - : pshape(other.values, utils::make_index_sequence()) + : pshape(other.values, std::make_index_sequence()) { static_assert(sizeof...(TyOs) == sizeof...(Tys), "compatible sizes"); } template - pshape(pythonic::types::array_base data) - : pshape(data.data()) + pshape(pythonic::types::array_base data) : pshape(data.data()) { } @@ -230,15 +219,14 @@ namespace types pshape &operator=(pshape &&) = default; template - types::array_tuple - array(utils::index_sequence) const + types::array_tuple array(std::index_sequence) const { return {{get()...}}; } types::array_tuple array() const { - return array(utils::make_index_sequence()); + return array(std::make_index_sequence()); } operator types::array_tuple() const { @@ -270,8 +258,7 @@ namespace types }; template - struct shape_builder - : shape_builder { + struct shape_builder : shape_builder { }; struct array_base_slicer { @@ -279,16 +266,14 @@ namespace types dynamic_tuple operator()(array_tuple const &b, slice const &s); template - dynamic_tuple operator()(array_tuple const &b, - cstride_slice const &s); + dynamic_tuple operator()(array_tuple const &b, cstride_slice const &s); template - dynamic_tuple operator()(array_tuple const &b, - fast_contiguous_slice const &s); + dynamic_tuple operator()(array_tuple const &b, fast_contiguous_slice const &s); template - typename std::enable_if::value, sliced_list>::type - operator()(static_list const &b, S const &s) + std::enable_if_t::value, sliced_list> operator()(static_list const &b, + S const &s) { return {b, s}; } @@ -326,8 +311,7 @@ namespace types // minimal ndarray interface using dtype = typename utils::nested_container_value_type::type; - static const size_t value = - utils::nested_container_depth::value; + static const size_t value = utils::nested_container_depth::value; static const bool is_vectorizable = true; static const bool is_flat = true; static const bool is_strided = false; @@ -405,8 +389,7 @@ namespace types const_reference operator[](long __n) const noexcept; template - auto operator[](S s) const -> decltype(array_base_slicer{}(*this, - (s.lower, s))) + auto operator[](S s) const -> decltype(array_base_slicer{}(*this, (s.lower, s))) { return array_base_slicer{}(*this, s); } @@ -426,8 +409,7 @@ namespace types template operator std::pair() const { - static_assert(std::is_same::value && std::is_same::value && - N == 2, + static_assert(std::is_same::value && std::is_same::value && N == 2, "compatible conversion"); return {data()[0], data()[1]}; } @@ -452,10 +434,9 @@ namespace types template operator array_base() const; - auto to_tuple() const - -> decltype(array_to_tuple(*this, utils::make_index_sequence{}, + auto to_tuple() const -> decltype(array_to_tuple(*this, std::make_index_sequence{}, - utils::make_repeated_type())); + utils::make_repeated_type())); template array_base to_array() const; @@ -479,13 +460,11 @@ namespace types /* array */ template - friend std::ostream & - operator<<(std::ostream &os, types::array_base const &v); + friend std::ostream &operator<<(std::ostream &os, types::array_base const &v); using shape_t = typename shape_builder::type; template - auto shape() const -> decltype(details::extract_shape(*this, - utils::int_{})) + auto shape() const -> decltype(details::extract_shape(*this, utils::int_{})) { return details::extract_shape(*this, utils::int_{}); } @@ -509,8 +488,7 @@ namespace types template struct alike { static bool const value = true; - using type = typename std::remove_cv< - typename std::remove_reference::type>::type; + using type = std::remove_cv_t>; }; template struct alike, numpy_gexpr> { @@ -521,7 +499,7 @@ namespace types template struct alike { static bool const value = std::is_same::value; - using type = typename std::conditional::type; + using type = std::conditional_t; }; // specialization to make static string alike types::str @@ -547,14 +525,10 @@ namespace types struct alike, array_base> { static bool const value = sizeof...(Types) == N && - alike::type>::type...>::value; - using type = typename std::conditional< - value, - typename alike::type>::type...>::type, - void>::type; + alike>...>::value; + using type = std::conditional_t< + value, typename alike>...>::type, + void>; }; template @@ -564,23 +538,21 @@ namespace types template struct alike { - static bool const value = alike::value && - alike::type>::value; + static bool const value = + alike::value && alike::type>::value; using type = typename alike::type>::type; }; } // namespace details template - struct alike : details::alike::type>::type...> { + struct alike : details::alike>...> { }; // Pythonic implementation for make_tuple to have the best return type // (static array for sames types || real tuple otherwise) template struct _make_tuple { - auto operator()(Types &&...types) - -> decltype(std::make_tuple(std::forward(types)...)) + auto operator()(Types &&...types) -> decltype(std::make_tuple(std::forward(types)...)) { return std::make_tuple(std::forward(types)...); } @@ -598,20 +570,17 @@ namespace types template auto make_tuple(Types &&...types) #if !_MSC_VER || __clang__ - -> decltype(_make_tuple::value, Types...>()( - std::forward(types)...)) + -> decltype(_make_tuple::value, Types...>()(std::forward(types)...)) #endif { - return _make_tuple::value, Types...>()( - std::forward(types)...); + return _make_tuple::value, Types...>()(std::forward(types)...); } template using make_tuple_t = decltype(types::make_tuple(std::declval()...)); template - types::array_tuple _to_array(Tuple const &t, - utils::index_sequence) + types::array_tuple _to_array(Tuple const &t, std::index_sequence) { return {{static_cast(std::get(t))...}}; } @@ -619,18 +588,16 @@ namespace types template types::array_tuple to_array(std::tuple const &t) { - return _to_array(t, utils::make_index_sequence()); + return _to_array(t, std::make_index_sequence()); } // Tuple concatenation for array && tuple template - auto operator+(std::tuple const &t, - types::array_base const <) + auto operator+(std::tuple const &t, types::array_base const <) -> decltype(std::tuple_cat(t, lt.to_tuple())); template - auto operator+(types::array_base const <, - std::tuple const &t) + auto operator+(types::array_base const <, std::tuple const &t) -> decltype(std::tuple_cat(lt.to_tuple(), t)); } // namespace types @@ -736,34 +703,27 @@ struct __combined, indexable> { }; template -struct __combined, - pythonic::types::static_list> { +struct __combined, pythonic::types::static_list> { using type = pythonic::types::static_list; }; template -struct __combined, - pythonic::types::array_tuple> { +struct __combined, pythonic::types::array_tuple> { using type = pythonic::types::array_tuple; }; template -struct __combined, - pythonic::types::array_base> { - using type = - pythonic::types::array_base::type, N, V>; +struct __combined, pythonic::types::array_base> { + using type = pythonic::types::array_base::type, N, V>; }; template -struct __combined, - pythonic::types::static_list> { - using type = - pythonic::types::static_list::type, N>; +struct __combined, pythonic::types::static_list> { + using type = pythonic::types::static_list::type, N>; }; template -struct __combined, - pythonic::types::static_list> { +struct __combined, pythonic::types::static_list> { using type = pythonic::types::list::type>; }; @@ -779,28 +739,22 @@ struct __combined, indexable> { template struct __combined, pythonic::types::array_base> { - using type = - pythonic::types::array_base::type, N, V>; + using type = pythonic::types::array_base::type, N, V>; }; template struct __combined, container> { - using type = - pythonic::types::array_base::type, N, V>; + using type = pythonic::types::array_base::type, N, V>; }; template -struct __combined, - pythonic::types::array_base> { - using type = - pythonic::types::array_base::type, N, AV>; +struct __combined, pythonic::types::array_base> { + using type = pythonic::types::array_base::type, N, AV>; }; template -struct __combined, - indexable_container> { - using type = - pythonic::types::array_base::type, N, AV>; +struct __combined, indexable_container> { + using type = pythonic::types::array_base::type, N, AV>; }; template @@ -835,16 +789,13 @@ namespace details PYTHONIC_NS_END template -struct __combined, - indexable_container, t>> { +struct __combined, indexable_container, t>> { using holder = std::tuple; template - static std::tuple::type, t, I == Is>::type...> - make_type(pythonic::utils::index_sequence); - static auto - make_type() -> decltype(make_type( - pythonic::utils::make_index_sequence())); + static std::tuple, t, + I == Is>::type...> + make_type(std::index_sequence); + static auto make_type() -> decltype(make_type(std::make_index_sequence())); using type = decltype(make_type()); }; @@ -859,13 +810,11 @@ struct __combined, std::tuple> { }; template -struct __combined, - pythonic::types::pshape> { +struct __combined, pythonic::types::pshape> { using type = pythonic::types::array_tuple; }; template -struct __combined, - pythonic::types::array_tuple> { +struct __combined, pythonic::types::array_tuple> { using type = pythonic::types::array_tuple; }; @@ -875,9 +824,8 @@ struct __combined, pythonic::types::array_tuple> { }; template struct __combined, std::pair> { - using type = - std::pair::type, - typename __combined::type>; // no further combination + using type = std::pair::type, + typename __combined::type>; // no further combination }; /* } */ @@ -941,8 +889,7 @@ namespace std template struct tuple_element> { - using type = typename std::tuple_element < - I>::type; + using type = std::tuple_element_t < I>; }; } // namespace std PYTHONIC_NS_BEGIN @@ -960,8 +907,7 @@ namespace sutils }; template - using shape_t = typename std::enable_if::value, - typename make_shape::type>::type; + using shape_t = std::enable_if_t::value, typename make_shape::type>; template struct shape_merger; @@ -975,8 +921,7 @@ namespace sutils using type = long; }; template - struct shape_merger, - std::integral_constant, Ss...> + struct shape_merger, std::integral_constant, Ss...> : shape_merger N1 ? N0 : N1)>, Ss...> { }; template @@ -986,32 +931,28 @@ namespace sutils template struct shape_selecter - : std::conditional< - (I < std::tuple_size::value), - typename std::tuple_element< - (I < std::tuple_size::value ? I : 0L), Ss>::type, - std::integral_constant> { + : std::conditional<(I < std::tuple_size::value), + std::tuple_element_t<(I < std::tuple_size::value ? I : 0L), Ss>, + std::integral_constant> { }; template struct merge_shape; template struct merge_shape> { - using type = - typename shape_merger::type...>::type; + using type = typename shape_merger::type...>::type; }; template struct merged_shapes; template - struct merged_shapes> { + struct merged_shapes> { using type = types::pshape::type...>; }; template using merged_shapes_t = - typename merged_shapes, - utils::make_index_sequence>::type; + typename merged_shapes, std::make_index_sequence>::type; template struct shape_commonifier; @@ -1028,34 +969,29 @@ namespace sutils using type = long; }; template - struct shape_commonifier, - std::integral_constant, Ss...> { - using type = typename std::conditional< - N0 == N1, - typename shape_commonifier, - Ss...>::type, - long>::type; + struct shape_commonifier, std::integral_constant, + Ss...> { + using type = std::conditional_t< + N0 == N1, typename shape_commonifier, Ss...>::type, long>; }; template struct common_shape; template struct common_shape> { - using type = typename shape_commonifier< - typename std::tuple_element::type...>::type; + using type = typename shape_commonifier...>::type; }; template struct common_shapes; template - struct common_shapes> { + struct common_shapes> { using type = types::pshape::type...>; }; template using common_shapes_t = - typename common_shapes, - utils::make_index_sequence>::type; + typename common_shapes, std::make_index_sequence>::type; template struct transpose; @@ -1083,28 +1019,22 @@ namespace sutils } template - void copy_shape(T0 &shape0, T1 const &shape1, utils::index_sequence) + void copy_shape(T0 &shape0, T1 const &shape1, std::index_sequence) { (void)std::initializer_list{ - (assign(std::get(shape0), - shape1.template shape()), - 1)...}; + (assign(std::get(shape0), shape1.template shape()), 1)...}; } template - void scopy_shape(T0 &shape0, T1 const &shape1, utils::index_sequence) + void scopy_shape(T0 &shape0, T1 const &shape1, std::index_sequence) { (void)std::initializer_list{ - (assign(std::get(shape0), - std::get(shape1)), - 1)...}; + (assign(std::get(shape0), std::get(shape1)), 1)...}; } template - void copy_strides(T0 &stride0, T1 const &stride1, - utils::index_sequence) + void copy_strides(T0 &stride0, T1 const &stride1, std::index_sequence) { (void)std::initializer_list{ - (assign(std::get(stride0), - stride1.template strides()), + (assign(std::get(stride0), stride1.template strides()), 1)...}; } template @@ -1115,8 +1045,7 @@ namespace sutils using type = types::pshape; }; template - struct pop_type, Ty, Tys...> - : pop_type, Tys...> { + struct pop_type, Ty, Tys...> : pop_type, Tys...> { }; template @@ -1165,8 +1094,7 @@ namespace sutils using head_t = typename head::type; template - types::array_tuple - array(types::pshape const &pS) + types::array_tuple array(types::pshape const &pS) { return pS.array(); } @@ -1177,16 +1105,14 @@ namespace sutils return pS; } template - types::array_tuple getshape(E const &e, - utils::index_sequence) + types::array_tuple getshape(E const &e, std::index_sequence) { return {(long)(e.template shape())...}; } template - auto getshape(E const &e) - -> decltype(getshape(e, utils::make_index_sequence())) + auto getshape(E const &e) -> decltype(getshape(e, std::make_index_sequence())) { - return getshape(e, utils::make_index_sequence()); + return getshape(e, std::make_index_sequence()); } inline std::tuple<> getshape(...) @@ -1233,19 +1159,16 @@ namespace sutils using push_front_t = concat_t, P>; template - long find(S &s, long v, std::integral_constant, long start, - bool comp(long, long)) + long find(S &s, long v, std::integral_constant, long start, bool comp(long, long)) { return comp(s.template shape<0>(), v) && 0 < start ? 0 : -1; } template - long find(S &s, long v, std::integral_constant, long start, - bool comp(long, long)) + long find(S &s, long v, std::integral_constant, long start, bool comp(long, long)) { return comp(s.template shape(), v) && I < start ? I - : find(s, v, std::integral_constant(), start, - comp); + : find(s, v, std::integral_constant(), start, comp); } template @@ -1253,23 +1176,19 @@ namespace sutils S &s, long v, long start = S::value, bool comp(long, long) = [](long a, long b) { return (a == b); }) { - return find(s, v, std::integral_constant(), start, - comp); + return find(s, v, std::integral_constant(), start, comp); } template - long sfind(S &s, long v, std::integral_constant, long start, - bool comp(long, long)) + long sfind(S &s, long v, std::integral_constant, long start, bool comp(long, long)) { return comp(std::get<0>(s), v) && 0 < start ? 0 : -1; } template - long sfind(S &s, long v, std::integral_constant, long start, - bool comp(long, long)) + long sfind(S &s, long v, std::integral_constant, long start, bool comp(long, long)) { return comp(std::get(s), v) && (long)I < start ? (long)I - : sfind(s, v, std::integral_constant(), start, - comp); + : sfind(s, v, std::integral_constant(), start, comp); } template @@ -1277,9 +1196,8 @@ namespace sutils S &s, long v, long start = std::tuple_size::value, bool comp(long, long) = [](long a, long b) { return (a == b); }) { - return sfind( - s, v, std::integral_constant::value - 1>(), - start, comp); + return sfind(s, v, std::integral_constant::value - 1>(), start, + comp); } template @@ -1295,14 +1213,12 @@ namespace sutils } template - typename std::enable_if::value, bool>::type - equals(S const &s, B const &other) + std::enable_if_t::value, bool> equals(S const &s, B const &other) { return equals(s, other, std::integral_constant()); } template - typename std::enable_if< - std::tuple_size::value != std::tuple_size::value, bool>::type + std::enable_if_t::value != std::tuple_size::value, bool> equals(S const &s, B const &other) { return false; @@ -1337,8 +1253,7 @@ namespace sutils template bool any_of(S const &s, P pred, std::integral_constant) { - return pred(s.template shape()) || - any_of(s, pred, std::integral_constant()); + return pred(s.template shape()) || any_of(s, pred, std::integral_constant()); } template bool any_of(S const &s, Pred pred) @@ -1354,14 +1269,12 @@ namespace sutils template long min(long curr, S const &s, std::integral_constant) { - return min(std::min(curr, s.template shape()), s, - std::integral_constant()); + return min(std::min(curr, s.template shape()), s, std::integral_constant()); } template long min(S const &s) { - return min(s.template shape(), s, - std::integral_constant()); + return min(s.template shape(), s, std::integral_constant()); } template @@ -1372,8 +1285,7 @@ namespace sutils template long prod(S const &s, std::integral_constant) { - return s.template shape() * - prod(s, std::integral_constant()); + return s.template shape() * prod(s, std::integral_constant()); } template long prod(S const &s) @@ -1393,8 +1305,7 @@ namespace sutils template long sprod(S const &s) { - return sprod( - s, std::integral_constant::value - 1>()); + return sprod(s, std::integral_constant::value - 1>()); } template @@ -1405,8 +1316,7 @@ namespace sutils template long prod_tail(S const &s, std::integral_constant) { - return s.template shape() * - prod_tail(s, std::integral_constant()); + return s.template shape() * prod_tail(s, std::integral_constant()); } template long prod_tail(S const &s) @@ -1432,9 +1342,7 @@ namespace sutils template struct safe_tuple_element { - using type = - typename std::tuple_element<(I < std::tuple_size

::value ? I : 0), - P>::type; + using type = std::tuple_element_t<(I < std::tuple_size

(utils::make_index_sequence()); + return iota

(std::make_index_sequence()); } } // namespace details template @@ -41,11 +41,9 @@ namespace numpy } template #ifdef USE_XSIMD - typename std::enable_if< - !E::is_vectorizable || - !types::is_vector_op::value || - std::is_same::value, - long>::type + std::enable_if_t::value || + std::is_same::value, + long> #else long #endif @@ -55,12 +53,11 @@ namespace numpy } template - std::tuple _argminmax_fast(E const &elts, T &minmax_elts, - long current_pos, utils::int_<1>, - Indices... indices) + std::tuple _argminmax_fast(E const &elts, T &minmax_elts, long current_pos, + utils::int_<1>, Indices... indices) { long res = -1; - long n = elts.template shape::type::value - 1>(); + long n = elts.template shape::value - 1>(); for (long i = 0; i < n; ++i) { auto elt = elts.load(indices..., i); if (Op::value(elt, minmax_elts)) { @@ -74,10 +71,9 @@ namespace numpy #ifdef USE_XSIMD template - typename std::enable_if< - E::is_vectorizable && types::is_vector_op::value && - !std::is_same::value, - long>::type + std::enable_if_t::value && + !std::is_same::value, + long> _argminmax(E const &elts, T &minmax_elts, utils::int_<1>) { using vT = xsimd::batch; @@ -151,16 +147,15 @@ namespace numpy return current_minmaxarg; } template - typename std::enable_if>::type - _argminmax_fast(E const &elts, T &minmax_elts, long current_pos, - utils::int_, Indices... indices) + std::enable_if_t> _argminmax_fast(E const &elts, T &minmax_elts, + long current_pos, utils::int_, + Indices... indices) { long current_minmaxarg = 0; - for (long i = 0, n = elts.template shape::type::value - N>(); - i < n; ++i) { + for (long i = 0, n = elts.template shape::value - N>(); i < n; ++i) { long v; - std::tie(v, current_pos) = _argminmax_fast( - elts, minmax_elts, current_pos, utils::int_(), indices..., i); + std::tie(v, current_pos) = + _argminmax_fast(elts, minmax_elts, current_pos, utils::int_(), indices..., i); if (v >= 0) current_minmaxarg = v; } @@ -176,8 +171,7 @@ namespace numpy elt_type argminmax_value = Op::limit(); #ifndef USE_XSIMD if (utils::no_broadcast_ex(expr)) { - return std::get<0>(_argminmax_fast(expr, argminmax_value, 0, - utils::int_())); + return std::get<0>(_argminmax_fast(expr, argminmax_value, 0, utils::int_())); } else #endif return _argminmax(expr, argminmax_value, utils::int_()); @@ -193,73 +187,65 @@ namespace numpy } } - template - typename std::enable_if::type - _argminmax_tail(T &&out, E const &expr, long curr, V &&curr_minmax, - std::integral_constant) + template + std::enable_if_t _argminmax_tail(T &&out, E const &expr, long curr, + V &&curr_minmax, + std::integral_constant) { static_assert(N >= 1, "specialization ok"); long i = 0; for (auto &&elt : expr) { - _argminmax_tail(out.fast(i), elt, curr, - curr_minmax.fast(i), + _argminmax_tail(out.fast(i), elt, curr, curr_minmax.fast(i), std::integral_constant()); ++i; } } template - typename std::enable_if::type - _argminmax_head(T &&out, E const &expr, std::integral_constant) + std::enable_if_t _argminmax_head(T &&out, E const &expr, + std::integral_constant) { typename E::dtype val = Op::limit(); long i = 0; for (auto &&elt : expr) - _argminmax_tail(out, elt, i++, val, - std::integral_constant()); + _argminmax_tail(out, elt, i++, val, std::integral_constant()); } template - typename std::enable_if::type - _argminmax_head(T &&out, E const &expr, std::integral_constant) + std::enable_if_t _argminmax_head(T &&out, E const &expr, + std::integral_constant) { static_assert(N > 1, "specialization ok"); - types::ndarray> val{ - sutils::getshape(out), Op::limit()}; + types::ndarray> val{sutils::getshape(out), + Op::limit()}; long i = 0; for (auto &&elt : expr) { - _argminmax_tail(out, elt, i++, val, - std::integral_constant()); + _argminmax_tail(out, elt, i++, val, std::integral_constant()); } } template - typename std::enable_if::type - _argminmax_head(T &&out, E const &expr, std::integral_constant) + std::enable_if_t _argminmax_head(T &&out, E const &expr, + std::integral_constant) { static_assert(N >= 1, "specialization ok"); auto out_iter = out.begin(); for (auto &&elt : expr) { - _argminmax_head(*out_iter, elt, - std::integral_constant()); + _argminmax_head(*out_iter, elt, std::integral_constant()); ++out_iter; } } template - void _argminmax_pick_axis(long axis, T &&out, E const &expr, - utils::index_sequence) + void _argminmax_pick_axis(long axis, T &&out, E const &expr, std::index_sequence) { (void)std::initializer_list{ - ((Axis == axis) && (_argminmax_head( - out, expr, std::integral_constant()), - true))...}; + ((Axis == axis) && + (_argminmax_head(out, expr, std::integral_constant()), true))...}; } template - types::ndarray> - argminmax(E const &array, long axis) + types::ndarray> argminmax(E const &array, long axis) { if (axis < 0) axis += E::value; @@ -269,10 +255,8 @@ namespace numpy types::array_tuple shp; auto next = std::copy(shape.begin(), shape.begin() + axis, shp.begin()); std::copy(shape.begin() + axis + 1, shape.end(), next); - types::ndarray> out{ - shp, builtins::None}; - _argminmax_pick_axis(axis, out, array, - utils::make_index_sequence()); + types::ndarray> out{shp, builtins::None}; + _argminmax_pick_axis(axis, out, array, std::make_index_sequence()); return out; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/argsort.hpp b/contrib/python/pythran/pythran/pythonic/numpy/argsort.hpp index 68bf4b76fba..9416327c164 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/argsort.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/argsort.hpp @@ -9,16 +9,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - argsort(E const &expr, types::none_type, types::none_type) + types::ndarray> argsort(E const &expr, types::none_type, + types::none_type) { auto out = functor::array{}(expr).flat(); return argsort(out); } template - types::ndarray _argsort(types::ndarray const &a, long axis, - Sorter sorter) + types::ndarray _argsort(types::ndarray const &a, long axis, Sorter sorter) { constexpr auto N = std::tuple_size::value; if (axis < 0) @@ -30,8 +29,7 @@ namespace numpy size_t step = a.template shape(); auto a_base = a.fbegin(); - for (long *iter_indices = indices.buffer, - *end_indices = indices.buffer + flat_size; + for (long *iter_indices = indices.buffer, *end_indices = indices.buffer + flat_size; iter_indices != end_indices; iter_indices += step, a_base += step) { // fill with the original indices std::iota(iter_indices, iter_indices + step, 0L); @@ -42,8 +40,7 @@ namespace numpy } else { auto out_shape = sutils::getshape(a); const long step = - std::accumulate(out_shape.begin() + axis, out_shape.end(), 1L, - std::multiplies()); + std::accumulate(out_shape.begin() + axis, out_shape.end(), 1L, std::multiplies()); long const buffer_size = out_shape[axis]; const long stepper = step / out_shape[axis]; const long n = flat_size / out_shape[axis]; @@ -54,10 +51,9 @@ namespace numpy std::iota(buffer_start, buffer_end, 0L); for (long i = 0; i < n; i++) { auto a_base = a.fbegin() + ith; - sorter(buffer, buffer + buffer_size, - [a_base, stepper](long i1, long i2) { - return a_base[i1 * stepper] < a_base[i2 * stepper]; - }); + sorter(buffer, buffer + buffer_size, [a_base, stepper](long i1, long i2) { + return a_base[i1 * stepper] < a_base[i2 * stepper]; + }); for (long j = 0; j < buffer_size; ++j) indices.buffer[ith + j * stepper] = buffer[j]; @@ -73,8 +69,7 @@ namespace numpy } template - types::ndarray argsort(types::ndarray const &a, long axis, - types::none_type) + types::ndarray argsort(types::ndarray const &a, long axis, types::none_type) { return _argsort(a, axis, ndarray::quicksorter()); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/argwhere.hpp b/contrib/python/pythran/pythran/pythonic/numpy/argwhere.hpp index 0a366decfb5..fa483aea92d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/argwhere.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/argwhere.hpp @@ -12,16 +12,14 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename types::ndarray> - argwhere(E const &expr) + typename types::ndarray> argwhere(E const &expr) { constexpr long N = E::value; auto arr = asarray(expr); long sz = arr.flat_size(); auto eshape = sutils::getshape(arr); - utils::shared_ref> buffer(sz * - N); // too much memory used + utils::shared_ref> buffer(sz * N); // too much memory used long *buffer_iter = buffer->data; long real_sz = 0; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/around.hpp b/contrib/python/pythran/pythran/pythonic/numpy/around.hpp index 920e53e92a0..600a321aba2 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/around.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/around.hpp @@ -23,40 +23,29 @@ namespace numpy // generic floating point version, pure numpy_expr template - auto around(E &&a, long decimals) -> - typename std::enable_if< - !std::is_integral::type>::type>::value, - decltype(functor::rint{}(functor::multiply{}( - std::forward(a), - std::declval::type>::type>())) / - std::declval::type>::type>())>::type + auto around(E &&a, long decimals) -> std::enable_if_t< + !std::is_integral>::type>::value, + decltype(functor::rint{}(functor::multiply{}( + std::forward(a), + std::declval>::type>())) / + std::declval>::type>())> { - typename types::dtype_of::type>::type const fact = - functor::power{}(10., decimals); - return functor::rint{}(functor::multiply{}(std::forward(a), fact)) / - fact; + typename types::dtype_of>::type const fact = functor::power{}(10., decimals); + return functor::rint{}(functor::multiply{}(std::forward(a), fact)) / fact; } // the integer version is only relevant when decimals < 0 template - auto around(E &&a, long decimals) -> - typename std::enable_if< - std::is_integral::type>::type>::value, - decltype(numpy::functor::floor_divide{}( - functor::float64{}(std::forward(a)), - std::declval::type>::type>()) * - std::declval::type>::type>())>::type + auto around(E &&a, long decimals) -> std::enable_if_t< + std::is_integral>::type>::value, + decltype(numpy::functor::floor_divide{}( + functor::float64{}(std::forward(a)), + std::declval>::type>()) * + std::declval>::type>())> { - typename types::dtype_of::type>::type const fact = + typename types::dtype_of>::type const fact = functor::power{}(10L, std::max(0L, -decimals)); - return pythonic::numpy::functor::floor_divide{}( - functor::float64{}(std::forward(a)), fact) * + return pythonic::numpy::functor::floor_divide{}(functor::float64{}(std::forward(a)), fact) * fact; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/array.hpp b/contrib/python/pythran/pythran/pythonic/numpy/array.hpp index 2feaf5cd70f..ca6df755da2 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/array.hpp @@ -12,46 +12,37 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::has_size::type>::value, - types::ndarray::type::value>>>:: - type - array(T &&iterable, dtype d) + std::enable_if_t< + types::has_size>::value, + types::ndarray::value>>> + array(T &&iterable, dtype d) { return {std::forward(iterable)}; } template - typename std::enable_if< - !types::has_size::type>::value && - !types::is_dtype::type>::value, - types::ndarray::type::value>>>:: - type - array(T &&iterable, dtype d) + std::enable_if_t< + !types::has_size>::value && !types::is_dtype>::value, + types::ndarray::type::value>>> + array(T &&iterable, dtype d) { - types::list::type::value_type> tmp{iterable.begin(), - iterable.end()}; + types::list::value_type> tmp{iterable.begin(), iterable.end()}; return {tmp}; } template - typename std::enable_if< - !types::has_size::type>::value && - types::is_dtype::type>::value, - typename dtype::type>::type + std::enable_if_t>::value && + types::is_dtype>::value, + typename dtype::type> array(T &&non_iterable, dtype d) { return non_iterable; } template - types::ndarray>> + types::ndarray>> array(std::tuple<>, dtype) { - return {types::pshape>{}, - types::none_type{}}; + return {types::pshape>{}, types::none_type{}}; } template @@ -61,16 +52,14 @@ namespace numpy } template - types::ndarray::shape_t> + types::ndarray::shape_t> array(types::array_base const &a, dtype) { return {a}; } template - types::ndarray::shape_t> + types::ndarray::shape_t> array(types::array_base &&a, dtype) { return {std::move(a)}; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/array_equiv.hpp b/contrib/python/pythran/pythran/pythonic/numpy/array_equiv.hpp index 77b45bae840..2aab705195d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/array_equiv.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/array_equiv.hpp @@ -23,15 +23,13 @@ namespace numpy } // namespace template - typename std::enable_if::type - array_equiv(U const &u, V const &v) + std::enable_if_t array_equiv(U const &u, V const &v) { return array_equal(u, v); } template - typename std::enable_if < - U::value::type array_equiv(U const &u, V const &v) + std::enable_if_t < U::value array_equiv(U const &u, V const &v) { if (v.flat_size() % u.flat_size() == 0) // requires allocation for u' as it is used multiple times. @@ -40,8 +38,7 @@ namespace numpy } template - typename std::enable_if<(U::value > V::value), bool>::type - array_equiv(U const &u, V const &v) + std::enable_if_t<(U::value > V::value), bool> array_equiv(U const &u, V const &v) { return array_equiv(v, u); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/array_split.hpp b/contrib/python/pythran/pythran/pythonic/numpy/array_split.hpp index 933a9fafa7c..519d192ffe4 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/array_split.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/array_split.hpp @@ -11,8 +11,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::list()[types::fast_contiguous_slice()])>::type> + types::list< + typename assignable()[types::fast_contiguous_slice()])>::type> array_split(E const &a, long nb_split) { long sz = a.template shape<0>(); @@ -21,8 +21,8 @@ namespace numpy long nb_full_split = nb_split; if (end != sz) nb_full_split -= (end - sz); - types::list()[types::fast_contiguous_slice()])>::type> + types::list< + typename assignable()[types::fast_contiguous_slice()])>::type> out(nb_split); long index = 0; @@ -35,16 +35,14 @@ namespace numpy } template - typename std::enable_if< - types::is_iterable::value, - types::list()[types::fast_contiguous_slice()])>::type>>:: - type - array_split(E const &a, I const &split_mask) + std::enable_if_t::value, + types::list()[types::fast_contiguous_slice()])>::type>> + array_split(E const &a, I const &split_mask) { long sz = a.template shape<0>(); - types::list()[types::fast_contiguous_slice()])>::type> + types::list< + typename assignable()[types::fast_contiguous_slice()])>::type> out(1 + split_mask.flat_size()); long index = 0; auto inserter = out.begin(); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/asarray.hpp b/contrib/python/pythran/pythran/pythonic/numpy/asarray.hpp index a1e19f7121a..e3bb11f7507 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/asarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/asarray.hpp @@ -29,24 +29,18 @@ namespace numpy template auto asarray(E &&e, types::none_type d) - -> decltype(_asarray::type, - typename types::dtype_of< - typename std::decay::type>::type>{}( + -> decltype(_asarray, typename types::dtype_of>::type>{}( std::forward(e))) { - return _asarray< - typename std::decay::type, - typename types::dtype_of::type>::type>{}( + return _asarray, typename types::dtype_of>::type>{}( std::forward(e)); } template auto asarray(E &&e, dtype d) - -> decltype(_asarray::type, - typename dtype::type>{}(std::forward(e), d)) + -> decltype(_asarray, typename dtype::type>{}(std::forward(e), d)) { - return _asarray::type, typename dtype::type>{}( - std::forward(e), d); + return _asarray, typename dtype::type>{}(std::forward(e), d); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/asscalar.hpp b/contrib/python/pythran/pythran/pythonic/numpy/asscalar.hpp index 23213ad4394..6b4d259ef9f 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/asscalar.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/asscalar.hpp @@ -16,8 +16,7 @@ namespace numpy asscalar_result_type asscalar(E const &expr) { if (expr.flat_size() != 1) - throw types::ValueError( - "can only convert an array of size 1 to a Python scalar"); + throw types::ValueError("can only convert an array of size 1 to a Python scalar"); return *asarray(expr).fbegin(); } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/atleast_1d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/atleast_1d.hpp index f5d5c6c7679..aa207335b67 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/atleast_1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/atleast_1d.hpp @@ -10,18 +10,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray>>>::type + std::enable_if_t::value, + types::ndarray>>> atleast_1d(T t) { return {types::pshape>(), t}; } template - auto atleast_1d(T const &t) -> - typename std::enable_if::value), - decltype(asarray(t))>::type + auto atleast_1d(T const &t) -> std::enable_if_t::value, decltype(asarray(t))> { return asarray(t); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/atleast_2d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/atleast_2d.hpp index e26f8abde95..7d1b02beb25 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/atleast_2d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/atleast_2d.hpp @@ -10,40 +10,30 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray, - std::integral_constant>>>::type + std::enable_if_t::value, + types::ndarray, + std::integral_constant>>> atleast_2d(T t) { - return {types::pshape, - std::integral_constant>(), - t}; + return {types::pshape, std::integral_constant>(), t}; } template - auto atleast_2d(T const &t) -> - typename std::enable_if < (!types::is_dtype::value) && - T::value<2, - types::ndarray< - typename T::dtype, - types::pshape, - typename std::tuple_element< - 0, typename T::shape_t>::type>>>::type + auto atleast_2d(T const &t) -> std::enable_if_t < (!types::is_dtype::value) && + T::value<2, types::ndarray, + std::tuple_element_t<0, typename T::shape_t>>>> { - return t.reshape(types::pshape< - std::integral_constant, - typename std::tuple_element<0, typename T::shape_t>::type>( + return t.reshape(types::pshape, + std::tuple_element_t<0, typename T::shape_t>>( std::integral_constant(), t.template shape<0>())); } template - auto atleast_2d(T &&t) -> - typename std::enable_if< - (!types::is_dtype::type>::type>::value) && - std::decay::type::value >= 2, - decltype(std::forward(t))>::type + auto atleast_2d(T &&t) + -> std::enable_if_t<(!types::is_dtype>>::value) && + std::decay_t::value >= 2, + decltype(std::forward(t))> { return std::forward(t); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/atleast_3d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/atleast_3d.hpp index 3bf8a3fbe4c..907882fff30 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/atleast_3d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/atleast_3d.hpp @@ -10,62 +10,49 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - types::is_dtype::value, - types::ndarray, - std::integral_constant, - std::integral_constant>>>::type + std::enable_if_t::value, + types::ndarray, + std::integral_constant, + std::integral_constant>>> atleast_3d(T t) { - return {types::pshape, - std::integral_constant, + return {types::pshape, std::integral_constant, std::integral_constant>(), t}; } template - auto atleast_3d(T const &t) -> - typename std::enable_if< - (!types::is_dtype::value) && (T::value == 1), - types::ndarray, - typename std::tuple_element< - 0, typename T::shape_t>::type, - std::integral_constant>>>::type + auto atleast_3d(T const &t) -> std::enable_if_t< + (!types::is_dtype::value) && (T::value == 1), + types::ndarray, + std::tuple_element_t<0, typename T::shape_t>, + std::integral_constant>>> { auto r = asarray(t); return r.reshape( - types::pshape, - typename std::tuple_element<0, typename T::shape_t>::type, - std::integral_constant>( - std::integral_constant(), r.template shape<0>(), - std::integral_constant())); + types::pshape, std::tuple_element_t<0, typename T::shape_t>, + std::integral_constant>(std::integral_constant(), + r.template shape<0>(), + std::integral_constant())); } template - auto atleast_3d(T const &t) -> - typename std::enable_if< - (!types::is_dtype::value) && (T::value == 2), - types::ndarray< - typename T::dtype, - types::pshape< - typename std::tuple_element<0, typename T::shape_t>::type, - typename std::tuple_element<1, typename T::shape_t>::type, - std::integral_constant>>>::type + auto atleast_3d(T const &t) -> std::enable_if_t< + (!types::is_dtype::value) && (T::value == 2), + types::ndarray, + std::tuple_element_t<1, typename T::shape_t>, + std::integral_constant>>> { auto r = asarray(t); - return r.reshape( - types::pshape::type, - typename std::tuple_element<1, typename T::shape_t>::type, - std::integral_constant>( - r.template shape<0>(), r.template shape<1>(), - std::integral_constant())); + return r.reshape(types::pshape, + std::tuple_element_t<1, typename T::shape_t>, + std::integral_constant>( + r.template shape<0>(), r.template shape<1>(), std::integral_constant())); } template - auto atleast_3d(T const &t) -> - typename std::enable_if<(!types::is_dtype::value) && T::value >= 3, - decltype(asarray(t))>::type + auto atleast_3d(T const &t) + -> std::enable_if_t<(!types::is_dtype::value) && T::value >= 3, decltype(asarray(t))> { return asarray(t); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/average.hpp b/contrib/python/pythran/pythran/pythonic/numpy/average.hpp index 3be4975aa7e..78848b350df 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/average.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/average.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto average(E const &expr, - types::none_type const &axis) -> decltype(sum(expr, axis) / 1.) + auto average(E const &expr, types::none_type const &axis) -> decltype(sum(expr, axis) / 1.) { return sum(expr, axis) / double(expr.flat_size()); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/base_repr.hpp b/contrib/python/pythran/pythran/pythonic/numpy/base_repr.hpp index 5c83c69b31d..17f9567f3a6 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/base_repr.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/base_repr.hpp @@ -19,11 +19,8 @@ namespace numpy return res; } - int const ndigits = - (number == 0 ? 1 - : std::ceil(std::log(std::labs(number)) / std::log(base))); - int const effective_padding = - padding - ((number == 0) && (padding > 0) ? 1 : 0); + int const ndigits = (number == 0 ? 1 : std::ceil(std::log(std::labs(number)) / std::log(base))); + int const effective_padding = padding - ((number == 0) && (padding > 0) ? 1 : 0); res.resize(ndigits + effective_padding + (number < 0 ? 1 : 0)); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/bincount.hpp b/contrib/python/pythran/pythran/pythonic/numpy/bincount.hpp index 0805a71ce0b..b7249f548b9 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/bincount.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/bincount.hpp @@ -11,43 +11,37 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value == 1, - types::ndarray>>::type - bincount(types::ndarray const &expr, types::none_type weights, - types::none minlength) + std::enable_if_t::value == 1, types::ndarray>> + bincount(types::ndarray const &expr, types::none_type weights, types::none minlength) { long length = 0; if (minlength) length = (long)minlength; length = std::max(length, 1 + max(expr)); - types::ndarray> out(types::pshape(length), - 0L); + types::ndarray> out(types::pshape(length), 0L); for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; ++iter) ++out[*iter]; return out; } template - typename std::enable_if< + std::enable_if_t< std::tuple_size::value == 1, - types::ndarray() * - std::declval()), - types::pshape>>::type - bincount(types::ndarray const &expr, E const &weights, - types::none minlength) + types::ndarray() * std::declval()), + types::pshape>> + bincount(types::ndarray const &expr, E const &weights, types::none minlength) { long length = 0; if (minlength) length = (long)minlength; length = std::max(length, 1 + max(expr)); - typename std::enable_if< + std::enable_if_t< std::tuple_size::value == 1, - types::ndarray< - decltype(std::declval() * std::declval()), - types::pshape>>::type out(types::pshape(length), 0L); + types::ndarray() * std::declval()), + types::pshape>> + out(types::pshape(length), 0L); auto iweight = weights.begin(); - for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; - ++iter, ++iweight) + for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; ++iter, ++iweight) out[*iter] += *iweight; return out; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/broadcast_to.hpp b/contrib/python/pythran/pythran/pythonic/numpy/broadcast_to.hpp index 8498a767e5e..dcfa0ccb9f0 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/broadcast_to.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/broadcast_to.hpp @@ -11,22 +11,18 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto broadcast_to(E const &expr, pS shape) - -> decltype(numpy::functor::empty{}( - shape, typename types::dtype_t::type>{})) + auto broadcast_to(E const &expr, pS shape) -> decltype(numpy::functor::empty{}( + shape, typename types::dtype_t::type>{})) { using dtype = typename types::dtype_of::type; using BExpr = - typename std::conditional::value, - types::broadcast, E const &>::type; + std::conditional_t::value, types::broadcast, E const &>; auto out = numpy::functor::empty{}(shape, typename types::dtype_t{}); using array_type = decltype(out); BExpr bexpr = expr; utils::broadcast_copy::value, - std::remove_reference::type::is_vectorizable>( - out, bexpr); + array_type::value - utils::nested_container_depth::value, + std::remove_reference_t::is_vectorizable>(out, bexpr); return out; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/byte.hpp b/contrib/python/pythran/pythran/pythonic/numpy/byte.hpp index 6bc80e6f941..405630297d7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/byte.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/byte.hpp @@ -34,4 +34,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::byte const &c) +{ + return (PyObject *)&PyByteArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyByteArrType_Type; +} + +inline numpy::functor::byte from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/complex128.hpp b/contrib/python/pythran/pythran/pythonic/numpy/complex128.hpp index e2366a60676..5ee949f279d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/complex128.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/complex128.hpp @@ -32,5 +32,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::complex128 const &c) +{ + return (PyObject *)&PyCDoubleArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyCDoubleArrType_Type; +} + +inline numpy::functor::complex128 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/complex256.hpp b/contrib/python/pythran/pythran/pythonic/numpy/complex256.hpp index 5f055554579..a580300f8ea 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/complex256.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/complex256.hpp @@ -33,4 +33,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::complex256 const &c) +{ + return (PyObject *)&PyCLongDoubleArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyCLongDoubleArrType_Type; +} + +inline numpy::functor::complex256 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/complex64.hpp b/contrib/python/pythran/pythran/pythonic/numpy/complex64.hpp index 2428d427c5e..37c0a629931 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/complex64.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/complex64.hpp @@ -40,4 +40,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::complex64 const &c) +{ + return (PyObject *)&PyCFloatArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyCFloatArrType_Type; +} + +inline numpy::functor::complex64 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/concatenate.hpp b/contrib/python/pythran/pythran/pythonic/numpy/concatenate.hpp index 9d49c83ba5a..dfd03d0cf1a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/concatenate.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/concatenate.hpp @@ -29,17 +29,13 @@ namespace numpy out_iter = std::copy(ifrom.begin(), ifrom.end(), out_iter); } else { using iterator_on_from_value = typename A::value_type::const_iterator; - std::vector> - ifroms; + std::vector> ifroms; for (auto &ifrom : from) ifroms.emplace_back(ifrom.begin()); using iterator_value_type = typename std::iterator_traits::value_type; - std::vector> - difroms; + std::vector> difroms; for (auto &&iout : out) { difroms.clear(); @@ -53,28 +49,23 @@ namespace numpy } // array version template - void operator()(Out &&out, A const &from, long axis, - utils::index_sequence) const + void operator()(Out &&out, A const &from, long axis, std::index_sequence) const { if (axis == 0) { auto out_iter = out.begin(); (void)std::initializer_list{ - (out_iter = std::copy(std::get(from).begin(), - std::get(from).end(), out_iter), + (out_iter = std::copy(std::get(from).begin(), std::get(from).end(), out_iter), 1)...}; } else { - types::array_tuple - ifroms = {std::get(from).begin()...}; + types::array_tuple ifroms = { + std::get(from).begin()...}; for (auto &&iout : out) { types::array_tuple< - typename std::iterator_traits< - typename A::value_type::const_iterator>::value_type, + typename std::iterator_traits::value_type, sizeof...(I)> difroms = {*std::get(ifroms)...}; - concatenate_helper()(iout, difroms, axis - 1, - utils::index_sequence{}); + concatenate_helper()(iout, difroms, axis - 1, std::index_sequence{}); (void)std::initializer_list{(++std::get(ifroms), 0)...}; } } @@ -82,21 +73,19 @@ namespace numpy // tuple version template void operator()(Out &&out, std::tuple const &from, long axis, - utils::index_sequence) const + std::index_sequence) const { if (axis == 0) { auto out_iter = out.begin(); (void)std::initializer_list{ - (out_iter = std::copy(std::get(from).begin(), - std::get(from).end(), out_iter), + (out_iter = std::copy(std::get(from).begin(), std::get(from).end(), out_iter), 1)...}; } else { auto ifroms = std::make_tuple(std::get(from).begin()...); for (auto &&iout : out) { auto difroms = std::make_tuple(*std::get(ifroms)...); - concatenate_helper()(iout, difroms, axis - 1, - utils::index_sequence{}); + concatenate_helper()(iout, difroms, axis - 1, std::index_sequence{}); (void)std::initializer_list{(++std::get(ifroms), 0)...}; } } @@ -112,49 +101,39 @@ namespace numpy } // array version template - void operator()(Out &&, E const &, long, - utils::index_sequence) const + void operator()(Out &&, E const &, long, std::index_sequence) const { } // tuple version - sentinel template - void operator()(Out &&, std::tuple const &, long, - utils::index_sequence) const + void operator()(Out &&, std::tuple const &, long, std::index_sequence) const { } }; template - long concatenate_axis_size(A const &from, long axis, - utils::index_sequence) + long concatenate_axis_size(A const &from, long axis, std::index_sequence) { long sizes[] = {sutils::getshape(std::get(from))[axis]...}; - return std::accumulate(std::begin(sizes), std::end(sizes), 0L, - std::plus()); + return std::accumulate(std::begin(sizes), std::end(sizes), 0L, std::plus()); } } // namespace details template - auto concatenate(std::tuple const &args, long axis) - -> types::ndarray< - typename __combined::type::dtype...>::type, - types::array_tuple< - long, std::tuple_element<0, std::tuple>::type::value>> + auto concatenate(std::tuple const &args, long axis) -> types::ndarray< + typename __combined::dtype...>::type, + types::array_tuple>::value>> { - using T = - typename __combined::type::dtype...>::type; - auto constexpr N = std::decay(args))>::type::value; + auto constexpr N = std::decay_t(args))>::value; auto shape = sutils::getshape(std::get<0>(args)); - shape[axis] = details::concatenate_axis_size( - args, axis, utils::make_index_sequence{}); + shape[axis] = + details::concatenate_axis_size(args, axis, std::make_index_sequence{}); - types::ndarray< - typename __combined::type::dtype...>::type, - types::array_tuple< - long, std::decay(args))>::type::value>> + types::ndarray::dtype...>::type, + types::array_tuple(args))>::value>> result{shape, types::none_type{}}; - details::concatenate_helper()( - result, args, axis, utils::make_index_sequence{}); + details::concatenate_helper()(result, args, axis, + std::make_index_sequence{}); return result; } @@ -162,15 +141,12 @@ namespace numpy types::ndarray> concatenate(types::array_base const &args, long axis) { - using T = typename E::dtype; auto constexpr N = E::value; auto shape = sutils::getshape(std::get<0>(args)); - shape[axis] = details::concatenate_axis_size( - args, axis, utils::make_index_sequence{}); - types::ndarray> out( - shape, types::none_type{}); - details::concatenate_helper()(out, args, axis, - utils::make_index_sequence{}); + shape[axis] = details::concatenate_axis_size(args, axis, std::make_index_sequence{}); + types::ndarray> out(shape, + types::none_type{}); + details::concatenate_helper()(out, args, axis, std::make_index_sequence{}); return out; } @@ -178,15 +154,12 @@ namespace numpy types::ndarray> concatenate(types::list const &ai, long axis) { - using return_type = - types::ndarray>; - using T = typename return_type::dtype; + using return_type = types::ndarray>; auto constexpr N = return_type::value; auto shape = sutils::getshape(ai[0]); - shape[axis] = std::accumulate(ai.begin(), ai.end(), 0L, - [axis](long v, E const &from) { - return v + sutils::getshape(from)[axis]; - }); + shape[axis] = std::accumulate(ai.begin(), ai.end(), 0L, [axis](long v, E const &from) { + return v + sutils::getshape(from)[axis]; + }); return_type out{shape, types::none_type{}}; details::concatenate_helper()(out, ai, axis); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/convolve.hpp b/contrib/python/pythran/pythran/pythonic/numpy/convolve.hpp index d078d06702f..78f16d4dcf0 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/convolve.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/convolve.hpp @@ -13,8 +13,8 @@ namespace numpy { template - types::ndarray> - convolve(A const &inA, B const &inB, U type) + types::ndarray> convolve(A const &inA, B const &inB, + U type) { auto inB_flipped = functor::flip{}(inB, 0); auto inB_flip_conj = functor::conjugate{}(inB_flipped); @@ -22,8 +22,7 @@ namespace numpy } template - types::ndarray> convolve(A const &inA, - B const &inB) + types::ndarray> convolve(A const &inA, B const &inB) { auto inB_flipped = functor::flip{}(inB, 0); auto inB_flip_conj = functor::conjugate{}(inB_flipped); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/copy.hpp b/contrib/python/pythran/pythran/pythonic/numpy/copy.hpp index 0b29116d81a..88b824af0c8 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/copy.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/copy.hpp @@ -13,10 +13,8 @@ namespace numpy { // list case template - typename std::enable_if< - !types::is_array::value && !types::is_dtype::value, - types::ndarray>>::type + std::enable_if_t::value && !types::is_dtype::value, + types::ndarray>> copy(E const &v) { return {v}; @@ -24,17 +22,14 @@ namespace numpy // scalar / complex case template - auto copy(E const &v) -> - typename std::enable_if::value, E>::type + auto copy(E const &v) -> std::enable_if_t::value, E> { return v; } // No copy is required for numpy_expr template - auto copy(E &&v) -> - typename std::enable_if::value, - decltype(std::forward(v))>::type + auto copy(E &&v) -> std::enable_if_t::value, decltype(std::forward(v))> { return std::forward(v); } @@ -48,8 +43,7 @@ namespace numpy // transposed ndarray case template - types::numpy_texpr> - copy(types::numpy_texpr> const &a) + types::numpy_texpr> copy(types::numpy_texpr> const &a) { return a.arg.copy(); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/copyto.hpp b/contrib/python/pythran/pythran/pythonic/numpy/copyto.hpp index 26fcbe3d507..927a1ed86d1 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/copyto.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/copyto.hpp @@ -20,16 +20,13 @@ namespace numpy out_type &, decltype(aexpr), out_type::value, (int)out_type::value - (int)utils::dim_of::value, out_type::is_vectorizable && - std::is_same::type>::value && + std::is_same::type>::value && types::is_vectorizable::value>(out, aexpr); } else { utils::broadcast_copy< - out_type &, E, out_type::value, - (int)out_type::value - (int)utils::dim_of::value, + out_type &, E, out_type::value, (int)out_type::value - (int)utils::dim_of::value, out_type::is_vectorizable && - std::is_same::type>::value && + std::is_same::type>::value && types::is_vectorizable::value>(out, expr); } return {}; @@ -42,8 +39,7 @@ namespace numpy } template - types::none_type copyto(types::numpy_texpr> &out, - E const &expr) + types::none_type copyto(types::numpy_texpr> &out, E const &expr) { using out_type = types::numpy_texpr>; if (may_overlap(out, expr)) { @@ -52,24 +48,20 @@ namespace numpy out_type &, decltype(aexpr), out_type::value, (int)out_type::value - (int)utils::dim_of::value, out_type::is_vectorizable && - std::is_same::type>::value && + std::is_same::type>::value && types::is_vectorizable::value>(out, aexpr); } else { utils::broadcast_copy< - out_type &, E, out_type::value, - (int)out_type::value - (int)utils::dim_of::value, + out_type &, E, out_type::value, (int)out_type::value - (int)utils::dim_of::value, out_type::is_vectorizable && - std::is_same::type>::value && + std::is_same::type>::value && types::is_vectorizable::value>(out, expr); } return {}; } template - types::none_type copyto(types::numpy_texpr> &&out, - E const &expr) + types::none_type copyto(types::numpy_texpr> &&out, E const &expr) { return copyto(out, expr); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/correlate.hpp b/contrib/python/pythran/pythran/pythonic/numpy/correlate.hpp index f87d8bf2573..d7ed201307d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/correlate.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/correlate.hpp @@ -24,8 +24,7 @@ namespace numpy long NA = shapeA[0]; long NB = shapeB[0]; - using out_type = - typename __combined::type; + using out_type = typename __combined::type; // At this point, handling views would slow things down tremendously auto inA_ = functor::asarray{}(inA); auto inB_ = functor::asarray{}(inB); @@ -75,21 +74,18 @@ namespace numpy } else { // Incomplete overlap left for (int i = iLeft; i < 0; i++, out_ptr += out_inc) { - *out_ptr = wrapper::conjugate( - numpy::dot(inA_(types::fast_contiguous_slice(0, NB + i)), - inB_(types::fast_contiguous_slice(-i, NB)))); + *out_ptr = wrapper::conjugate(numpy::dot(inA_(types::fast_contiguous_slice(0, NB + i)), + inB_(types::fast_contiguous_slice(-i, NB)))); } // Complete overlap middle for (int i = 0; i <= NA - NB; i++, out_ptr += out_inc) { - *out_ptr = wrapper::conjugate( - numpy::dot(inA_(types::fast_contiguous_slice(i, i + NB)), - inB_(types::fast_contiguous_slice(0, NB)))); + *out_ptr = wrapper::conjugate(numpy::dot(inA_(types::fast_contiguous_slice(i, i + NB)), + inB_(types::fast_contiguous_slice(0, NB)))); } // Incomplete overlap right. for (int i = NA - NB + 1; i < iRight; i++, out_ptr += out_inc) { - *out_ptr = wrapper::conjugate( - numpy::dot(inA_(types::fast_contiguous_slice(i, NA)), - inB_(types::fast_contiguous_slice(0, NA - i)))); + *out_ptr = wrapper::conjugate(numpy::dot(inA_(types::fast_contiguous_slice(i, NA)), + inB_(types::fast_contiguous_slice(0, NA - i)))); } } @@ -97,8 +93,8 @@ namespace numpy } template - types::ndarray> - correlate(A const &inA, B const &inB, types::str const &type) + types::ndarray> correlate(A const &inA, B const &inB, + types::str const &type) { long NA = inA.template shape<0>(); long NB = inB.template shape<0>(); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/count_nonzero.hpp b/contrib/python/pythran/pythran/pythonic/numpy/count_nonzero.hpp index 0fe9e6a132f..6b3adaa6e36 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/count_nonzero.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/count_nonzero.hpp @@ -12,8 +12,8 @@ namespace numpy { template - auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) -> - typename std::enable_if::value>::type + auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) + -> std::enable_if_t::value> { for (; begin != end; ++begin) // Behaviour defined in the standard @@ -21,8 +21,8 @@ namespace numpy } template - auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) -> - typename std::enable_if::value>::type + auto _count_nonzero(E begin, E end, long &count, utils::int_<1>) + -> std::enable_if_t::value> { for (; begin != end; ++begin) if (*begin != static_cast(0)) @@ -33,16 +33,14 @@ namespace numpy void _count_nonzero(E begin, E end, long &count, utils::int_) { for (; begin != end; ++begin) - _count_nonzero((*begin).begin(), (*begin).end(), count, - utils::int_()); + _count_nonzero((*begin).begin(), (*begin).end(), count, utils::int_()); } template long count_nonzero(E const &array) { long count(0); - _count_nonzero(array.begin(), array.end(), count, - utils::int_()); + _count_nonzero(array.begin(), array.end(), count, utils::int_()); return count; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/cross.hpp b/contrib/python/pythran/pythran/pythonic/numpy/cross.hpp index bb69d50af34..f4240181a30 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/cross.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/cross.hpp @@ -16,8 +16,8 @@ namespace numpy void operator()(Out obegin, Out oend, E ebegin, F fbegin) { while (obegin != oend) { - _cross{}((*obegin).begin(), (*obegin).end(), - (*ebegin).begin(), (*fbegin).begin()); + _cross{}((*obegin).begin(), (*obegin).end(), (*ebegin).begin(), + (*fbegin).begin()); ++obegin, ++ebegin, ++fbegin; } } @@ -102,41 +102,38 @@ namespace numpy }; template - types::ndarray< - typename __combined::type, - types::array_tuple> + types::ndarray::type, + types::array_tuple> cross(E const &e, F const &f) { - using dtype = - typename __combined::type; + using dtype = typename __combined::type; types::array_tuple out_shape; - sutils::copy_shape<0, 0>(out_shape, e, - utils::make_index_sequence()); + sutils::copy_shape<0, 0>(out_shape, e, std::make_index_sequence()); if (e.template shape() == 2) { if (f.template shape() == 2) { out_shape[E::value - 1] = 1; - types::ndarray> out{ - out_shape, types::none_type{}}; + types::ndarray> out{out_shape, + types::none_type{}}; _cross{}(out.begin(), out.end(), e.begin(), f.begin()); return out; } else { out_shape[E::value - 1] = 3; - types::ndarray> out{ - out_shape, types::none_type{}}; + types::ndarray> out{out_shape, + types::none_type{}}; _cross{}(out.begin(), out.end(), e.begin(), f.begin()); return out; } } else { if (f.template shape() == 2) { out_shape[E::value - 1] = 3; - types::ndarray> out{ - out_shape, types::none_type{}}; + types::ndarray> out{out_shape, + types::none_type{}}; _cross{}(out.begin(), out.end(), e.begin(), f.begin()); return out; } else { out_shape[E::value - 1] = 3; - types::ndarray> out{ - out_shape, types::none_type{}}; + types::ndarray> out{out_shape, + types::none_type{}}; _cross{}(out.begin(), out.end(), e.begin(), f.begin()); return out; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ctypeslib/as_array.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ctypeslib/as_array.hpp index 7532bea5626..0edf0f8c84f 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ctypeslib/as_array.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ctypeslib/as_array.hpp @@ -12,16 +12,14 @@ namespace numpy namespace ctypeslib { template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> as_array(types::pointer ptr, pS shape) { return {ptr.data, shape, types::ownership::external}; } template - types::ndarray> as_array(types::pointer ptr, - long size) + types::ndarray> as_array(types::pointer ptr, long size) { return as_array(ptr, types::pshape{size}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/cumprod.hpp b/contrib/python/pythran/pythran/pythonic/numpy/cumprod.hpp index 962871b833a..f0a93164da5 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/cumprod.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/cumprod.hpp @@ -14,11 +14,10 @@ namespace numpy template auto cumprod(E &&e, Opts &&...opts) - -> decltype(partial_sum( - std::forward(e), std::forward(opts)...)) + -> decltype(partial_sum(std::forward(e), + std::forward(opts)...)) { - return partial_sum(std::forward(e), - std::forward(opts)...); + return partial_sum(std::forward(e), std::forward(opts)...); } NUMPY_EXPR_TO_NDARRAY0_IMPL(cumprod); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/cumsum.hpp b/contrib/python/pythran/pythran/pythonic/numpy/cumsum.hpp index 2f54a703b54..7d01563c6bb 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/cumsum.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/cumsum.hpp @@ -14,11 +14,10 @@ namespace numpy template auto cumsum(E &&e, Opts &&...opts) - -> decltype(partial_sum( - std::forward(e), std::forward(opts)...)) + -> decltype(partial_sum(std::forward(e), + std::forward(opts)...)) { - return partial_sum(std::forward(e), - std::forward(opts)...); + return partial_sum(std::forward(e), std::forward(opts)...); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/delete_.hpp b/contrib/python/pythran/pythran/pythonic/numpy/delete_.hpp index 6520eae3884..eb132136d65 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/delete_.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/delete_.hpp @@ -11,11 +11,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - delete_(types::ndarray const &a, long index, types::none_type axis) + types::ndarray> delete_(types::ndarray const &a, long index, + types::none_type axis) { - types::ndarray> out( - types::pshape(long(a.flat_size()) - 1), builtins::None); + types::ndarray> out(types::pshape(long(a.flat_size()) - 1), + builtins::None); long n = a.flat_size(); index = std::min(n, index); std::copy(a.buffer + index + 1, a.buffer + n, @@ -24,14 +24,11 @@ namespace numpy } template - typename std::enable_if::value, - types::ndarray>>::type - delete_(types::ndarray const &in, I const &indices, - types::none_type axis) + std::enable_if_t::value, types::ndarray>> + delete_(types::ndarray const &in, I const &indices, types::none_type axis) { types::ndarray> out( - types::pshape(long(in.flat_size()) - indices.flat_size()), - builtins::None); + types::pshape(long(in.flat_size()) - indices.flat_size()), builtins::None); auto out_iter = out.buffer; auto in_iter = in.buffer; for (long index : indices) { diff --git a/contrib/python/pythran/pythran/pythonic/numpy/diag.hpp b/contrib/python/pythran/pythran/pythonic/numpy/diag.hpp index 7f4dde7d5e5..80d5f17e741 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/diag.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/diag.hpp @@ -13,8 +13,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value == 2, - types::ndarray>>::type + std::enable_if_t::value == 2, types::ndarray>> diag(types::ndarray const &a, long k) { auto &&a_shape = a._shape; @@ -23,26 +22,22 @@ namespace numpy types::pshape shape = 0; auto iter = buffer->data; if (k >= 0) - for (int i = 0, j = k; - i < std::get<0>(a_shape) && j < std::get<1>(a_shape); + for (int i = 0, j = k; i < std::get<0>(a_shape) && j < std::get<1>(a_shape); ++i, ++j, ++std::get<0>(shape)) *iter++ = a[i][j]; else - for (int i = -k, j = 0; - i < std::get<0>(a_shape) && j < std::get<1>(a_shape); + for (int i = -k, j = 0; i < std::get<0>(a_shape) && j < std::get<1>(a_shape); ++i, ++j, ++std::get<0>(shape)) *iter++ = a[i][j]; return {buffer, shape}; } template - typename std::enable_if::value == 1, - types::ndarray>>::type + std::enable_if_t::value == 1, types::ndarray>> diag(types::ndarray const &a, long k) { long n = a.flat_size() + std::abs(k); - types::ndarray> out(types::make_tuple(n, n), - 0); + types::ndarray> out(types::make_tuple(n, n), 0); if (k >= 0) for (long i = 0, j = k; i < n && j < n; ++i, ++j) out[i][j] = a[i]; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/diff.hpp b/contrib/python/pythran/pythran/pythonic/numpy/diff.hpp index 763d1cefe5c..e9ea466160e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/diff.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/diff.hpp @@ -14,14 +14,13 @@ namespace numpy namespace details { template - types::ndarray> - diff(E const &arr, long n, long axis) + types::ndarray> diff(E const &arr, long n, + long axis) { auto shape = sutils::getshape(arr); - auto stride = (axis == E::value - 1) - ? arr.template shape() - : std::accumulate(shape.begin() + axis + 1, shape.end(), - 1L, std::multiplies()); + auto stride = (axis == E::value - 1) ? arr.template shape() + : std::accumulate(shape.begin() + axis + 1, shape.end(), + 1L, std::multiplies()); --shape[axis]; // this does not leak, but uses slightly too much memory @@ -52,8 +51,8 @@ namespace numpy } } // namespace details template - types::ndarray> - diff(E const &expr, long n, long axis) + types::ndarray> diff(E const &expr, long n, + long axis) { if (axis < 0) axis += E::value; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/digitize.hpp b/contrib/python/pythran/pythran/pythonic/numpy/digitize.hpp index 65655aba634..0f30ff66917 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/digitize.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/digitize.hpp @@ -15,21 +15,17 @@ namespace numpy namespace { template - void _digitize(I begin, I end, O &out, B &bins, Op const &op, - utils::int_<1>) + void _digitize(I begin, I end, O &out, B &bins, Op const &op, utils::int_<1>) { for (; begin != end; ++begin, ++out) - *out = std::lower_bound(bins.begin(), bins.end(), *begin, op) - - bins.begin(); + *out = std::lower_bound(bins.begin(), bins.end(), *begin, op) - bins.begin(); } template - void _digitize(I begin, I end, O &out, B &bins, Op const &op, - utils::int_) + void _digitize(I begin, I end, O &out, B &bins, Op const &op, utils::int_) { for (; begin != end; ++begin) - _digitize((*begin).begin(), (*begin).end(), out, bins, op, - utils::int_()); + _digitize((*begin).begin(), (*begin).end(), out, bins, op, utils::int_()); } } // namespace @@ -37,17 +33,16 @@ namespace numpy types::ndarray> digitize(E const &expr, F const &b) { auto bins = asarray(b); - bool is_increasing = - bins.flat_size() > 1 && *bins.fbegin() < *(bins.fbegin() + 1); - types::ndarray> out( - types::make_tuple(long(expr.flat_size())), builtins::None); + bool is_increasing = bins.flat_size() > 1 && *bins.fbegin() < *(bins.fbegin() + 1); + types::ndarray> out(types::make_tuple(long(expr.flat_size())), + builtins::None); auto out_iter = out.fbegin(); if (is_increasing) - _digitize(expr.begin(), expr.end(), out_iter, bins, - operator_::functor::lt(), utils::int_()); + _digitize(expr.begin(), expr.end(), out_iter, bins, operator_::functor::lt(), + utils::int_()); else - _digitize(expr.begin(), expr.end(), out_iter, bins, - operator_::functor::gt(), utils::int_()); + _digitize(expr.begin(), expr.end(), out_iter, bins, operator_::functor::gt(), + utils::int_()); return out; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/dot.hpp b/contrib/python/pythran/pythran/pythonic/numpy/dot.hpp index 5beadb4489a..69ee3df259d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/dot.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/dot.hpp @@ -41,23 +41,19 @@ char *scipy_openblas_get_config64_(void); char *scipy_openblas_get_corename64_(void); /*Set the threading backend to a custom callback.*/ -typedef void (*scipy_openblas_dojob_callback64_)(int thread_num, void *jobdata, - int dojob_data); -typedef void (*scipy_openblas_threads_callback64_)( - int sync, scipy_openblas_dojob_callback64_ dojob, int numjobs, - size_t jobdata_elsize, void *jobdata, int dojob_data); -void scipy_openblas_set_threads_callback_function64_( - scipy_openblas_threads_callback64_ callback); +typedef void (*scipy_openblas_dojob_callback64_)(int thread_num, void *jobdata, int dojob_data); +typedef void (*scipy_openblas_threads_callback64_)(int sync, scipy_openblas_dojob_callback64_ dojob, + int numjobs, size_t jobdata_elsize, + void *jobdata, int dojob_data); +void scipy_openblas_set_threads_callback_function64_(scipy_openblas_threads_callback64_ callback); #ifdef OPENBLAS_OS_LINUX /* Sets thread affinity for OpenBLAS threads. `thread_idx` is in [0, * scipy_openblas_get_num_threads64_()-1]. */ -int scipy_openblas_setaffinity64_(int thread_idx, size_t cpusetsize, - cpu_set_t *cpu_set); +int scipy_openblas_setaffinity64_(int thread_idx, size_t cpusetsize, cpu_set_t *cpu_set); /* Queries thread affinity for OpenBLAS threads. `thread_idx` is in [0, * scipy_openblas_get_num_threads64_()-1]. */ -int scipy_openblas_getaffinity64_(int thread_idx, size_t cpusetsize, - cpu_set_t *cpu_set); +int scipy_openblas_getaffinity64_(int thread_idx, size_t cpusetsize, cpu_set_t *cpu_set); #endif /* Get the parallelization type which is used by OpenBLAS */ @@ -79,10 +75,7 @@ int scipy_openblas_get_parallel64_(void); #define CBLAS_INDEX size_t -typedef enum CBLAS_ORDER { - CblasRowMajor = 101, - CblasColMajor = 102 -} CBLAS_ORDER; +typedef enum CBLAS_ORDER { CblasRowMajor = 101, CblasColMajor = 102 } CBLAS_ORDER; typedef enum CBLAS_TRANSPOSE { CblasNoTrans = 111, CblasTrans = 112, @@ -94,59 +87,43 @@ typedef enum CBLAS_DIAG { CblasNonUnit = 131, CblasUnit = 132 } CBLAS_DIAG; typedef enum CBLAS_SIDE { CblasLeft = 141, CblasRight = 142 } CBLAS_SIDE; typedef CBLAS_ORDER CBLAS_LAYOUT; -float scipy_cblas_sdsdot64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST float *y, - OPENBLAS_CONST blasint incy); +float scipy_cblas_sdsdot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); double scipy_cblas_dsdot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST float *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); float scipy_cblas_sdot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, OPENBLAS_CONST float *y, OPENBLAS_CONST blasint incy); double scipy_cblas_ddot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST double *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST double *y, OPENBLAS_CONST blasint incy); -openblas_complex_float scipy_cblas_cdotu64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, +openblas_complex_float scipy_cblas_cdotu64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_float scipy_cblas_cdotc64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, +openblas_complex_float scipy_cblas_cdotc64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_double scipy_cblas_zdotu64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, +openblas_complex_double scipy_cblas_zdotu64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); -openblas_complex_double scipy_cblas_zdotc64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, +openblas_complex_double scipy_cblas_zdotc64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy); void scipy_cblas_cdotu_sub64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); void scipy_cblas_cdotc_sub64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); void scipy_cblas_zdotu_sub64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); void scipy_cblas_zdotc_sub64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST void *y, OPENBLAS_CONST blasint incy, void *ret); float scipy_cblas_sasum64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, @@ -176,30 +153,22 @@ float scipy_cblas_scnrm264_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *X, double scipy_cblas_dznrm264_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX); -CBLAS_INDEX scipy_cblas_isamax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float *x, +CBLAS_INDEX scipy_cblas_isamax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_idamax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double *x, +CBLAS_INDEX scipy_cblas_idamax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_icamax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_icamax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_izamax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_izamax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_isamin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float *x, +CBLAS_INDEX scipy_cblas_isamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_idamin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double *x, +CBLAS_INDEX scipy_cblas_idamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_icamin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_icamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_izamin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_izamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); float scipy_cblas_samax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, @@ -220,1073 +189,854 @@ float scipy_cblas_scamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, double scipy_cblas_dzamin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_ismax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float *x, +CBLAS_INDEX scipy_cblas_ismax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_idmax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double *x, +CBLAS_INDEX scipy_cblas_idmax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_icmax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_icmax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_izmax64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_izmax64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_ismin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float *x, +CBLAS_INDEX scipy_cblas_ismin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_idmin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double *x, +CBLAS_INDEX scipy_cblas_idmin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_icmin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_icmin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); -CBLAS_INDEX scipy_cblas_izmin64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *x, +CBLAS_INDEX scipy_cblas_izmin64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx); void scipy_cblas_saxpy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, - float *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, float *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_daxpy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, - double *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, double *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_caxpy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - void *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_zaxpy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - void *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_caxpyc64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - void *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_zaxpyc64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - void *y, OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, void *y, + OPENBLAS_CONST blasint incy); void scipy_cblas_scopy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *x, - OPENBLAS_CONST blasint incx, float *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST blasint incx, float *y, OPENBLAS_CONST blasint incy); void scipy_cblas_dcopy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *x, - OPENBLAS_CONST blasint incx, double *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST blasint incx, double *y, OPENBLAS_CONST blasint incy); void scipy_cblas_ccopy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); void scipy_cblas_zcopy64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_sswap64_(OPENBLAS_CONST blasint n, float *x, - OPENBLAS_CONST blasint incx, float *y, - OPENBLAS_CONST blasint incy); -void scipy_cblas_dswap64_(OPENBLAS_CONST blasint n, double *x, - OPENBLAS_CONST blasint incx, double *y, +void scipy_cblas_sswap64_(OPENBLAS_CONST blasint n, float *x, OPENBLAS_CONST blasint incx, float *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_cswap64_(OPENBLAS_CONST blasint n, void *x, - OPENBLAS_CONST blasint incx, void *y, +void scipy_cblas_dswap64_(OPENBLAS_CONST blasint n, double *x, OPENBLAS_CONST blasint incx, + double *y, OPENBLAS_CONST blasint incy); +void scipy_cblas_cswap64_(OPENBLAS_CONST blasint n, void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_zswap64_(OPENBLAS_CONST blasint n, void *x, - OPENBLAS_CONST blasint incx, void *y, +void scipy_cblas_zswap64_(OPENBLAS_CONST blasint n, void *x, OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_srot64_(OPENBLAS_CONST blasint N, float *X, - OPENBLAS_CONST blasint incX, float *Y, +void scipy_cblas_srot64_(OPENBLAS_CONST blasint N, float *X, OPENBLAS_CONST blasint incX, float *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST float c, OPENBLAS_CONST float s); -void scipy_cblas_drot64_(OPENBLAS_CONST blasint N, double *X, - OPENBLAS_CONST blasint incX, double *Y, - OPENBLAS_CONST blasint incY, OPENBLAS_CONST double c, +void scipy_cblas_drot64_(OPENBLAS_CONST blasint N, double *X, OPENBLAS_CONST blasint incX, + double *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST double c, OPENBLAS_CONST double s); void scipy_cblas_csrot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, void *y, - OPENBLAS_CONST blasint incY, OPENBLAS_CONST float c, - OPENBLAS_CONST float s); + OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incY, + OPENBLAS_CONST float c, OPENBLAS_CONST float s); void scipy_cblas_zdrot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, void *y, - OPENBLAS_CONST blasint incY, OPENBLAS_CONST double c, - OPENBLAS_CONST double s); + OPENBLAS_CONST blasint incx, void *y, OPENBLAS_CONST blasint incY, + OPENBLAS_CONST double c, OPENBLAS_CONST double s); void scipy_cblas_srotg64_(float *a, float *b, float *c, float *s); void scipy_cblas_drotg64_(double *a, double *b, double *c, double *s); void scipy_cblas_crotg64_(void *a, void *b, float *c, void *s); void scipy_cblas_zrotg64_(void *a, void *b, double *c, void *s); -void scipy_cblas_srotm64_(OPENBLAS_CONST blasint N, float *X, - OPENBLAS_CONST blasint incX, float *Y, +void scipy_cblas_srotm64_(OPENBLAS_CONST blasint N, float *X, OPENBLAS_CONST blasint incX, float *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST float *P); -void scipy_cblas_drotm64_(OPENBLAS_CONST blasint N, double *X, - OPENBLAS_CONST blasint incX, double *Y, - OPENBLAS_CONST blasint incY, - OPENBLAS_CONST double *P); - -void scipy_cblas_srotmg64_(float *d1, float *d2, float *b1, - OPENBLAS_CONST float b2, float *P); -void scipy_cblas_drotmg64_(double *d1, double *d2, double *b1, - OPENBLAS_CONST double b2, double *P); - -void scipy_cblas_sscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - float *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_dscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - double *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_cscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - void *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_zscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - void *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_csscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - void *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_zdscal64_(OPENBLAS_CONST blasint N, - OPENBLAS_CONST double alpha, void *X, +void scipy_cblas_drotm64_(OPENBLAS_CONST blasint N, double *X, OPENBLAS_CONST blasint incX, + double *Y, OPENBLAS_CONST blasint incY, OPENBLAS_CONST double *P); + +void scipy_cblas_srotmg64_(float *d1, float *d2, float *b1, OPENBLAS_CONST float b2, float *P); +void scipy_cblas_drotmg64_(double *d1, double *d2, double *b1, OPENBLAS_CONST double b2, double *P); + +void scipy_cblas_sscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, float *X, + OPENBLAS_CONST blasint incX); +void scipy_cblas_dscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, double *X, + OPENBLAS_CONST blasint incX); +void scipy_cblas_cscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, void *X, + OPENBLAS_CONST blasint incX); +void scipy_cblas_zscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, void *X, + OPENBLAS_CONST blasint incX); +void scipy_cblas_csscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, void *X, + OPENBLAS_CONST blasint incX); +void scipy_cblas_zdscal64_(OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_sgemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, - OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *a, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST float beta, float *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, + OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *a, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); void scipy_cblas_dgemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, - OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *a, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST double beta, double *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, + OPENBLAS_CONST blasint n, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *a, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST double beta, double *y, OPENBLAS_CONST blasint incy); void scipy_cblas_cgemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, - OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *a, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *beta, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, + OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *a, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); void scipy_cblas_zgemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, - OPENBLAS_CONST blasint m, OPENBLAS_CONST blasint n, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *a, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *beta, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, + OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *a, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_sger64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, - OPENBLAS_CONST blasint incY, float *A, +void scipy_cblas_sger64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, float *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_dger64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, - OPENBLAS_CONST blasint incY, double *A, +void scipy_cblas_dger64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, double *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_cgeru64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, - OPENBLAS_CONST blasint incY, void *A, +void scipy_cblas_cgeru64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_cgerc64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, - OPENBLAS_CONST blasint incY, void *A, +void scipy_cblas_cgerc64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_zgeru64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, - OPENBLAS_CONST blasint incY, void *A, +void scipy_cblas_zgeru64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_zgerc64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, - OPENBLAS_CONST blasint incY, void *A, +void scipy_cblas_zgerc64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); void scipy_cblas_strsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, float *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtrsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, double *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctrsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztrsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_strmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, float *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtrmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, double *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctrmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztrmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *X, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); -void scipy_cblas_ssyr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, +void scipy_cblas_ssyr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, - float *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_dsyr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, float *A, + OPENBLAS_CONST blasint lda); +void scipy_cblas_dsyr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, - double *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_cher64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, double *A, + OPENBLAS_CONST blasint lda); +void scipy_cblas_cher64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - void *A, OPENBLAS_CONST blasint lda); -void scipy_cblas_zher64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A, + OPENBLAS_CONST blasint lda); +void scipy_cblas_zher64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - void *A, OPENBLAS_CONST blasint lda); + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A, + OPENBLAS_CONST blasint lda); void scipy_cblas_ssyr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, - float *A, OPENBLAS_CONST blasint lda); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, + OPENBLAS_CONST blasint incY, float *A, OPENBLAS_CONST blasint lda); void scipy_cblas_dsyr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, - double *A, OPENBLAS_CONST blasint lda); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, + OPENBLAS_CONST blasint incY, double *A, OPENBLAS_CONST blasint lda); void scipy_cblas_cher264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, - void *A, OPENBLAS_CONST blasint lda); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, + OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); void scipy_cblas_zher264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, - void *A, OPENBLAS_CONST blasint lda); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, + OPENBLAS_CONST blasint incY, void *A, OPENBLAS_CONST blasint lda); void scipy_cblas_sgbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float beta, float *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint KL, + OPENBLAS_CONST blasint KU, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_dgbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double beta, double *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint KL, + OPENBLAS_CONST blasint KU, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_cgbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint KL, + OPENBLAS_CONST blasint KU, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_zgbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint KL, OPENBLAS_CONST blasint KU, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint KL, + OPENBLAS_CONST blasint KU, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_ssbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float beta, float *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_dsbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double beta, double *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_stbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, - float *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float *A, + OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, - double *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double *A, + OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_stbsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, - float *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float *A, + OPENBLAS_CONST blasint lda, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtbsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, - double *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double *A, + OPENBLAS_CONST blasint lda, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctbsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztbsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_stpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *Ap, - float *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float *Ap, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *Ap, - double *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double *Ap, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_stpsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float *Ap, - float *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float *Ap, float *X, OPENBLAS_CONST blasint incX); void scipy_cblas_dtpsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double *Ap, - double *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double *Ap, double *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ctpsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ztpsv64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *Ap, - void *X, OPENBLAS_CONST blasint incX); + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *Ap, void *X, OPENBLAS_CONST blasint incX); void scipy_cblas_ssymv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float beta, float *Y, + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_dsymv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double beta, double *Y, + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_chemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_zhemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_sspmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *Ap, OPENBLAS_CONST float *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float beta, float *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float alpha, OPENBLAS_CONST float *Ap, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST float beta, float *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_dspmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *Ap, OPENBLAS_CONST double *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double beta, double *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double alpha, OPENBLAS_CONST double *Ap, + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST double beta, double *Y, OPENBLAS_CONST blasint incY); -void scipy_cblas_sspr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, +void scipy_cblas_sspr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, - float *Ap); -void scipy_cblas_dspr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, float *Ap); +void scipy_cblas_dspr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, - double *Ap); + OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, double *Ap); -void scipy_cblas_chpr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, +void scipy_cblas_chpr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - void *A); -void scipy_cblas_zhpr64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A); +void scipy_cblas_zhpr64_(OPENBLAS_CONST enum CBLAS_ORDER order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - void *A); + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, void *A); void scipy_cblas_sspr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST float *Y, OPENBLAS_CONST blasint incY, - float *A); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST float alpha, OPENBLAS_CONST float *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST float *Y, + OPENBLAS_CONST blasint incY, float *A); void scipy_cblas_dspr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST double *Y, OPENBLAS_CONST blasint incY, - double *A); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST double alpha, OPENBLAS_CONST double *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST double *Y, + OPENBLAS_CONST blasint incY, double *A); void scipy_cblas_chpr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, - void *Ap); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, + OPENBLAS_CONST blasint incY, void *Ap); void scipy_cblas_zhpr264_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *Y, OPENBLAS_CONST blasint incY, - void *Ap); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *X, + OPENBLAS_CONST blasint incX, OPENBLAS_CONST void *Y, + OPENBLAS_CONST blasint incY, void *Ap); void scipy_cblas_chbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_zhbmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_chpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *Ap, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *Ap, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_zhpmv64_(OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *Ap, OPENBLAS_CONST void *X, - OPENBLAS_CONST blasint incX, - OPENBLAS_CONST void *beta, void *Y, - OPENBLAS_CONST blasint incY); + OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint N, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *Ap, + OPENBLAS_CONST void *X, OPENBLAS_CONST blasint incX, + OPENBLAS_CONST void *beta, void *Y, OPENBLAS_CONST blasint incY); void scipy_cblas_sgemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, - OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST float beta, float *C, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, + OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_dgemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST double beta, double *C, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, + OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_cgemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_cgemm3m64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zgemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, - OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, + OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zgemm3m64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_sgemmt64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST float beta, float *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_dgemmt64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST double beta, double *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_cgemmt64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zgemmt64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_ssymm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, - OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, - float *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, + OPENBLAS_CONST blasint ldc); void scipy_cblas_dsymm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST double beta, double *C, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_csymm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldc); void scipy_cblas_zsymm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldc); void scipy_cblas_ssyrk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float beta, - float *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_dsyrk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, - OPENBLAS_CONST double beta, double *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_csyrk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zsyrk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_ssyr2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST float beta, float *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_dsyr2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST double *B, OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST double beta, double *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST double beta, double *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_csyr2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zsyr2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST void *beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST void *beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_strmm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, float *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_dtrmm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, double *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_ctrmm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_ztrmm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_strsm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST float alpha, OPENBLAS_CONST float *A, - OPENBLAS_CONST blasint lda, float *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST float alpha, + OPENBLAS_CONST float *A, OPENBLAS_CONST blasint lda, float *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_dtrsm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST double alpha, OPENBLAS_CONST double *A, - OPENBLAS_CONST blasint lda, double *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *A, OPENBLAS_CONST blasint lda, double *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_ctrsm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_ztrsm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_DIAG Diag, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, void *B, + OPENBLAS_CONST enum CBLAS_DIAG Diag, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, void *B, OPENBLAS_CONST blasint ldb); void scipy_cblas_chemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldc); void scipy_cblas_zhemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, - OPENBLAS_CONST enum CBLAS_SIDE Side, - OPENBLAS_CONST enum CBLAS_UPLO Uplo, + OPENBLAS_CONST enum CBLAS_SIDE Side, OPENBLAS_CONST enum CBLAS_UPLO Uplo, OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST void *beta, void *C, + OPENBLAS_CONST blasint ldc); void scipy_cblas_cherk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST float alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST float beta, - void *C, OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST float beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zherk64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST double alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, - OPENBLAS_CONST double beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST double alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST double beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_cher2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST float beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST float beta, void *C, OPENBLAS_CONST blasint ldc); void scipy_cblas_zher2k64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_UPLO Uplo, - OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, - OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, - OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *A, - OPENBLAS_CONST blasint lda, OPENBLAS_CONST void *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST double beta, void *C, - OPENBLAS_CONST blasint ldc); + OPENBLAS_CONST enum CBLAS_TRANSPOSE Trans, OPENBLAS_CONST blasint N, + OPENBLAS_CONST blasint K, OPENBLAS_CONST void *alpha, + OPENBLAS_CONST void *A, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST void *B, OPENBLAS_CONST blasint ldb, + OPENBLAS_CONST double beta, void *C, OPENBLAS_CONST blasint ldc); -void scipy_cblas_xerbla64_(blasint p, OPENBLAS_CONST char *rout, - OPENBLAS_CONST char *form, ...); +void scipy_cblas_xerbla64_(blasint p, OPENBLAS_CONST char *rout, OPENBLAS_CONST char *form, ...); /*** BLAS extensions ***/ void scipy_cblas_saxpby64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, OPENBLAS_CONST float *x, OPENBLAS_CONST blasint incx, - OPENBLAS_CONST float beta, float *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_daxpby64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double alpha, - OPENBLAS_CONST double *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST double beta, double *y, - OPENBLAS_CONST blasint incy); +void scipy_cblas_daxpby64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double alpha, + OPENBLAS_CONST double *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST double beta, double *y, OPENBLAS_CONST blasint incy); void scipy_cblas_caxpby64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *beta, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); void scipy_cblas_zaxpby64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST void *alpha, OPENBLAS_CONST void *x, OPENBLAS_CONST blasint incx, - OPENBLAS_CONST void *beta, void *y, - OPENBLAS_CONST blasint incy); + OPENBLAS_CONST void *beta, void *y, OPENBLAS_CONST blasint incy); void scipy_cblas_somatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float calpha, - OPENBLAS_CONST float *a, - OPENBLAS_CONST blasint clda, float *b, - OPENBLAS_CONST blasint cldb); + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST float calpha, OPENBLAS_CONST float *a, + OPENBLAS_CONST blasint clda, float *b, OPENBLAS_CONST blasint cldb); void scipy_cblas_domatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double calpha, - OPENBLAS_CONST double *a, - OPENBLAS_CONST blasint clda, double *b, - OPENBLAS_CONST blasint cldb); + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST double calpha, OPENBLAS_CONST double *a, + OPENBLAS_CONST blasint clda, double *b, OPENBLAS_CONST blasint cldb); void scipy_cblas_comatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float *calpha, - OPENBLAS_CONST float *a, - OPENBLAS_CONST blasint clda, float *b, - OPENBLAS_CONST blasint cldb); + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST float *calpha, OPENBLAS_CONST float *a, + OPENBLAS_CONST blasint clda, float *b, OPENBLAS_CONST blasint cldb); void scipy_cblas_zomatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double *calpha, - OPENBLAS_CONST double *a, - OPENBLAS_CONST blasint clda, double *b, - OPENBLAS_CONST blasint cldb); + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST double *calpha, OPENBLAS_CONST double *a, + OPENBLAS_CONST blasint clda, double *b, OPENBLAS_CONST blasint cldb); void scipy_cblas_simatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float calpha, float *a, - OPENBLAS_CONST blasint clda, + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST float calpha, float *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); void scipy_cblas_dimatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double calpha, double *a, - OPENBLAS_CONST blasint clda, + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST double calpha, double *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); void scipy_cblas_cimatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float *calpha, float *a, - OPENBLAS_CONST blasint clda, + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST float *calpha, float *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); void scipy_cblas_zimatcopy64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST enum CBLAS_TRANSPOSE CTRANS, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double *calpha, double *a, - OPENBLAS_CONST blasint clda, + OPENBLAS_CONST blasint crows, OPENBLAS_CONST blasint ccols, + OPENBLAS_CONST double *calpha, double *a, OPENBLAS_CONST blasint clda, OPENBLAS_CONST blasint cldb); -void scipy_cblas_sgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float calpha, float *a, - OPENBLAS_CONST blasint clda, - OPENBLAS_CONST float cbeta, float *c, +void scipy_cblas_sgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST blasint crows, + OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float calpha, float *a, + OPENBLAS_CONST blasint clda, OPENBLAS_CONST float cbeta, float *c, OPENBLAS_CONST blasint cldc); -void scipy_cblas_dgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double calpha, double *a, - OPENBLAS_CONST blasint clda, - OPENBLAS_CONST double cbeta, double *c, +void scipy_cblas_dgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST blasint crows, + OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double calpha, double *a, + OPENBLAS_CONST blasint clda, OPENBLAS_CONST double cbeta, double *c, OPENBLAS_CONST blasint cldc); -void scipy_cblas_cgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST float *calpha, float *a, - OPENBLAS_CONST blasint clda, - OPENBLAS_CONST float *cbeta, float *c, +void scipy_cblas_cgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST blasint crows, + OPENBLAS_CONST blasint ccols, OPENBLAS_CONST float *calpha, float *a, + OPENBLAS_CONST blasint clda, OPENBLAS_CONST float *cbeta, float *c, OPENBLAS_CONST blasint cldc); -void scipy_cblas_zgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, - OPENBLAS_CONST blasint crows, - OPENBLAS_CONST blasint ccols, - OPENBLAS_CONST double *calpha, double *a, - OPENBLAS_CONST blasint clda, - OPENBLAS_CONST double *cbeta, double *c, +void scipy_cblas_zgeadd64_(OPENBLAS_CONST enum CBLAS_ORDER CORDER, OPENBLAS_CONST blasint crows, + OPENBLAS_CONST blasint ccols, OPENBLAS_CONST double *calpha, double *a, + OPENBLAS_CONST blasint clda, OPENBLAS_CONST double *cbeta, double *c, OPENBLAS_CONST blasint cldc); /*** BFLOAT16 and INT8 extensions ***/ /* convert float array to BFLOAT16 array by rounding */ -void scipy_cblas_sbstobf1664_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST float *in, +void scipy_cblas_sbstobf1664_(OPENBLAS_CONST blasint n, OPENBLAS_CONST float *in, OPENBLAS_CONST blasint incin, bfloat16 *out, OPENBLAS_CONST blasint incout); /* convert double array to BFLOAT16 array by rounding */ -void scipy_cblas_sbdtobf1664_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST double *in, +void scipy_cblas_sbdtobf1664_(OPENBLAS_CONST blasint n, OPENBLAS_CONST double *in, OPENBLAS_CONST blasint incin, bfloat16 *out, OPENBLAS_CONST blasint incout); /* convert BFLOAT16 array to float array */ -void scipy_cblas_sbf16tos64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST bfloat16 *in, +void scipy_cblas_sbf16tos64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST bfloat16 *in, OPENBLAS_CONST blasint incin, float *out, OPENBLAS_CONST blasint incout); /* convert BFLOAT16 array to double array */ -void scipy_cblas_dbf16tod64_(OPENBLAS_CONST blasint n, - OPENBLAS_CONST bfloat16 *in, +void scipy_cblas_dbf16tod64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST bfloat16 *in, OPENBLAS_CONST blasint incin, double *out, OPENBLAS_CONST blasint incout); /* dot production of BFLOAT16 input arrays, and output as float */ float scipy_cblas_sbdot64_(OPENBLAS_CONST blasint n, OPENBLAS_CONST bfloat16 *x, - OPENBLAS_CONST blasint incx, - OPENBLAS_CONST bfloat16 *y, + OPENBLAS_CONST blasint incx, OPENBLAS_CONST bfloat16 *y, OPENBLAS_CONST blasint incy); -void scipy_cblas_sbgemv64_( - OPENBLAS_CONST enum CBLAS_ORDER order, - OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, - OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, - OPENBLAS_CONST bfloat16 *a, OPENBLAS_CONST blasint lda, - OPENBLAS_CONST bfloat16 *x, OPENBLAS_CONST blasint incx, - OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); +void scipy_cblas_sbgemv64_(OPENBLAS_CONST enum CBLAS_ORDER order, + OPENBLAS_CONST enum CBLAS_TRANSPOSE trans, OPENBLAS_CONST blasint m, + OPENBLAS_CONST blasint n, OPENBLAS_CONST float alpha, + OPENBLAS_CONST bfloat16 *a, OPENBLAS_CONST blasint lda, + OPENBLAS_CONST bfloat16 *x, OPENBLAS_CONST blasint incx, + OPENBLAS_CONST float beta, float *y, OPENBLAS_CONST blasint incy); void scipy_cblas_sbgemm64_(OPENBLAS_CONST enum CBLAS_ORDER Order, OPENBLAS_CONST enum CBLAS_TRANSPOSE TransA, - OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, - OPENBLAS_CONST blasint M, OPENBLAS_CONST blasint N, - OPENBLAS_CONST blasint K, OPENBLAS_CONST float alpha, - OPENBLAS_CONST bfloat16 *A, - OPENBLAS_CONST blasint lda, - OPENBLAS_CONST bfloat16 *B, - OPENBLAS_CONST blasint ldb, - OPENBLAS_CONST float beta, float *C, + OPENBLAS_CONST enum CBLAS_TRANSPOSE TransB, OPENBLAS_CONST blasint M, + OPENBLAS_CONST blasint N, OPENBLAS_CONST blasint K, + OPENBLAS_CONST float alpha, OPENBLAS_CONST bfloat16 *A, + OPENBLAS_CONST blasint lda, OPENBLAS_CONST bfloat16 *B, + OPENBLAS_CONST blasint ldb, OPENBLAS_CONST float beta, float *C, OPENBLAS_CONST blasint ldc); } /* } VENDORED HEADER */ @@ -1307,9 +1057,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value && - types::is_dtype::value, - decltype(std::declval() * std::declval())>::type + std::enable_if_t::value && types::is_dtype::value, + decltype(std::declval() * std::declval())> dot(E const &e, F const &f) { return e * f; @@ -1350,51 +1099,45 @@ namespace numpy } template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // Arguments are array_like - && E::value == 1 && F::value == 1 // It is a two vectors. - && (!is_blas_view::value || !is_blas_view::value || - !std::is_same::value), - typename __combined::type>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // Arguments are array_like + && E::value == 1 && F::value == 1 // It is a two vectors. + && (!is_blas_view::value || !is_blas_view::value || + !std::is_same::value), + typename __combined::type> dot(E const &e, F const &f) { return sum(functor::multiply{}(e, f)); } template - typename std::enable_if::value && - std::is_same::value && - is_blas_array::value && - is_blas_array::value, - float>::type + std::enable_if_t::value && + std::is_same::value && is_blas_array::value && + is_blas_array::value, + float> dot(E const &e, F const &f) { - return BLAS_MANGLE(cblas_sdot)(e.size(), blas_buffer(e), 1, blas_buffer(f), - 1); + return BLAS_MANGLE(cblas_sdot)(e.size(), blas_buffer(e), 1, blas_buffer(f), 1); } template - typename std::enable_if::value && - std::is_same::value && - is_blas_array::value && - is_blas_array::value, - double>::type + std::enable_if_t::value && + std::is_same::value && is_blas_array::value && + is_blas_array::value, + double> dot(E const &e, F const &f) { - return BLAS_MANGLE(cblas_ddot)(e.size(), blas_buffer(e), 1, blas_buffer(f), - 1); + return BLAS_MANGLE(cblas_ddot)(e.size(), blas_buffer(e), 1, blas_buffer(f), 1); } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - is_blas_array::value && is_blas_array::value, - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + is_blas_array::value && is_blas_array::value, + std::complex> dot(E const &e, F const &f) { std::complex out; @@ -1404,12 +1147,11 @@ namespace numpy } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - is_blas_array::value && is_blas_array::value, - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + is_blas_array::value && is_blas_array::value, + std::complex> dot(E const &e, F const &f) { std::complex out; @@ -1419,58 +1161,53 @@ namespace numpy } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same::value && - std::is_same::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - float>::type + std::enable_if_t::value && + std::is_same::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + float> dot(E const &e, F const &f) { if (e.template strides<0>() >= 1 && f.template strides<0>() >= 1) { - return BLAS_MANGLE(cblas_sdot)(e.size(), blas_buffer(e), - e.template strides<0>(), blas_buffer(f), - f.template strides<0>()); + return BLAS_MANGLE(cblas_sdot)(e.size(), blas_buffer(e), e.template strides<0>(), + blas_buffer(f), f.template strides<0>()); } else { return dot(asarray(e), asarray(f)); } } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same::value && - std::is_same::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - double>::type + std::enable_if_t::value && + std::is_same::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + double> dot(E const &e, F const &f) { if (e.template strides<0>() >= 1 && f.template strides<0>() >= 1) { - return BLAS_MANGLE(cblas_ddot)(e.size(), blas_buffer(e), - e.template strides<0>(), blas_buffer(f), - f.template strides<0>()); + return BLAS_MANGLE(cblas_ddot)(e.size(), blas_buffer(e), e.template strides<0>(), + blas_buffer(f), f.template strides<0>()); } else { return dot(asarray(e), asarray(f)); } } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + std::complex> dot(E const &e, F const &f) { if (e.template strides<0>() >= 1 && f.template strides<0>() >= 1) { std::complex out; BLAS_MANGLE(cblas_cdotu_sub) - (e.size(), blas_buffer(e), e.template strides<0>(), blas_buffer(f), - f.template strides<0>(), &out); + (e.size(), blas_buffer(e), e.template strides<0>(), blas_buffer(f), f.template strides<0>(), + &out); return out; } else { return dot(asarray(e), asarray(f)); @@ -1478,20 +1215,19 @@ namespace numpy } template - typename std::enable_if< - E::value == 1 && F::value == 1 && - std::is_same>::value && - std::is_same>::value && - (is_blas_view::value && is_blas_view::value && - !(is_blas_array::value && is_blas_array::value)), - std::complex>::type + std::enable_if_t>::value && + std::is_same>::value && + (is_blas_view::value && is_blas_view::value && + !(is_blas_array::value && is_blas_array::value)), + std::complex> dot(E const &e, F const &f) { if (e.template strides<0>() >= 1 && f.template strides<0>() >= 1) { std::complex out; BLAS_MANGLE(cblas_zdotu_sub) - (e.size(), blas_buffer(e), e.template strides<0>(), blas_buffer(f), - f.template strides<0>(), &out); + (e.size(), blas_buffer(e), e.template strides<0>(), blas_buffer(f), f.template strides<0>(), + &out); return out; } else { return dot(asarray(e), asarray(f)); @@ -1500,11 +1236,11 @@ namespace numpy /// Matrice / Vector multiplication -#define MV_DEF(T, L) \ - inline void mv(int m, int n, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasNoTrans, n, m, 1, A, m, B, 1, 0, C, 1); \ +#define MV_DEF(T, L) \ + inline void mv(int m, int n, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasNoTrans, n, m, 1, A, m, B, 1, 0, C, 1); \ } MV_DEF(double, d) @@ -1512,11 +1248,11 @@ namespace numpy #undef MV_DEF -#define TV_DEF(T, L) \ - inline void tv(int m, int n, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasTrans, m, n, 1, A, n, B, 1, 0, C, 1); \ +#define TV_DEF(T, L) \ + inline void tv(int m, int n, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasTrans, m, n, 1, A, n, B, 1, 0, C, 1); \ } TV_DEF(double, d) @@ -1524,106 +1260,98 @@ namespace numpy #undef TV_DEF -#define MV_DEF(T, K, L) \ - inline void mv(int m, int n, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasNoTrans, n, m, (K *)&alpha, (K *)A, m, (K *)B, 1, \ - (K *)&beta, (K *)C, 1); \ +#define MV_DEF(T, K, L) \ + inline void mv(int m, int n, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasNoTrans, n, m, (K *)&alpha, (K *)A, m, (K *)B, 1, (K *)&beta, (K *)C, 1); \ } MV_DEF(std::complex, float, c) MV_DEF(std::complex, double, z) #undef MV_DEF template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 1, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 1, + types::ndarray>> dot(types::ndarray const &f, types::ndarray const &e) { - types::ndarray> out( - types::pshape{f.template shape<0>()}, builtins::None); + types::ndarray> out(types::pshape{f.template shape<0>()}, + builtins::None); const int m = f.template shape<1>(), n = f.template shape<0>(); mv(m, n, f.buffer, e.buffer, out.buffer); return out; } template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 1, - types::ndarray>>::type - dot(types::numpy_texpr> const &f, - types::ndarray const &e) + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 1, + types::ndarray>> + dot(types::numpy_texpr> const &f, types::ndarray const &e) { - types::ndarray> out( - types::pshape{f.template shape<0>()}, builtins::None); + types::ndarray> out(types::pshape{f.template shape<0>()}, + builtins::None); const int m = f.template shape<1>(), n = f.template shape<0>(); tv(m, n, f.arg.buffer, e.buffer, out.buffer); return out; } // The trick is to not transpose the matrix so that MV become VM -#define VM_DEF(T, L) \ - inline void vm(int m, int n, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasTrans, n, m, 1, A, m, B, 1, 0, C, 1); \ +#define VM_DEF(T, L) \ + inline void vm(int m, int n, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasTrans, n, m, 1, A, m, B, 1, 0, C, 1); \ } VM_DEF(double, d) VM_DEF(float, s) #undef VM_DEF -#define VT_DEF(T, L) \ - inline void vt(int m, int n, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasNoTrans, m, n, 1, A, n, B, 1, 0, C, 1); \ +#define VT_DEF(T, L) \ + inline void vt(int m, int n, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasNoTrans, m, n, 1, A, n, B, 1, 0, C, 1); \ } VT_DEF(double, d) VT_DEF(float, s) #undef VM_DEF -#define VM_DEF(T, K, L) \ - inline void vm(int m, int n, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemv) \ - (CblasRowMajor, CblasTrans, n, m, (K *)&alpha, (K *)A, m, (K *)B, 1, \ - (K *)&beta, (K *)C, 1); \ +#define VM_DEF(T, K, L) \ + inline void vm(int m, int n, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemv) \ + (CblasRowMajor, CblasTrans, n, m, (K *)&alpha, (K *)A, m, (K *)B, 1, (K *)&beta, (K *)C, 1); \ } VM_DEF(std::complex, float, c) VM_DEF(std::complex, double, z) #undef VM_DEF template - typename std::enable_if::value && - std::tuple_size::value == 1 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 1 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::ndarray const &e, types::ndarray const &f) { - types::ndarray> out( - types::pshape{f.template shape<1>()}, builtins::None); + types::ndarray> out(types::pshape{f.template shape<1>()}, + builtins::None); const int m = f.template shape<1>(), n = f.template shape<0>(); vm(m, n, f.buffer, e.buffer, out.buffer); return out; } template - typename std::enable_if::value && - std::tuple_size::value == 1 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::ndarray const &e, - types::numpy_texpr> const &f) + std::enable_if_t::value && std::tuple_size::value == 1 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::ndarray const &e, types::numpy_texpr> const &f) { - types::ndarray> out( - types::pshape{f.template shape<1>()}, builtins::None); + types::ndarray> out(types::pshape{f.template shape<1>()}, + builtins::None); const int m = f.template shape<1>(), n = f.template shape<0>(); vt(m, n, f.arg.buffer, e.buffer, out.buffer); return out; @@ -1632,27 +1360,23 @@ namespace numpy // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 2 && F::value == 1, // And it is matrix / vect - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 2 && F::value == 1, // And it is matrix / vect + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - typename E::shape_t> + types::ndarray::type, + typename E::shape_t> e_ = e; - types::ndarray< - typename __combined::type, - typename F::shape_t> + types::ndarray::type, + typename F::shape_t> f_ = f; return dot(e_, f_); } @@ -1660,27 +1384,23 @@ namespace numpy // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 1 && F::value == 2, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 1 && F::value == 2, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - typename E::shape_t> + types::ndarray::type, + typename E::shape_t> e_ = e; - types::ndarray< - typename __combined::type, - typename F::shape_t> + types::ndarray::type, + typename F::shape_t> f_ = f; return dot(e_, f_); } @@ -1688,18 +1408,15 @@ namespace numpy // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix vector multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 1 && F::value == 2, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 1 && F::value == 2, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> out(types::pshape{f.template shape<1>()}, 0); for (long i = 0; i < out.template shape<0>(); i++) for (long j = 0; j < f.template shape<0>(); j++) @@ -1710,18 +1427,15 @@ namespace numpy // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix vector multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 2 && F::value == 1, // And it is vect / matrix - types::ndarray< - typename __combined::type, - types::pshape>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 2 && F::value == 1, // And it is vect / matrix + types::ndarray::type, + types::pshape>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> out(types::pshape{e.template shape<0>()}, 0); for (long i = 0; i < out.template shape<0>(); i++) for (long j = 0; j < f.template shape<0>(); j++) @@ -1731,171 +1445,155 @@ namespace numpy /// Matrix / Matrix multiplication -#define MM_DEF(T, L) \ - inline void mm(int m, int n, int k, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, 1, A, k, B, n, 0, C, \ - n); \ +#define MM_DEF(T, L) \ + inline void mm(int m, int n, int k, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, 1, A, k, B, n, 0, C, n); \ } MM_DEF(double, d) MM_DEF(float, s) #undef MM_DEF -#define MM_DEF(T, K, L) \ - inline void mm(int m, int n, int k, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, (K *)&alpha, (K *)A, \ - k, (K *)B, n, (K *)&beta, (K *)C, n); \ +#define MM_DEF(T, K, L) \ + inline void mm(int m, int n, int k, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, k, (K *)&alpha, (K *)A, k, (K *)B, n, \ + (K *)&beta, (K *)C, n); \ } MM_DEF(std::complex, float, c) MM_DEF(std::complex, double, z) #undef MM_DEF template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::ndarray const &a, types::ndarray const &b) { - int n = b.template shape<1>(), m = a.template shape<0>(), - k = b.template shape<0>(); + int n = b.template shape<1>(), m = a.template shape<0>(), k = b.template shape<0>(); - types::ndarray> out( - types::array_tuple{{m, n}}, builtins::None); + types::ndarray> out(types::array_tuple{{m, n}}, + builtins::None); mm(m, n, k, a.buffer, b.buffer, out.buffer); return out; } template - typename std::enable_if< - is_blas_type::value && std::tuple_size::value == 2 && - std::tuple_size::value == 2 && std::tuple_size::value == 2, - types::ndarray>::type & - dot(types::ndarray const &a, types::ndarray const &b, - types::ndarray &c) + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2 && std::tuple_size::value == 2, + types::ndarray> & + dot(types::ndarray const &a, types::ndarray const &b, types::ndarray &c) { - int n = b.template shape<1>(), m = a.template shape<0>(), - k = b.template shape<0>(); + int n = b.template shape<1>(), m = a.template shape<0>(), k = b.template shape<0>(); mm(m, n, k, a.buffer, b.buffer, c.buffer); return c; } -#define TM_DEF(T, L) \ - inline void tm(int m, int n, int k, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasTrans, CblasNoTrans, m, n, k, 1, A, m, B, n, 0, C, \ - n); \ +#define TM_DEF(T, L) \ + inline void tm(int m, int n, int k, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasTrans, CblasNoTrans, m, n, k, 1, A, m, B, n, 0, C, n); \ } TM_DEF(double, d) TM_DEF(float, s) #undef TM_DEF -#define TM_DEF(T, K, L) \ - inline void tm(int m, int n, int k, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasTrans, CblasNoTrans, m, n, k, (K *)&alpha, (K *)A, m, \ - (K *)B, n, (K *)&beta, (K *)C, n); \ +#define TM_DEF(T, K, L) \ + inline void tm(int m, int n, int k, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasTrans, CblasNoTrans, m, n, k, (K *)&alpha, (K *)A, m, (K *)B, n, \ + (K *)&beta, (K *)C, n); \ } TM_DEF(std::complex, float, c) TM_DEF(std::complex, double, z) #undef TM_DEF template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::numpy_texpr> const &a, - types::ndarray const &b) + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::numpy_texpr> const &a, types::ndarray const &b) { - int n = b.template shape<1>(), m = a.template shape<0>(), - k = b.template shape<0>(); + int n = b.template shape<1>(), m = a.template shape<0>(), k = b.template shape<0>(); - types::ndarray> out( - types::array_tuple{{m, n}}, builtins::None); + types::ndarray> out(types::array_tuple{{m, n}}, + builtins::None); tm(m, n, k, a.arg.buffer, b.buffer, out.buffer); return out; } -#define MT_DEF(T, L) \ - inline void mt(int m, int n, int k, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasNoTrans, CblasTrans, m, n, k, 1, A, k, B, k, 0, C, \ - n); \ +#define MT_DEF(T, L) \ + inline void mt(int m, int n, int k, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasNoTrans, CblasTrans, m, n, k, 1, A, k, B, k, 0, C, n); \ } MT_DEF(double, d) MT_DEF(float, s) #undef MT_DEF -#define MT_DEF(T, K, L) \ - inline void mt(int m, int n, int k, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasNoTrans, CblasTrans, m, n, k, (K *)&alpha, (K *)A, k, \ - (K *)B, k, (K *)&beta, (K *)C, n); \ +#define MT_DEF(T, K, L) \ + inline void mt(int m, int n, int k, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasNoTrans, CblasTrans, m, n, k, (K *)&alpha, (K *)A, k, (K *)B, k, \ + (K *)&beta, (K *)C, n); \ } MT_DEF(std::complex, float, c) MT_DEF(std::complex, double, z) #undef MT_DEF template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type - dot(types::ndarray const &a, - types::numpy_texpr> const &b) + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> + dot(types::ndarray const &a, types::numpy_texpr> const &b) { - int n = b.template shape<1>(), m = a.template shape<0>(), - k = b.template shape<0>(); + int n = b.template shape<1>(), m = a.template shape<0>(), k = b.template shape<0>(); - types::ndarray> out( - types::array_tuple{{m, n}}, builtins::None); + types::ndarray> out(types::array_tuple{{m, n}}, + builtins::None); mt(m, n, k, a.buffer, b.arg.buffer, out.buffer); return out; } -#define TT_DEF(T, L) \ - inline void tt(int m, int n, int k, T *A, T *B, T *C) \ - { \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasTrans, CblasTrans, m, n, k, 1, A, m, B, k, 0, C, n); \ +#define TT_DEF(T, L) \ + inline void tt(int m, int n, int k, T *A, T *B, T *C) \ + { \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasTrans, CblasTrans, m, n, k, 1, A, m, B, k, 0, C, n); \ } TT_DEF(double, d) TT_DEF(float, s) #undef TT_DEF -#define TT_DEF(T, K, L) \ - inline void tt(int m, int n, int k, T *A, T *B, T *C) \ - { \ - T alpha = 1, beta = 0; \ - BLAS_MANGLE(cblas_##L##gemm) \ - (CblasRowMajor, CblasTrans, CblasTrans, m, n, k, (K *)&alpha, (K *)A, m, \ - (K *)B, k, (K *)&beta, (K *)C, n); \ +#define TT_DEF(T, K, L) \ + inline void tt(int m, int n, int k, T *A, T *B, T *C) \ + { \ + T alpha = 1, beta = 0; \ + BLAS_MANGLE(cblas_##L##gemm) \ + (CblasRowMajor, CblasTrans, CblasTrans, m, n, k, (K *)&alpha, (K *)A, m, (K *)B, k, \ + (K *)&beta, (K *)C, n); \ } TT_DEF(std::complex, float, c) TT_DEF(std::complex, double, z) #undef TT_DEF template - typename std::enable_if::value && - std::tuple_size::value == 2 && - std::tuple_size::value == 2, - types::ndarray>>::type + std::enable_if_t::value && std::tuple_size::value == 2 && + std::tuple_size::value == 2, + types::ndarray>> dot(types::numpy_texpr> const &a, types::numpy_texpr> const &b) { - int n = b.template shape<1>(), m = a.template shape<0>(), - k = b.template shape<0>(); + int n = b.template shape<1>(), m = a.template shape<0>(), k = b.template shape<0>(); - types::ndarray> out( - types::array_tuple{{m, n}}, builtins::None); + types::ndarray> out(types::array_tuple{{m, n}}, + builtins::None); tt(m, n, k, a.arg.buffer, b.arg.buffer, out.buffer); return out; } @@ -1903,27 +1601,23 @@ namespace numpy // If arguments could be use with blas, we evaluate them as we need pointer // on array for blas template - typename std::enable_if< - types::is_numexpr_arg::value && - types::is_numexpr_arg::value // It is an array_like - && (!(types::is_ndarray::value && types::is_ndarray::value) || - !std::is_same::value) && - is_blas_type::value && - is_blas_type::value // With dtype compatible with - // blas - && E::value == 2 && F::value == 2, // And both are matrix - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t::value && + types::is_numexpr_arg::value // It is an array_like + && (!(types::is_ndarray::value && types::is_ndarray::value) || + !std::is_same::value) && + is_blas_type::value && + is_blas_type::value // With dtype compatible with + // blas + && E::value == 2 && F::value == 2, // And both are matrix + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - typename E::shape_t> + types::ndarray::type, + typename E::shape_t> e_ = e; - types::ndarray< - typename __combined::type, - typename F::shape_t> + types::ndarray::type, + typename F::shape_t> f_ = f; return dot(e_, f_); } @@ -1931,41 +1625,31 @@ namespace numpy // If one of the arg doesn't have a "blas compatible type", we use a slow // matrix multiplication. template - typename std::enable_if< - (!is_blas_type::value || - !is_blas_type::value) && - E::value == 2 && F::value == 2, // And it is matrix / matrix - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(!is_blas_type::value || + !is_blas_type::value) && + E::value == 2 && F::value == 2, // And it is matrix / matrix + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f) { - types::ndarray< - typename __combined::type, - types::array_tuple> - out(types::array_tuple{{e.template shape<0>(), - f.template shape<1>()}}, - 0); + types::ndarray::type, + types::array_tuple> + out(types::array_tuple{{e.template shape<0>(), f.template shape<1>()}}, 0); for (long i = 0; i < out.template shape<0>(); i++) for (long j = 0; j < out.template shape<1>(); j++) for (long k = 0; k < e.template shape<1>(); k++) out[types::array_tuple{{i, j}}] += - e[types::array_tuple{{i, k}}] * - f[types::array_tuple{{k, j}}]; + e[types::array_tuple{{i, k}}] * f[types::array_tuple{{k, j}}]; return out; } template - typename std::enable_if< - (E::value >= 3 && F::value == 1), // And it is matrix / matrix - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(E::value >= 3 && F::value == 1), // And it is matrix / matrix + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f) { - auto out = dot(e.reshape(types::array_tuple{ - {sutils::prod_head(e), f.size()}}), - f); + auto out = dot(e.reshape(types::array_tuple{{sutils::prod_head(e), f.size()}}), f); types::array_tuple out_shape; auto tmp = sutils::getshape(e); std::copy(tmp.begin(), tmp.end() - 1, out_shape.begin()); @@ -1973,11 +1657,9 @@ namespace numpy } template - typename std::enable_if< - (E::value >= 3 && F::value >= 2), - types::ndarray< - typename __combined::type, - types::array_tuple>>::type + std::enable_if_t<(E::value >= 3 && F::value >= 2), + types::ndarray::type, + types::array_tuple>> dot(E const &e, F const &f) { static_assert(E::value == 0, "not implemented yet"); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ediff1d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ediff1d.hpp index d194e4cb351..82df86aff7d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ediff1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ediff1d.hpp @@ -14,8 +14,8 @@ namespace numpy { auto arr = asarray(expr); long n = arr.flat_size() - 1; - types::ndarray> out( - types::pshape(n), builtins::None); + types::ndarray> out(types::pshape(n), + builtins::None); // Compute adjacent difference except for the first element std::adjacent_difference(arr.fbegin() + 1, arr.fend(), out.fbegin()); // First element can be done now diff --git a/contrib/python/pythran/pythran/pythonic/numpy/empty.hpp b/contrib/python/pythran/pythran/pythonic/numpy/empty.hpp index 373f5f4dad4..26763b3856b 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/empty.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/empty.hpp @@ -17,22 +17,19 @@ namespace numpy } template - types::ndarray> - empty(pS const &shape, dtype) + types::ndarray> empty(pS const &shape, dtype) { return {(sutils::shape_t)shape, builtins::None}; } template - types::ndarray> empty(long size, - dtype d) + types::ndarray> empty(long size, dtype d) { return empty(types::pshape(size), d); } template - types::ndarray>> + types::ndarray>> empty(std::integral_constant, dtype d) { return empty(types::pshape>({}), d); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/empty_like.hpp b/contrib/python/pythran/pythran/pythonic/numpy/empty_like.hpp index d1776b0def9..e017774b208 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/empty_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/empty_like.hpp @@ -11,16 +11,14 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto empty_like(E const &expr, - dtype d) -> decltype(empty(sutils::getshape(expr), d)) + auto empty_like(E const &expr, dtype d) -> decltype(empty(sutils::getshape(expr), d)) { return empty(sutils::getshape(expr), d); } template auto empty_like(E const &expr, types::none_type) - -> decltype(empty(sutils::getshape(expr), - types::dtype_t())) + -> decltype(empty(sutils::getshape(expr), types::dtype_t())) { return empty(sutils::getshape(expr), types::dtype_t()); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/eye.hpp b/contrib/python/pythran/pythran/pythonic/numpy/eye.hpp index 816a3351782..738f2b4d39c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/eye.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/eye.hpp @@ -12,8 +12,8 @@ namespace numpy { template - types::ndarray> - eye(long N, long M, long k, dtype d) + types::ndarray> eye(long N, long M, long k, + dtype d) { types::ndarray> out = zeros(types::make_tuple(N, M), d); @@ -27,8 +27,8 @@ namespace numpy } template - types::ndarray> - eye(long N, types::none_type M, long k, dtype d) + types::ndarray> eye(long N, types::none_type M, + long k, dtype d) { return eye(N, N, k, d); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/c2c.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/c2c.hpp index bb84da4eaa3..1f7f0e7dfa2 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/c2c.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/c2c.hpp @@ -24,14 +24,11 @@ namespace numpy { using pocketfft::shape_t; using pocketfft::stride_t; - using ldbl_t = - typename std::conditional::type; + using ldbl_t = std::conditional_t; template - types::ndarray< - typename std::enable_if::value, double>::type, - types::array_tuple::value>> + types::ndarray::value, double>, + types::array_tuple::value>> _copy_to_double(types::ndarray const &in_array) { auto out_shape = sutils::getshape(in_array); @@ -42,29 +39,25 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> _copy_to_complex(types::ndarray const &in_array) { auto out_shape = sutils::getshape(in_array); size_t l = in_array.flat_size(); - auto out_array = - numpy::empty(out_shape, types::dtype_t>()); + auto out_array = numpy::empty(out_shape, types::dtype_t>()); std::copy(in_array.buffer, in_array.buffer + l, out_array.buffer); return out_array; } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> _copy_to_complex(types::ndarray const &in_array) { auto out_shape = sutils::getshape(in_array); size_t l = in_array.flat_size(); - auto out_array = numpy::empty( - out_shape, types::dtype_t>()); + auto out_array = numpy::empty(out_shape, types::dtype_t>()); std::copy(in_array.buffer, in_array.buffer + l, out_array.buffer); return out_array; } @@ -102,8 +95,8 @@ namespace numpy } template - T norm_fct(Inorm inorm, const shape_t &shape, const shape_t &axes, - size_t fct = 1, int delta = 0) + T norm_fct(Inorm inorm, const shape_t &shape, const shape_t &axes, size_t fct = 1, + int delta = 0) { // Fast path if (inorm == Inorm::forward) @@ -122,8 +115,8 @@ namespace numpy auto shape = sutils::getshape(in_array); stride_t strides = stride_t(N); strides[N - 1] = sizeof(T); - std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin(), - strides.rbegin() + 1, std::multiplies()); + std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin(), strides.rbegin() + 1, + std::multiplies()); return strides; } @@ -131,14 +124,11 @@ namespace numpy types::ndarray::value>> _pad_in_array(types::ndarray const &in_array, long axis, long n) { - types::ndarray::value>> - extended_array; + types::ndarray::value>> extended_array; auto tmp_shape = sutils::getshape(in_array); tmp_shape[axis] = n; auto tmp_array = zeros(tmp_shape, types::dtype_t()); - types::list::value>>> - bi(0); + types::list::value>>> bi(0); bi.push_back(in_array); bi.push_back(tmp_array); extended_array = concatenate(bi, axis); @@ -161,11 +151,10 @@ namespace numpy auto out_shape = sutils::getshape(in_array); out_shape[axis] = n; // Create output array. - types::ndarray::value>> - out_array(out_shape, builtins::None); + types::ndarray::value>> out_array( + out_shape, builtins::None); std::complex *d_in; - types::ndarray, - types::array_tuple::value>> + types::ndarray, types::array_tuple::value>> extended_array; stride_t in_strides; auto out_strides = create_strides(out_array); @@ -175,8 +164,8 @@ namespace numpy in_strides = create_strides(extended_array); d_in = reinterpret_cast *>(extended_array.buffer); } else { - in_strides = create_strides( - in_array); // for cropped arrays we need to use different strides + in_strides = + create_strides(in_array); // for cropped arrays we need to use different strides d_in = reinterpret_cast *>(in_array.buffer); } auto d_out = reinterpret_cast(out_array.buffer); @@ -186,14 +175,12 @@ namespace numpy shape_t shapes = shape_t(size_t(N)); std::copy(out_shape.begin(), out_shape.begin() + N, shapes.begin()); auto fct = norm_fct(inorm, shapes, axes); - pocketfft::c2r(shapes, in_strides, out_strides, axes, forward, d_in, - d_out, fct, size_t(0)); + pocketfft::c2r(shapes, in_strides, out_strides, axes, forward, d_in, d_out, fct, size_t(0)); return out_array; } template - types::ndarray, - types::array_tuple::value>> + types::ndarray, types::array_tuple::value>> c2c(types::ndarray, pS> const &in_array, long n, long axis, types::str const &norm, bool forward) { @@ -208,12 +195,10 @@ namespace numpy auto out_shape = sutils::getshape(in_array); out_shape[axis] = n; // Create output array. - types::ndarray, - types::array_tuple::value>> + types::ndarray, types::array_tuple::value>> out_array(out_shape, builtins::None); std::complex *d_in; - types::ndarray, - types::array_tuple::value>> + types::ndarray, types::array_tuple::value>> extended_array; stride_t in_strides; if (n > npts) { @@ -223,8 +208,8 @@ namespace numpy in_strides = create_strides(extended_array); // } else { d_in = reinterpret_cast *>(in_array.buffer); - in_strides = create_strides( - in_array); // for cropped arrays we need to use different strides + in_strides = + create_strides(in_array); // for cropped arrays we need to use different strides } auto d_out = reinterpret_cast *>(out_array.buffer); // axes calculation is for 1D transform @@ -235,17 +220,15 @@ namespace numpy for (size_t i = 0; i < N; ++i) shapes[i] = size_t(out_shape[i]); auto fct = norm_fct(inorm, shapes, axes); - pocketfft::c2c(shapes, in_strides, out_strides, axes, forward, d_in, - d_out, fct, size_t(0)); + pocketfft::c2c(shapes, in_strides, out_strides, axes, forward, d_in, d_out, fct, size_t(0)); return out_array; } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - r2c(types::ndarray const &in_array, long n, long axis, - types::str const &norm, bool forward, bool extend = true) + r2c(types::ndarray const &in_array, long n, long axis, types::str const &norm, + bool forward, bool extend = true) { auto constexpr N = std::tuple_size::value; Inorm inorm = _get_inorm(norm, forward); @@ -262,12 +245,10 @@ namespace numpy out_shape[axis] = n / 2 + 1; } // Create output array. - types::ndarray, - types::array_tuple::value>> + types::ndarray, types::array_tuple::value>> out_array(out_shape, builtins::None); T *d_in; - types::ndarray::value>> - extended_array; + types::ndarray::value>> extended_array; shape_t shapes = shape_t(size_t(N)); stride_t in_strides; if (n > npts) { @@ -281,8 +262,8 @@ namespace numpy d_in = reinterpret_cast(in_array.buffer); in_shape[axis] = n; std::copy(in_shape.begin(), in_shape.begin() + N, shapes.begin()); - in_strides = create_strides( - in_array); // for cropped arrays we need to use different strides + in_strides = + create_strides(in_array); // for cropped arrays we need to use different strides } auto d_out = reinterpret_cast *>(out_array.buffer); // axes calculation is for 1D transform @@ -290,8 +271,7 @@ namespace numpy axes[0] = axis; auto out_strides = create_strides(out_array); auto fct = norm_fct(inorm, shapes, axes); - pocketfft::r2c(shapes, in_strides, out_strides, axes, forward, d_in, - d_out, fct, size_t(0)); + pocketfft::r2c(shapes, in_strides, out_strides, axes, forward, d_in, d_out, fct, size_t(0)); if (extend) { using namespace pocketfft::detail; ndarr> ares(out_array.buffer, shapes, out_strides); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/fft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/fft.hpp index 87d093367a2..e504b778004 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/fft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/fft.hpp @@ -39,33 +39,26 @@ namespace numpy } // namespace details template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fft(types::ndarray const &in_array, N const &n, long axis, - Norm const &norm) + types::ndarray::value, T>, + types::array_tuple::value>> + fft(types::ndarray const &in_array, N const &n, long axis, Norm const &norm) { - return c2c(in_array, details::normalize_n(n), axis, - details::normalize_norm(norm), true); + return c2c(in_array, details::normalize_n(n), axis, details::normalize_norm(norm), true); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - fft(types::ndarray const &in_array, N const &n, long axis, - Norm const &norm) + fft(types::ndarray const &in_array, N const &n, long axis, Norm const &norm) { - return r2c(in_array, details::normalize_n(n), axis, - details::normalize_norm(norm), true, true); + return r2c(in_array, details::normalize_n(n), axis, details::normalize_norm(norm), true, + true); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - fft(types::ndarray const &in_array, N const &n, long axis, - Norm const &norm) + fft(types::ndarray const &in_array, N const &n, long axis, Norm const &norm) { auto tmp_array = _copy_to_double(in_array); return fft(tmp_array, n, axis, norm); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/fftn.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/fftn.hpp index 28ce369592c..8783e64b55f 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/fftn.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/fftn.hpp @@ -38,8 +38,7 @@ namespace numpy return result; } template - types::array_base const & - normalize_axes(types::array_base const &axes) + types::array_base const &normalize_axes(types::array_base const &axes) { return axes; } @@ -48,22 +47,20 @@ namespace numpy // without shape template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &in_array, types::none_type s, - Axes const &axes, Norm const &norm) + fftn(types::ndarray const &in_array, types::none_type s, Axes const &axes, + Norm const &norm) { auto tmp_array = _copy_to_double(in_array); return fftn(tmp_array, s, axes, norm); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &in_array, types::none_type s, - Axes const &axes, Norm const &norm) + fftn(types::ndarray const &in_array, types::none_type s, Axes const &axes, + Norm const &norm) { auto naxes = details::normalize_axes::value, 1>(axes); auto nnorm = details::normalize_norm(norm); @@ -74,11 +71,10 @@ namespace numpy } template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fftn(types::ndarray const &in_array, types::none_type s, - Axes const &axes, Norm const &norm) + types::ndarray::value, T>, + types::array_tuple::value>> + fftn(types::ndarray const &in_array, types::none_type s, Axes const &axes, + Norm const &norm) { auto naxes = details::normalize_axes::value, 1>(axes); auto nnorm = details::normalize_norm(norm); @@ -89,25 +85,21 @@ namespace numpy } // with shape - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes, Norm const &norm) + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes, + Norm const &norm) { auto tmp_array = _copy_to_double(a); return fftn(tmp_array, s, axes, norm); } - template - types::ndarray::value, - std::complex>::type, + template + types::ndarray::value, std::complex>, types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes, Norm const &norm) + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes, + Norm const &norm) { auto nnorm = details::normalize_norm(norm); auto naxes = details::normalize_axes::value, N>(axes); @@ -119,13 +111,11 @@ namespace numpy return out; } - template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - fftn(types::ndarray const &a, types::array_base const &s, - Axes const &axes, Norm const &norm) + template + types::ndarray::value, T>, + types::array_tuple::value>> + fftn(types::ndarray const &a, types::array_base const &s, Axes const &axes, + Norm const &norm) { auto nnorm = details::normalize_norm(norm); auto naxes = details::normalize_axes::value, N>(axes); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/hfft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/hfft.hpp index bf230a19bfc..aee58bb1a84 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/hfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/hfft.hpp @@ -17,16 +17,16 @@ namespace numpy template types::ndarray::value>> - hfft(types::ndarray, pS> const &in_array, - types::none_type n, long axis, types::str const &norm) + hfft(types::ndarray, pS> const &in_array, types::none_type n, long axis, + types::str const &norm) { return c2r(in_array, -1, axis, norm, true); } template types::ndarray::value>> - hfft(types::ndarray, pS> const &in_array, - types::none_type n, long axis, types::none_type norm) + hfft(types::ndarray, pS> const &in_array, types::none_type n, long axis, + types::none_type norm) { return c2r(in_array, -1, axis, "", true); } @@ -48,10 +48,8 @@ namespace numpy } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> hfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -61,10 +59,8 @@ namespace numpy } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> hfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -74,26 +70,20 @@ namespace numpy } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - hfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + hfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { auto tmp_array = _copy_to_complex(in_array); return c2r(tmp_array, n, axis, "", true); } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - hfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + hfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { auto tmp_array = _copy_to_complex(in_array); return c2r(tmp_array, n, axis, norm, true); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/ifft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/ifft.hpp index 743615e9923..d724ec5786c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/ifft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/ifft.hpp @@ -16,9 +16,8 @@ namespace numpy { template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> + types::ndarray::value, T>, + types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) { @@ -26,9 +25,8 @@ namespace numpy } template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> + types::ndarray::value, T>, + types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) { @@ -36,28 +34,23 @@ namespace numpy } template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + types::ndarray::value, T>, + types::array_tuple::value>> + ifft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { return c2c(in_array, n, axis, "", false); } template - types::ndarray< - typename std::enable_if::value, T>::type, - types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + types::ndarray::value, T>, + types::array_tuple::value>> + ifft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { return c2c(in_array, n, axis, norm, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -66,8 +59,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -76,28 +68,23 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + ifft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { return r2c(in_array, n, axis, "", false, true); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + ifft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { return r2c(in_array, n, axis, norm, false, true); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -107,8 +94,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ifft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -118,22 +104,18 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + ifft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, "", false, true); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ifft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + ifft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, norm, false, true); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/ihfft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/ihfft.hpp index e8c1fed129e..4a3801649f2 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/ihfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/ihfft.hpp @@ -15,8 +15,7 @@ namespace numpy { template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -25,8 +24,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -35,28 +33,23 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + ihfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { return r2c(in_array, n, axis, "", false, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + ihfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { return r2c(in_array, n, axis, norm, false, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -66,8 +59,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> ihfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -77,22 +69,18 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + ihfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, "", false, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - ihfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + ihfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, norm, false, false); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/irfft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/irfft.hpp index 6d3c5a97114..6af35651581 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/irfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/irfft.hpp @@ -17,41 +17,39 @@ namespace numpy template types::ndarray::value>> - irfft(types::ndarray, pS> const &in_array, - types::none_type n, long axis, types::str const &norm) + irfft(types::ndarray, pS> const &in_array, types::none_type n, long axis, + types::str const &norm) { return c2r(in_array, -1, axis, norm, false); } template types::ndarray::value>> - irfft(types::ndarray, pS> const &in_array, - types::none_type n, long axis, types::none_type norm) + irfft(types::ndarray, pS> const &in_array, types::none_type n, long axis, + types::none_type norm) { return c2r(in_array, -1, axis, "", false); } template types::ndarray::value>> - irfft(types::ndarray, pS> const &in_array, long n, - long axis, types::none_type norm) + irfft(types::ndarray, pS> const &in_array, long n, long axis, + types::none_type norm) { return c2r(in_array, n, axis, "", false); } template types::ndarray::value>> - irfft(types::ndarray, pS> const &in_array, long n, - long axis, types::str const &norm) + irfft(types::ndarray, pS> const &in_array, long n, long axis, + types::str const &norm) { return c2r(in_array, n, axis, norm, false); } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> irfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -61,10 +59,8 @@ namespace numpy } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> irfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -74,26 +70,20 @@ namespace numpy } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - irfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + irfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { auto tmp_array = _copy_to_complex(in_array); return c2r(tmp_array, n, axis, "", false); } template - types::ndarray::value, - typename std::conditional::value, - double, T>::type>::type, + types::ndarray::value, + std::conditional_t::value, double, T>>, types::array_tuple::value>> - irfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + irfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { auto tmp_array = _copy_to_complex(in_array); return c2r(tmp_array, n, axis, norm, false); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/pocketfft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/pocketfft.hpp index 3ad32f425d0..503da758cc5 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/pocketfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/pocketfft.hpp @@ -199,9 +199,8 @@ namespace pocketfft free(ptr); } // C++17 in principle has "aligned_alloc", but unfortunately not everywhere ... -#elif (__cplusplus >= 201703L) && \ - ((!defined(__MINGW32__)) || defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)) && \ - (!defined(__APPLE__)) +#elif (__cplusplus >= 201703L) && \ + ((!defined(__MINGW32__)) || defined(_GLIBCXX_HAVE_ALIGNED_ALLOC)) && (!defined(__APPLE__)) static T *ralloc(size_t num) { if (num == 0) @@ -223,8 +222,7 @@ namespace pocketfft void *ptr = malloc(num * sizeof(T) + 64); if (!ptr) throw std::bad_alloc(); - T *res = reinterpret_cast( - (reinterpret_cast(ptr) & ~(size_t(63))) + 64); + T *res = reinterpret_cast((reinterpret_cast(ptr) & ~(size_t(63))) + 64); (reinterpret_cast(res))[-1] = ptr; return res; } @@ -345,26 +343,22 @@ namespace pocketfft return {r * other, i * other}; } template - auto - operator+(const cmplx &other) const -> cmplx + auto operator+(const cmplx &other) const -> cmplx { return {r + other.r, i + other.i}; } template - auto - operator-(const cmplx &other) const -> cmplx + auto operator-(const cmplx &other) const -> cmplx { return {r - other.r, i - other.i}; } template - auto - operator*(const cmplx &other) const -> cmplx + auto operator*(const cmplx &other) const -> cmplx { return {r * other.r - i * other.i, r * other.i + i * other.r}; } template - auto - special_mul(const cmplx &other) const -> cmplx + auto special_mul(const cmplx &other) const -> cmplx { using Tres = cmplx; return fwd ? Tres(r * other.r + i * other.i, i * other.r - r * other.i) @@ -399,9 +393,8 @@ namespace pocketfft template void special_mul(const cmplx &v1, const cmplx &v2, cmplx &res) { - res = - fwd ? cmplx(v1.r * v2.r + v1.i * v2.i, v1.i * v2.r - v1.r * v2.i) - : cmplx(v1.r * v2.r - v1.i * v2.i, v1.r * v2.i + v1.i * v2.r); + res = fwd ? cmplx(v1.r * v2.r + v1.i * v2.i, v1.i * v2.r - v1.r * v2.i) + : cmplx(v1.r * v2.r - v1.i * v2.i, v1.r * v2.i + v1.i * v2.r); } template @@ -426,8 +419,7 @@ namespace pocketfft class sincos_2pibyn { private: - using Thigh = typename std::conditional<(sizeof(T) > sizeof(double)), T, - double>::type; + using Thigh = std::conditional_t<(sizeof(T) > sizeof(double)), T, double>; size_t N, mask, shift; arr> v1, v2; @@ -439,16 +431,13 @@ namespace pocketfft if (x < 2 * n) // first quadrant { if (x < n) - return cmplx(std::cos(Thigh(x) * ang), - std::sin(Thigh(x) * ang)); - return cmplx(std::sin(Thigh(2 * n - x) * ang), - std::cos(Thigh(2 * n - x) * ang)); + return cmplx(std::cos(Thigh(x) * ang), std::sin(Thigh(x) * ang)); + return cmplx(std::sin(Thigh(2 * n - x) * ang), std::cos(Thigh(2 * n - x) * ang)); } else // second quadrant { x -= 2 * n; if (x < n) - return cmplx(-std::sin(Thigh(x) * ang), - std::cos(Thigh(x) * ang)); + return cmplx(-std::sin(Thigh(x) * ang), std::cos(Thigh(x) * ang)); return cmplx(-std::cos(Thigh(2 * n - x) * ang), std::sin(Thigh(2 * n - x) * ang)); } @@ -457,16 +446,14 @@ namespace pocketfft if (x < 2 * n) // third quadrant { if (x < n) - return cmplx(std::cos(Thigh(x) * ang), - -std::sin(Thigh(x) * ang)); + return cmplx(std::cos(Thigh(x) * ang), -std::sin(Thigh(x) * ang)); return cmplx(std::sin(Thigh(2 * n - x) * ang), -std::cos(Thigh(2 * n - x) * ang)); } else // fourth quadrant { x -= 2 * n; if (x < n) - return cmplx(-std::sin(Thigh(x) * ang), - -std::cos(Thigh(x) * ang)); + return cmplx(-std::sin(Thigh(x) * ang), -std::cos(Thigh(x) * ang)); return cmplx(-std::cos(Thigh(2 * n - x) * ang), -std::sin(Thigh(2 * n - x) * ang)); } @@ -497,13 +484,11 @@ namespace pocketfft { if (2 * idx <= N) { auto x1 = v1[idx & mask], x2 = v2[idx >> shift]; - return cmplx(T(x1.r * x2.r - x1.i * x2.i), - T(x1.r * x2.i + x1.i * x2.r)); + return cmplx(T(x1.r * x2.r - x1.i * x2.i), T(x1.r * x2.i + x1.i * x2.r)); } idx = N - idx; auto x1 = v1[idx & mask], x2 = v2[idx >> shift]; - return cmplx(T(x1.r * x2.r - x1.i * x2.i), - -T(x1.r * x2.i + x1.i * x2.r)); + return cmplx(T(x1.r * x2.r - x1.i * x2.i), -T(x1.r * x2.i + x1.i * x2.r)); } }; @@ -537,9 +522,7 @@ namespace pocketfft } for (size_t x = 3; x * x <= n; x += 2) while ((n % x) == 0) { - result += (x <= 5) - ? double(x) - : lfp * double(x); // penalize larger prime factors + result += (x <= 5) ? double(x) : lfp * double(x); // penalize larger prime factors n /= x; } if (n > 1) @@ -611,10 +594,8 @@ namespace pocketfft return res; } - static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, - const stride_t &stride_in, - const stride_t &stride_out, - bool inplace) + static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, const stride_t &stride_in, + const stride_t &stride_out, bool inplace) { auto ndim = shape.size(); if (ndim < 1) @@ -625,10 +606,8 @@ namespace pocketfft throw std::runtime_error("stride mismatch"); } - static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, - const stride_t &stride_in, - const stride_t &stride_out, - bool inplace, + static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, const stride_t &stride_in, + const stride_t &stride_out, bool inplace, const shape_t &axes) { sanity_check(shape, stride_in, stride_out, inplace); @@ -642,10 +621,9 @@ namespace pocketfft } } - static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, - const stride_t &stride_in, - const stride_t &stride_out, - bool inplace, size_t axis) + static POCKETFFT_NOINLINE void sanity_check(const shape_t &shape, const stride_t &stride_in, + const stride_t &stride_out, bool inplace, + size_t axis) { sanity_check(shape, stride_in, stride_out, inplace); if (axis >= shape.size()) @@ -653,14 +631,13 @@ namespace pocketfft } #ifdef POCKETFFT_NO_MULTITHREADING - static size_t thread_count(size_t /*nthreads*/, const shape_t & /*shape*/, - size_t /*axis*/, size_t /*vlen*/) + static size_t thread_count(size_t /*nthreads*/, const shape_t & /*shape*/, size_t /*axis*/, + size_t /*vlen*/) { return 1; } #else - static size_t thread_count(size_t nthreads, const shape_t &shape, - size_t axis, size_t vlen) + static size_t thread_count(size_t nthreads, const shape_t &shape, size_t axis, size_t vlen) { if (nthreads == 1) return 1; @@ -668,8 +645,7 @@ namespace pocketfft size_t parallel = size / (shape[axis] * vlen); if (shape[axis] < 1000) parallel /= 4; - size_t max_threads = - nthreads == 0 ? std::thread::hardware_concurrency() : nthreads; + size_t max_threads = nthreads == 0 ? std::thread::hardware_concurrency() : nthreads; return std::max(size_t(1), std::min(parallel, max_threads)); } #endif @@ -707,8 +683,7 @@ namespace pocketfft static thread_local size_t num_threads_ = 1; return num_threads_; } - static const size_t max_threads = - std::max(1u, std::thread::hardware_concurrency()); + static const size_t max_threads = std::max(1u, std::thread::hardware_concurrency()); class latch { @@ -930,8 +905,7 @@ namespace pocketfft } template - void pass2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { @@ -940,9 +914,7 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 2 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { @@ -955,37 +927,33 @@ namespace pocketfft CH(0, k, 1) = CC(0, 0, k) - CC(0, 1, k); for (size_t i = 1; i < ido; ++i) { CH(i, k, 0) = CC(i, 0, k) + CC(i, 1, k); - special_mul(CC(i, 0, k) - CC(i, 1, k), WA(0, i), - CH(i, k, 1)); + special_mul(CC(i, 0, k) - CC(i, 1, k), WA(0, i), CH(i, k, 1)); } } } -#define POCKETFFT_PREP3(idx) \ - T t0 = CC(idx, 0, k), t1, t2; \ - PM(t1, t2, CC(idx, 1, k), CC(idx, 2, k)); \ +#define POCKETFFT_PREP3(idx) \ + T t0 = CC(idx, 0, k), t1, t2; \ + PM(t1, t2, CC(idx, 1, k), CC(idx, 2, k)); \ CH(idx, k, 0) = t0 + t1; -#define POCKETFFT_PARTSTEP3a(u1, u2, twr, twi) \ - { \ - T ca = t0 + t1 * twr; \ - T cb{-t2.i * twi, t2.r * twi}; \ - PM(CH(0, k, u1), CH(0, k, u2), ca, cb); \ +#define POCKETFFT_PARTSTEP3a(u1, u2, twr, twi) \ + { \ + T ca = t0 + t1 * twr; \ + T cb{-t2.i * twi, t2.r * twi}; \ + PM(CH(0, k, u1), CH(0, k, u2), ca, cb); \ } -#define POCKETFFT_PARTSTEP3b(u1, u2, twr, twi) \ - { \ - T ca = t0 + t1 * twr; \ - T cb{-t2.i * twi, t2.r * twi}; \ - special_mul(ca + cb, WA(u1 - 1, i), CH(i, k, u1)); \ - special_mul(ca - cb, WA(u2 - 1, i), CH(i, k, u2)); \ +#define POCKETFFT_PARTSTEP3b(u1, u2, twr, twi) \ + { \ + T ca = t0 + t1 * twr; \ + T cb{-t2.i * twi, t2.r * twi}; \ + special_mul(ca + cb, WA(u1 - 1, i), CH(i, k, u1)); \ + special_mul(ca - cb, WA(u2 - 1, i), CH(i, k, u2)); \ } template - void pass3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { - constexpr T0 tw1r = -0.5, - tw1i = (fwd ? -1 : 1) * - T0(0.8660254037844386467637231707529362L); + constexpr T0 tw1r = -0.5, tw1i = (fwd ? -1 : 1) * T0(0.8660254037844386467637231707529362L); auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { return ch[a + ido * (b + l1 * c)]; @@ -993,9 +961,7 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 3 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { @@ -1020,8 +986,7 @@ namespace pocketfft #undef POCKETFFT_PREP3 template - void pass4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { @@ -1030,9 +995,7 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 4 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { @@ -1055,8 +1018,7 @@ namespace pocketfft } for (size_t i = 1; i < ido; ++i) { T t1, t2, t3, t4; - T cc0 = CC(i, 0, k), cc1 = CC(i, 1, k), cc2 = CC(i, 2, k), - cc3 = CC(i, 3, k); + T cc0 = CC(i, 0, k), cc1 = CC(i, 1, k), cc2 = CC(i, 2, k), cc3 = CC(i, 3, k); PM(t2, t1, cc0, cc2); PM(t3, t4, cc1, cc3); ROTX90(t4); @@ -1068,44 +1030,41 @@ namespace pocketfft } } -#define POCKETFFT_PREP5(idx) \ - T t0 = CC(idx, 0, k), t1, t2, t3, t4; \ - PM(t1, t4, CC(idx, 1, k), CC(idx, 4, k)); \ - PM(t2, t3, CC(idx, 2, k), CC(idx, 3, k)); \ - CH(idx, k, 0).r = t0.r + t1.r + t2.r; \ +#define POCKETFFT_PREP5(idx) \ + T t0 = CC(idx, 0, k), t1, t2, t3, t4; \ + PM(t1, t4, CC(idx, 1, k), CC(idx, 4, k)); \ + PM(t2, t3, CC(idx, 2, k), CC(idx, 3, k)); \ + CH(idx, k, 0).r = t0.r + t1.r + t2.r; \ CH(idx, k, 0).i = t0.i + t1.i + t2.i; -#define POCKETFFT_PARTSTEP5a(u1, u2, twar, twbr, twai, twbi) \ - { \ - T ca, cb; \ - ca.r = t0.r + twar * t1.r + twbr * t2.r; \ - ca.i = t0.i + twar * t1.i + twbr * t2.i; \ - cb.i = twai * t4.r twbi * t3.r; \ - cb.r = -(twai * t4.i twbi * t3.i); \ - PM(CH(0, k, u1), CH(0, k, u2), ca, cb); \ +#define POCKETFFT_PARTSTEP5a(u1, u2, twar, twbr, twai, twbi) \ + { \ + T ca, cb; \ + ca.r = t0.r + twar * t1.r + twbr * t2.r; \ + ca.i = t0.i + twar * t1.i + twbr * t2.i; \ + cb.i = twai * t4.r twbi * t3.r; \ + cb.r = -(twai * t4.i twbi * t3.i); \ + PM(CH(0, k, u1), CH(0, k, u2), ca, cb); \ } -#define POCKETFFT_PARTSTEP5b(u1, u2, twar, twbr, twai, twbi) \ - { \ - T ca, cb, da, db; \ - ca.r = t0.r + twar * t1.r + twbr * t2.r; \ - ca.i = t0.i + twar * t1.i + twbr * t2.i; \ - cb.i = twai * t4.r twbi * t3.r; \ - cb.r = -(twai * t4.i twbi * t3.i); \ - special_mul(ca + cb, WA(u1 - 1, i), CH(i, k, u1)); \ - special_mul(ca - cb, WA(u2 - 1, i), CH(i, k, u2)); \ +#define POCKETFFT_PARTSTEP5b(u1, u2, twar, twbr, twai, twbi) \ + { \ + T ca, cb, da, db; \ + ca.r = t0.r + twar * t1.r + twbr * t2.r; \ + ca.i = t0.i + twar * t1.i + twbr * t2.i; \ + cb.i = twai * t4.r twbi * t3.r; \ + cb.r = -(twai * t4.i twbi * t3.i); \ + special_mul(ca + cb, WA(u1 - 1, i), CH(i, k, u1)); \ + special_mul(ca - cb, WA(u2 - 1, i), CH(i, k, u2)); \ } template - void pass5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { constexpr T0 tw1r = T0(0.3090169943749474241022934171828191L), - tw1i = (fwd ? -1 : 1) * - T0(0.9510565162951535721164393333793821L), + tw1i = (fwd ? -1 : 1) * T0(0.9510565162951535721164393333793821L), tw2r = T0(-0.8090169943749474241022934171828191L), - tw2i = (fwd ? -1 : 1) * - T0(0.5877852522924731291687059546390728L); + tw2i = (fwd ? -1 : 1) * T0(0.5877852522924731291687059546390728L); auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { return ch[a + ido * (b + l1 * c)]; @@ -1113,9 +1072,7 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 5 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { @@ -1142,48 +1099,43 @@ namespace pocketfft #undef POCKETFFT_PARTSTEP5a #undef POCKETFFT_PREP5 -#define POCKETFFT_PREP7(idx) \ - T t1 = CC(idx, 0, k), t2, t3, t4, t5, t6, t7; \ - PM(t2, t7, CC(idx, 1, k), CC(idx, 6, k)); \ - PM(t3, t6, CC(idx, 2, k), CC(idx, 5, k)); \ - PM(t4, t5, CC(idx, 3, k), CC(idx, 4, k)); \ - CH(idx, k, 0).r = t1.r + t2.r + t3.r + t4.r; \ +#define POCKETFFT_PREP7(idx) \ + T t1 = CC(idx, 0, k), t2, t3, t4, t5, t6, t7; \ + PM(t2, t7, CC(idx, 1, k), CC(idx, 6, k)); \ + PM(t3, t6, CC(idx, 2, k), CC(idx, 5, k)); \ + PM(t4, t5, CC(idx, 3, k), CC(idx, 4, k)); \ + CH(idx, k, 0).r = t1.r + t2.r + t3.r + t4.r; \ CH(idx, k, 0).i = t1.i + t2.i + t3.i + t4.i; -#define POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, out1, out2) \ - { \ - T ca, cb; \ - ca.r = t1.r + x1 * t2.r + x2 * t3.r + x3 * t4.r; \ - ca.i = t1.i + x1 * t2.i + x2 * t3.i + x3 * t4.i; \ - cb.i = y1 * t7.r y2 * t6.r y3 * t5.r; \ - cb.r = -(y1 * t7.i y2 * t6.i y3 * t5.i); \ - PM(out1, out2, ca, cb); \ +#define POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, out1, out2) \ + { \ + T ca, cb; \ + ca.r = t1.r + x1 * t2.r + x2 * t3.r + x3 * t4.r; \ + ca.i = t1.i + x1 * t2.i + x2 * t3.i + x3 * t4.i; \ + cb.i = y1 * t7.r y2 * t6.r y3 * t5.r; \ + cb.r = -(y1 * t7.i y2 * t6.i y3 * t5.i); \ + PM(out1, out2, ca, cb); \ } -#define POCKETFFT_PARTSTEP7a(u1, u2, x1, x2, x3, y1, y2, y3) \ - POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, CH(0, k, u1), \ - CH(0, k, u2)) -#define POCKETFFT_PARTSTEP7(u1, u2, x1, x2, x3, y1, y2, y3) \ - { \ - T da, db; \ - POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, da, db) \ - special_mul(da, WA(u1 - 1, i), CH(i, k, u1)); \ - special_mul(db, WA(u2 - 1, i), CH(i, k, u2)); \ +#define POCKETFFT_PARTSTEP7a(u1, u2, x1, x2, x3, y1, y2, y3) \ + POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, CH(0, k, u1), CH(0, k, u2)) +#define POCKETFFT_PARTSTEP7(u1, u2, x1, x2, x3, y1, y2, y3) \ + { \ + T da, db; \ + POCKETFFT_PARTSTEP7a0(u1, u2, x1, x2, x3, y1, y2, y3, da, db) \ + special_mul(da, WA(u1 - 1, i), CH(i, k, u1)); \ + special_mul(db, WA(u2 - 1, i), CH(i, k, u2)); \ } template - void pass7(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass7(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { constexpr T0 tw1r = T0(0.6234898018587335305250048840042398L), - tw1i = (fwd ? -1 : 1) * - T0(0.7818314824680298087084445266740578L), + tw1i = (fwd ? -1 : 1) * T0(0.7818314824680298087084445266740578L), tw2r = T0(-0.2225209339563144042889025644967948L), - tw2i = (fwd ? -1 : 1) * - T0(0.9749279121818236070181316829939312L), + tw2i = (fwd ? -1 : 1) * T0(0.9749279121818236070181316829939312L), tw3r = T0(-0.9009688679024191262361023195074451L), - tw3i = (fwd ? -1 : 1) * - T0(0.433883739117558120475768332848359L); + tw3i = (fwd ? -1 : 1) * T0(0.433883739117558120475768332848359L); auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { return ch[a + ido * (b + l1 * c)]; @@ -1191,28 +1143,22 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 7 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { POCKETFFT_PREP7(0) POCKETFFT_PARTSTEP7a(1, 6, tw1r, tw2r, tw3r, +tw1i, +tw2i, +tw3i) - POCKETFFT_PARTSTEP7a(2, 5, tw2r, tw3r, tw1r, +tw2i, -tw3i, - -tw1i) - POCKETFFT_PARTSTEP7a(3, 4, tw3r, tw1r, tw2r, +tw3i, -tw1i, - +tw2i) + POCKETFFT_PARTSTEP7a(2, 5, tw2r, tw3r, tw1r, +tw2i, -tw3i, -tw1i) + POCKETFFT_PARTSTEP7a(3, 4, tw3r, tw1r, tw2r, +tw3i, -tw1i, +tw2i) } else for (size_t k = 0; k < l1; ++k) { { POCKETFFT_PREP7(0) POCKETFFT_PARTSTEP7a(1, 6, tw1r, tw2r, tw3r, +tw1i, +tw2i, +tw3i) - POCKETFFT_PARTSTEP7a(2, 5, tw2r, tw3r, tw1r, +tw2i, -tw3i, - -tw1i) - POCKETFFT_PARTSTEP7a(3, 4, tw3r, tw1r, tw2r, +tw3i, -tw1i, - +tw2i) + POCKETFFT_PARTSTEP7a(2, 5, tw2r, tw3r, tw1r, +tw2i, -tw3i, -tw1i) + POCKETFFT_PARTSTEP7a(3, 4, tw3r, tw1r, tw2r, +tw3i, -tw1i, +tw2i) } for (size_t i = 1; i < ido; ++i) { POCKETFFT_PREP7(i) @@ -1258,8 +1204,7 @@ namespace pocketfft } template - void pass8(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass8(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { @@ -1268,9 +1213,7 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 8 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { @@ -1342,52 +1285,47 @@ namespace pocketfft } } -#define POCKETFFT_PREP11(idx) \ - T t1 = CC(idx, 0, k), t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; \ - PM(t2, t11, CC(idx, 1, k), CC(idx, 10, k)); \ - PM(t3, t10, CC(idx, 2, k), CC(idx, 9, k)); \ - PM(t4, t9, CC(idx, 3, k), CC(idx, 8, k)); \ - PM(t5, t8, CC(idx, 4, k), CC(idx, 7, k)); \ - PM(t6, t7, CC(idx, 5, k), CC(idx, 6, k)); \ - CH(idx, k, 0).r = t1.r + t2.r + t3.r + t4.r + t5.r + t6.r; \ +#define POCKETFFT_PREP11(idx) \ + T t1 = CC(idx, 0, k), t2, t3, t4, t5, t6, t7, t8, t9, t10, t11; \ + PM(t2, t11, CC(idx, 1, k), CC(idx, 10, k)); \ + PM(t3, t10, CC(idx, 2, k), CC(idx, 9, k)); \ + PM(t4, t9, CC(idx, 3, k), CC(idx, 8, k)); \ + PM(t5, t8, CC(idx, 4, k), CC(idx, 7, k)); \ + PM(t6, t7, CC(idx, 5, k), CC(idx, 6, k)); \ + CH(idx, k, 0).r = t1.r + t2.r + t3.r + t4.r + t5.r + t6.r; \ CH(idx, k, 0).i = t1.i + t2.i + t3.i + t4.i + t5.i + t6.i; -#define POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, \ - out1, out2) \ - { \ - T ca = t1 + t2 * x1 + t3 * x2 + t4 * x3 + t5 * x4 + t6 * x5, cb; \ - cb.i = y1 * t11.r y2 * t10.r y3 * t9.r y4 * t8.r y5 * t7.r; \ - cb.r = -(y1 * t11.i y2 * t10.i y3 * t9.i y4 * t8.i y5 * t7.i); \ - PM(out1, out2, ca, cb); \ +#define POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, out1, out2) \ + { \ + T ca = t1 + t2 * x1 + t3 * x2 + t4 * x3 + t5 * x4 + t6 * x5, cb; \ + cb.i = y1 * t11.r y2 * t10.r y3 * t9.r y4 * t8.r y5 * t7.r; \ + cb.r = -(y1 * t11.i y2 * t10.i y3 * t9.i y4 * t8.i y5 * t7.i); \ + PM(out1, out2, ca, cb); \ } -#define POCKETFFT_PARTSTEP11a(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5) \ - POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, \ - CH(0, k, u1), CH(0, k, u2)) -#define POCKETFFT_PARTSTEP11(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5) \ - { \ - T da, db; \ - POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, da, \ - db) \ - special_mul(da, WA(u1 - 1, i), CH(i, k, u1)); \ - special_mul(db, WA(u2 - 1, i), CH(i, k, u2)); \ +#define POCKETFFT_PARTSTEP11a(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5) \ + POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, CH(0, k, u1), CH(0, k, u2)) +#define POCKETFFT_PARTSTEP11(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5) \ + { \ + T da, db; \ + POCKETFFT_PARTSTEP11a0(u1, u2, x1, x2, x3, x4, x5, y1, y2, y3, y4, y5, da, db) \ + special_mul(da, WA(u1 - 1, i), CH(i, k, u1)); \ + special_mul(db, WA(u2 - 1, i), CH(i, k, u2)); \ } template - void pass11(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void pass11(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa) const { - constexpr T0 - tw1r = T0(0.8412535328311811688618116489193677L), - tw1i = (fwd ? -1 : 1) * T0(0.5406408174555975821076359543186917L), - tw2r = T0(0.4154150130018864255292741492296232L), - tw2i = (fwd ? -1 : 1) * T0(0.9096319953545183714117153830790285L), - tw3r = T0(-0.1423148382732851404437926686163697L), - tw3i = (fwd ? -1 : 1) * T0(0.9898214418809327323760920377767188L), - tw4r = T0(-0.6548607339452850640569250724662936L), - tw4i = (fwd ? -1 : 1) * T0(0.7557495743542582837740358439723444L), - tw5r = T0(-0.9594929736144973898903680570663277L), - tw5i = (fwd ? -1 : 1) * T0(0.2817325568414296977114179153466169L); + constexpr T0 tw1r = T0(0.8412535328311811688618116489193677L), + tw1i = (fwd ? -1 : 1) * T0(0.5406408174555975821076359543186917L), + tw2r = T0(0.4154150130018864255292741492296232L), + tw2i = (fwd ? -1 : 1) * T0(0.9096319953545183714117153830790285L), + tw3r = T0(-0.1423148382732851404437926686163697L), + tw3i = (fwd ? -1 : 1) * T0(0.9898214418809327323760920377767188L), + tw4r = T0(-0.6548607339452850640569250724662936L), + tw4i = (fwd ? -1 : 1) * T0(0.7557495743542582837740358439723444L), + tw5r = T0(-0.9594929736144973898903680570663277L), + tw5i = (fwd ? -1 : 1) * T0(0.2817325568414296977114179153466169L); auto CH = [ch, ido, l1](size_t a, size_t b, size_t c) -> T & { return ch[a + ido * (b + l1 * c)]; @@ -1395,55 +1333,47 @@ namespace pocketfft auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 11 * c)]; }; - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i - 1 + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i - 1 + x * (ido - 1)]; }; if (ido == 1) for (size_t k = 0; k < l1; ++k) { POCKETFFT_PREP11(0) - POCKETFFT_PARTSTEP11a(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, - +tw2i, +tw3i, +tw4i, +tw5i) - POCKETFFT_PARTSTEP11a(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, +tw2i, - +tw4i, -tw5i, -tw3i, -tw1i) - POCKETFFT_PARTSTEP11a(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, - +tw3i, -tw5i, -tw2i, +tw1i, +tw4i) - POCKETFFT_PARTSTEP11a(4, 7, tw4r, tw3r, tw1r, tw5r, - tw2r, +tw4i, -tw3i, +tw1i, +tw5i, - -tw2i) - POCKETFFT_PARTSTEP11a(5, 6, tw5r, tw1r, tw4r, tw2r, - tw3r, +tw5i, -tw1i, +tw4i, - -tw2i, +tw3i) + POCKETFFT_PARTSTEP11a(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, +tw2i, +tw3i, +tw4i, + +tw5i) POCKETFFT_PARTSTEP11a(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, + +tw2i, +tw4i, -tw5i, -tw3i, -tw1i) + POCKETFFT_PARTSTEP11a(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, +tw3i, -tw5i, -tw2i, + +tw1i, +tw4i) + POCKETFFT_PARTSTEP11a(4, 7, tw4r, tw3r, tw1r, tw5r, tw2r, +tw4i, -tw3i, +tw1i, + +tw5i, -tw2i) + POCKETFFT_PARTSTEP11a(5, 6, tw5r, tw1r, tw4r, tw2r, tw3r, +tw5i, -tw1i, + +tw4i, -tw2i, +tw3i) } else for (size_t k = 0; k < l1; ++k) { { POCKETFFT_PREP11(0) - POCKETFFT_PARTSTEP11a(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, - +tw2i, +tw3i, +tw4i, +tw5i) - POCKETFFT_PARTSTEP11a(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, - +tw2i, +tw4i, -tw5i, -tw3i, -tw1i) - POCKETFFT_PARTSTEP11a(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, - +tw3i, -tw5i, -tw2i, +tw1i, +tw4i) - POCKETFFT_PARTSTEP11a(4, 7, tw4r, tw3r, tw1r, tw5r, - tw2r, +tw4i, -tw3i, +tw1i, - +tw5i, -tw2i) - POCKETFFT_PARTSTEP11a(5, 6, tw5r, tw1r, tw4r, - tw2r, tw3r, +tw5i, -tw1i, - +tw4i, -tw2i, +tw3i) + POCKETFFT_PARTSTEP11a(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, +tw2i, +tw3i, +tw4i, + +tw5i) POCKETFFT_PARTSTEP11a(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, + +tw2i, +tw4i, -tw5i, -tw3i, -tw1i) + POCKETFFT_PARTSTEP11a(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, +tw3i, -tw5i, -tw2i, + +tw1i, +tw4i) + POCKETFFT_PARTSTEP11a(4, 7, tw4r, tw3r, tw1r, tw5r, tw2r, +tw4i, -tw3i, +tw1i, + +tw5i, -tw2i) + POCKETFFT_PARTSTEP11a(5, 6, tw5r, tw1r, tw4r, tw2r, tw3r, +tw5i, -tw1i, + +tw4i, -tw2i, +tw3i) } for (size_t i = 1; i < ido; ++i) { POCKETFFT_PREP11(i) - POCKETFFT_PARTSTEP11(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, - +tw2i, +tw3i, +tw4i, +tw5i) - POCKETFFT_PARTSTEP11(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, +tw2i, - +tw4i, -tw5i, -tw3i, -tw1i) - POCKETFFT_PARTSTEP11(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, +tw3i, - -tw5i, -tw2i, +tw1i, +tw4i) - POCKETFFT_PARTSTEP11(4, 7, tw4r, tw3r, tw1r, tw5r, tw2r, +tw4i, - -tw3i, +tw1i, +tw5i, -tw2i) - POCKETFFT_PARTSTEP11(5, 6, tw5r, tw1r, tw4r, tw2r, tw3r, +tw5i, - -tw1i, +tw4i, -tw2i, +tw3i) + POCKETFFT_PARTSTEP11(1, 10, tw1r, tw2r, tw3r, tw4r, tw5r, +tw1i, +tw2i, +tw3i, +tw4i, + +tw5i) + POCKETFFT_PARTSTEP11(2, 9, tw2r, tw4r, tw5r, tw3r, tw1r, +tw2i, +tw4i, -tw5i, -tw3i, + -tw1i) + POCKETFFT_PARTSTEP11(3, 8, tw3r, tw5r, tw2r, tw1r, tw4r, +tw3i, -tw5i, -tw2i, +tw1i, + +tw4i) + POCKETFFT_PARTSTEP11(4, 7, tw4r, tw3r, tw1r, tw5r, tw2r, +tw4i, -tw3i, +tw1i, +tw5i, + -tw2i) + POCKETFFT_PARTSTEP11(5, 6, tw5r, tw1r, tw4r, tw2r, tw3r, +tw5i, -tw1i, +tw4i, -tw2i, + +tw3i) } } } @@ -1455,8 +1385,7 @@ namespace pocketfft template void passg(size_t ido, size_t ip, size_t l1, T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, - const cmplx *POCKETFFT_RESTRICT wa, + T *POCKETFFT_RESTRICT ch, const cmplx *POCKETFFT_RESTRICT wa, const cmplx *POCKETFFT_RESTRICT csarr) const { const size_t cdim = ip; @@ -1472,12 +1401,8 @@ namespace pocketfft auto CX = [cc, ido, l1](size_t a, size_t b, size_t c) -> T & { return cc[a + ido * (b + l1 * c)]; }; - auto CX2 = [cc, idl1](size_t a, size_t b) -> T & { - return cc[a + idl1 * b]; - }; - auto CH2 = [ch, idl1](size_t a, size_t b) -> const T & { - return ch[a + idl1 * b]; - }; + auto CX2 = [cc, idl1](size_t a, size_t b) -> T & { return cc[a + idl1 * b]; }; + auto CH2 = [ch, idl1](size_t a, size_t b) -> const T & { return ch[a + idl1 * b]; }; arr> wal(ip); wal[0] = cmplx(1., 0.); @@ -1501,14 +1426,10 @@ namespace pocketfft for (size_t l = 1, lc = ip - 1; l < ipph; ++l, --lc) { // j=0 for (size_t ik = 0; ik < idl1; ++ik) { - CX2(ik, l).r = CH2(ik, 0).r + wal[l].r * CH2(ik, 1).r + - wal[2 * l].r * CH2(ik, 2).r; - CX2(ik, l).i = CH2(ik, 0).i + wal[l].r * CH2(ik, 1).i + - wal[2 * l].r * CH2(ik, 2).i; - CX2(ik, lc).r = -wal[l].i * CH2(ik, ip - 1).i - - wal[2 * l].i * CH2(ik, ip - 2).i; - CX2(ik, lc).i = - wal[l].i * CH2(ik, ip - 1).r + wal[2 * l].i * CH2(ik, ip - 2).r; + CX2(ik, l).r = CH2(ik, 0).r + wal[l].r * CH2(ik, 1).r + wal[2 * l].r * CH2(ik, 2).r; + CX2(ik, l).i = CH2(ik, 0).i + wal[l].r * CH2(ik, 1).i + wal[2 * l].r * CH2(ik, 2).i; + CX2(ik, lc).r = -wal[l].i * CH2(ik, ip - 1).i - wal[2 * l].i * CH2(ik, ip - 2).i; + CX2(ik, lc).i = wal[l].i * CH2(ik, ip - 1).r + wal[2 * l].i * CH2(ik, ip - 2).r; } size_t iwal = 2 * l; @@ -1523,14 +1444,10 @@ namespace pocketfft iwal -= ip; cmplx xwal2 = wal[iwal]; for (size_t ik = 0; ik < idl1; ++ik) { - CX2(ik, l).r += - CH2(ik, j).r * xwal.r + CH2(ik, j + 1).r * xwal2.r; - CX2(ik, l).i += - CH2(ik, j).i * xwal.r + CH2(ik, j + 1).i * xwal2.r; - CX2(ik, lc).r -= - CH2(ik, jc).i * xwal.i + CH2(ik, jc - 1).i * xwal2.i; - CX2(ik, lc).i += - CH2(ik, jc).r * xwal.i + CH2(ik, jc - 1).r * xwal2.i; + CX2(ik, l).r += CH2(ik, j).r * xwal.r + CH2(ik, j + 1).r * xwal2.r; + CX2(ik, l).i += CH2(ik, j).i * xwal.r + CH2(ik, j + 1).i * xwal2.r; + CX2(ik, lc).r -= CH2(ik, jc).i * xwal.i + CH2(ik, jc - 1).i * xwal2.i; + CX2(ik, lc).i += CH2(ik, jc).r * xwal.i + CH2(ik, jc - 1).r * xwal2.i; } } for (; j < ipph; ++j, --jc) { @@ -1731,13 +1648,10 @@ namespace pocketfft } template - void radf2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radf2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido, l1](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + l1 * c)]; }; @@ -1758,34 +1672,29 @@ namespace pocketfft for (size_t i = 2; i < ido; i += 2) { size_t ic = ido - i; T tr2, ti2; - MULPM(tr2, ti2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), - CC(i, k, 1)); + MULPM(tr2, ti2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), CC(i, k, 1)); PM(CH(i - 1, 0, k), CH(ic - 1, 1, k), CC(i - 1, k, 0), tr2); PM(CH(i, 0, k), CH(ic, 1, k), ti2, CC(i, k, 0)); } } // a2=a+b; b2=i*(b-a); -#define POCKETFFT_REARRANGE(rx, ix, ry, iy) \ - { \ - auto t1 = rx + ry, t2 = ry - rx, t3 = ix + iy, t4 = ix - iy; \ - rx = t1; \ - ix = t3; \ - ry = t4; \ - iy = t2; \ +#define POCKETFFT_REARRANGE(rx, ix, ry, iy) \ + { \ + auto t1 = rx + ry, t2 = ry - rx, t3 = ix + iy, t4 = ix - iy; \ + rx = t1; \ + ix = t3; \ + ry = t4; \ + iy = t2; \ } template - void radf3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radf3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { - constexpr T0 taur = -0.5, - taui = T0(0.8660254037844386467637231707529362L); + constexpr T0 taur = -0.5, taui = T0(0.8660254037844386467637231707529362L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido, l1](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + l1 * c)]; }; @@ -1817,20 +1726,17 @@ namespace pocketfft T tr3 = taui * dr3; // t3 = taui*i*(d3-d2)? T ti3 = taui * di3; PM(CH(i - 1, 2, k), CH(ic - 1, 1, k), tr2, tr3); // PM(i) = t2+t3 - PM(CH(i, 2, k), CH(ic, 1, k), ti3, ti2); // PM(ic) = conj(t2-t3) + PM(CH(i, 2, k), CH(ic, 1, k), ti3, ti2); // PM(ic) = conj(t2-t3) } } template - void radf4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radf4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { constexpr T0 hsqt2 = T0(0.707106781186547524400844362104849L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido, l1](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + l1 * c)]; }; @@ -1856,14 +1762,10 @@ namespace pocketfft for (size_t k = 0; k < l1; k++) for (size_t i = 2; i < ido; i += 2) { size_t ic = ido - i; - T ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, - tr4; - MULPM(cr2, ci2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), - CC(i, k, 1)); - MULPM(cr3, ci3, WA(1, i - 2), WA(1, i - 1), CC(i - 1, k, 2), - CC(i, k, 2)); - MULPM(cr4, ci4, WA(2, i - 2), WA(2, i - 1), CC(i - 1, k, 3), - CC(i, k, 3)); + T ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; + MULPM(cr2, ci2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), CC(i, k, 1)); + MULPM(cr3, ci3, WA(1, i - 2), WA(1, i - 1), CC(i - 1, k, 2), CC(i, k, 2)); + MULPM(cr4, ci4, WA(2, i - 2), WA(2, i - 1), CC(i - 1, k, 3), CC(i, k, 3)); PM(tr1, tr4, cr4, cr2); PM(ti1, ti4, ci2, ci4); PM(tr2, tr3, CC(i - 1, k, 0), cr3); @@ -1876,8 +1778,7 @@ namespace pocketfft } template - void radf5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radf5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { constexpr T0 tr11 = T0(0.3090169943749474241022934171828191L), @@ -1885,9 +1786,7 @@ namespace pocketfft tr12 = T0(-0.8090169943749474241022934171828191L), ti12 = T0(0.5877852522924731291687059546390728L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido, l1](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + l1 * c)]; }; @@ -1910,14 +1809,10 @@ namespace pocketfft for (size_t k = 0; k < l1; ++k) for (size_t i = 2, ic = ido - 2; i < ido; i += 2, ic -= 2) { T di2, di3, di4, di5, dr2, dr3, dr4, dr5; - MULPM(dr2, di2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), - CC(i, k, 1)); - MULPM(dr3, di3, WA(1, i - 2), WA(1, i - 1), CC(i - 1, k, 2), - CC(i, k, 2)); - MULPM(dr4, di4, WA(2, i - 2), WA(2, i - 1), CC(i - 1, k, 3), - CC(i, k, 3)); - MULPM(dr5, di5, WA(3, i - 2), WA(3, i - 1), CC(i - 1, k, 4), - CC(i, k, 4)); + MULPM(dr2, di2, WA(0, i - 2), WA(0, i - 1), CC(i - 1, k, 1), CC(i, k, 1)); + MULPM(dr3, di3, WA(1, i - 2), WA(1, i - 1), CC(i - 1, k, 2), CC(i, k, 2)); + MULPM(dr4, di4, WA(2, i - 2), WA(2, i - 1), CC(i - 1, k, 3), CC(i, k, 3)); + MULPM(dr5, di5, WA(3, i - 2), WA(3, i - 1), CC(i - 1, k, 4), CC(i, k, 4)); POCKETFFT_REARRANGE(dr2, di2, dr5, di5); POCKETFFT_REARRANGE(dr3, di3, dr4, di4); CH(i - 1, 0, k) = CC(i - 1, k, 0) + dr2 + dr3; @@ -1957,12 +1852,8 @@ namespace pocketfft auto C1 = [cc, ido, l1](size_t a, size_t b, size_t c) -> T & { return cc[a + ido * (b + l1 * c)]; }; - auto C2 = [cc, idl1](size_t a, size_t b) -> T & { - return cc[a + idl1 * b]; - }; - auto CH2 = [ch, idl1](size_t a, size_t b) -> T & { - return ch[a + idl1 * b]; - }; + auto C2 = [cc, idl1](size_t a, size_t b) -> T & { return cc[a + idl1 * b]; }; + auto CH2 = [ch, idl1](size_t a, size_t b) -> T & { return ch[a + idl1 * b]; }; if (ido > 1) { for (size_t j = 1, jc = ip - 1; j < ipph; ++j, --jc) // 114 @@ -1974,10 +1865,8 @@ namespace pocketfft size_t idij2 = is2; for (size_t i = 1; i <= ido - 2; i += 2) // 112 { - T t1 = C1(i, k, j), t2 = C1(i + 1, k, j), t3 = C1(i, k, jc), - t4 = C1(i + 1, k, jc); - T x1 = wa[idij] * t1 + wa[idij + 1] * t2, - x2 = wa[idij] * t2 - wa[idij + 1] * t1, + T t1 = C1(i, k, j), t2 = C1(i + 1, k, j), t3 = C1(i, k, jc), t4 = C1(i + 1, k, jc); + T x1 = wa[idij] * t1 + wa[idij + 1] * t2, x2 = wa[idij] * t2 - wa[idij + 1] * t1, x3 = wa[idij2] * t3 + wa[idij2 + 1] * t4, x4 = wa[idij2] * t4 - wa[idij2 + 1] * t3; PM(C1(i, k, j), C1(i + 1, k, jc), x3, x1); @@ -2000,10 +1889,8 @@ namespace pocketfft { for (size_t ik = 0; ik < idl1; ++ik) // 124 { - CH2(ik, l) = - C2(ik, 0) + csarr[2 * l] * C2(ik, 1) + csarr[4 * l] * C2(ik, 2); - CH2(ik, lc) = csarr[2 * l + 1] * C2(ik, ip - 1) + - csarr[4 * l + 1] * C2(ik, ip - 2); + CH2(ik, l) = C2(ik, 0) + csarr[2 * l] * C2(ik, 1) + csarr[4 * l] * C2(ik, 2); + CH2(ik, lc) = csarr[2 * l + 1] * C2(ik, ip - 1) + csarr[4 * l + 1] * C2(ik, ip - 2); } size_t iang = 2 * l; size_t j = 3, jc = ip - 3; @@ -2027,10 +1914,10 @@ namespace pocketfft T0 ar4 = csarr[2 * iang], ai4 = csarr[2 * iang + 1]; for (size_t ik = 0; ik < idl1; ++ik) // 125 { - CH2(ik, l) += ar1 * C2(ik, j) + ar2 * C2(ik, j + 1) + - ar3 * C2(ik, j + 2) + ar4 * C2(ik, j + 3); - CH2(ik, lc) += ai1 * C2(ik, jc) + ai2 * C2(ik, jc - 1) + - ai3 * C2(ik, jc - 2) + ai4 * C2(ik, jc - 3); + CH2(ik, l) += + ar1 * C2(ik, j) + ar2 * C2(ik, j + 1) + ar3 * C2(ik, j + 2) + ar4 * C2(ik, j + 3); + CH2(ik, lc) += ai1 * C2(ik, jc) + ai2 * C2(ik, jc - 1) + ai3 * C2(ik, jc - 2) + + ai4 * C2(ik, jc - 3); } } for (; j < ipph - 1; j += 2, jc -= 2) // 126 @@ -2091,9 +1978,8 @@ namespace pocketfft for (size_t j = 1, jc = ip - 1; j < ipph; ++j, --jc) // 140 { size_t j2 = 2 * j - 1; - for (size_t k = 0; k < l1; ++k) // 139 - for (size_t i = 1, ic = ido - i - 2; i <= ido - 2; - i += 2, ic -= 2) // 138 + for (size_t k = 0; k < l1; ++k) // 139 + for (size_t i = 1, ic = ido - i - 2; i <= ido - 2; i += 2, ic -= 2) // 138 { CC(i, j2 + 1, k) = CH(i, k, j) + CH(i, k, jc); CC(ic, j2, k) = CH(i, k, j) - CH(i, k, jc); @@ -2104,13 +1990,10 @@ namespace pocketfft } template - void radb2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radb2(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 2 * c)]; }; @@ -2133,22 +2016,17 @@ namespace pocketfft T ti2, tr2; PM(CH(i - 1, k, 0), tr2, CC(i - 1, 0, k), CC(ic - 1, 1, k)); PM(ti2, CH(i, k, 0), CC(i, 0, k), CC(ic, 1, k)); - MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), ti2, - tr2); + MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), ti2, tr2); } } template - void radb3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radb3(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { - constexpr T0 taur = -0.5, - taui = T0(0.8660254037844386467637231707529362L); + constexpr T0 taur = -0.5, taui = T0(0.8660254037844386467637231707529362L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 3 * c)]; }; @@ -2167,36 +2045,30 @@ namespace pocketfft return; for (size_t k = 0; k < l1; k++) for (size_t i = 2, ic = ido - 2; i < ido; i += 2, ic -= 2) { - T tr2 = - CC(i - 1, 2, k) + CC(ic - 1, 1, k); // t2=CC(I) + conj(CC(ic)) + T tr2 = CC(i - 1, 2, k) + CC(ic - 1, 1, k); // t2=CC(I) + conj(CC(ic)) T ti2 = CC(i, 2, k) - CC(ic, 1, k); T cr2 = CC(i - 1, 0, k) + taur * tr2; // c2=CC +taur*t2 T ci2 = CC(i, 0, k) + taur * ti2; CH(i - 1, k, 0) = CC(i - 1, 0, k) + tr2; // CH=CC+t2 CH(i, k, 0) = CC(i, 0, k) + ti2; - T cr3 = taui * (CC(i - 1, 2, k) - - CC(ic - 1, 1, k)); // c3=taui*(CC(i)-conj(CC(ic))) + T cr3 = taui * (CC(i - 1, 2, k) - CC(ic - 1, 1, k)); // c3=taui*(CC(i)-conj(CC(ic))) T ci3 = taui * (CC(i, 2, k) + CC(ic, 1, k)); T di2, di3, dr2, dr3; PM(dr3, dr2, cr2, ci3); // d2= (cr2-ci3, ci2+cr3) = c2+i*c3 PM(di2, di3, ci2, cr3); // d3= (cr2+ci3, ci2-cr3) = c2-i*c3 MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), di2, dr2); // ch = WA*d2 - MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), di3, - dr3); + MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), di3, dr3); } } template - void radb4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radb4(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { constexpr T0 sqrt2 = T0(1.414213562373095048801688724209698L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 4 * c)]; }; @@ -2226,8 +2098,7 @@ namespace pocketfft return; for (size_t k = 0; k < l1; ++k) for (size_t i = 2; i < ido; i += 2) { - T ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, - tr4; + T ci2, ci3, ci4, cr2, cr3, cr4, ti1, ti2, ti3, ti4, tr1, tr2, tr3, tr4; size_t ic = ido - i; PM(tr2, tr1, CC(i - 1, 0, k), CC(ic - 1, 3, k)); PM(ti1, ti2, CC(i, 0, k), CC(ic, 3, k)); @@ -2237,18 +2108,14 @@ namespace pocketfft PM(CH(i, k, 0), ci3, ti2, ti3); PM(cr4, cr2, tr1, tr4); PM(ci2, ci4, ti1, ti4); - MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), ci2, - cr2); - MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), ci3, - cr3); - MULPM(CH(i, k, 3), CH(i - 1, k, 3), WA(2, i - 2), WA(2, i - 1), ci4, - cr4); + MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), ci2, cr2); + MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), ci3, cr3); + MULPM(CH(i, k, 3), CH(i - 1, k, 3), WA(2, i - 2), WA(2, i - 1), ci4, cr4); } } template - void radb5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, - T *POCKETFFT_RESTRICT ch, + void radb5(size_t ido, size_t l1, const T *POCKETFFT_RESTRICT cc, T *POCKETFFT_RESTRICT ch, const T0 *POCKETFFT_RESTRICT wa) const { constexpr T0 tr11 = T0(0.3090169943749474241022934171828191L), @@ -2256,9 +2123,7 @@ namespace pocketfft tr12 = T0(-0.8090169943749474241022934171828191L), ti12 = T0(0.5877852522924731291687059546390728L); - auto WA = [wa, ido](size_t x, size_t i) { - return wa[i + x * (ido - 1)]; - }; + auto WA = [wa, ido](size_t x, size_t i) { return wa[i + x * (ido - 1)]; }; auto CC = [cc, ido](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + 5 * c)]; }; @@ -2302,14 +2167,10 @@ namespace pocketfft PM(di3, di4, ci3, cr4); PM(dr5, dr2, cr2, ci5); PM(di2, di5, ci2, cr5); - MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), di2, - dr2); - MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), di3, - dr3); - MULPM(CH(i, k, 3), CH(i - 1, k, 3), WA(2, i - 2), WA(2, i - 1), di4, - dr4); - MULPM(CH(i, k, 4), CH(i - 1, k, 4), WA(3, i - 2), WA(3, i - 1), di5, - dr5); + MULPM(CH(i, k, 1), CH(i - 1, k, 1), WA(0, i - 2), WA(0, i - 1), di2, dr2); + MULPM(CH(i, k, 2), CH(i - 1, k, 2), WA(1, i - 2), WA(1, i - 1), di3, dr3); + MULPM(CH(i, k, 3), CH(i - 1, k, 3), WA(2, i - 2), WA(2, i - 1), di4, dr4); + MULPM(CH(i, k, 4), CH(i - 1, k, 4), WA(3, i - 2), WA(3, i - 1), di5, dr5); } } @@ -2331,12 +2192,8 @@ namespace pocketfft auto C1 = [cc, ido, l1](size_t a, size_t b, size_t c) -> const T & { return cc[a + ido * (b + l1 * c)]; }; - auto C2 = [cc, idl1](size_t a, size_t b) -> T & { - return cc[a + idl1 * b]; - }; - auto CH2 = [ch, idl1](size_t a, size_t b) -> T & { - return ch[a + idl1 * b]; - }; + auto C2 = [cc, idl1](size_t a, size_t b) -> T & { return cc[a + idl1 * b]; }; + auto CH2 = [ch, idl1](size_t a, size_t b) -> T & { return ch[a + idl1 * b]; }; for (size_t k = 0; k < l1; ++k) // 102 for (size_t i = 0; i < ido; ++i) // 101 @@ -2355,8 +2212,7 @@ namespace pocketfft { size_t j2 = 2 * j - 1; for (size_t k = 0; k < l1; ++k) - for (size_t i = 1, ic = ido - i - 2; i <= ido - 2; - i += 2, ic -= 2) // 109 + for (size_t i = 1, ic = ido - i - 2; i <= ido - 2; i += 2, ic -= 2) // 109 { CH(i, k, j) = CC(i, j2 + 1, k) + CC(ic, j2, k); CH(i, k, jc) = CC(i, j2 + 1, k) - CC(ic, j2, k); @@ -2367,10 +2223,8 @@ namespace pocketfft } for (size_t l = 1, lc = ip - 1; l < ipph; ++l, --lc) { for (size_t ik = 0; ik < idl1; ++ik) { - C2(ik, l) = CH2(ik, 0) + csarr[2 * l] * CH2(ik, 1) + - csarr[4 * l] * CH2(ik, 2); - C2(ik, lc) = csarr[2 * l + 1] * CH2(ik, ip - 1) + - csarr[4 * l + 1] * CH2(ik, ip - 2); + C2(ik, l) = CH2(ik, 0) + csarr[2 * l] * CH2(ik, 1) + csarr[4 * l] * CH2(ik, 2); + C2(ik, lc) = csarr[2 * l + 1] * CH2(ik, ip - 1) + csarr[4 * l + 1] * CH2(ik, ip - 2); } size_t iang = 2 * l; size_t j = 3, jc = ip - 3; @@ -2392,10 +2246,10 @@ namespace pocketfft iang -= ip; T0 ar4 = csarr[2 * iang], ai4 = csarr[2 * iang + 1]; for (size_t ik = 0; ik < idl1; ++ik) { - C2(ik, l) += ar1 * CH2(ik, j) + ar2 * CH2(ik, j + 1) + - ar3 * CH2(ik, j + 2) + ar4 * CH2(ik, j + 3); - C2(ik, lc) += ai1 * CH2(ik, jc) + ai2 * CH2(ik, jc - 1) + - ai3 * CH2(ik, jc - 2) + ai4 * CH2(ik, jc - 3); + C2(ik, l) += ar1 * CH2(ik, j) + ar2 * CH2(ik, j + 1) + ar3 * CH2(ik, j + 2) + + ar4 * CH2(ik, j + 3); + C2(ik, lc) += ai1 * CH2(ik, jc) + ai2 * CH2(ik, jc - 1) + ai3 * CH2(ik, jc - 2) + + ai4 * CH2(ik, jc - 3); } } for (; j < ipph - 1; j += 2, jc -= 2) { @@ -2573,10 +2427,8 @@ namespace pocketfft ptr += (ip - 1) * (ido - 1); for (size_t j = 1; j < ip; ++j) for (size_t i = 1; i <= (ido - 1) / 2; ++i) { - fact[k].tw[(j - 1) * (ido - 1) + 2 * i - 2] = - twid[j * l1 * i].r; - fact[k].tw[(j - 1) * (ido - 1) + 2 * i - 1] = - twid[j * l1 * i].i; + fact[k].tw[(j - 1) * (ido - 1) + 2 * i - 2] = twid[j * l1 * i].r; + fact[k].tw[(j - 1) * (ido - 1) + 2 * i - 1] = twid[j * l1 * i].i; } } if (ip > 5) // special factors required by *g functions @@ -2655,8 +2507,8 @@ namespace pocketfft public: POCKETFFT_NOINLINE fftblue(size_t length) - : n(length), n2(util::good_size_cmplx(n * 2 - 1)), plan(n2), - mem(n + n2 / 2 + 1), bk(mem.data()), bkf(mem.data() + n) + : n(length), n2(util::good_size_cmplx(n * 2 - 1)), plan(n2), mem(n + n2 / 2 + 1), + bk(mem.data()), bkf(mem.data() + n) { /* initialize b_k */ sincos_2pibyn tmp(2 * n); @@ -2703,8 +2555,8 @@ namespace pocketfft memcpy(c + 1, tmp.data() + 1, (n - 1) * sizeof(T)); } else { tmp[0].Set(c[0], c[0] * 0); - memcpy(reinterpret_cast(tmp.data() + 1), - reinterpret_cast(c + 1), (n - 1) * sizeof(T)); + memcpy(reinterpret_cast(tmp.data() + 1), reinterpret_cast(c + 1), + (n - 1) * sizeof(T)); if ((n & 1) == 0) tmp[n / 2].i = T0(0) * c[0]; for (size_t m = 1; 2 * m < n; ++m) @@ -2739,8 +2591,7 @@ namespace pocketfft return; } double comp1 = util::cost_guess(length); - double comp2 = - 2 * util::cost_guess(util::good_size_cmplx(2 * length - 1)); + double comp2 = 2 * util::cost_guess(util::good_size_cmplx(2 * length - 1)); comp2 *= 1.5; /* fudge factor that appears to give good overall performance */ if (comp2 < comp1) // use Bluestein @@ -2784,8 +2635,7 @@ namespace pocketfft return; } double comp1 = 0.5 * util::cost_guess(length); - double comp2 = - 2 * util::cost_guess(util::good_size_cmplx(2 * length - 1)); + double comp2 = 2 * util::cost_guess(util::good_size_cmplx(2 * length - 1)); comp2 *= 1.5; /* fudge factor that appears to give good overall performance */ if (comp2 < comp1) // use Bluestein @@ -2822,8 +2672,7 @@ namespace pocketfft } template - POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool ortho, int /*type*/, - bool /*cosine*/) const + POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool ortho, int /*type*/, bool /*cosine*/) const { constexpr T0 sqrt2 = T0(1.414213562373095048801688724209698L); size_t N = fftplan.length(), n = N / 2 + 1; @@ -2892,8 +2741,7 @@ namespace pocketfft std::vector twiddle; public: - POCKETFFT_NOINLINE T_dcst23(size_t length) - : fftplan(length), twiddle(length) + POCKETFFT_NOINLINE T_dcst23(size_t length) : fftplan(length), twiddle(length) { sincos_2pibyn tw(4 * length); for (size_t i = 0; i < length; ++i) @@ -2901,8 +2749,7 @@ namespace pocketfft } template - POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool ortho, int type, - bool cosine) const + POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool ortho, int type, bool cosine) const { constexpr T0 sqrt2 = T0(1.414213562373095048801688724209698L); size_t N = length(); @@ -2970,8 +2817,7 @@ namespace pocketfft public: POCKETFFT_NOINLINE T_dcst4(size_t length) : N(length), fft((N & 1) ? nullptr : new pocketfft_c(N / 2)), - rfft((N & 1) ? new pocketfft_r(N) : nullptr), - C2((N & 1) ? 0 : N / 2) + rfft((N & 1) ? new pocketfft_r(N) : nullptr), C2((N & 1) ? 0 : N / 2) { if ((N & 1) == 0) { sincos_2pibyn tw(16 * N); @@ -2981,8 +2827,7 @@ namespace pocketfft } template - POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool /*ortho*/, int /*type*/, - bool cosine) const + POCKETFFT_NOINLINE void exec(T c[], T0 fct, bool /*ortho*/, int /*type*/, bool cosine) const { size_t n2 = N / 2; if (!cosine) @@ -3018,10 +2863,8 @@ namespace pocketfft for (; k < n2; ++i, ++i1, k += 2) { c[i] = y[2 * k - 1] * SGN(i1) + y[2 * k] * SGN(i); c[N - i1] = y[2 * k - 1] * SGN(N - i) - y[2 * k] * SGN(N - i1); - c[n2 - i1] = - y[2 * k + 1] * SGN(n2 - i) - y[2 * k + 2] * SGN(n2 - i1); - c[n2 + i1] = - y[2 * k + 1] * SGN(n2 + i + 2) + y[2 * k + 2] * SGN(n2 + i1); + c[n2 - i1] = y[2 * k + 1] * SGN(n2 - i) - y[2 * k + 2] * SGN(n2 - i1); + c[n2 + i1] = y[2 * k + 1] * SGN(n2 + i + 2) + y[2 * k + 2] * SGN(n2 + i1); } if (k == n2) { c[i] = y[2 * k - 1] * SGN(i + 1) + y[2 * k] * SGN(i); @@ -3119,8 +2962,7 @@ namespace pocketfft stride_t str; public: - arr_info(const shape_t &shape_, const stride_t &stride_) - : shp(shape_), str(stride_) + arr_info(const shape_t &shape_, const stride_t &stride_) : shp(shape_), str(stride_) { } size_t ndim() const @@ -3207,9 +3049,8 @@ namespace pocketfft public: multi_iter(const arr_info &iarr_, const arr_info &oarr_, size_t idim_) - : pos(iarr_.ndim(), 0), iarr(iarr_), oarr(oarr_), p_ii(0), - str_i(iarr.stride(idim_)), p_oi(0), str_o(oarr.stride(idim_)), - idim(idim_), rem(iarr.size() / iarr.shape(idim)) + : pos(iarr_.ndim(), 0), iarr(iarr_), oarr(oarr_), p_ii(0), str_i(iarr.stride(idim_)), + p_oi(0), str_o(oarr.stride(idim_)), idim(idim_), rem(iarr.size() / iarr.shape(idim)) { auto nshares = threading::num_threads(); if (nshares == 1) @@ -3221,8 +3062,7 @@ namespace pocketfft throw std::runtime_error("impossible share requested"); size_t nbase = rem / nshares; size_t additional = rem % nshares; - size_t lo = - myshare * nbase + ((myshare < additional) ? myshare : additional); + size_t lo = myshare * nbase + ((myshare < additional) ? myshare : additional); size_t hi = lo + nbase + (myshare < additional); size_t todo = hi - lo; @@ -3297,8 +3137,7 @@ namespace pocketfft size_t rem; public: - simple_iter(const arr_info &arr_) - : pos(arr_.ndim(), 0), arr(arr_), p(0), rem(arr_.size()) + simple_iter(const arr_info &arr_) : pos(arr_.ndim(), 0), arr(arr_), p(0), rem(arr_.size()) { } void advance() @@ -3337,8 +3176,8 @@ namespace pocketfft public: rev_iter(const arr_info &arr_, const shape_t &axes) - : pos(arr_.ndim(), 0), arr(arr_), rev_axis(arr_.ndim(), 0), - rev_jump(arr_.ndim(), 1), p(0), rp(0) + : pos(arr_.ndim(), 0), arr(arr_), rev_axis(arr_.ndim(), 0), rev_jump(arr_.ndim(), 1), + p(0), rp(0) { for (auto ax : axes) rev_axis[ax] = 1; @@ -3399,18 +3238,16 @@ namespace pocketfft #ifndef POCKETFFT_NO_VECTORS template <> struct VTYPE { - using type = - float __attribute__((vector_size(VLEN::val * sizeof(float)))); + using type = float __attribute__((vector_size(VLEN::val * sizeof(float)))); }; template <> struct VTYPE { - using type = double - __attribute__((vector_size(VLEN::val * sizeof(double)))); + using type = double __attribute__((vector_size(VLEN::val * sizeof(double)))); }; template <> struct VTYPE { - using type = long double __attribute__(( - vector_size(VLEN::val * sizeof(long double)))); + using type = + long double __attribute__((vector_size(VLEN::val * sizeof(long double)))); }; #endif @@ -3422,8 +3259,7 @@ namespace pocketfft return arr(tmpsize * elemsize); } template - arr alloc_tmp(const shape_t &shape, const shape_t &axes, - size_t elemsize) + arr alloc_tmp(const shape_t &shape, const shape_t &axes, size_t elemsize) { size_t fullsize = util::prod(shape); size_t tmpsize = 0; @@ -3458,8 +3294,7 @@ namespace pocketfft } template - void copy_input(const multi_iter &it, const cndarr &src, - T *POCKETFFT_RESTRICT dst) + void copy_input(const multi_iter &it, const cndarr &src, T *POCKETFFT_RESTRICT dst) { if (dst == &src[it.iofs(0)]) return; // in-place @@ -3468,8 +3303,7 @@ namespace pocketfft } template - void copy_output(const multi_iter &it, - const cmplx> *POCKETFFT_RESTRICT src, + void copy_output(const multi_iter &it, const cmplx> *POCKETFFT_RESTRICT src, ndarr> &dst) { for (size_t i = 0; i < it.length_out(); ++i) @@ -3478,8 +3312,8 @@ namespace pocketfft } template - void copy_output(const multi_iter &it, - const vtype_t *POCKETFFT_RESTRICT src, ndarr &dst) + void copy_output(const multi_iter &it, const vtype_t *POCKETFFT_RESTRICT src, + ndarr &dst) { for (size_t i = 0; i < it.length_out(); ++i) for (size_t j = 0; j < vlen; ++j) @@ -3487,8 +3321,7 @@ namespace pocketfft } template - void copy_output(const multi_iter &it, - const T *POCKETFFT_RESTRICT src, ndarr &dst) + void copy_output(const multi_iter &it, const T *POCKETFFT_RESTRICT src, ndarr &dst) { if (src == &dst[it.oofs(0)]) return; // in-place @@ -3508,9 +3341,8 @@ namespace pocketfft using add_vec_t = typename add_vec::type; template - POCKETFFT_NOINLINE void general_nd(const cndarr &in, ndarr &out, - const shape_t &axes, T0 fct, - size_t nthreads, const Exec &exec, + POCKETFFT_NOINLINE void general_nd(const cndarr &in, ndarr &out, const shape_t &axes, + T0 fct, size_t nthreads, const Exec &exec, const bool allow_inplace = true) { std::shared_ptr plan; @@ -3520,31 +3352,29 @@ namespace pocketfft if ((!plan) || (len != plan->length())) plan = get_plan(len); - threading::thread_map( - util::thread_count(nthreads, in.shape(), axes[iax], VLEN::val), - [&] { - constexpr auto vlen = VLEN::val; - auto storage = alloc_tmp(in.shape(), len, sizeof(T)); - const auto &tin(iax == 0 ? in : out); - multi_iter it(tin, out, axes[iax]); + threading::thread_map(util::thread_count(nthreads, in.shape(), axes[iax], VLEN::val), + [&] { + constexpr auto vlen = VLEN::val; + auto storage = alloc_tmp(in.shape(), len, sizeof(T)); + const auto &tin(iax == 0 ? in : out); + multi_iter it(tin, out, axes[iax]); #ifndef POCKETFFT_NO_VECTORS - if (vlen > 1) - while (it.remaining() >= vlen) { - it.advance(vlen); - auto tdatav = - reinterpret_cast *>(storage.data()); - exec(it, tin, out, tdatav, *plan, fct); - } + if (vlen > 1) + while (it.remaining() >= vlen) { + it.advance(vlen); + auto tdatav = reinterpret_cast *>(storage.data()); + exec(it, tin, out, tdatav, *plan, fct); + } #endif - while (it.remaining() > 0) { - it.advance(1); - auto buf = allow_inplace && it.stride_out() == sizeof(T) - ? &out[it.oofs(0)] - : reinterpret_cast(storage.data()); - exec(it, tin, out, buf, *plan, fct); - } - }); // end of parallel region - fct = T0(1); // factor has been applied, use 1 for remaining axes + while (it.remaining() > 0) { + it.advance(1); + auto buf = allow_inplace && it.stride_out() == sizeof(T) + ? &out[it.oofs(0)] + : reinterpret_cast(storage.data()); + exec(it, tin, out, buf, *plan, fct); + } + }); // end of parallel region + fct = T0(1); // factor has been applied, use 1 for remaining axes } } @@ -3553,8 +3383,7 @@ namespace pocketfft template void operator()(const multi_iter &it, const cndarr> &in, - ndarr> &out, T *buf, - const pocketfft_c &plan, T0 fct) const + ndarr> &out, T *buf, const pocketfft_c &plan, T0 fct) const { copy_input(it, in, buf); plan.exec(buf, fct, forward); @@ -3563,8 +3392,8 @@ namespace pocketfft }; template - void copy_hartley(const multi_iter &it, - const vtype_t *POCKETFFT_RESTRICT src, ndarr &dst) + void copy_hartley(const multi_iter &it, const vtype_t *POCKETFFT_RESTRICT src, + ndarr &dst) { for (size_t j = 0; j < vlen; ++j) dst[it.oofs(j, 0)] = src[0][j]; @@ -3580,8 +3409,7 @@ namespace pocketfft } template - void copy_hartley(const multi_iter &it, - const T *POCKETFFT_RESTRICT src, ndarr &dst) + void copy_hartley(const multi_iter &it, const T *POCKETFFT_RESTRICT src, ndarr &dst) { dst[it.oofs(0)] = src[0]; size_t i = 1, i1 = 1, i2 = it.length_out() - 1; @@ -3595,9 +3423,8 @@ namespace pocketfft struct ExecHartley { template - void operator()(const multi_iter &it, const cndarr &in, - ndarr &out, T *buf, const pocketfft_r &plan, - T0 fct) const + void operator()(const multi_iter &it, const cndarr &in, ndarr &out, T *buf, + const pocketfft_r &plan, T0 fct) const { copy_input(it, in, buf); plan.exec(buf, fct, true); @@ -3611,8 +3438,8 @@ namespace pocketfft bool cosine; template - void operator()(const multi_iter &it, const cndarr &in, - ndarr &out, T *buf, const Tplan &plan, T0 fct) const + void operator()(const multi_iter &it, const cndarr &in, ndarr &out, T *buf, + const Tplan &plan, T0 fct) const { copy_input(it, in, buf); plan.exec(buf, fct, ortho, type, cosine); @@ -3621,131 +3448,126 @@ namespace pocketfft }; template - POCKETFFT_NOINLINE void general_r2c(const cndarr &in, - ndarr> &out, size_t axis, + POCKETFFT_NOINLINE void general_r2c(const cndarr &in, ndarr> &out, size_t axis, bool forward, T fct, size_t nthreads) { auto plan = get_plan>(in.shape(axis)); size_t len = in.shape(axis); - threading::thread_map( - util::thread_count(nthreads, in.shape(), axis, VLEN::val), [&] { - constexpr auto vlen = VLEN::val; - auto storage = alloc_tmp(in.shape(), len, sizeof(T)); - multi_iter it(in, out, axis); + threading::thread_map(util::thread_count(nthreads, in.shape(), axis, VLEN::val), [&] { + constexpr auto vlen = VLEN::val; + auto storage = alloc_tmp(in.shape(), len, sizeof(T)); + multi_iter it(in, out, axis); #ifndef POCKETFFT_NO_VECTORS - if (vlen > 1) - while (it.remaining() >= vlen) { - it.advance(vlen); - auto tdatav = reinterpret_cast *>(storage.data()); - copy_input(it, in, tdatav); - plan->exec(tdatav, fct, true); + if (vlen > 1) + while (it.remaining() >= vlen) { + it.advance(vlen); + auto tdatav = reinterpret_cast *>(storage.data()); + copy_input(it, in, tdatav); + plan->exec(tdatav, fct, true); + for (size_t j = 0; j < vlen; ++j) + out[it.oofs(j, 0)].Set(tdatav[0][j]); + size_t i = 1, ii = 1; + if (forward) + for (; i < len - 1; i += 2, ++ii) for (size_t j = 0; j < vlen; ++j) - out[it.oofs(j, 0)].Set(tdatav[0][j]); - size_t i = 1, ii = 1; - if (forward) - for (; i < len - 1; i += 2, ++ii) - for (size_t j = 0; j < vlen; ++j) - out[it.oofs(j, ii)].Set(tdatav[i][j], tdatav[i + 1][j]); - else - for (; i < len - 1; i += 2, ++ii) - for (size_t j = 0; j < vlen; ++j) - out[it.oofs(j, ii)].Set(tdatav[i][j], -tdatav[i + 1][j]); - if (i < len) - for (size_t j = 0; j < vlen; ++j) - out[it.oofs(j, ii)].Set(tdatav[i][j]); - } + out[it.oofs(j, ii)].Set(tdatav[i][j], tdatav[i + 1][j]); + else + for (; i < len - 1; i += 2, ++ii) + for (size_t j = 0; j < vlen; ++j) + out[it.oofs(j, ii)].Set(tdatav[i][j], -tdatav[i + 1][j]); + if (i < len) + for (size_t j = 0; j < vlen; ++j) + out[it.oofs(j, ii)].Set(tdatav[i][j]); + } #endif - while (it.remaining() > 0) { - it.advance(1); - auto tdata = reinterpret_cast(storage.data()); - copy_input(it, in, tdata); - plan->exec(tdata, fct, true); - out[it.oofs(0)].Set(tdata[0]); - size_t i = 1, ii = 1; - if (forward) - for (; i < len - 1; i += 2, ++ii) - out[it.oofs(ii)].Set(tdata[i], tdata[i + 1]); - else - for (; i < len - 1; i += 2, ++ii) - out[it.oofs(ii)].Set(tdata[i], -tdata[i + 1]); - if (i < len) - out[it.oofs(ii)].Set(tdata[i]); - } - }); // end of parallel region + while (it.remaining() > 0) { + it.advance(1); + auto tdata = reinterpret_cast(storage.data()); + copy_input(it, in, tdata); + plan->exec(tdata, fct, true); + out[it.oofs(0)].Set(tdata[0]); + size_t i = 1, ii = 1; + if (forward) + for (; i < len - 1; i += 2, ++ii) + out[it.oofs(ii)].Set(tdata[i], tdata[i + 1]); + else + for (; i < len - 1; i += 2, ++ii) + out[it.oofs(ii)].Set(tdata[i], -tdata[i + 1]); + if (i < len) + out[it.oofs(ii)].Set(tdata[i]); + } + }); // end of parallel region } template - POCKETFFT_NOINLINE void general_c2r(const cndarr> &in, - ndarr &out, size_t axis, + POCKETFFT_NOINLINE void general_c2r(const cndarr> &in, ndarr &out, size_t axis, bool forward, T fct, size_t nthreads) { auto plan = get_plan>(out.shape(axis)); size_t len = out.shape(axis); - threading::thread_map( - util::thread_count(nthreads, in.shape(), axis, VLEN::val), [&] { - constexpr auto vlen = VLEN::val; - auto storage = alloc_tmp(out.shape(), len, sizeof(T)); - multi_iter it(in, out, axis); + threading::thread_map(util::thread_count(nthreads, in.shape(), axis, VLEN::val), [&] { + constexpr auto vlen = VLEN::val; + auto storage = alloc_tmp(out.shape(), len, sizeof(T)); + multi_iter it(in, out, axis); #ifndef POCKETFFT_NO_VECTORS - if (vlen > 1) - while (it.remaining() >= vlen) { - it.advance(vlen); - auto tdatav = reinterpret_cast *>(storage.data()); - for (size_t j = 0; j < vlen; ++j) - tdatav[0][j] = in[it.iofs(j, 0)].r; - { - size_t i = 1, ii = 1; - if (forward) - for (; i < len - 1; i += 2, ++ii) - for (size_t j = 0; j < vlen; ++j) { - tdatav[i][j] = in[it.iofs(j, ii)].r; - tdatav[i + 1][j] = -in[it.iofs(j, ii)].i; - } - else - for (; i < len - 1; i += 2, ++ii) - for (size_t j = 0; j < vlen; ++j) { - tdatav[i][j] = in[it.iofs(j, ii)].r; - tdatav[i + 1][j] = in[it.iofs(j, ii)].i; - } - if (i < len) - for (size_t j = 0; j < vlen; ++j) - tdatav[i][j] = in[it.iofs(j, ii)].r; - } - plan->exec(tdatav, fct, false); - copy_output(it, tdatav, out); - } -#endif - while (it.remaining() > 0) { - it.advance(1); - auto tdata = reinterpret_cast(storage.data()); - tdata[0] = in[it.iofs(0)].r; - { - size_t i = 1, ii = 1; - if (forward) - for (; i < len - 1; i += 2, ++ii) { - tdata[i] = in[it.iofs(ii)].r; - tdata[i + 1] = -in[it.iofs(ii)].i; + if (vlen > 1) + while (it.remaining() >= vlen) { + it.advance(vlen); + auto tdatav = reinterpret_cast *>(storage.data()); + for (size_t j = 0; j < vlen; ++j) + tdatav[0][j] = in[it.iofs(j, 0)].r; + { + size_t i = 1, ii = 1; + if (forward) + for (; i < len - 1; i += 2, ++ii) + for (size_t j = 0; j < vlen; ++j) { + tdatav[i][j] = in[it.iofs(j, ii)].r; + tdatav[i + 1][j] = -in[it.iofs(j, ii)].i; } - else - for (; i < len - 1; i += 2, ++ii) { - tdata[i] = in[it.iofs(ii)].r; - tdata[i + 1] = in[it.iofs(ii)].i; + else + for (; i < len - 1; i += 2, ++ii) + for (size_t j = 0; j < vlen; ++j) { + tdatav[i][j] = in[it.iofs(j, ii)].r; + tdatav[i + 1][j] = in[it.iofs(j, ii)].i; } - if (i < len) - tdata[i] = in[it.iofs(ii)].r; - } - plan->exec(tdata, fct, false); - copy_output(it, tdata, out); + if (i < len) + for (size_t j = 0; j < vlen; ++j) + tdatav[i][j] = in[it.iofs(j, ii)].r; } - }); // end of parallel region + plan->exec(tdatav, fct, false); + copy_output(it, tdatav, out); + } +#endif + while (it.remaining() > 0) { + it.advance(1); + auto tdata = reinterpret_cast(storage.data()); + tdata[0] = in[it.iofs(0)].r; + { + size_t i = 1, ii = 1; + if (forward) + for (; i < len - 1; i += 2, ++ii) { + tdata[i] = in[it.iofs(ii)].r; + tdata[i + 1] = -in[it.iofs(ii)].i; + } + else + for (; i < len - 1; i += 2, ++ii) { + tdata[i] = in[it.iofs(ii)].r; + tdata[i + 1] = in[it.iofs(ii)].i; + } + if (i < len) + tdata[i] = in[it.iofs(ii)].r; + } + plan->exec(tdata, fct, false); + copy_output(it, tdata, out); + } + }); // end of parallel region } struct ExecR2R { bool r2c, forward; template - void operator()(const multi_iter &it, const cndarr &in, - ndarr &out, T *buf, const pocketfft_r &plan, - T0 fct) const + void operator()(const multi_iter &it, const cndarr &in, ndarr &out, T *buf, + const pocketfft_r &plan, T0 fct) const { copy_input(it, in, buf); if ((!r2c) && forward) @@ -3760,33 +3582,28 @@ namespace pocketfft }; template - void c2c(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, bool forward, - const std::complex *data_in, std::complex *data_out, T fct, - size_t nthreads = 1) + void c2c(const shape_t &shape, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, bool forward, const std::complex *data_in, + std::complex *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape) == 0) return; - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); cndarr> ain(data_in, shape, stride_in); ndarr> aout(data_out, shape, stride_out); - general_nd>(ain, aout, axes, fct, nthreads, - ExecC2C{forward}); + general_nd>(ain, aout, axes, fct, nthreads, ExecC2C{forward}); } template - void dct(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, int type, - const T *data_in, T *data_out, T fct, bool ortho, + void dct(const shape_t &shape, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, int type, const T *data_in, T *data_out, T fct, bool ortho, size_t nthreads = 1) { if ((type < 1) || (type > 4)) throw std::invalid_argument("invalid DCT type"); if (util::prod(shape) == 0) return; - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); cndarr ain(data_in, shape, stride_in); ndarr aout(data_out, shape, stride_out); const ExecDcst exec{ortho, type, true}; @@ -3799,17 +3616,15 @@ namespace pocketfft } template - void dst(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, int type, - const T *data_in, T *data_out, T fct, bool ortho, + void dst(const shape_t &shape, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, int type, const T *data_in, T *data_out, T fct, bool ortho, size_t nthreads = 1) { if ((type < 1) || (type > 4)) throw std::invalid_argument("invalid DST type"); if (util::prod(shape) == 0) return; - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); cndarr ain(data_in, shape, stride_in); ndarr aout(data_out, shape, stride_out); const ExecDcst exec{ortho, type, false}; @@ -3822,9 +3637,8 @@ namespace pocketfft } template - void r2c(const shape_t &shape_in, const stride_t &stride_in, - const stride_t &stride_out, size_t axis, bool forward, - const T *data_in, std::complex *data_out, T fct, + void r2c(const shape_t &shape_in, const stride_t &stride_in, const stride_t &stride_out, + size_t axis, bool forward, const T *data_in, std::complex *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape_in) == 0) @@ -3838,30 +3652,26 @@ namespace pocketfft } template - void r2c(const shape_t &shape_in, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, bool forward, - const T *data_in, std::complex *data_out, T fct, + void r2c(const shape_t &shape_in, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, bool forward, const T *data_in, std::complex *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape_in) == 0) return; util::sanity_check(shape_in, stride_in, stride_out, false, axes); - r2c(shape_in, stride_in, stride_out, axes.back(), forward, data_in, - data_out, fct, nthreads); + r2c(shape_in, stride_in, stride_out, axes.back(), forward, data_in, data_out, fct, nthreads); if (axes.size() == 1) return; shape_t shape_out(shape_in); shape_out[axes.back()] = shape_in[axes.back()] / 2 + 1; auto newaxes = shape_t{axes.begin(), --axes.end()}; - c2c(shape_out, stride_out, stride_out, newaxes, forward, data_out, - data_out, T(1), nthreads); + c2c(shape_out, stride_out, stride_out, newaxes, forward, data_out, data_out, T(1), nthreads); } template - void c2r(const shape_t &shape_out, const stride_t &stride_in, - const stride_t &stride_out, size_t axis, bool forward, - const std::complex *data_in, T *data_out, T fct, + void c2r(const shape_t &shape_out, const stride_t &stride_in, const stride_t &stride_out, + size_t axis, bool forward, const std::complex *data_in, T *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape_out) == 0) @@ -3875,16 +3685,15 @@ namespace pocketfft } template - void c2r(const shape_t &shape_out, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, bool forward, - const std::complex *data_in, T *data_out, T fct, + void c2r(const shape_t &shape_out, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, bool forward, const std::complex *data_in, T *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape_out) == 0) return; if (axes.size() == 1) - return c2r(shape_out, stride_in, stride_out, axes[0], forward, data_in, - data_out, fct, nthreads); + return c2r(shape_out, stride_in, stride_out, axes[0], forward, data_in, data_out, fct, + nthreads); util::sanity_check(shape_out, stride_in, stride_out, false, axes); auto shape_in = shape_out; shape_in[axes.back()] = shape_out[axes.back()] / 2 + 1; @@ -3892,61 +3701,51 @@ namespace pocketfft stride_t stride_inter(shape_in.size()); stride_inter.back() = sizeof(cmplx); for (int i = int(shape_in.size()) - 2; i >= 0; --i) - stride_inter[size_t(i)] = - stride_inter[size_t(i + 1)] * ptrdiff_t(shape_in[size_t(i + 1)]); + stride_inter[size_t(i)] = stride_inter[size_t(i + 1)] * ptrdiff_t(shape_in[size_t(i + 1)]); arr> tmp(nval); auto newaxes = shape_t{axes.begin(), --axes.end()}; - c2c(shape_in, stride_in, stride_inter, newaxes, forward, data_in, - tmp.data(), T(1), nthreads); - c2r(shape_out, stride_inter, stride_out, axes.back(), forward, tmp.data(), - data_out, fct, nthreads); + c2c(shape_in, stride_in, stride_inter, newaxes, forward, data_in, tmp.data(), T(1), nthreads); + c2r(shape_out, stride_inter, stride_out, axes.back(), forward, tmp.data(), data_out, fct, + nthreads); } template - void r2r_fftpack(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, - bool real2hermitian, bool forward, const T *data_in, + void r2r_fftpack(const shape_t &shape, const stride_t &stride_in, const stride_t &stride_out, + const shape_t &axes, bool real2hermitian, bool forward, const T *data_in, T *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape) == 0) return; - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); cndarr ain(data_in, shape, stride_in); ndarr aout(data_out, shape, stride_out); - general_nd>(ain, aout, axes, fct, nthreads, - ExecR2R{real2hermitian, forward}); + general_nd>(ain, aout, axes, fct, nthreads, ExecR2R{real2hermitian, forward}); } template void r2r_separable_hartley(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, - const T *data_in, T *data_out, T fct, - size_t nthreads = 1) + const stride_t &stride_out, const shape_t &axes, const T *data_in, + T *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape) == 0) return; - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); cndarr ain(data_in, shape, stride_in); ndarr aout(data_out, shape, stride_out); - general_nd>(ain, aout, axes, fct, nthreads, ExecHartley{}, - false); + general_nd>(ain, aout, axes, fct, nthreads, ExecHartley{}, false); } template void r2r_genuine_hartley(const shape_t &shape, const stride_t &stride_in, - const stride_t &stride_out, const shape_t &axes, - const T *data_in, T *data_out, T fct, - size_t nthreads = 1) + const stride_t &stride_out, const shape_t &axes, const T *data_in, + T *data_out, T fct, size_t nthreads = 1) { if (util::prod(shape) == 0) return; if (axes.size() == 1) - return r2r_separable_hartley(shape, stride_in, stride_out, axes, - data_in, data_out, fct, nthreads); - util::sanity_check(shape, stride_in, stride_out, data_in == data_out, - axes); + return r2r_separable_hartley(shape, stride_in, stride_out, axes, data_in, data_out, fct, + nthreads); + util::sanity_check(shape, stride_in, stride_out, data_in == data_out, axes); shape_t tshp(shape); tshp[axes.back()] = tshp[axes.back()] / 2 + 1; arr> tdata(util::prod(tshp)); @@ -3954,8 +3753,7 @@ namespace pocketfft tstride.back() = sizeof(std::complex); for (size_t i = tstride.size() - 1; i > 0; --i) tstride[i - 1] = tstride[i] * ptrdiff_t(tshp[i]); - r2c(shape, stride_in, tstride, axes, true, data_in, tdata.data(), fct, - nthreads); + r2c(shape, stride_in, tstride, axes, true, data_in, tdata.data(), fct, nthreads); cndarr> atmp(tdata.data(), tshp, tstride); ndarr aout(data_out, shape, stride_out); simple_iter iin(atmp); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fft/rfft.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fft/rfft.hpp index 84d1300c8db..463292d5e31 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fft/rfft.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fft/rfft.hpp @@ -15,8 +15,7 @@ namespace numpy { template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -25,8 +24,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -35,28 +33,23 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + rfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { return r2c(in_array, n, axis, "", true, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + rfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { return r2c(in_array, n, axis, norm, true, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &in_array, types::none_type n, long axis, types::str const &norm) @@ -66,8 +59,7 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> rfft(types::ndarray const &in_array, types::none_type n, long axis, types::none_type norm) @@ -77,22 +69,18 @@ namespace numpy } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &in_array, long n, long axis, - types::none_type norm) + rfft(types::ndarray const &in_array, long n, long axis, types::none_type norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, "", true, false); } template - types::ndarray::value, - std::complex>::type, + types::ndarray::value, std::complex>, types::array_tuple::value>> - rfft(types::ndarray const &in_array, long n, long axis, - types::str const &norm) + rfft(types::ndarray const &in_array, long n, long axis, types::str const &norm) { auto tmp_array = _copy_to_double(in_array); return r2c(tmp_array, n, axis, norm, true, false); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fill_diagonal.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fill_diagonal.hpp index dd5bc0889bc..21cc2829a97 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fill_diagonal.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fill_diagonal.hpp @@ -11,10 +11,9 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type fill_diagonal(E &&expr, - typename std::decay::type::dtype fill_value) + types::none_type fill_diagonal(E &&expr, typename std::decay_t::dtype fill_value) { - constexpr auto N = std::decay::type::value; + constexpr auto N = std::decay_t::value; types::array_tuple indices; for (long i = 0, n = sutils::min(expr); i < n; ++i) { std::fill(indices.begin(), indices.end(), i); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/flatnonzero.hpp b/contrib/python/pythran/pythran/pythonic/numpy/flatnonzero.hpp index 987a2069006..81e1b86d1eb 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/flatnonzero.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/flatnonzero.hpp @@ -23,8 +23,7 @@ namespace numpy void _flatnonzero(I begin, I end, O &out, long &i, utils::int_) { for (; begin != end; ++begin) - _flatnonzero((*begin).begin(), (*begin).end(), out, i, - utils::int_()); + _flatnonzero((*begin).begin(), (*begin).end(), out, i, utils::int_()); } } // namespace template diff --git a/contrib/python/pythran/pythran/pythonic/numpy/flip.hpp b/contrib/python/pythran/pythran/pythonic/numpy/flip.hpp index 3bcdaf7f198..f4d6cf7f799 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/flip.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/flip.hpp @@ -14,8 +14,8 @@ namespace numpy namespace details { template - auto flip(E const &expr, S const &slices, - utils::index_sequence) -> decltype(expr(slices[I]...)) + auto flip(E const &expr, S const &slices, std::index_sequence) + -> decltype(expr(slices[I]...)) { return expr(slices[I]...); } @@ -24,11 +24,11 @@ namespace numpy template auto flip(E const &expr, long axis) -> decltype(details::flip(expr, std::array{}, - utils::make_index_sequence{})) + std::make_index_sequence{})) { std::array slices; slices[axis].step = -1; - return details::flip(expr, slices, utils::make_index_sequence{}); + return details::flip(expr, slices, std::make_index_sequence{}); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fliplr.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fliplr.hpp index d19474358fa..484ab65d408 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fliplr.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fliplr.hpp @@ -11,14 +11,12 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto - fliplr(E &&expr) -> decltype(std::forward(expr)( - types::cstride_slice<1>{builtins::None, builtins::None}, - types::slice{builtins::None, builtins::None, -1})) + auto fliplr(E &&expr) + -> decltype(std::forward(expr)(types::cstride_slice<1>{builtins::None, builtins::None}, + types::slice{builtins::None, builtins::None, -1})) { - return std::forward(expr)( - types::cstride_slice<1>{builtins::None, builtins::None}, - types::slice{builtins::None, builtins::None, -1}); + return std::forward(expr)(types::cstride_slice<1>{builtins::None, builtins::None}, + types::slice{builtins::None, builtins::None, -1}); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/flipud.hpp b/contrib/python/pythran/pythran/pythonic/numpy/flipud.hpp index a5a0331f8ad..fa154962587 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/flipud.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/flipud.hpp @@ -11,12 +11,10 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto - flipud(E &&expr) -> decltype(std::forward( - expr)[types::slice{builtins::None, builtins::None, -1}]) + auto flipud(E &&expr) + -> decltype(std::forward(expr)[types::slice{builtins::None, builtins::None, -1}]) { - return std::forward( - expr)[types::slice{builtins::None, builtins::None, -1}]; + return std::forward(expr)[types::slice{builtins::None, builtins::None, -1}]; } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/float128.hpp b/contrib/python/pythran/pythran/pythonic/numpy/float128.hpp index e5c2ea5b552..e56d3d8b851 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/float128.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/float128.hpp @@ -28,4 +28,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::float128 const &c) +{ + return (PyObject *)&PyLongDoubleArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyLongDoubleArrType_Type; +} + +inline numpy::functor::float128 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/float32.hpp b/contrib/python/pythran/pythran/pythonic/numpy/float32.hpp index 04b4a118650..b99a2f7a80c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/float32.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/float32.hpp @@ -34,4 +34,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::float32 const &c) +{ + return (PyObject *)&PyFloatArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyFloatArrType_Type; +} + +inline numpy::functor::float32 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/float64.hpp b/contrib/python/pythran/pythran/pythonic/numpy/float64.hpp index 3c5c179d797..6f12831e3dc 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/float64.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/float64.hpp @@ -33,4 +33,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::float64 const &c) +{ + return (PyObject *)&PyDoubleArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyDoubleArrType_Type; +} + +inline numpy::functor::float64 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/float_.hpp b/contrib/python/pythran/pythran/pythonic/numpy/float_.hpp index 721101c1b86..ccfd3fccf2e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/float_.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/float_.hpp @@ -15,4 +15,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::float_ const &c) +{ + return (PyObject *)&PyDoubleArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyDoubleArrType_Type; +} + +inline numpy::functor::float_ from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/frexp.hpp b/contrib/python/pythran/pythran/pythonic/numpy/frexp.hpp index 57bf14cd1e1..1fa3d4e75d1 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/frexp.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/frexp.hpp @@ -13,8 +13,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, std::tuple>::type - frexp(T val) + std::enable_if_t::value, std::tuple> frexp(T val) { int exp; T significand = std::frexp(val, &exp); @@ -24,36 +23,31 @@ namespace numpy namespace { template - void _frexp(E begin, E end, F significands_iter, G exps_iter, - utils::int_<1>) + void _frexp(E begin, E end, F significands_iter, G exps_iter, utils::int_<1>) { for (; begin != end; ++begin, ++significands_iter, ++exps_iter) *significands_iter = std::frexp(*begin, exps_iter); } template - void _frexp(E begin, E end, F significands_iter, G exps_iter, - utils::int_) + void _frexp(E begin, E end, F significands_iter, G exps_iter, utils::int_) { for (; begin != end; ++begin, ++significands_iter, ++exps_iter) - _frexp((*begin).begin(), (*begin).end(), (*significands_iter).begin(), - (*exps_iter).begin(), utils::int_()); + _frexp((*begin).begin(), (*begin).end(), (*significands_iter).begin(), (*exps_iter).begin(), + utils::int_()); } } // namespace template - typename std::enable_if< - !types::is_dtype::value, - std::tuple, - types::ndarray>>::type + std::enable_if_t::value, + std::tuple, + types::ndarray>> frexp(E const &arr) { auto arr_shape = sutils::getshape(arr); - types::ndarray significands( - arr_shape, builtins::None); + types::ndarray significands(arr_shape, builtins::None); types::ndarray exps(arr_shape, builtins::None); - _frexp(arr.begin(), arr.end(), significands.begin(), exps.begin(), - utils::int_()); + _frexp(arr.begin(), arr.end(), significands.begin(), exps.begin(), utils::int_()); return std::make_tuple(significands, exps); } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/frombuffer.hpp b/contrib/python/pythran/pythran/pythonic/numpy/frombuffer.hpp new file mode 100644 index 00000000000..65886858665 --- /dev/null +++ b/contrib/python/pythran/pythran/pythonic/numpy/frombuffer.hpp @@ -0,0 +1,33 @@ +#ifndef PYTHONIC_NUMPY_FROMBUFFER_HPP +#define PYTHONIC_NUMPY_FROMBUFFER_HPP + +#include "pythonic/include/numpy/frombuffer.hpp" + +#include "pythonic/types/list.hpp" +#include "pythonic/types/ndarray.hpp" +#include "pythonic/types/str.hpp" +#include "pythonic/utils/functor.hpp" + +#include +#include + +PYTHONIC_NS_BEGIN + +namespace numpy +{ + template + types::ndarray> + frombuffer(types::str const &string, dtype d, long count, long offset) + { + if (count < 0) + count = string.size() / sizeof(typename dtype::type); + types::pshape shape = count; + utils::shared_ref> buffer(std::get<0>(shape)); + auto const *tstring = reinterpret_cast(string.c_str()) + offset; + std::copy(tstring, tstring + std::get<0>(shape), buffer->data); + return {buffer, shape}; + } +} // namespace numpy +PYTHONIC_NS_END + +#endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fromfile.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fromfile.hpp index 771062f49ed..d941bf21c92 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fromfile.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fromfile.hpp @@ -18,12 +18,10 @@ namespace numpy { template types::ndarray> - fromfile(types::str const &file_name, dtype d, long count, - types::str const &sep, long offset) + fromfile(types::str const &file_name, dtype d, long count, types::str const &sep, long offset) { if (sep.size() != 0) - throw types::NotImplementedError( - "Sep input is not implemented yet, should be left empty"); + throw types::NotImplementedError("Sep input is not implemented yet, should be left empty"); std::fstream fs; fs.open(file_name.c_str(), std::fstream::in | std::fstream::binary); if (fs.rdstate() != std::fstream::goodbit) { @@ -40,8 +38,8 @@ namespace numpy count = maxCount; } - types::ndarray> res( - types::pshape{count}, types::none_type{}); + types::ndarray> res(types::pshape{count}, + types::none_type{}); fs.read((char *)res.buffer, sizeof(typename dtype::type) * count); return res; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fromfunction.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fromfunction.hpp index 857ecf35cce..46327dbbde2 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fromfunction.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fromfunction.hpp @@ -17,17 +17,11 @@ namespace numpy template template - types::ndarray::type>::type>::type, - pS> - fromfunction_helper::operator()(F &&f, - pS const &shape, - dtype d) + types::ndarray>>, pS> + fromfunction_helper::operator()(F &&f, pS const &shape, dtype d) { - types::ndarray::type>::type>::type, - pS> - out(shape, builtins::None); + types::ndarray>>, pS> out( + shape, builtins::None); long n = out.template shape<0>(); for (long i = 0; i < n; ++i) out[i] = f(i); @@ -36,18 +30,10 @@ namespace numpy template template - types::ndarray< - typename std::remove_cv::type>::type>::type, - pS> - fromfunction_helper::operator()(F &&f, - pS const &shape, - dtype d) + types::ndarray>>, pS> + fromfunction_helper::operator()(F &&f, pS const &shape, dtype d) { - types::ndarray< - typename std::remove_cv::type>::type>::type, - pS> + types::ndarray>>, pS> out(shape, builtins::None); long n = out.template shape<0>(); long m = out.template shape<1>(); @@ -60,12 +46,11 @@ namespace numpy template auto fromfunction(F &&f, pS const &shape, dtype d) -> decltype(fromfunction_helper::value, dtype, - typename pythonic::purity_of::type>()( - std::forward(f), shape)) + typename pythonic::purity_of::type>()(std::forward(f), + shape)) { return fromfunction_helper::value, dtype, - typename pythonic::purity_of::type>()( - std::forward(f), shape); + typename pythonic::purity_of::type>()(std::forward(f), shape); } /* TODO: must specialize for higher order */ diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fromiter.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fromiter.hpp index 7bbe112370c..9e03102ae22 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fromiter.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fromiter.hpp @@ -11,13 +11,11 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray::type>::type::value_type, + types::ndarray>::value_type, types::pshape> fromiter(Iterable &&iterable, dtype d, long count) { - using T = typename std::remove_cv< - typename std::remove_reference::type>::type::value_type; + using T = typename std::remove_cv_t>::value_type; if (count < 0) { types::list buffer(0); std::copy(iterable.begin(), iterable.end(), std::back_inserter(buffer)); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/fromstring.hpp b/contrib/python/pythran/pythran/pythonic/numpy/fromstring.hpp index d744824deb9..09dbd6cfaf0 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/fromstring.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/fromstring.hpp @@ -17,8 +17,7 @@ namespace numpy { template types::ndarray> - fromstring(types::str const &string, dtype d, long count, - types::str const &sep) + fromstring(types::str const &string, dtype d, long count, types::kwonly, types::str const &sep) { if (sep) { types::list res(0); @@ -42,10 +41,8 @@ namespace numpy if (count < 0) count = string.size(); types::pshape shape = count; - utils::shared_ref> buffer( - std::get<0>(shape)); - auto const *tstring = - reinterpret_cast(string.c_str()); + utils::shared_ref> buffer(std::get<0>(shape)); + auto const *tstring = reinterpret_cast(string.c_str()); std::copy(tstring, tstring + std::get<0>(shape), buffer->data); return {buffer, shape}; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/full.hpp b/contrib/python/pythran/pythran/pythonic/numpy/full.hpp index cca07499544..b70ae9d7cae 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/full.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/full.hpp @@ -12,38 +12,33 @@ namespace numpy { template - types::ndarray> - full(pS const &shape, F fill_value, dtype d) + types::ndarray> full(pS const &shape, F fill_value, + dtype d) { return {(sutils::shape_t)shape, typename dtype::type(fill_value)}; } template - types::ndarray> - full(long size, F fill_value, dtype d) + types::ndarray> full(long size, F fill_value, dtype d) { return full(types::pshape(size), fill_value, d); } template - types::ndarray>> + types::ndarray>> full(std::integral_constant, F fill_value, dtype d) { - return full(types::pshape>({}), fill_value, - d); + return full(types::pshape>({}), fill_value, d); } template - types::ndarray> full(pS const &shape, F fill_value, - types::none_type) + types::ndarray> full(pS const &shape, F fill_value, types::none_type) { return {(sutils::shape_t)shape, fill_value}; } template - types::ndarray> full(long size, F fill_value, - types::none_type nt) + types::ndarray> full(long size, F fill_value, types::none_type nt) { return full(types::pshape(size), fill_value, nt); } @@ -52,8 +47,7 @@ namespace numpy types::ndarray>> full(std::integral_constant, F fill_value, types::none_type nt) { - return full(types::pshape>({}), fill_value, - nt); + return full(types::pshape>({}), fill_value, nt); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/full_like.hpp b/contrib/python/pythran/pythran/pythonic/numpy/full_like.hpp index 721893baa4f..4ee5c279612 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/full_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/full_like.hpp @@ -20,11 +20,9 @@ namespace numpy template auto full_like(E const &expr, F fill_value, types::none_type) - -> decltype(full(sutils::getshape(expr), fill_value, - types::dtype_t())) + -> decltype(full(sutils::getshape(expr), fill_value, types::dtype_t())) { - return full(sutils::getshape(expr), fill_value, - types::dtype_t()); + return full(sutils::getshape(expr), fill_value, types::dtype_t()); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/hstack.hpp b/contrib/python/pythran/pythran/pythonic/numpy/hstack.hpp index de2e6f69372..6b4a55bf922 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/hstack.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/hstack.hpp @@ -10,12 +10,10 @@ namespace numpy { template - auto hstack(ArraySequence &&seq) - -> decltype(concatenate(std::forward(seq), 1)) + auto hstack(ArraySequence &&seq) -> decltype(concatenate(std::forward(seq), 1)) { auto constexpr concatenate_axis = - (decltype(concatenate(std::forward(seq), 1))::value != - 1); + (decltype(concatenate(std::forward(seq), 1))::value != 1); return concatenate(std::forward(seq), concatenate_axis); } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/imag.hpp b/contrib/python/pythran/pythran/pythonic/numpy/imag.hpp index d974c4c7cde..14b729bf9d9 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/imag.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/imag.hpp @@ -13,15 +13,13 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto imag(E &&expr) -> decltype(builtins::getattr(types::attr::IMAG{}, - std::forward(expr))) + auto imag(E &&expr) -> decltype(builtins::getattr(types::attr::IMAG{}, std::forward(expr))) { return builtins::getattr(types::attr::IMAG{}, std::forward(expr)); } template - auto imag(types::list const &expr) - -> decltype(imag(numpy::functor::asarray{}(expr))) + auto imag(types::list const &expr) -> decltype(imag(numpy::functor::asarray{}(expr))) { return imag(numpy::functor::asarray{}(expr)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/indices.hpp b/contrib/python/pythran/pythran/pythonic/numpy/indices.hpp index d22b05549a2..5b2768fe511 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/indices.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/indices.hpp @@ -11,17 +11,14 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename dtype::type, - sutils::push_front_t< - pS, std::integral_constant::value>>> + types::ndarray::value>>> indices(pS const &shape, dtype) { auto constexpr N = std::tuple_size::value; sutils::push_front_t> oshape; - sutils::scopy_shape<1, -1>(oshape, shape, utils::make_index_sequence()); - types::ndarray>> + sutils::scopy_shape<1, -1>(oshape, shape, std::make_index_sequence()); + types::ndarray>> out(oshape, builtins::None); typename dtype::type *iters[N]; for (size_t n = 0; n < N; ++n) diff --git a/contrib/python/pythran/pythran/pythonic/numpy/insert.hpp b/contrib/python/pythran/pythran/pythonic/numpy/insert.hpp index 8b71eda74db..ac46214fd57 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/insert.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/insert.hpp @@ -16,15 +16,12 @@ namespace numpy { template - typename std::enable_if::value && - types::is_iterable::value, - types::ndarray>>::type - insert(types::ndarray in, I const &indices, F const &data, - types::none_type axis) + std::enable_if_t::value && types::is_iterable::value, + types::ndarray>> + insert(types::ndarray in, I const &indices, F const &data, types::none_type axis) { types::ndarray> out( - types::pshape(long( - in.flat_size() + std::min(indices.flat_size(), data.flat_size()))), + types::pshape(long(in.flat_size() + std::min(indices.flat_size(), data.flat_size()))), builtins::None); auto out_iter = out.fbegin(); auto in_iter = in.fbegin(); @@ -39,31 +36,25 @@ namespace numpy } template - typename std::enable_if::value && - !types::is_iterable::value, - types::ndarray>>::type - insert(types::ndarray in, I const &indices, F const &data, - types::none_type axis) + std::enable_if_t::value && !types::is_iterable::value, + types::ndarray>> + insert(types::ndarray in, I const &indices, F const &data, types::none_type axis) { return insert(in, indices, types::list({data}), axis); } template - typename std::enable_if::value && - types::is_iterable::value, - types::ndarray>>::type - insert(types::ndarray in, I const &indices, F const &data, - types::none_type axis) + std::enable_if_t::value && types::is_iterable::value, + types::ndarray>> + insert(types::ndarray in, I const &indices, F const &data, types::none_type axis) { return insert(in, types::list({indices}), {data}, axis); } template - typename std::enable_if::value && - !types::is_iterable::value, - types::ndarray>>::type - insert(types::ndarray in, I const &indices, F const &data, - types::none_type axis) + std::enable_if_t::value && !types::is_iterable::value, + types::ndarray>> + insert(types::ndarray in, I const &indices, F const &data, types::none_type axis) { return insert(in, types::list({indices}), types::list({data}), axis); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/int16.hpp b/contrib/python/pythran/pythran/pythonic/numpy/int16.hpp index 8da42923c6b..37a44901235 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/int16.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/int16.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::int16 const &c) +{ + return (PyObject *)&PyInt16ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyInt16ArrType_Type; +} + +inline numpy::functor::int16 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/int32.hpp b/contrib/python/pythran/pythran/pythonic/numpy/int32.hpp index 463fcbe2ca8..48830d3a7e1 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/int32.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/int32.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::int32 const &c) +{ + return (PyObject *)&PyInt32ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyInt32ArrType_Type; +} + +inline numpy::functor::int32 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/int64.hpp b/contrib/python/pythran/pythran/pythonic/numpy/int64.hpp index 2fd941f10b6..38c3342d683 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/int64.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/int64.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::int64 const &c) +{ + return (PyObject *)&PyInt64ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyInt64ArrType_Type; +} + +inline numpy::functor::int64 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/int8.hpp b/contrib/python/pythran/pythran/pythonic/numpy/int8.hpp index af22837c712..a6588673e88 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/int8.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/int8.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::int8 const &c) +{ + return (PyObject *)&PyInt8ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyInt8ArrType_Type; +} + +inline numpy::functor::int8 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/int_.hpp b/contrib/python/pythran/pythran/pythonic/numpy/int_.hpp index 6c336194f6c..5a87779114c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/int_.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/int_.hpp @@ -34,4 +34,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::int_ const &c) +{ + return (PyObject *)&PyLong_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyLong_Type || obj == (PyObject *)&PyLongArrType_Type; +} + +inline numpy::functor::int_ from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/intc.hpp b/contrib/python/pythran/pythran/pythonic/numpy/intc.hpp index f47b6d8879c..7ef96eb5831 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/intc.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/intc.hpp @@ -33,5 +33,35 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::intc const &c) +{ + if (sizeof(int) == 4) + return (PyObject *)&PyInt32ArrType_Type; + else + return (PyObject *)&PyInt64ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (sizeof(int) == 4) + return obj == (PyObject *)&PyInt32ArrType_Type; + else + return obj == (PyObject *)&PyInt64ArrType_Type; +} + +inline numpy::functor::intc from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/interp.hpp b/contrib/python/pythran/pythran/pythonic/numpy/interp.hpp index 3b0993a3410..4d12b59f2f3 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/interp.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/interp.hpp @@ -21,8 +21,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray, types::pshape> - interp(T1 x, T2 xp, T3 fp, t1 _left, t2 _right, t3 _period) + types::ndarray, types::pshape> interp(T1 x, T2 xp, T3 fp, t1 _left, + t2 _right, t3 _period) { interp_out_type left = _left; interp_out_type right = _right; @@ -32,8 +32,8 @@ namespace numpy assert(xp.template shape<0>() == fp.template shape<0>()); interp_out_type outVal(0); - types::ndarray, types::pshape> out = { - (long)(x.template shape<0>()), outVal}; + types::ndarray, types::pshape> out = {(long)(x.template shape<0>()), + outVal}; if (period) { auto x_rem = pythonic::numpy::functor::remainder{}(x, period); @@ -42,21 +42,17 @@ namespace numpy auto xp_sorted = xp_rem[idx]; auto fp_sorted = fp[idx]; - auto left_pad_xp = - types::ndarray>( - types::pshape(1), xp_sorted[-1] - period); - auto right_pad_xp = - types::ndarray>( - types::pshape(1), xp_sorted[0] + period); + auto left_pad_xp = types::ndarray>( + types::pshape(1), xp_sorted[-1] - period); + auto right_pad_xp = types::ndarray>( + types::pshape(1), xp_sorted[0] + period); auto new_xp = pythonic::numpy::functor::concatenate{}( pythonic::types::make_tuple(left_pad_xp, xp_sorted, right_pad_xp)); - auto left_pad_fp = - types::ndarray, types::pshape>( - types::pshape(1), fp_sorted[-1]); - auto right_pad_fp = - types::ndarray, types::pshape>( - types::pshape(1), fp_sorted[0]); + auto left_pad_fp = types::ndarray, types::pshape>( + types::pshape(1), fp_sorted[-1]); + auto right_pad_fp = types::ndarray, types::pshape>( + types::pshape(1), fp_sorted[0]); auto new_fp = pythonic::numpy::functor::concatenate{}( pythonic::types::make_tuple(left_pad_fp, fp_sorted, right_pad_fp)); @@ -74,11 +70,9 @@ namespace numpy // No parameter specified template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - types::none_type period) + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, types::none_type period) { auto _left = fp[0]; auto _right = fp[-1]; @@ -87,33 +81,27 @@ namespace numpy // left specified template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right, - types::none_type period) + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right, types::none_type period) { auto _right = fp[-1]; return interp(x, xp, fp, left, _right, 0.); } // right specified template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, - types::none_type period) + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, types::none_type period) { auto _left = fp[0]; return interp(x, xp, fp, _left, right, 0.); } // period specified template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - t1 period) + std::enable_if_t::value, + types::ndarray, types::pshape>> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, t1 period) { assert(period != 0); return interp(x, xp, fp, 0., 0., period); @@ -121,9 +109,8 @@ namespace numpy // left and right specified template - typename std::enable_if< - !std::is_arithmetic::value, - types::ndarray, types::pshape>>::type + std::enable_if_t::value, + types::ndarray, types::pshape>> interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, types::none_type period) { return interp(x, xp, fp, left, right, 0.); @@ -131,63 +118,49 @@ namespace numpy // No parameter specified template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - types::none_type period) + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, types::none_type period) { auto _left = fp[0]; auto _right = fp[-1]; - auto temp_array = - types::ndarray>(types::pshape(1), x); + auto temp_array = types::ndarray>(types::pshape(1), x); return interp(temp_array, xp, fp, _left, _right, 0.)[0]; } // left specified template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right, - types::none_type period) + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, t1 left, types::none_type right, types::none_type period) { auto _right = fp[-1]; - auto temp_array = - types::ndarray>(types::pshape(1), x); + auto temp_array = types::ndarray>(types::pshape(1), x); return interp(temp_array, xp, fp, left, _right, 0.)[0]; } // right specified template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, - types::none_type period) + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, types::none_type left, t1 right, types::none_type period) { auto _left = fp[0]; - auto temp_array = - types::ndarray>(types::pshape(1), x); + auto temp_array = types::ndarray>(types::pshape(1), x); return interp(temp_array, xp, fp, _left, right, 0.)[0]; } // period specified template - typename std::enable_if::value, - interp_out_type>::type - interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, - t1 period) + std::enable_if_t::value, interp_out_type> + interp(T1 x, T2 xp, T3 fp, types::none_type left, types::none_type right, t1 period) { assert(period != 0); - auto temp_array = - types::ndarray>(types::pshape(1), x); + auto temp_array = types::ndarray>(types::pshape(1), x); return interp(temp_array, xp, fp, 0., 0., period)[0]; } // left and right specified, template - typename std::enable_if::value, - interp_out_type>::type + std::enable_if_t::value, interp_out_type> interp(T1 x, T2 xp, T3 fp, t1 left, t2 right, types::none_type period) { - auto temp_array = - types::ndarray>(types::pshape(1), x); + auto temp_array = types::ndarray>(types::pshape(1), x); return interp(temp_array, xp, fp, left, right, 0.)[0]; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/interp_core.hpp b/contrib/python/pythran/pythran/pythonic/numpy/interp_core.hpp index 93da77f9990..9a1048099c5 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/interp_core.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/interp_core.hpp @@ -28,8 +28,8 @@ PYTHONIC_NS_BEGIN template -static npy_intp binary_search_with_guess(const npy_double key, const T &arr, - npy_intp len, npy_intp guess) +static npy_intp binary_search_with_guess(const npy_double key, const T &arr, npy_intp len, + npy_intp guess) { npy_intp imin = 0; npy_intp imax = len; @@ -65,8 +65,7 @@ static npy_intp binary_search_with_guess(const npy_double key, const T &arr, if (key < arr[guess - 1]) { imax = guess - 1; /* last attempt to restrict search to items in cache */ - if (guess > LIKELY_IN_CACHE_SIZE && - key >= arr[guess - LIKELY_IN_CACHE_SIZE]) { + if (guess > LIKELY_IN_CACHE_SIZE && key >= arr[guess - LIKELY_IN_CACHE_SIZE]) { imin = guess - LIKELY_IN_CACHE_SIZE; } } else { @@ -85,8 +84,7 @@ static npy_intp binary_search_with_guess(const npy_double key, const T &arr, /* key >= arr[guess + 2] */ imin = guess + 2; /* last attempt to restrict search to items in cache */ - if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && - key < arr[guess + LIKELY_IN_CACHE_SIZE]) { + if (guess < len - LIKELY_IN_CACHE_SIZE - 1 && key < arr[guess + LIKELY_IN_CACHE_SIZE]) { imax = guess + LIKELY_IN_CACHE_SIZE; } } @@ -187,13 +185,11 @@ static npy_intp binary_search_with_guess(const npy_double key, const T &arr, // This is the output type, based on the type of T, which can be complex. template using out_type = - typename std::conditional::value, - std::complex, double>::type; + std::conditional_t::value, std::complex, double>; -template -void do_interp(const T1 &dz, const T2 &dx, const T3 &dy, T4 &dres, - npy_intp lenxp, npy_intp lenx, T5 lval, T5 rval) +template +void do_interp(const T1 &dz, const T2 &dx, const T3 &dy, T4 &dres, npy_intp lenxp, npy_intp lenx, + T5 lval, T5 rval) { npy_intp i; out_type *slopes = NULL; @@ -246,8 +242,7 @@ void do_interp(const T1 &dz, const T2 &dx, const T3 &dy, T4 &dres, dres[i] = dy[j]; } else { const out_type slope = - (slopes != NULL) ? slopes[j] - : (dy[j + 1] - dy[j]) / (dx[j + 1] - dx[j]); + (slopes != NULL) ? slopes[j] : (dy[j + 1] - dy[j]) / (dx[j + 1] - dx[j]); dres[i] = slope * (x_val - dx[j]) + dy[j]; } } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/intersect1d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/intersect1d.hpp index ca9f974dfd6..0e4e67ffda7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/intersect1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/intersect1d.hpp @@ -17,9 +17,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> intersect1d(E const &e, F const &f) { using T = typename __combined::type; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/isclose.hpp b/contrib/python/pythran/pythran/pythonic/numpy/isclose.hpp index c48e0006208..3e721e59829 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/isclose.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/isclose.hpp @@ -16,8 +16,7 @@ namespace numpy namespace wrapper { template - bool isclose(T0 const &u, T1 const &v, double rtol, double atol, - bool equal_nan) + bool isclose(T0 const &u, T1 const &v, double rtol, double atol, bool equal_nan) { if (functor::isfinite()(u) && functor::isfinite()(v)) return functor::abs()(u - v) <= (atol + rtol * functor::abs()(v)); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/iscomplex.hpp b/contrib/python/pythran/pythran/pythonic/numpy/iscomplex.hpp index b2b529b73fc..65d4f29886c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/iscomplex.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/iscomplex.hpp @@ -16,15 +16,13 @@ namespace numpy namespace wrapper { template - typename std::enable_if::value, bool>::type - iscomplex(I const &a) + std::enable_if_t::value, bool> iscomplex(I const &a) { return a.imag() != 0.; } template - constexpr typename std::enable_if::value, bool>::type - iscomplex(I const &a) + constexpr std::enable_if_t::value, bool> iscomplex(I const &a) { return false; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/isnan.hpp b/contrib/python/pythran/pythran/pythonic/numpy/isnan.hpp index a946eeeee74..53ddf613b52 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/isnan.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/isnan.hpp @@ -20,19 +20,14 @@ namespace numpy } template - auto isnan(T const &v) -> - typename std::enable_if< - std::is_floating_point::type>::value, - bool>::type + auto isnan(T const &v) -> std::enable_if_t>::value, bool> { return std::isnan(v); } template - auto isnan(T const &v) -> - typename std::enable_if< - !std::is_floating_point::type>::value, - bool>::type + auto isnan(T const &v) + -> std::enable_if_t>::value, bool> { return false; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/isreal.hpp b/contrib/python/pythran/pythran/pythonic/numpy/isreal.hpp index 134fdc307d4..58be012e421 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/isreal.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/isreal.hpp @@ -16,15 +16,13 @@ namespace numpy namespace wrapper { template - typename std::enable_if::value, bool>::type - isreal(I const &a) + std::enable_if_t::value, bool> isreal(I const &a) { return a.imag() == 0.; } template - typename std::enable_if::value, bool>::type - isreal(I const &a) + std::enable_if_t::value, bool> isreal(I const &a) { return true; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/issctype.hpp b/contrib/python/pythran/pythran/pythonic/numpy/issctype.hpp index 45fdedec58b..0fdb4565d25 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/issctype.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/issctype.hpp @@ -10,19 +10,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - constexpr auto issctype(E const &expr) -> - typename std::enable_if::value && - !std::is_same::value, - bool>::type + constexpr auto issctype(E const &expr) + -> std::enable_if_t::value && !std::is_same::value, bool> { return isscalar(typename E::type()); } template - constexpr auto issctype(E const &expr) -> - typename std::enable_if::value || - std::is_same::value, - bool>::type + constexpr auto issctype(E const &expr) + -> std::enable_if_t::value || std::is_same::value, bool> { return false; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/lexsort.hpp b/contrib/python/pythran/pythran/pythonic/numpy/lexsort.hpp index c8b1afa04bf..2acc4b13cfe 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/lexsort.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/lexsort.hpp @@ -54,8 +54,7 @@ namespace numpy types::ndarray> lexsort(pS const &keys) { long n = std::get<0>(keys).size(); - types::ndarray> out(types::pshape(n), - builtins::None); + types::ndarray> out(types::pshape(n), builtins::None); // fill with the original indices std::iota(out.buffer, out.buffer + n, 0L); // then sort using keys as the comparator diff --git a/contrib/python/pythran/pythran/pythonic/numpy/linalg/matrix_power.hpp b/contrib/python/pythran/pythran/pythonic/numpy/linalg/matrix_power.hpp index 7d873ab274c..c2c2cc0564c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/linalg/matrix_power.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/linalg/matrix_power.hpp @@ -43,8 +43,7 @@ namespace numpy } // namespace details template - auto matrix_power(E const &expr, - long n) -> decltype(numpy::functor::array{}(expr)) + auto matrix_power(E const &expr, long n) -> decltype(numpy::functor::array{}(expr)) { if (n == 0) return numpy::functor::identity{}(expr.template shape<0>(), diff --git a/contrib/python/pythran/pythran/pythonic/numpy/linalg/norm.hpp b/contrib/python/pythran/pythran/pythonic/numpy/linalg/norm.hpp index 1f24579776e..dcf6ef763d0 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/linalg/norm.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/linalg/norm.hpp @@ -20,28 +20,23 @@ namespace numpy { template auto norm(Array &&array, types::none_type ord, types::none_type axis) - -> decltype(pythonic::numpy::functor::sqrt{}( - pythonic::numpy::functor::sum{}( - pythonic::builtins::pythran::functor::abssqr{}( - std::forward(array))))) + -> decltype(pythonic::numpy::functor::sqrt{}(pythonic::numpy::functor::sum{}( + pythonic::builtins::pythran::functor::abssqr{}(std::forward(array))))) { return pythonic::numpy::functor::sqrt{}(pythonic::numpy::functor::sum{}( - pythonic::builtins::pythran::functor::abssqr{}( - std::forward(array)))); + pythonic::builtins::pythran::functor::abssqr{}(std::forward(array)))); } template norm_t norm(Array &&x, double ord, types::none_type) { - switch (std::decay::type::value) { + switch (std::decay_t::value) { case 1: return norm(std::forward(x), ord, 0L); case 2: - return norm(std::forward(x), ord, - types::array_tuple{{0L, 1L}}); + return norm(std::forward(x), ord, types::array_tuple{{0L, 1L}}); default: - throw pythonic::builtins::NotImplementedError( - "Invalid norm order for matrices."); + throw pythonic::builtins::NotImplementedError("Invalid norm order for matrices."); } } @@ -50,27 +45,20 @@ namespace numpy { auto &&y = pythonic::numpy::functor::asfarray{}(x); if (ord == inf) - return pythonic::numpy::functor::max{}( - pythonic::numpy::functor::abs{}(y), axis); + return pythonic::numpy::functor::max{}(pythonic::numpy::functor::abs{}(y), axis); else if (ord == -inf) - return pythonic::numpy::functor::min{}( - pythonic::numpy::functor::abs{}(y), axis); + return pythonic::numpy::functor::min{}(pythonic::numpy::functor::abs{}(y), axis); else if (ord == 0.) return pythonic::numpy::functor::sum{}(y != 0., axis); else if (ord == 1.) - return pythonic::numpy::functor::sum{}( - pythonic::numpy::functor::abs{}(y), axis); + return pythonic::numpy::functor::sum{}(pythonic::numpy::functor::abs{}(y), axis); else if (ord == 2.) return pythonic::numpy::functor::sqrt{}(pythonic::numpy::functor::sum{}( - pythonic::numpy::functor::real{}( - pythonic::numpy::functor::conj{}(y)*y), - axis)); + pythonic::numpy::functor::real{}(pythonic::numpy::functor::conj{}(y)*y), axis)); else { return pythonic::numpy::functor::power{}( pythonic::numpy::functor::sum{}( - pythonic::numpy::functor::power{}( - pythonic::numpy::functor::abs{}(y), ord), - axis), + pythonic::numpy::functor::power{}(pythonic::numpy::functor::abs{}(y), ord), axis), 1. / ord); } } @@ -85,8 +73,7 @@ namespace numpy return norm(std::forward(x), ord, axis[0]); } template - norm_t norm(Array &&array, double ord, - types::array_tuple axis) + norm_t norm(Array &&array, double ord, types::array_tuple axis) { throw pythonic::builtins::NotImplementedError("We need more dev!"); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/linspace.hpp b/contrib/python/pythran/pythran/pythonic/numpy/linspace.hpp index 9ee28f1276b..a832aab9bea 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/linspace.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/linspace.hpp @@ -12,11 +12,16 @@ namespace numpy { template types::ndarray> - linspace(double start, double stop, long num, bool endpoint, bool retstep, - dtype d) + linspace(double start, double stop, long num, bool endpoint, bool retstep, dtype d) { assert(!retstep && "retstep not supported"); - double step = (stop - start) / (num - (endpoint ? 1 : 0)); + if (num <= 1) + endpoint = 0; + double step = 1.; + if (stop == start || num == 0) // Special case, return [start] if num>0 and [] if num=0 + stop = start + ((num > 0) ? 1 : 0); + else + step = (stop - start) / (num - (endpoint ? 1 : 0)); if (std::is_integral::value) return asarray(arange(start, stop + (endpoint ? step * .5 : 0), step), d); else diff --git a/contrib/python/pythran/pythran/pythonic/numpy/logaddexp2.hpp b/contrib/python/pythran/pythran/pythonic/numpy/logaddexp2.hpp index b776d5e01ac..733dc3a040a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/logaddexp2.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/logaddexp2.hpp @@ -19,11 +19,9 @@ namespace numpy { template auto logaddexp2(T0 const &t0, T1 const &t1) - -> decltype(functor::log2{}(functor::power{}(T0(2), t0) + - functor::power{}(T1(2), t1))) + -> decltype(functor::log2{}(functor::power{}(T0(2), t0) + functor::power{}(T1(2), t1))) { - return functor::log2{}(functor::power{}(T0(2), t0) + - functor::power{}(T1(2), t1)); + return functor::log2{}(functor::power{}(T0(2), t0) + functor::power{}(T1(2), t1)); } } // namespace wrapper diff --git a/contrib/python/pythran/pythran/pythonic/numpy/logical_xor.hpp b/contrib/python/pythran/pythran/pythonic/numpy/logical_xor.hpp index 6758609df34..0223fe8f452 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/logical_xor.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/logical_xor.hpp @@ -15,8 +15,7 @@ namespace numpy namespace wrapper { template - auto logical_xor(T0 const &t0, - T1 const &t1) -> decltype((t0 && !t1) || (t1 && !t0)) + auto logical_xor(T0 const &t0, T1 const &t1) -> decltype((t0 && !t1) || (t1 && !t0)) { return (t0 && !t1) || (t1 && !t0); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/logspace.hpp b/contrib/python/pythran/pythran/pythonic/numpy/logspace.hpp index 8f33b1c38fa..50cba931575 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/logspace.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/logspace.hpp @@ -11,11 +11,9 @@ PYTHONIC_NS_BEGIN namespace numpy { auto logspace(double start, double stop, long num, bool endpoint, double base) - -> decltype(functor::power()(base, functor::linspace()(start, stop, num, - endpoint))) + -> decltype(functor::power()(base, functor::linspace()(start, stop, num, endpoint))) { - return functor::power()(base, - functor::linspace()(start, stop, num, endpoint)); + return functor::power()(base, functor::linspace()(start, stop, num, endpoint)); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/mean.hpp b/contrib/python/pythran/pythran/pythonic/numpy/mean.hpp index a4266b7633b..b9ec64283ba 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/mean.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/mean.hpp @@ -16,19 +16,16 @@ namespace numpy template auto mean(E const &expr, types::none_type axis, dtype d, types::none_type out, types::false_immediate keepdims) - -> decltype(sum(expr, axis, d) / - details::dtype_or_double(expr.flat_size())) + -> decltype(sum(expr, axis, d) / details::dtype_or_double(expr.flat_size())) { - return sum(expr, axis, d) / - details::dtype_or_double(expr.flat_size()); + return sum(expr, axis, d) / details::dtype_or_double(expr.flat_size()); } template auto mean(E const &expr, long axis, dtype d, types::none_type out, types::false_immediate keepdims) -> decltype(sum(expr, axis, d)) { - return sum(expr, axis, d) /= - details::dtype_or_double(sutils::getshape(expr)[axis]); + return sum(expr, axis, d) /= details::dtype_or_double(sutils::getshape(expr)[axis]); } template @@ -37,13 +34,11 @@ namespace numpy mean(E const &expr, types::none_type axis, dtype d, types::none_type out, types::true_immediate keep_dims) { - return {typename details::make_scalar_pshape::type(), - mean(expr, axis, d, out)}; + return {typename details::make_scalar_pshape::type(), mean(expr, axis, d, out)}; } template - auto mean(E const &expr, long axis, dtype d, types::none_type out, - types::true_immediate keepdims) + auto mean(E const &expr, long axis, dtype d, types::none_type out, types::true_immediate keepdims) -> decltype(expand_dims(mean(expr, axis, d), axis)) { return expand_dims(mean(expr, axis, d), axis); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/median.hpp b/contrib/python/pythran/pythran/pythonic/numpy/median.hpp index 939d2a3dd12..26c333765b7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/median.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/median.hpp @@ -18,13 +18,12 @@ namespace numpy { template - typename std::enable_if::value != 1, void>::type + std::enable_if_t::value != 1, void> _median(T_out *out, types::ndarray const &tmp, long axis) { auto tmp_shape = sutils::getshape(tmp); const long step = - std::accumulate(tmp_shape.begin() + axis, tmp_shape.end(), 1L, - std::multiplies()); + std::accumulate(tmp_shape.begin() + axis, tmp_shape.end(), 1L, std::multiplies()); long const buffer_size = tmp_shape[axis]; T *buffer = utils::allocate(buffer_size); const long stepper = step / tmp_shape[axis]; @@ -39,15 +38,13 @@ namespace numpy iter += stepper; } if (buffer_size % 2 == 1) { - std::nth_element(buffer, buffer + buffer_size / 2, buffer_iter, - ndarray::comparator{}); + std::nth_element(buffer, buffer + buffer_size / 2, buffer_iter, ndarray::comparator{}); *out++ = buffer[buffer_size / 2]; } else { - std::nth_element(buffer, buffer + buffer_size / 2, buffer_iter, - ndarray::comparator{}); + std::nth_element(buffer, buffer + buffer_size / 2, buffer_iter, ndarray::comparator{}); auto t0 = buffer[buffer_size / 2]; - std::nth_element(buffer, buffer + buffer_size / 2 - 1, - buffer + buffer_size / 2, ndarray::comparator{}); + std::nth_element(buffer, buffer + buffer_size / 2 - 1, buffer + buffer_size / 2, + ndarray::comparator{}); auto t1 = buffer[buffer_size / 2 - 1]; *out++ = (t0 + t1) / double(2); } @@ -62,8 +59,7 @@ namespace numpy } // namespace template - decltype(std::declval() + 1.) median(types::ndarray const &arr, - types::none_type) + decltype(std::declval() + 1.) median(types::ndarray const &arr, types::none_type) { size_t n = arr.flat_size(); T *tmp = utils::allocate(n); @@ -74,8 +70,7 @@ namespace numpy utils::deallocate(tmp); return t0; } else { - std::nth_element(tmp, tmp + n / 2 - 1, tmp + n / 2, - ndarray::comparator{}); + std::nth_element(tmp, tmp + n / 2 - 1, tmp + n / 2, ndarray::comparator{}); T t1 = tmp[n / 2 - 1]; utils::deallocate(tmp); return (t0 + t1) / 2.; @@ -83,11 +78,9 @@ namespace numpy } template - typename std::enable_if< - std::tuple_size::value != 1, - types::ndarray< - decltype(std::declval() + 1.), - types::array_tuple::value - 1>>>::type + std::enable_if_t::value != 1, + types::ndarray() + 1.), + types::array_tuple::value - 1>>> median(types::ndarray const &arr, long axis) { constexpr auto N = std::tuple_size::value; @@ -107,8 +100,7 @@ namespace numpy } template - typename std::enable_if::value == 1, - decltype(std::declval() + 1.)>::type + std::enable_if_t::value == 1, decltype(std::declval() + 1.)> median(types::ndarray const &arr, long axis) { if (axis != 0) diff --git a/contrib/python/pythran/pythran/pythonic/numpy/nanargmax.hpp b/contrib/python/pythran/pythran/pythonic/numpy/nanargmax.hpp index 931e14a2127..379db2ef0c9 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/nanargmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/nanargmax.hpp @@ -15,8 +15,7 @@ namespace numpy namespace { template - void _nanargmax(E begin, E end, F &max, long &index, long &where, - utils::int_<1>) + void _nanargmax(E begin, E end, F &max, long &index, long &where, utils::int_<1>) { for (; begin != end; ++begin, ++index) { auto curr = *begin; @@ -28,12 +27,10 @@ namespace numpy } template - void _nanargmax(E begin, E end, F &max, long &index, long &where, - utils::int_) + void _nanargmax(E begin, E end, F &max, long &index, long &where, utils::int_) { for (; begin != end; ++begin) - _nanargmax((*begin).begin(), (*begin).end(), max, index, where, - utils::int_()); + _nanargmax((*begin).begin(), (*begin).end(), max, index, where, utils::int_()); } } // namespace @@ -43,8 +40,7 @@ namespace numpy typename E::dtype max = -std::numeric_limits::infinity(); long where = -1; long index = 0; - _nanargmax(expr.begin(), expr.end(), max, index, where, - utils::int_()); + _nanargmax(expr.begin(), expr.end(), max, index, where, utils::int_()); if (where >= 0) return where; else diff --git a/contrib/python/pythran/pythran/pythonic/numpy/nanargmin.hpp b/contrib/python/pythran/pythran/pythonic/numpy/nanargmin.hpp index 5a1ec075579..1be27a3548b 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/nanargmin.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/nanargmin.hpp @@ -16,8 +16,7 @@ namespace numpy namespace { template - void _nanargmin(E begin, E end, F &min, long &index, long &where, - utils::int_<1>) + void _nanargmin(E begin, E end, F &min, long &index, long &where, utils::int_<1>) { for (; begin != end; ++begin, ++index) { auto curr = *begin; @@ -29,12 +28,10 @@ namespace numpy } template - void _nanargmin(E begin, E end, F &min, long &index, long &where, - utils::int_) + void _nanargmin(E begin, E end, F &min, long &index, long &where, utils::int_) { for (; begin != end; ++begin) - _nanargmin((*begin).begin(), (*begin).end(), min, index, where, - utils::int_()); + _nanargmin((*begin).begin(), (*begin).end(), min, index, where, utils::int_()); } } // namespace @@ -44,8 +41,7 @@ namespace numpy typename E::dtype min = std::numeric_limits::infinity(); long where = -1; long index = 0; - _nanargmin(expr.begin(), expr.end(), min, index, where, - utils::int_()); + _nanargmin(expr.begin(), expr.end(), min, index, where, utils::int_()); if (where >= 0) return where; else diff --git a/contrib/python/pythran/pythran/pythonic/numpy/nanmax.hpp b/contrib/python/pythran/pythran/pythonic/numpy/nanmax.hpp index ed69f52f52f..01342ab16a3 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/nanmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/nanmax.hpp @@ -33,8 +33,7 @@ namespace numpy { bool found = false; for (; begin != end; ++begin) - found |= _nanmax((*begin).begin(), (*begin).end(), max, - utils::int_()); + found |= _nanmax((*begin).begin(), (*begin).end(), max, utils::int_()); return found; } } // namespace diff --git a/contrib/python/pythran/pythran/pythonic/numpy/nanmin.hpp b/contrib/python/pythran/pythran/pythonic/numpy/nanmin.hpp index 6f06df15ac3..2bf2b81b134 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/nanmin.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/nanmin.hpp @@ -33,8 +33,7 @@ namespace numpy { bool found = false; for (; begin != end; ++begin) - found |= _nanmin((*begin).begin(), (*begin).end(), min, - utils::int_()); + found |= _nanmin((*begin).begin(), (*begin).end(), min, utils::int_()); return found; } } // namespace diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray.hpp index cf84d27eab6..d8d947a129d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray.hpp @@ -11,27 +11,30 @@ PYTHONIC_NS_BEGIN namespace numpy { - template - types::ndarray> - ndarray(pS const &shape, dtype) - { - return {(sutils::shape_t)shape, builtins::None}; - } - template - types::ndarray> ndarray(long size, - dtype d) + namespace anonymous { - return ndarray(types::pshape(size), d); - } - template - types::ndarray>> - ndarray(std::integral_constant, dtype d) - { - return ndarray(types::pshape>({}), d); - } + template + types::ndarray> ndarray(pS const &shape, dtype) + { + return {(sutils::shape_t)shape, builtins::None}; + } + + template + types::ndarray> ndarray(long size, dtype d) + { + return ndarray(types::pshape(size), d); + } + + template + types::ndarray>> + ndarray(std::integral_constant, dtype d) + { + return ndarray(types::pshape>({}), d); + } + + } // namespace anonymous } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/flatten.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/flatten.hpp index 1c260db223f..a7c1fcf66ed 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/flatten.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/flatten.hpp @@ -14,8 +14,7 @@ namespace numpy namespace ndarray { template - types::ndarray> - flatten(types::ndarray const &a) + types::ndarray> flatten(types::ndarray const &a) { return {a.mem, types::pshape{a.flat_size()}}; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/item.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/item.hpp index e08caf0698a..a55c8bf546e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/item.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/item.hpp @@ -24,15 +24,14 @@ namespace numpy } template - auto item(E &&expr, - types::array_tuple const &i) -> decltype(expr[i]) + auto item(E &&expr, types::array_tuple const &i) -> decltype(expr[i]) { return expr[i]; } // only for compatibility purpose, very bad impl template - typename std::decay::type::dtype item(E &&expr, long i) + typename std::decay_t::dtype item(E &&expr, long i) { if (i < 0) i += expr.flat_size(); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/reshape.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/reshape.hpp index 9e0c29678dc..6e5e2b54627 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/reshape.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/reshape.hpp @@ -17,33 +17,28 @@ namespace numpy namespace misc { template - void set(P &p, long i, long v, utils::index_sequence) + void set(P &p, long i, long v, std::index_sequence) { (void)std::initializer_list{ (i == Is && (sutils::assign(std::get(p), v), true))...}; } } // namespace misc template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> reshape(types::ndarray const &expr, NpS const &new_shape) { - long where = sutils::sfind( - new_shape, -1, - std::integral_constant::value>(), - [](long a, long b) { return a <= b; }); - long next = sutils::sfind(new_shape, -1, where, - [](long a, long b) { return a <= b; }); + long where = sutils::sfind(new_shape, -1, + std::integral_constant::value>(), + [](long a, long b) { return a <= b; }); + long next = sutils::sfind(new_shape, -1, where, [](long a, long b) { return a <= b; }); if (next >= 0) { - throw pythonic::types::ValueError( - "Reshape: can only specify one unknown dimension"); + throw pythonic::types::ValueError("Reshape: can only specify one unknown dimension"); } if (where >= 0) { auto auto_shape = new_shape; - misc::set(auto_shape, where, - expr.flat_size() / -sutils::sprod(new_shape), - utils::make_index_sequence::value>()); + misc::set(auto_shape, where, expr.flat_size() / -sutils::sprod(new_shape), + std::make_index_sequence::value>()); return expr.reshape(auto_shape); } else { auto nshape = sutils::sprod(new_shape); @@ -61,8 +56,7 @@ namespace numpy } } template - typename std::enable_if::value, - types::ndarray>>::type + std::enable_if_t::value, types::ndarray>> reshape(types::ndarray const &expr, NpS const &new_shape) { auto n = expr.flat_size(); @@ -70,8 +64,7 @@ namespace numpy return expr.reshape(types::pshape(n)); } if (n < new_shape) { - types::ndarray> out( - types::pshape{new_shape}, builtins::None); + types::ndarray> out(types::pshape{new_shape}, builtins::None); auto iter = std::copy(expr.fbegin(), expr.fend(), out.fbegin()); for (long i = 1; i < new_shape / n; ++i) iter = std::copy(out.fbegin(), out.fbegin() + n, iter); @@ -83,10 +76,8 @@ namespace numpy } template - auto reshape(types::ndarray const &expr, S0 i0, S1 i1, - S const &...indices) - -> decltype(reshape(expr, - types::pshape{i0, i1, indices...})) + auto reshape(types::ndarray const &expr, S0 i0, S1 i1, S const &...indices) + -> decltype(reshape(expr, types::pshape{i0, i1, indices...})) { return reshape(expr, types::pshape{i0, i1, indices...}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/sort.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/sort.hpp index a5860780f70..d1b392a1a9e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/sort.hpp @@ -55,11 +55,32 @@ namespace numpy }; template - struct _comp; + struct _comp : std::less { + }; + + template <> + struct _comp { + bool operator()(float x, float y) + { + if (__builtin_expect(std::isnan(y), false)) + return true; + return x < y; + } + }; + + template <> + struct _comp { + bool operator()(double x, double y) + { + if (__builtin_expect(std::isnan(y), false)) + return true; + return x < y; + } + }; + template struct _comp> { - bool operator()(std::complex const &i, - std::complex const &j) const + bool operator()(std::complex const &i, std::complex const &j) const { if (std::real(i) == std::real(j)) return std::imag(i) < std::imag(j); @@ -69,20 +90,18 @@ namespace numpy }; template - using comparator = - typename std::conditional::value, _comp, - std::less>::type; + using comparator = _comp; template - typename std::enable_if::value == 1, void>::type - _sort(types::ndarray &out, long axis, Sorter sorter) + std::enable_if_t::value == 1, void> _sort(types::ndarray &out, + long axis, Sorter sorter) { sorter(out.begin(), out.end(), comparator{}); } template - typename std::enable_if::value != 1, void>::type - _sort(types::ndarray &out, long axis, Sorter sorter) + std::enable_if_t::value != 1, void> _sort(types::ndarray &out, + long axis, Sorter sorter) { constexpr auto N = std::tuple_size::value; if (axis < 0) @@ -90,14 +109,13 @@ namespace numpy long const flat_size = out.flat_size(); if (axis == N - 1) { const long step = out.template shape(); - for (T *out_iter = out.buffer, *end_iter = out.buffer + flat_size; - out_iter != end_iter; out_iter += step) + for (T *out_iter = out.buffer, *end_iter = out.buffer + flat_size; out_iter != end_iter; + out_iter += step) sorter(out_iter, out_iter + step, comparator{}); } else { auto out_shape = sutils::getshape(out); - const long step = - std::accumulate(out_shape.begin() + axis, out_shape.end(), 1L, - std::multiplies()); + const long step = std::accumulate(out_shape.begin() + axis, out_shape.end(), 1L, + std::multiplies()); long const buffer_size = out_shape[axis]; const long stepper = step / out_shape[axis]; const long n = flat_size / out_shape[axis]; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tofile.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tofile.hpp index 8c64f1cde10..05fbc517a26 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tofile.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tofile.hpp @@ -22,8 +22,7 @@ namespace numpy types::str const &sep, types::str const &format) { if (sep.size() != 0) - throw types::NotImplementedError( - "Sep input is not implemented yet, should be left empty"); + throw types::NotImplementedError("Sep input is not implemented yet, should be left empty"); if (format.size() != 0) throw types::NotImplementedError( "Format input is not implemented yet, should be left empty"); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tolist.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tolist.hpp index 8731ca87541..0cb4742942e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tolist.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tolist.hpp @@ -16,17 +16,15 @@ namespace numpy { template - typename std::enable_if::value == 1, - types::list>::type + std::enable_if_t::value == 1, types::list> tolist(types::ndarray const &expr) { return {expr.fbegin(), expr.fend()}; } template - typename std::enable_if< - std::tuple_size::value != 1, - typename tolist_type::value>::type>::type + std::enable_if_t::value != 1, + typename tolist_type::value>::type> tolist(types::ndarray const &expr) { typename tolist_type::value>::type out(0); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tostring.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tostring.hpp index 9b01099a71e..c21e9eece33 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tostring.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndarray/tostring.hpp @@ -18,8 +18,7 @@ namespace numpy template types::str tostring(types::ndarray const &expr) { - return types::str(reinterpret_cast(expr.buffer), - expr.flat_size() * sizeof(T)); + return types::str(reinterpret_cast(expr.buffer), expr.flat_size() * sizeof(T)); } NUMPY_EXPR_TO_NDARRAY0_IMPL(tostring); } // namespace ndarray diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndenumerate.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndenumerate.hpp index 5ef52f452c0..f7319d59d2a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndenumerate.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndenumerate.hpp @@ -32,8 +32,7 @@ namespace numpy mult *= shape[j]; } out[0] = index / mult; - return std::tuple, typename E::dtype>{ - out, *iter}; + return std::tuple, typename E::dtype>{out, *iter}; } template @@ -51,22 +50,19 @@ namespace numpy } template - bool ndenumerate_iterator::operator!=( - ndenumerate_iterator const &other) const + bool ndenumerate_iterator::operator!=(ndenumerate_iterator const &other) const { return index != other.index; } template - bool - ndenumerate_iterator::operator<(ndenumerate_iterator const &other) const + bool ndenumerate_iterator::operator<(ndenumerate_iterator const &other) const { return index < other.index; } template - long - ndenumerate_iterator::operator-(ndenumerate_iterator const &other) const + long ndenumerate_iterator::operator-(ndenumerate_iterator const &other) const { return index - other.index; } @@ -78,8 +74,7 @@ namespace numpy template _ndenumerate::_ndenumerate(E const &expr) - : ndenumerate_iterator(expr, 0), expr(expr), - end_iter(expr, expr.flat_size()) + : ndenumerate_iterator(expr, 0), expr(expr), end_iter(expr, expr.flat_size()) { } @@ -102,8 +97,7 @@ namespace numpy } template - _ndenumerate> - ndenumerate(types::ndarray const &expr) + _ndenumerate> ndenumerate(types::ndarray const &expr) { return {expr}; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ndindex.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ndindex.hpp index e32e6bab84f..edd102150be 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ndindex.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ndindex.hpp @@ -17,8 +17,7 @@ namespace numpy } template - ndindex_iterator::ndindex_iterator( - types::array_tuple const &shape, long first) + ndindex_iterator::ndindex_iterator(types::array_tuple const &shape, long first) : index(first), shape(shape) { } @@ -76,8 +75,7 @@ namespace numpy template _ndindex::_ndindex(types::array_tuple const &shape) : ndindex_iterator(shape, 0), shape(shape), - end_iter(shape, std::accumulate(shape.begin(), shape.end(), 1L, - std::multiplies())) + end_iter(shape, std::accumulate(shape.begin(), shape.end(), 1L, std::multiplies())) { } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/nonzero.hpp b/contrib/python/pythran/pythran/pythonic/numpy/nonzero.hpp index 5b22e8ba571..f4a7f9a3a6a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/nonzero.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/nonzero.hpp @@ -14,8 +14,7 @@ namespace numpy namespace { template - void _nonzero(I begin, I end, O &out, types::array_tuple &curr, - utils::int_<1>) + void _nonzero(I begin, I end, O &out, types::array_tuple &curr, utils::int_<1>) { I start = begin; for (; begin != end; ++begin) { @@ -29,21 +28,19 @@ namespace numpy } template - void _nonzero(I begin, I end, O &out, types::array_tuple &curr, - utils::int_) + void _nonzero(I begin, I end, O &out, types::array_tuple &curr, utils::int_) { I start = begin; for (; begin != end; ++begin) { curr[M - N] = begin - start; - _nonzero((*begin).begin(), (*begin).end(), out, curr, - utils::int_()); + _nonzero((*begin).begin(), (*begin).end(), out, curr, utils::int_()); } } } // namespace template types::array_tuple>, sizeof...(Is)> - init_buffers(long sz, utils::index_sequence) + init_buffers(long sz, std::index_sequence) { auto fwd = [](long ret, long) { return ret; }; // just to avoid a warning return {{fwd(sz, Is)...}}; // too much memory used @@ -51,17 +48,15 @@ namespace numpy template auto nonzero(E const &expr) - -> types::array_tuple>, - E::value> + -> types::array_tuple>, E::value> { constexpr long N = E::value; - typedef types::array_tuple< - types::ndarray>, E::value> + typedef types::array_tuple>, E::value> out_type; long sz = expr.flat_size(); - types::array_tuple>, N> - out_buffers = init_buffers(sz, utils::make_index_sequence()); + types::array_tuple>, N> out_buffers = + init_buffers(sz, std::make_index_sequence()); types::array_tuple out_iters; for (size_t i = 0; i < N; ++i) out_iters[i] = out_buffers[i]->data; @@ -69,13 +64,11 @@ namespace numpy types::array_tuple indices; _nonzero(expr.begin(), expr.end(), out_iters, indices, utils::int_()); - types::array_tuple shape = { - {(long)(out_iters[0] - out_buffers[0]->data)}}; + types::array_tuple shape = {{(long)(out_iters[0] - out_buffers[0]->data)}}; out_type out; for (size_t i = 0; i < N; ++i) - out[i] = types::ndarray>( - std::move(out_buffers[i]), shape); + out[i] = types::ndarray>(std::move(out_buffers[i]), shape); return out; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ones.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ones.hpp index 13a94109807..59562a4c091 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ones.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ones.hpp @@ -18,22 +18,19 @@ namespace numpy } template - types::ndarray> - ones(pS const &shape, dtype d) + types::ndarray> ones(pS const &shape, dtype d) { return {(sutils::shape_t)shape, typename dtype::type(1)}; } template - types::ndarray> ones(long size, - dtype d) + types::ndarray> ones(long size, dtype d) { return ones(types::pshape(size), d); } template - types::ndarray>> + types::ndarray>> ones(std::integral_constant, dtype d) { return ones(types::pshape>({}), d); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ones_like.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ones_like.hpp index b6070aa733c..35ba00f7555 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ones_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ones_like.hpp @@ -12,16 +12,14 @@ namespace numpy { template - auto ones_like(E const &expr, - dtype d) -> decltype(ones(sutils::getshape(expr), d)) + auto ones_like(E const &expr, dtype d) -> decltype(ones(sutils::getshape(expr), d)) { return ones(sutils::getshape(expr), d); } template auto ones_like(E const &expr, types::none_type) - -> decltype(ones(sutils::getshape(expr), - types::dtype_t())) + -> decltype(ones(sutils::getshape(expr), types::dtype_t())) { return ones(sutils::getshape(expr), types::dtype_t()); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/outer.hpp b/contrib/python/pythran/pythran/pythonic/numpy/outer.hpp index 99d9983bffe..fd5539e5241 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/outer.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/outer.hpp @@ -13,41 +13,33 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray() + std::declval()), - types::pshape> + types::ndarray() + std::declval()), types::pshape> outer(types::ndarray const &a, types::ndarray const &b) { - types::ndarray() + std::declval()), - types::pshape> - out(types::pshape{a.flat_size(), b.flat_size()}, - builtins::None); + types::ndarray() + std::declval()), types::pshape> + out(types::pshape{a.flat_size(), b.flat_size()}, builtins::None); auto iter = out.fbegin(); - for (auto iter_a = a.fbegin(), end_a = a.fend(); iter_a != end_a; - ++iter_a) { + for (auto iter_a = a.fbegin(), end_a = a.fend(); iter_a != end_a; ++iter_a) { auto val_a = *iter_a; - iter = std::transform(b.fbegin(), b.fend(), iter, - [=](T1 val) { return val_a * val; }); + iter = std::transform(b.fbegin(), b.fend(), iter, [=](T1 val) { return val_a * val; }); } return out; } template - auto outer(types::ndarray const &a, - E1 const &b) -> decltype(outer(a, asarray(b))) + auto outer(types::ndarray const &a, E1 const &b) -> decltype(outer(a, asarray(b))) { return outer(a, asarray(b)); } template - auto outer(E0 const &a, - types::ndarray const &b) -> decltype(outer(asarray(a), b)) + auto outer(E0 const &a, types::ndarray const &b) -> decltype(outer(asarray(a), b)) { return outer(asarray(a), b); } template - auto outer(E0 const &a, - E1 const &b) -> decltype(outer(asarray(a), asarray(b))) + auto outer(E0 const &a, E1 const &b) -> decltype(outer(asarray(a), asarray(b))) { return outer(asarray(a), asarray(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/partial_sum.hpp b/contrib/python/pythran/pythran/pythonic/numpy/partial_sum.hpp index 2074d7ca0f3..76f2f4f2b8c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/partial_sum.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/partial_sum.hpp @@ -73,8 +73,7 @@ namespace numpy } // namespace template - types::ndarray> - partial_sum(E const &expr, dtype d) + types::ndarray> partial_sum(E const &expr, dtype d) { const long count = expr.flat_size(); types::ndarray> the_partial_sum{ @@ -85,9 +84,8 @@ namespace numpy } template - auto partial_sum(E const &expr, long axis, dtype d) -> - typename std::enable_if(expr))>::type + auto partial_sum(E const &expr, long axis, dtype d) + -> std::enable_if_t(expr))> { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -95,8 +93,8 @@ namespace numpy } template - typename std::enable_if>::type - partial_sum(E const &expr, long axis, dtype d) + std::enable_if_t> partial_sum(E const &expr, + long axis, dtype d) { if (axis < 0 || size_t(axis) >= E::value) throw types::ValueError("axis out of bounds"); @@ -109,9 +107,9 @@ namespace numpy } else { std::transform( expr.begin(), expr.end(), the_partial_sum.begin(), - [axis, - d](typename std::iterator_traits::value_type - other) { return partial_sum(other, axis - 1, d); }); + [axis, d](typename std::iterator_traits::value_type other) { + return partial_sum(other, axis - 1, d); + }); } return the_partial_sum; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/place.hpp b/contrib/python/pythran/pythran/pythonic/numpy/place.hpp index 5cf1da62caa..1481963107d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/place.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/place.hpp @@ -13,14 +13,13 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type place(types::ndarray &expr, - types::ndarray const &mask, F const &values) + types::none_type place(types::ndarray &expr, types::ndarray const &mask, + F const &values) { auto first = expr.fend(); auto viter = values.begin(), vend = values.end(); auto miter = mask.fbegin(); - for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; - ++iter, ++miter) { + for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; ++iter, ++miter) { if (*miter) { if (first == expr.fend()) first = iter; @@ -34,8 +33,7 @@ namespace numpy } template - types::none_type place(types::ndarray &expr, M const &mask, - F const &values) + types::none_type place(types::ndarray &expr, M const &mask, F const &values) { return place(expr, asarray(mask), values); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ptp.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ptp.hpp index 5db6f7036f3..53c2acda1fe 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ptp.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ptp.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto ptp(E const &expr, - long axis) -> decltype(max(expr, axis) - min(expr, axis)) + auto ptp(E const &expr, long axis) -> decltype(max(expr, axis) - min(expr, axis)) { return max(expr, axis) - min(expr, axis); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/put.hpp b/contrib/python/pythran/pythran/pythonic/numpy/put.hpp index fc7b27d34a0..377f9db5d39 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/put.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/put.hpp @@ -14,8 +14,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if::value, - types::none_type>::type + std::enable_if_t::value, types::none_type> put(types::ndarray &expr, F const &ind, E const &v) { auto vind = asarray(ind); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/putmask.hpp b/contrib/python/pythran/pythran/pythonic/numpy/putmask.hpp index 8b9b9f14aaf..c1327de2f3e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/putmask.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/putmask.hpp @@ -13,8 +13,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::none_type putmask(types::ndarray &expr, E const &mask, - F const &values) + types::none_type putmask(types::ndarray &expr, E const &mask, F const &values) { auto amask = asarray(mask); auto avalues = asarray(values); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/bytes.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/bytes.hpp index a4c870b98ca..0955dee35c8 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/bytes.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/bytes.hpp @@ -21,9 +21,8 @@ namespace numpy // dummy init + rewrite is faster than reserve && push_back types::str result(std::string(length, 0)); std::uniform_int_distribution distribution{0, 255}; - std::generate(result.chars().begin(), result.chars().end(), [&]() { - return static_cast(distribution(details::generator)); - }); + std::generate(result.chars().begin(), result.chars().end(), + [&]() { return static_cast(distribution(details::generator)); }); return result; } } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/choice.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/choice.hpp index 1027cd81136..17eb978b42a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/choice.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/choice.hpp @@ -22,8 +22,7 @@ namespace numpy * Implementation with long as first argument **********************************************************/ template - types::ndarray choice(long max, pS const &shape, bool replace, - P const &p) + types::ndarray choice(long max, pS const &shape, bool replace, P const &p) { if (!replace) throw pythonic::builtins::NotImplementedError( @@ -38,16 +37,13 @@ namespace numpy } template - types::ndarray> choice(long max, long size, - bool replace, P &&p) + types::ndarray> choice(long max, long size, bool replace, P &&p) { - return choice(max, types::pshape{size}, replace, - std::forward

(p)); + return choice(max, types::pshape{size}, replace, std::forward

(p)); } template - auto choice(long max, - T &&size) -> decltype(randint(0, max, std::forward(size))) + auto choice(long max, T &&size) -> decltype(randint(0, max, std::forward(size))) { return randint(0, max, std::forward(size)); } @@ -84,15 +80,14 @@ namespace numpy } template - types::ndarray> choice(T &&a, - long size) + types::ndarray> choice(T &&a, long size) { return choice(std::forward(a), types::pshape{size}); } template - types::ndarray choice(T const &a, pS const &shape, - bool replace, P const &p) + types::ndarray choice(T const &a, pS const &shape, bool replace, + P const &p) { // This is a numpy constraint static_assert(T::value == 1, "ValueError: a must be 1-dimensional"); @@ -110,11 +105,10 @@ namespace numpy } template - types::ndarray> - choice(T &&a, long size, bool replace, P &&p) + types::ndarray> choice(T &&a, long size, bool replace, + P &&p) { - return choice(std::forward(a), types::pshape{size}, replace, - std::forward

(p)); + return choice(std::forward(a), types::pshape{size}, replace, std::forward

(p)); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/exponential.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/exponential.hpp index ae3abd473fe..031ff917525 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/exponential.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/exponential.hpp @@ -37,8 +37,7 @@ namespace numpy inline double exponential(double scale, types::none_type d) { - return std::exponential_distribution{1 / - scale}(details::generator); + return std::exponential_distribution{1 / scale}(details::generator); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/f.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/f.hpp index d6dcf1bcd5a..95108b093ac 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/f.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/f.hpp @@ -31,19 +31,16 @@ namespace numpy return result; } - inline auto f(double dfnum, double dfden, - long size) -> decltype(f(dfnum, dfden, - types::array_tuple{{size}})) + inline auto f(double dfnum, double dfden, long size) + -> decltype(f(dfnum, dfden, types::array_tuple{{size}})) { return f(dfnum, dfden, types::array_tuple{{size}}); } inline double f(double dfnum, double dfden, types::none_type d) { - return (std::chi_squared_distribution{dfnum}( - details::generator)*dfden) / - (std::chi_squared_distribution{dfden}( - details::generator)*dfnum); + return (std::chi_squared_distribution{dfnum}(details::generator)*dfden) / + (std::chi_squared_distribution{dfden}(details::generator)*dfnum); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/gamma.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/gamma.hpp index 9d6cc1fb831..ec24f59a823 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/gamma.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/gamma.hpp @@ -19,8 +19,7 @@ namespace numpy { template - types::ndarray gamma(double shape, double scale, - pS const &array_shape) + types::ndarray gamma(double shape, double scale, pS const &array_shape) { types::ndarray result{array_shape, types::none_type()}; std::gamma_distribution distribution{shape, scale}; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/gumbel.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/gumbel.hpp index 666c6906f9a..dc145a88d4e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/gumbel.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/gumbel.hpp @@ -22,8 +22,7 @@ namespace numpy types::ndarray gumbel(double loc, double scale, pS const &shape) { types::ndarray result{shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return gumbel(loc, scale); }); + std::generate(result.fbegin(), result.fend(), [&]() { return gumbel(loc, scale); }); return result; } @@ -35,8 +34,7 @@ namespace numpy inline double gumbel(double loc, double scale, types::none_type d) { - double U = - std::uniform_real_distribution{0., 1.}(details::generator); + double U = std::uniform_real_distribution{0., 1.}(details::generator); if (U < 1.0) { return loc - scale * xsimd::log(-xsimd::log(U)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/laplace.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/laplace.hpp index a000332971f..442b5f5d68e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/laplace.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/laplace.hpp @@ -19,12 +19,10 @@ namespace numpy { template - types::ndarray laplace(double loc, double scale, - pS const &shape) + types::ndarray laplace(double loc, double scale, pS const &shape) { types::ndarray result{shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return laplace(loc, scale); }); + std::generate(result.fbegin(), result.fend(), [&]() { return laplace(loc, scale); }); return result; } @@ -36,8 +34,7 @@ namespace numpy inline double laplace(double loc, double scale, types::none_type d) { - double U = - std::uniform_real_distribution{0., 1.}(details::generator); + double U = std::uniform_real_distribution{0., 1.}(details::generator); if (U >= 0.5) { U = loc - scale * xsimd::log(2.0 - U - U); } else if (U > 0.0) { diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/logistic.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/logistic.hpp index bb9cbb4e665..9cdb4a10bf1 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/logistic.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/logistic.hpp @@ -19,12 +19,10 @@ namespace numpy { template - types::ndarray logistic(double loc, double scale, - pS const &shape) + types::ndarray logistic(double loc, double scale, pS const &shape) { types::ndarray result{shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return logistic(loc, scale); }); + std::generate(result.fbegin(), result.fend(), [&]() { return logistic(loc, scale); }); return result; } @@ -36,8 +34,7 @@ namespace numpy inline double logistic(double loc, double scale, types::none_type d) { - double U = - std::uniform_real_distribution{0., 1.}(details::generator); + double U = std::uniform_real_distribution{0., 1.}(details::generator); if (U > 0.0) { return loc + scale * xsimd::log(U / (1 - U)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/lognormal.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/lognormal.hpp index be6b5705713..7676f7a0378 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/lognormal.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/lognormal.hpp @@ -19,8 +19,7 @@ namespace numpy { template - types::ndarray lognormal(double mean, double sigma, - pS const &shape) + types::ndarray lognormal(double mean, double sigma, pS const &shape) { types::ndarray result{shape, types::none_type()}; std::lognormal_distribution distribution{mean, sigma}; @@ -37,8 +36,7 @@ namespace numpy inline double lognormal(double mean, double sigma, types::none_type d) { - return std::lognormal_distribution{mean, - sigma}(details::generator); + return std::lognormal_distribution{mean, sigma}(details::generator); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/logseries.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/logseries.hpp index 89bf6d377be..6c3c122cc85 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/logseries.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/logseries.hpp @@ -23,8 +23,7 @@ namespace numpy types::ndarray logseries(double p, pS const &shape) { types::ndarray result{shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return logseries(p); }); + std::generate(result.fbegin(), result.fend(), [&]() { return logseries(p); }); return result; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/negative_binomial.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/negative_binomial.hpp index 1e09660f815..5277c489c2e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/negative_binomial.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/negative_binomial.hpp @@ -19,8 +19,7 @@ namespace numpy { template - types::ndarray negative_binomial(long n, double p, - pS const &shape) + types::ndarray negative_binomial(long n, double p, pS const &shape) { types::ndarray result{shape, types::none_type()}; std::negative_binomial_distribution distribution{n, p}; @@ -30,8 +29,7 @@ namespace numpy } inline auto negative_binomial(long n, double p, long size) - -> decltype(negative_binomial(n, p, - types::array_tuple{{size}})) + -> decltype(negative_binomial(n, p, types::array_tuple{{size}})) { return negative_binomial(n, p, types::array_tuple{{size}}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/pareto.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/pareto.hpp index 8900b2a5c54..573bd56dbbc 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/pareto.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/pareto.hpp @@ -23,9 +23,8 @@ namespace numpy { types::ndarray result{shape, types::none_type()}; std::exponential_distribution distribution{}; - std::generate(result.fbegin(), result.fend(), [&]() { - return expm1(distribution(details::generator) / a); - }); + std::generate(result.fbegin(), result.fend(), + [&]() { return expm1(distribution(details::generator) / a); }); return result; } @@ -38,8 +37,7 @@ namespace numpy inline double pareto(double a, types::none_type d) { - return expm1(std::exponential_distribution{}(details::generator) / - a); + return expm1(std::exponential_distribution{}(details::generator) / a); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/power.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/power.hpp index 36db5bcdd4e..bf446c70442 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/power.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/power.hpp @@ -36,9 +36,7 @@ namespace numpy inline double power(double a, types::none_type d) { - return pow( - -expm1(-std::exponential_distribution{}(details::generator)), - 1. / a); + return pow(-expm1(-std::exponential_distribution{}(details::generator)), 1. / a); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/rand.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/rand.hpp index 677fd5e6ff4..2f131318770 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/rand.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/rand.hpp @@ -15,8 +15,7 @@ namespace numpy { template - types::ndarray> - rand(T... shape) + types::ndarray> rand(T... shape) { return random(types::array_tuple{{shape...}}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/randint.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/randint.hpp index 9911415453b..244694fe5e3 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/randint.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/randint.hpp @@ -17,8 +17,7 @@ namespace numpy { template - typename std::enable_if::value, - types::ndarray>::type + std::enable_if_t::value, types::ndarray> randint(long min, long max, pS const &shape) { types::ndarray result{shape, types::none_type()}; @@ -29,16 +28,14 @@ namespace numpy } template - typename std::enable_if::value, - types::ndarray>>::type + std::enable_if_t::value, types::ndarray>> randint(long min, long max, pS const &shape) { return randint(min, max, types::pshape{shape}); } template - auto randint(long max, types::none_type, - pS const &shape) -> decltype(randint(0, max, shape)) + auto randint(long max, types::none_type, pS const &shape) -> decltype(randint(0, max, shape)) { return randint(0, max, shape); } @@ -51,14 +48,12 @@ namespace numpy inline long randint(long max, types::none_type) { - return std::uniform_int_distribution{0, - max - 1}(details::generator); + return std::uniform_int_distribution{0, max - 1}(details::generator); } inline long randint(long min, long max) { - return std::uniform_int_distribution{min, - max - 1}(details::generator); + return std::uniform_int_distribution{min, max - 1}(details::generator); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/randn.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/randn.hpp index c732058fd32..ee0287cd39a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/randn.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/randn.hpp @@ -15,11 +15,9 @@ namespace numpy { template - types::ndarray> - randn(T... shape) + types::ndarray> randn(T... shape) { - return standard_normal( - types::array_tuple{{shape...}}); + return standard_normal(types::array_tuple{{shape...}}); } inline double randn() diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/random.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/random.hpp index 7bd6e85e9e1..ceb0885c564 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/random.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/random.hpp @@ -28,8 +28,7 @@ namespace numpy return result; } - inline auto - random(long size) -> decltype(random(types::array_tuple{{size}})) + inline auto random(long size) -> decltype(random(types::array_tuple{{size}})) { return random(types::array_tuple{{size}}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/rayleigh.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/rayleigh.hpp index 659d2d66d72..29d51ebdce0 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/rayleigh.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/rayleigh.hpp @@ -23,8 +23,7 @@ namespace numpy types::ndarray rayleigh(double scale, pS const &array_shape) { types::ndarray result{array_shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return rayleigh(scale); }); + std::generate(result.fbegin(), result.fend(), [&]() { return rayleigh(scale); }); return result; } @@ -36,9 +35,8 @@ namespace numpy inline double rayleigh(double scale, types::none_type d) { - return scale * - sqrt(-2.0 * log(1.0 - std::uniform_real_distribution{ - 0., 1.}(details::generator))); + return scale * sqrt(-2.0 * log(1.0 - std::uniform_real_distribution{0., 1.}( + details::generator))); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/random/uniform.hpp b/contrib/python/pythran/pythran/pythonic/numpy/random/uniform.hpp index 29df0df1b55..fd8a34487ab 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/random/uniform.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/random/uniform.hpp @@ -20,12 +20,10 @@ namespace numpy { template - types::ndarray uniform(double low, double high, - pS const &array_shape) + types::ndarray uniform(double low, double high, pS const &array_shape) { types::ndarray result{array_shape, types::none_type()}; - std::generate(result.fbegin(), result.fend(), - [&]() { return uniform(low, high); }); + std::generate(result.fbegin(), result.fend(), [&]() { return uniform(low, high); }); return result; } @@ -37,8 +35,7 @@ namespace numpy inline double uniform(double low, double high, types::none_type d) { - return std::uniform_real_distribution{low, - high}(details::generator); + return std::uniform_real_distribution{low, high}(details::generator); } } // namespace random } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ravel.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ravel.hpp index f8257fa3996..30a0e282a35 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ravel.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ravel.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - ravel(types::ndarray const &expr) + types::ndarray> ravel(types::ndarray const &expr) { return expr.reshape(types::pshape{expr.flat_size()}); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/real.hpp b/contrib/python/pythran/pythran/pythonic/numpy/real.hpp index 28a4143ff89..60bf72516ff 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/real.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/real.hpp @@ -13,15 +13,13 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto real(E &&expr) -> decltype(builtins::getattr(types::attr::REAL{}, - std::forward(expr))) + auto real(E &&expr) -> decltype(builtins::getattr(types::attr::REAL{}, std::forward(expr))) { return builtins::getattr(types::attr::REAL{}, std::forward(expr)); } template - auto real(types::list const &expr) - -> decltype(real(numpy::functor::asarray{}(expr))) + auto real(types::list const &expr) -> decltype(real(numpy::functor::asarray{}(expr))) { return real(numpy::functor::asarray{}(expr)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/reduce.hpp b/contrib/python/pythran/pythran/pythonic/numpy/reduce.hpp index e1b2588f140..b32b7251f5c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/reduce.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/reduce.hpp @@ -24,8 +24,7 @@ namespace numpy F operator()(E &&e, F acc) { for (auto &&value : std::forward(e)) - acc = _reduce{}( - std::forward(value), acc); + acc = _reduce{}(std::forward(value), acc); return acc; } @@ -49,10 +48,8 @@ namespace numpy template F operator()(E &&e, F acc, Indices... indices) { - for (long i = 0, n = e.template shape::type::value - N>(); - i < n; ++i) { - acc = _reduce{}( - e, acc, indices..., i); + for (long i = 0, n = e.template shape::value - N>(); i < n; ++i) { + acc = _reduce{}(e, acc, indices..., i); } return acc; } @@ -63,8 +60,7 @@ namespace numpy template F operator()(E &&e, F acc, Indices... indices) { - for (long i = 0, n = e.template shape::type::value - 1>(); - i < n; ++i) { + for (long i = 0, n = e.template shape::value - 1>(); i < n; ++i) { Op{}(acc, e.load(indices..., i)); } return acc; @@ -111,8 +107,7 @@ namespace numpy template F operator()(E &&e, F acc) { - return vreduce(std::forward(e), - acc); + return vreduce(std::forward(e), acc); } }; #else @@ -151,16 +146,14 @@ namespace numpy } }; template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, E>::type + std::enable_if_t::value || types::is_complex::value, E> reduce(E const &expr, types::none_type) { return expr; } template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, E>::type + std::enable_if_t::value || types::is_complex::value, E> reduce(E const &array, long axis) { if (axis != 0) @@ -169,20 +162,19 @@ namespace numpy } template - typename std::enable_if::value, - reduce_result_type>::type + std::enable_if_t::value, reduce_result_type> reduce(E const &expr, types::none_type axis, dtype) { using rrt = reduce_result_type; - bool constexpr is_vectorizable = - E::is_vectorizable && !std::is_same::value && - std::is_same::value; + bool constexpr is_vectorizable = E::is_vectorizable && + !std::is_same::value && + std::is_same::value; rrt p = utils::neutral::value; return reduce_helper{}(expr, p); } template - typename std::enable_if>::type + std::enable_if_t> reduce(E const &array, long axis, dtype d, types::none_type) { if (axis != 0) @@ -191,8 +183,8 @@ namespace numpy } template - typename std::enable_if>::type - reduce(E const &array, long axis, types::none_type, Out &&out) + std::enable_if_t> reduce(E const &array, long axis, + types::none_type, Out &&out) { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -202,60 +194,46 @@ namespace numpy template struct _reduce_axisb { template - void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, - FIndices &&f_indices) + void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, FIndices &&f_indices) { - for (long i = 0, n = e.template shape::type::value - N>(); - i < n; ++i) { - _reduce_axisb{}( - e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), - std::tuple_cat(f_indices, std::make_tuple(i))); + for (long i = 0, n = e.template shape::value - N>(); i < n; ++i) { + _reduce_axisb{}(e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), + std::tuple_cat(f_indices, std::make_tuple(i))); } } }; template struct _reduce_axisb { - template + template void helper(E &&e, F &&f, EIndices &&e_indices, FIndices &&f_indices, - utils::index_sequence, utils::index_sequence) + std::index_sequence, std::index_sequence) { - f.template update(e.load(std::get(e_indices)...), - (long)std::get(f_indices)...); + f.template update(e.load(std::get(e_indices)...), (long)std::get(f_indices)...); } template - void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, - FIndices &&f_indices) + void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, FIndices &&f_indices) { - helper( - std::forward(e), std::forward(f), e_indices, f_indices, - utils::make_index_sequence< - std::tuple_size::type>::value>(), - utils::make_index_sequence< - std::tuple_size::type>::value>()); + helper(std::forward(e), std::forward(f), e_indices, f_indices, + std::make_index_sequence>::value>(), + std::make_index_sequence>::value>()); } }; template struct _reduce_axis { template - void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, - FIndices &&f_indices) + void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, FIndices &&f_indices) { - if (axis == std::decay::type::value - N) { - for (long i = 0, n = e.template shape::type::value - N>(); - i < n; ++i) { - _reduce_axisb{}( - e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), - std::forward(f_indices)); + if (axis == std::decay_t::value - N) { + for (long i = 0, n = e.template shape::value - N>(); i < n; ++i) { + _reduce_axisb{}(e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), + std::forward(f_indices)); } } else { - for (long i = 0, n = e.template shape::type::value - N>(); - i < n; ++i) { - _reduce_axis{}( - e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), - std::tuple_cat(f_indices, std::make_tuple(i))); + for (long i = 0, n = e.template shape::value - N>(); i < n; ++i) { + _reduce_axis{}(e, f, axis, std::tuple_cat(e_indices, std::make_tuple(i)), + std::tuple_cat(f_indices, std::make_tuple(i))); } } } @@ -263,15 +241,14 @@ namespace numpy template struct _reduce_axis { template - void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, - FIndices &&f_indices) + void operator()(E &&e, F &&f, long axis, EIndices &&e_indices, FIndices &&f_indices) { } }; template - typename std::enable_if>::type - reduce(E const &array, long axis, dtype, types::none_type) + std::enable_if_t> reduce(E const &array, long axis, + dtype, types::none_type) { if (axis < 0) axis += E::value; @@ -282,30 +259,27 @@ namespace numpy auto next = std::copy(tmp.begin(), tmp.begin() + axis, shp.begin()); std::copy(tmp.begin() + axis + 1, tmp.end(), next); reduced_type out{shp, builtins::None}; - std::fill(out.begin(), out.end(), - utils::neutral::value); + std::fill(out.begin(), out.end(), utils::neutral::value); return reduce(array, axis, types::none_type{}, out); } template - typename std::enable_if>::type - reduce(E const &array, long axis, types::none_type, Out &&out) + std::enable_if_t> reduce(E const &array, long axis, + types::none_type, Out &&out) { if (axis < 0) axis += E::value; if (axis < 0 || size_t(axis) >= E::value) throw types::ValueError("axis out of bounds"); if (utils::no_broadcast(array)) { - std::fill(out.begin(), out.end(), - utils::neutral::value); - _reduce_axis{}(array, std::forward(out), axis, - std::make_tuple(), std::make_tuple()); + std::fill(out.begin(), out.end(), utils::neutral::value); + _reduce_axis{}(array, std::forward(out), axis, std::make_tuple(), + std::make_tuple()); return std::forward(out); } else { if (axis == 0) { - std::fill(out.begin(), out.end(), - utils::neutral::value); - return _reduce{}( - array, std::forward(out)); + std::fill(out.begin(), out.end(), utils::neutral::value); + return _reduce{}(array, + std::forward(out)); } else { std::transform(array.begin(), array.end(), out.begin(), [axis](typename E::const_iterator::value_type other) { diff --git a/contrib/python/pythran/pythran/pythonic/numpy/repeat.hpp b/contrib/python/pythran/pythran/pythonic/numpy/repeat.hpp index a7acb2d9060..c8c4fe311e9 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/repeat.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/repeat.hpp @@ -21,25 +21,24 @@ namespace numpy axis += N; auto shape = sutils::getshape(expr); - const long stride = std::accumulate(shape.begin() + axis + 1, shape.end(), - 1L, std::multiplies()); + const long stride = + std::accumulate(shape.begin() + axis + 1, shape.end(), 1L, std::multiplies()); shape[axis] *= repeats; - types::ndarray::value>> out( - shape, builtins::None); + types::ndarray::value>> out(shape, + builtins::None); auto out_iter = out.fbegin(); - for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; - iter += stride) + for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; iter += stride) for (int i = 0; i < repeats; ++i) out_iter = std::copy(iter, iter + stride, out_iter); return out; } template - types::ndarray> - repeat(types::ndarray const &expr, long repeats, types::none_type axis) + types::ndarray> repeat(types::ndarray const &expr, long repeats, + types::none_type axis) { - types::ndarray> out( - types::pshape{expr.flat_size() * repeats}, builtins::None); + types::ndarray> out(types::pshape{expr.flat_size() * repeats}, + builtins::None); auto out_iter = out.fbegin(); for (auto iter = expr.fbegin(), end = expr.fend(); iter != end; ++iter) for (int i = 0; i < repeats; ++i) diff --git a/contrib/python/pythran/pythran/pythonic/numpy/roll.hpp b/contrib/python/pythran/pythran/pythonic/numpy/roll.hpp index a17d1db88dc..e61a2b6ae2c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/roll.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/roll.hpp @@ -31,8 +31,8 @@ namespace numpy namespace { template - To _roll(To to, From from, long shift, long axis, - types::array_tuple const &shape, utils::int_) + To _roll(To to, From from, long shift, long axis, types::array_tuple const &shape, + utils::int_) { long dim = shape[N - 1]; if (axis == N - 1) { @@ -45,23 +45,20 @@ namespace numpy } template - typename std::enable_if::type - _roll(To to, From from, long shift, long axis, - types::array_tuple const &shape, utils::int_) + std::enable_if_t _roll(To to, From from, long shift, long axis, + types::array_tuple const &shape, utils::int_) { long dim = shape[M]; - long offset = std::accumulate(shape.begin() + M + 1, shape.end(), 1L, - std::multiplies()); + long offset = + std::accumulate(shape.begin() + M + 1, shape.end(), 1L, std::multiplies()); if (axis == M) { const From split = from + (dim - shift) * offset; - for (From iter = split, end = from + dim * offset; iter != end; - iter += offset) + for (From iter = split, end = from + dim * offset; iter != end; iter += offset) to = _roll(to, iter, shift, axis, shape, utils::int_()); for (From iter = from, end = split; iter != end; iter += offset) to = _roll(to, iter, shift, axis, shape, utils::int_()); } else { - for (From iter = from, end = from + dim * offset; iter != end; - iter += offset) + for (From iter = from, end = from + dim * offset; iter != end; iter += offset) to = _roll(to, iter, shift, axis, shape, utils::int_()); } return to; @@ -69,8 +66,7 @@ namespace numpy } // namespace template - types::ndarray roll(types::ndarray const &expr, long shift, - long axis) + types::ndarray roll(types::ndarray const &expr, long shift, long axis) { auto expr_shape = sutils::array(expr._shape); if (expr_shape[axis] == 0) @@ -81,16 +77,15 @@ namespace numpy shift %= expr_shape[axis]; types::ndarray out(expr._shape, builtins::None); - _roll(out.fbegin(), expr.fbegin(), shift, axis, expr_shape, - utils::int_<0>()); + _roll(out.fbegin(), expr.fbegin(), shift, axis, expr_shape, utils::int_<0>()); return out; } namespace { template - To _rolls(To to, From from, long shifts[N], - types::array_tuple const &shape, utils::int_) + To _rolls(To to, From from, long shifts[N], types::array_tuple const &shape, + utils::int_) { long dim = shape[N - 1]; if (long shift = shifts[N - 1]) { @@ -103,23 +98,21 @@ namespace numpy } template - typename std::enable_if::type - _rolls(To to, From from, long shifts[N], - types::array_tuple const &shape, utils::int_) + std::enable_if_t _rolls(To to, From from, long shifts[N], + types::array_tuple const &shape, + utils::int_) { long dim = shape[M]; - long offset = std::accumulate(shape.begin() + M + 1, shape.end(), 1L, - std::multiplies()); + long offset = + std::accumulate(shape.begin() + M + 1, shape.end(), 1L, std::multiplies()); if (long shift = shifts[M]) { const From split = from + (dim - shift) * offset; - for (From iter = split, end = from + dim * offset; iter != end; - iter += offset) + for (From iter = split, end = from + dim * offset; iter != end; iter += offset) to = _rolls(to, iter, shifts, shape, utils::int_()); for (From iter = from; iter != split; iter += offset) to = _rolls(to, iter, shifts, shape, utils::int_()); } else { - for (From iter = from, end = from + dim * offset; iter != end; - iter += offset) + for (From iter = from, end = from + dim * offset; iter != end; iter += offset) to = _rolls(to, iter, shifts, shape, utils::int_()); } return to; @@ -127,8 +120,7 @@ namespace numpy } // namespace template - types::ndarray roll(types::ndarray const &expr, - types::array_tuple shifts, + types::ndarray roll(types::ndarray const &expr, types::array_tuple shifts, types::array_tuple axes) { constexpr long ndim = types::ndarray::value; @@ -145,8 +137,7 @@ namespace numpy } types::ndarray out(expr._shape, builtins::None); - _rolls(out.fbegin(), expr.fbegin(), axes_shifts, expr_shape, - utils::int_<0>()); + _rolls(out.fbegin(), expr.fbegin(), axes_shifts, expr_shape, utils::int_<0>()); return out; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/searchsorted.hpp b/contrib/python/pythran/pythran/pythonic/numpy/searchsorted.hpp index fc88ab0f1b7..b7b9ea2ccec 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/searchsorted.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/searchsorted.hpp @@ -36,14 +36,13 @@ namespace numpy else if (side[0] == "r") return false; else - throw types::ValueError("'" + side + - "' is an invalid value for keyword 'side'"); + throw types::ValueError("'" + side + "' is an invalid value for keyword 'side'"); } } // namespace details template - typename std::enable_if::value, long>::type - searchsorted(U const &a, T const &v, types::str const &side) + std::enable_if_t::value, long> searchsorted(U const &a, T const &v, + types::str const &side) { bool left = details::issearchsortedleft(side); return details::searchsorted(a, v, left); @@ -52,37 +51,31 @@ namespace numpy namespace { template - void _search_sorted(E const &a, I0 ibegin, I0 iend, I1 obegin, bool left, - utils::int_<1>) + void _search_sorted(E const &a, I0 ibegin, I0 iend, I1 obegin, bool left, utils::int_<1>) { for (; ibegin != iend; ++ibegin, ++obegin) *obegin = details::searchsorted(a, *ibegin, left); } template - void _search_sorted(E const &a, I0 ibegin, I0 iend, I1 obegin, bool left, - utils::int_) + void _search_sorted(E const &a, I0 ibegin, I0 iend, I1 obegin, bool left, utils::int_) { for (; ibegin != iend; ++ibegin, ++obegin) - _search_sorted(a, (*ibegin).begin(), (*ibegin).end(), (*obegin).begin(), - left, utils::int_()); + _search_sorted(a, (*ibegin).begin(), (*ibegin).end(), (*obegin).begin(), left, + utils::int_()); } } // namespace template - typename std::enable_if< - types::is_numexpr_arg::value, - types::ndarray>>::type + std::enable_if_t::value, + types::ndarray>> searchsorted(T const &a, E const &v, types::str const &side) { - static_assert(T::value == 1, - "Not Implemented : searchsorted for dimension != 1"); + static_assert(T::value == 1, "Not Implemented : searchsorted for dimension != 1"); bool left = details::issearchsortedleft(side); - types::ndarray> out( - asarray(v)._shape, builtins::None); - _search_sorted(a, v.begin(), v.end(), out.begin(), left, - utils::int_()); + types::ndarray> out(asarray(v)._shape, builtins::None); + _search_sorted(a, v.begin(), v.end(), out.begin(), left, utils::int_()); return out; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/select.hpp b/contrib/python/pythran/pythran/pythonic/numpy/select.hpp index 3b00ce46ef0..18d781745a1 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/select.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/select.hpp @@ -17,12 +17,11 @@ namespace numpy // is computed without information from neighbor. // template - long _select(Ichoice ibegin, Ichoice iend, Iout obegin, Isel sbegin, - Icond cbegin, long size, utils::int_<1>) + long _select(Ichoice ibegin, Ichoice iend, Iout obegin, Isel sbegin, Icond cbegin, long size, + utils::int_<1>) { static_assert(std::is_same::value, ""); - for (; ibegin != iend && size != 0; - ++ibegin, ++obegin, ++sbegin, ++cbegin) { + for (; ibegin != iend && size != 0; ++ibegin, ++obegin, ++sbegin, ++cbegin) { // If elements it not already selected && condition match, copy it! if (!*sbegin && *cbegin) { *obegin = *ibegin; @@ -34,14 +33,12 @@ namespace numpy } template - long _select(Ichoice ibegin, Ichoice iend, Iout obegin, Isel sbegin, - Icond cbegin, long size, utils::int_) + long _select(Ichoice ibegin, Ichoice iend, Iout obegin, Isel sbegin, Icond cbegin, long size, + utils::int_) { - for (; ibegin != iend && size != 0; - ++ibegin, ++obegin, ++sbegin, ++cbegin) - size = _select((*ibegin).begin(), (*ibegin).end(), (*obegin).begin(), - (*sbegin).begin(), (*cbegin).begin(), size, - utils::int_()); + for (; ibegin != iend && size != 0; ++ibegin, ++obegin, ++sbegin, ++cbegin) + size = _select((*ibegin).begin(), (*ibegin).end(), (*obegin).begin(), (*sbegin).begin(), + (*cbegin).begin(), size, utils::int_()); return size; } } // namespace @@ -52,15 +49,13 @@ namespace numpy { constexpr size_t N = L::value - 1; auto &&choicelist0_shape = sutils::getshape(choicelist[0]); - types::ndarray> out( - choicelist0_shape, _default); - types::ndarray> selected( - choicelist0_shape, false); + types::ndarray> out(choicelist0_shape, _default); + types::ndarray> selected(choicelist0_shape, + false); long size = selected.flat_size(); for (long i = 0; i < condlist.size() && size != 0; i++) - size = - _select(choicelist[i].begin(), choicelist[i].end(), out.begin(), - selected.begin(), condlist.begin(), size, utils::int_()); + size = _select(choicelist[i].begin(), choicelist[i].end(), out.begin(), selected.begin(), + condlist.begin(), size, utils::int_()); return out; } @@ -68,8 +63,8 @@ namespace numpy types::ndarray> select_helper(C const &condlist, L const &choicelist, T _default) { - types::ndarray> - out(sutils::getshape(choicelist[0]), _default); + types::ndarray> out( + sutils::getshape(choicelist[0]), _default); for (long i = 0; i < out.flat_size(); ++i) for (long j = 0; j < (long)condlist.size(); ++j) if (condlist[j].buffer[i]) { @@ -80,40 +75,34 @@ namespace numpy } template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::list> const &condlist, types::list> const &choicelist, T _default) { return select_helper(condlist, choicelist, _default); } template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::static_list, M> const &condlist, - types::static_list, M> const &choicelist, - T _default) + types::static_list, M> const &choicelist, T _default) { return select_helper(condlist, choicelist, _default); } template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::static_list, M> const &condlist, types::list> const &choicelist, T _default) { return select_helper(condlist, choicelist, _default); } template - typename std::enable_if::value == - std::tuple_size::value, - types::ndarray>::type + std::enable_if_t::value == std::tuple_size::value, + types::ndarray> select(types::list> const &condlist, - types::static_list, M> const &choicelist, - T _default) + types::static_list, M> const &choicelist, T _default) { return select_helper(condlist, choicelist, _default); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/setdiff1d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/setdiff1d.hpp index 0325efcc435..b2b5b62bd0c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/setdiff1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/setdiff1d.hpp @@ -19,12 +19,10 @@ namespace numpy namespace impl { - template - OutputIterator - set_difference_unique(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - OutputIterator result) + template + OutputIterator set_difference_unique(InputIterator1 first1, InputIterator1 last1, + InputIterator2 first2, InputIterator2 last2, + OutputIterator result) { while (first1 != last1 && first2 != last2) { auto const t1 = *first1; @@ -72,11 +70,10 @@ namespace numpy dtype *out_last; if (assume_unique) { - out_last = std::set_difference(far1.fbegin(), far1.fend(), far2.fbegin(), - far2.fend(), out); + out_last = std::set_difference(far1.fbegin(), far1.fend(), far2.fbegin(), far2.fend(), out); } else { - out_last = impl::set_difference_unique(far1.fbegin(), far1.fend(), - far2.fbegin(), far2.fend(), out); + out_last = + impl::set_difference_unique(far1.fbegin(), far1.fend(), far2.fbegin(), far2.fend(), out); } auto size = out_last - out; out = utils::reallocate(out, size); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/short_.hpp b/contrib/python/pythran/pythran/pythonic/numpy/short_.hpp index a4e9b5dd8f1..272796a7220 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/short_.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/short_.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::short_ const &c) +{ + return (PyObject *)&PyShortArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyShortArrType_Type; +} + +inline numpy::functor::short_ from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/sort.hpp b/contrib/python/pythran/pythran/pythonic/numpy/sort.hpp index 1fb91dccdcc..528eed05b15 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/sort.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/sort.hpp @@ -9,8 +9,8 @@ namespace numpy { template - types::ndarray> - sort(E const &expr, long axis) + types::ndarray> sort(E const &expr, + long axis) { auto out = functor::array{}(expr); ndarray::sort(out, axis); @@ -18,8 +18,8 @@ namespace numpy } template - types::ndarray> - sort(E const &expr, types::none_type) + types::ndarray> sort(E const &expr, + types::none_type) { auto out = functor::array{}(expr).flat(); ndarray::sort(out, types::none_type{}); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/split.hpp b/contrib/python/pythran/pythran/pythonic/numpy/split.hpp index 9e22cef39d2..74aa50c0a2a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/split.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/split.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::list< - types::ndarray::value>>> + types::list::value>>> split(types::ndarray const &a, long nb_split) { if (a.flat_size() % nb_split != 0) @@ -21,18 +20,16 @@ namespace numpy } template - typename std::enable_if< + std::enable_if_t< types::is_iterable::value, - types::list::value>>>>::type + types::list::value>>>> split(types::ndarray const &a, I const &split_mask) { return array_split(a, split_mask); } template - types::list< - types::ndarray>> + types::list>> split(E const &a, I const &) { throw std::runtime_error("split only partially implemented"); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/stack.hpp b/contrib/python/pythran/pythran/pythonic/numpy/stack.hpp index 2d5de6b7091..d286f048b10 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/stack.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/stack.hpp @@ -19,13 +19,10 @@ namespace numpy if (builtins::len(args) == 0) throw pythonic::types::ValueError("need at least one array to stack"); auto shape = sutils::getshape(args[0]); - constexpr long N = - std::tuple_size::value; // The length of the shape - // array. - auto values = sutils::array( - shape); // You can't do shape[i] but you can do shape.array()[i] - types::array_tuple - new_shape; // A new array that's 1 element longer than shape. + constexpr long N = std::tuple_size::value; // The length of the shape + // array. + auto values = sutils::array(shape); // You can't do shape[i] but you can do shape.array()[i] + types::array_tuple new_shape; // A new array that's 1 element longer than shape. // Insert a "0" at the position indicated by axis. for (long i = 0; i < N + 1; i++) { if (i < axis) @@ -37,9 +34,8 @@ namespace numpy } // Create a new empty list. - types::list>> + types::list>> bi(0); // Push the resized arrays into the list. for (auto &&arg : args) { @@ -49,27 +45,24 @@ namespace numpy return concatenate(bi, axis); } template - types::ndarray< - typename details::stack_helper_t::dtype, - types::array_tuple::value + 1>> - stack(std::tuple const &args, long axis, utils::index_sequence) + types::ndarray::dtype, + types::array_tuple::value + 1>> + stack(std::tuple const &args, long axis, std::index_sequence) { types::array_tuple< - types::ndarray< - typename details::stack_helper_t::dtype, - types::array_tuple::value>>, + types::ndarray::dtype, + types::array_tuple::value>>, sizeof...(Tys)> vargs{{std::get(args)...}}; return stack(vargs, axis); } template - types::ndarray< - typename details::stack_helper_t::dtype, - types::array_tuple::value + 1>> + types::ndarray::dtype, + types::array_tuple::value + 1>> stack(std::tuple const &args, long axis) { - return stack(args, axis, utils::make_index_sequence()); + return stack(args, axis, std::make_index_sequence()); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/std_.hpp b/contrib/python/pythran/pythran/pythonic/numpy/std_.hpp index 76be6d48b30..478fbefc2ae 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/std_.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/std_.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto std_(Args &&...args) - -> decltype(functor::sqrt{}(var(std::forward(args)...))) + auto std_(Args &&...args) -> decltype(functor::sqrt{}(var(std::forward(args)...))) { return functor::sqrt{}(var(std::forward(args)...)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/swapaxes.hpp b/contrib/python/pythran/pythran/pythonic/numpy/swapaxes.hpp index bc83a64a458..ac162e8c82a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/swapaxes.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/swapaxes.hpp @@ -10,12 +10,10 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto swapaxes(T &&a, int axis1, int axis2) - -> decltype(functor::transpose{}( - std::forward(a), - std::declval::type::value>>())) + auto swapaxes(T &&a, int axis1, int axis2) -> decltype(functor::transpose{}( + std::forward(a), std::declval::value>>())) { - constexpr long N = std::decay::type::value; + constexpr long N = std::decay_t::value; types::array_tuple t; for (unsigned long i = 0; i < N; ++i) t[i] = i; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/take.hpp b/contrib/python/pythran/pythran/pythonic/numpy/take.hpp index 7ab952f8702..de7d2d90765 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/take.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/take.hpp @@ -8,8 +8,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - auto take(T &&expr, F &&indices) - -> decltype(std::forward(expr)[std::forward(indices)]) + auto take(T &&expr, F &&indices) -> decltype(std::forward(expr)[std::forward(indices)]) { return expr[indices]; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/tile.hpp b/contrib/python/pythran/pythran/pythonic/numpy/tile.hpp index a9590003a3f..17b98ae7275 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/tile.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/tile.hpp @@ -28,8 +28,8 @@ namespace numpy } // namespace template - types::ndarray> - tile(E const &expr, long reps) + types::ndarray> tile(E const &expr, + long reps) { size_t n = expr.flat_size(); types::ndarray> out( @@ -42,15 +42,11 @@ namespace numpy } template - types::array_tuple - tile_init_shape(R const &reps, S const &expr_shape, - utils::index_sequence) + types::array_tuple tile_init_shape(R const &reps, S const &expr_shape, + std::index_sequence) { constexpr size_t M = S::value; - return { - {(reps[Is] * ((Is < Shift) ? 1 - : expr_shape.template shape < (Is < M) ? Is - : 0 > ()))...}}; + return {{(reps[Is] * ((Is < Shift) ? 1 : expr_shape.template shape<(Is < M) ? Is : 0>()))...}}; } template @@ -58,15 +54,13 @@ namespace numpy tile(E const &expr, types::array_tuple const &reps) { size_t n = expr.flat_size(); - types::array_tuple shape = tile_init_shape( - reps, expr, utils::make_index_sequence()); + types::array_tuple shape = + tile_init_shape(reps, expr, std::make_index_sequence()); long last_rep = (E::value == N) ? std::get(reps) : 1; - types::ndarray> out( - shape, builtins::None); + types::ndarray> out(shape, builtins::None); auto out_iter = out.fbegin(); - _tile(expr.begin(), expr.end(), out_iter, last_rep, - utils::int_()); + _tile(expr.begin(), expr.end(), out_iter, last_rep, utils::int_()); size_t nreps = out.flat_size() / (n * last_rep); for (size_t i = 1; i < nreps; ++i) diff --git a/contrib/python/pythran/pythran/pythonic/numpy/trace.hpp b/contrib/python/pythran/pythran/pythonic/numpy/trace.hpp index 9ec8b874a0b..a3cc620763f 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/trace.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/trace.hpp @@ -18,8 +18,7 @@ namespace numpy typename T::dtype res = 0; long y_offset = std::max(-offset, 0); long x_offset = std::max(0, offset); - long size = std::min(expr.flat_size() - y_offset, - expr.fast(0).flat_size() - x_offset); + long size = std::min(expr.flat_size() - y_offset, expr.fast(0).flat_size() - x_offset); if (offset < 0) for (long i = 0; i < size; i++) res += expr.fast(i + offset).fast(i); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/transpose.hpp b/contrib/python/pythran/pythran/pythonic/numpy/transpose.hpp index 36f5fdba803..93972d221f7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/transpose.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/transpose.hpp @@ -16,8 +16,8 @@ namespace numpy namespace { template - O const *_transposer(types::ndarray &expr, O const *iter, - Indices &indices, S const &shape, Perm const &perm, + O const *_transposer(types::ndarray &expr, O const *iter, Indices &indices, + S const &shape, Perm const &perm, utils::int_::value - 1>) { for (long i = 0, n = shape[std::tuple_size::value - 1]; i < n; ++i) { @@ -28,25 +28,21 @@ namespace numpy return iter; } - template - typename std::enable_if::value - 1 != I, - O const *>::type - _transposer(types::ndarray &expr, O const *iter, Indices &indices, - S const &shape, Perm const &perm, utils::int_) + template + std::enable_if_t::value - 1 != I, O const *> + _transposer(types::ndarray &expr, O const *iter, Indices &indices, S const &shape, + Perm const &perm, utils::int_) { for (long i = 0, n = shape[I]; i < n; ++i) { indices[perm[I]] = i; - iter = - _transposer(expr, iter, indices, shape, perm, utils::int_()); + iter = _transposer(expr, iter, indices, shape, perm, utils::int_()); } indices[perm[I]] = 0; return iter; } template types::ndarray::value>> - _transposer(types::ndarray const &a, - long const l[std::tuple_size::value]) + _transposer(types::ndarray const &a, long const l[std::tuple_size::value]) { auto shape = sutils::getshape(a); types::array_tuple::value> shp; @@ -57,8 +53,8 @@ namespace numpy for (std::size_t i = 0; i < std::tuple_size::value; ++i) perm[l[i]] = i; - types::ndarray::value>> - new_array(shp, builtins::None); + types::ndarray::value>> new_array( + shp, builtins::None); auto const *iter = a.buffer; types::array_tuple::value> indices; @@ -69,11 +65,9 @@ namespace numpy } // namespace template - typename std::enable_if< - (std::tuple_size::value > 2), - types::ndarray::value>>>:: - type - transpose(types::ndarray const &a) + std::enable_if_t<(std::tuple_size::value > 2), + types::ndarray::value>>> + transpose(types::ndarray const &a) { long t[std::tuple_size::value]; for (unsigned long i = 0; i < std::tuple_size::value; ++i) @@ -83,8 +77,7 @@ namespace numpy template types::ndarray::value>> - transpose(types::ndarray const &a, - types::array_tuple const &t) + transpose(types::ndarray const &a, types::array_tuple const &t) { static_assert(std::tuple_size::value == M, "axes don't match array"); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/tri.hpp b/contrib/python/pythran/pythran/pythonic/numpy/tri.hpp index 8e42ba0e0b7..1fa911559be 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/tri.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/tri.hpp @@ -11,8 +11,8 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::ndarray> - tri(long N, long M, long k, dtype d) + types::ndarray> tri(long N, long M, long k, + dtype d) { if (M == -1) M = N; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/trim_zeros.hpp b/contrib/python/pythran/pythran/pythonic/numpy/trim_zeros.hpp index 89b8be558ad..c2f1afab873 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/trim_zeros.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/trim_zeros.hpp @@ -11,17 +11,15 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::numpy_gexpr> - trim_zeros(T const &expr, types::str const &trim) + types::numpy_gexpr> trim_zeros(T const &expr, + types::str const &trim) { - static_assert(T::value == 1, - "Not implemented : trim_zeroes only works for 1D array"); + static_assert(T::value == 1, "Not implemented : trim_zeroes only works for 1D array"); long begin = 0; long end = expr.flat_size(); if (trim.find("f") != -1) - begin = std::find_if(expr.begin(), expr.end(), - [](typename T::dtype i) { return i != 0; }) - + begin = std::find_if(expr.begin(), expr.end(), [](typename T::dtype i) { return i != 0; }) - expr.begin(); if (trim.find("b") != -1) while (*(expr.begin() + --end) != 0) diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ubyte.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ubyte.hpp index 67936f26531..bd7cc69e914 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ubyte.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ubyte.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::ubyte const &c) +{ + return (PyObject *)&PyUByteArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUByteArrType_Type; +} + +inline numpy::functor::ubyte from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ufunc_accumulate.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ufunc_accumulate.hpp index 601fbd98017..bead84becae 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ufunc_accumulate.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ufunc_accumulate.hpp @@ -15,11 +15,9 @@ namespace numpy { template auto accumulate(T &&a, long axis, dtype d) - -> decltype(partial_sum(std::forward(a), - axis, d)) + -> decltype(partial_sum(std::forward(a), axis, d)) { - return partial_sum(std::forward(a), axis, - d); + return partial_sum(std::forward(a), axis, d); } } // namespace UFUNC_NAME } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uint.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uint.hpp index 75e75d28360..1fca195c63c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uint.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uint.hpp @@ -34,4 +34,35 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uint const &c) +{ + return (PyObject *)&PyUIntArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUIntArrType_Type || +#if NPY_SIZEOF_INTP == NPY_SIZEOF_LONG + obj == (PyObject *)&PyUInt64ArrType_Type +#else + obj == (PyObject *)&PyUInt32ArrType_Type +#endif + ; +} + +inline numpy::functor::uint from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uint16.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uint16.hpp index 136b6ebbf98..7aa980af3e7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uint16.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uint16.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uint16 const &c) +{ + return (PyObject *)&PyUInt16ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUInt16ArrType_Type; +} + +inline numpy::functor::uint16 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uint32.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uint32.hpp index ae328a01a44..7012d6cdbcf 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uint32.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uint32.hpp @@ -33,4 +33,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uint32 const &c) +{ + return (PyObject *)&PyUInt32ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUInt32ArrType_Type; +} + +inline numpy::functor::uint32 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uint64.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uint64.hpp index 39973a556d3..fecc3ce870e 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uint64.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uint64.hpp @@ -33,4 +33,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uint64 const &c) +{ + return (PyObject *)&PyUInt64ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUInt64ArrType_Type; +} + +inline numpy::functor::uint64 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uint8.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uint8.hpp index ada239aa891..8cd95e8464a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uint8.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uint8.hpp @@ -33,5 +33,29 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uint8 const &c) +{ + return (PyObject *)&PyUInt8ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUInt8ArrType_Type; +} + +inline numpy::functor::uint8 from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/uintc.hpp b/contrib/python/pythran/pythran/pythonic/numpy/uintc.hpp index bcb68c5f63f..356a62c75c8 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/uintc.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/uintc.hpp @@ -33,5 +33,35 @@ namespace numpy #include "pythonic/types/numpy_nary_expr.hpp" } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::uintc const &c) +{ + if (sizeof(unsigned) == 4) + return (PyObject *)&PyUInt32ArrType_Type; + else + return (PyObject *)&PyUInt64ArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + if (sizeof(unsigned) == 4) + return obj == (PyObject *)&PyUInt32ArrType_Type; + else + return obj == (PyObject *)&PyUInt64ArrType_Type; +} + +inline numpy::functor::uintc from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/union1d.hpp b/contrib/python/pythran/pythran/pythonic/numpy/union1d.hpp index e9e7ff67775..334d866493d 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/union1d.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/union1d.hpp @@ -30,13 +30,11 @@ namespace numpy } // namespace template - types::ndarray< - typename __combined::type, - types::pshape> + types::ndarray::type, + types::pshape> union1d(E const &e, F const &f) { - std::set::type> - res; + std::set::type> res; _union1d(e.begin(), e.end(), res, utils::int_()); _union1d(f.begin(), f.end(), res, utils::int_()); return {res}; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/unique.hpp b/contrib/python/pythran/pythran/pythonic/numpy/unique.hpp index 822077f5fde..8e04ef18ed9 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/unique.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/unique.hpp @@ -44,12 +44,10 @@ namespace numpy void _unique2(I begin, I end, O0 &out0, O1 &out1, long &i, utils::int_) { for (; begin != end; ++begin) - _unique2((*begin).begin(), (*begin).end(), out0, out1, i, - utils::int_()); + _unique2((*begin).begin(), (*begin).end(), out0, out1, i, utils::int_()); } template - void _unique3(I begin, I end, O0 &out0, O1 &out1, O2 &out2, long &i, - utils::int_<1>) + void _unique3(I begin, I end, O0 &out0, O1 &out1, O2 &out2, long &i, utils::int_<1>) { for (; begin != end; ++begin, ++i) { auto pair = out0.insert(*begin); @@ -59,17 +57,14 @@ namespace numpy } } template - void _unique3(I begin, I end, O0 &out0, O1 &out1, O2 &out2, long &i, - utils::int_) + void _unique3(I begin, I end, O0 &out0, O1 &out1, O2 &out2, long &i, utils::int_) { for (; begin != end; ++begin) - _unique3((*begin).begin(), (*begin).end(), out0, out1, out2, i, - utils::int_()); + _unique3((*begin).begin(), (*begin).end(), out0, out1, out2, i, utils::int_()); } template - void _unique4(I begin, I end, O1 &out1, O2 &out2, O3 &out3, long &i, - utils::int_<1>) + void _unique4(I begin, I end, O1 &out1, O2 &out2, O3 &out3, long &i, utils::int_<1>) { for (; begin != end; ++begin, ++i) { auto res = out3.insert(std::make_pair(*begin, 0)); @@ -81,12 +76,10 @@ namespace numpy } } template - void _unique4(I begin, I end, O1 &out1, O2 &out2, O3 &out3, long &i, - utils::int_) + void _unique4(I begin, I end, O1 &out1, O2 &out2, O3 &out3, long &i, utils::int_) { for (; begin != end; ++begin) - _unique4((*begin).begin(), (*begin).end(), out1, out2, out3, i, - utils::int_()); + _unique4((*begin).begin(), (*begin).end(), out1, out2, out3, i, utils::int_()); } template void _unique5(I begin, I end, O0 &out0, O2 &out2, long &i, utils::int_<1>) @@ -100,8 +93,7 @@ namespace numpy void _unique5(I begin, I end, O0 &out0, O2 &out2, long &i, utils::int_) { for (; begin != end; ++begin) - _unique5((*begin).begin(), (*begin).end(), out0, out2, i, - utils::int_()); + _unique5((*begin).begin(), (*begin).end(), out0, out2, i, utils::int_()); } template @@ -119,8 +111,7 @@ namespace numpy void _unique6(I begin, I end, O1 &out1, O3 &out3, long &i, utils::int_) { for (; begin != end; ++begin) - _unique6((*begin).begin(), (*begin).end(), out1, out3, i, - utils::int_()); + _unique6((*begin).begin(), (*begin).end(), out1, out3, i, utils::int_()); } template @@ -136,8 +127,7 @@ namespace numpy void _unique7(I begin, I end, O2 &out2, O3 &out3, long &i, utils::int_) { for (; begin != end; ++begin) - _unique7((*begin).begin(), (*begin).end(), out2, out3, i, - utils::int_()); + _unique7((*begin).begin(), (*begin).end(), out2, out3, i, utils::int_()); } template @@ -152,8 +142,7 @@ namespace numpy void _unique8(I begin, I end, O3 &out3, long &i, utils::int_) { for (; begin != end; ++begin) - _unique8((*begin).begin(), (*begin).end(), out3, i, - utils::int_()); + _unique8((*begin).begin(), (*begin).end(), out3, i, utils::int_()); } } // namespace @@ -175,16 +164,14 @@ namespace numpy std::set, utils::allocator> res; std::vector> return_index_res; long i = 0; - _unique2(expr.begin(), expr.end(), res, return_index_res, i, - utils::int_()); - return std::make_tuple( - types::ndarray>(res), - types::ndarray>(return_index_res)); + _unique2(expr.begin(), expr.end(), res, return_index_res, i, utils::int_()); + return std::make_tuple(types::ndarray>(res), + types::ndarray>(return_index_res)); } template - types::ndarray> - unique(E const &expr, types::false_immediate return_index) + types::ndarray> unique(E const &expr, + types::false_immediate return_index) { using dtype = typename E::dtype; std::set, utils::allocator> res; @@ -195,24 +182,20 @@ namespace numpy template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse) + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse) { using dtype = typename E::dtype; std::set, utils::allocator> res; types::ndarray> return_inverse_res( types::pshape{expr.flat_size()}, builtins::None); long i = 0; - _unique5(expr.begin(), expr.end(), res, return_inverse_res, i, - utils::int_()); - return std::make_tuple(types::ndarray>(res), - return_inverse_res); + _unique5(expr.begin(), expr.end(), res, return_inverse_res, i, utils::int_()); + return std::make_tuple(types::ndarray>(res), return_inverse_res); } template types::ndarray> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse) + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse) { using dtype = typename E::dtype; std::set, utils::allocator> res; @@ -223,18 +206,15 @@ namespace numpy template std::tuple>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse) + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse) { return unique(expr, return_index); } template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse) + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse) { assert(return_inverse && "invalid signature otherwise"); @@ -244,21 +224,18 @@ namespace numpy types::ndarray> return_inverse_res( types::pshape{expr.flat_size()}, builtins::None); long i = 0; - _unique3(expr.begin(), expr.end(), res, return_index_res, - return_inverse_res, i, utils::int_()); - return std::make_tuple( - types::ndarray>(res), - types::ndarray>(return_index_res), - return_inverse_res); + _unique3(expr.begin(), expr.end(), res, return_index_res, return_inverse_res, i, + utils::int_()); + return std::make_tuple(types::ndarray>(res), + types::ndarray>(return_index_res), + return_inverse_res); } template std::tuple>, - types::ndarray>, - types::ndarray>, + types::ndarray>, types::ndarray>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse, + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse, types::true_immediate return_counts) { assert(return_counts && "invalid signature otherwise"); @@ -270,37 +247,32 @@ namespace numpy std::map return_counts_map; { long i = 0; - _unique4(expr.begin(), expr.end(), return_index_res, return_inverse_res, - return_counts_map, i, utils::int_()); + _unique4(expr.begin(), expr.end(), return_index_res, return_inverse_res, return_counts_map, i, + utils::int_()); } types::pshape shp{(long)return_counts_map.size()}; types::ndarray> unique_array(shp, builtins::None); - types::ndarray> return_counts_array( - shp, builtins::None); + types::ndarray> return_counts_array(shp, builtins::None); { long i = 0; - for (auto it = return_counts_map.begin(); it != return_counts_map.end(); - ++i, ++it) { + for (auto it = return_counts_map.begin(); it != return_counts_map.end(); ++i, ++it) { unique_array.fast(i) = it->first; return_counts_array.fast(i) = it->second; } } - return std::make_tuple( - unique_array, - types::ndarray>(return_index_res), - return_inverse_res, return_counts_array); + return std::make_tuple(unique_array, + types::ndarray>(return_index_res), + return_inverse_res, return_counts_array); } template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::true_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::true_immediate return_inverse, types::false_immediate return_counts) { return unique(expr, return_index, return_inverse); @@ -309,8 +281,7 @@ namespace numpy template std::tuple>, types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse, types::false_immediate return_counts) { return unique(expr, return_index); @@ -318,10 +289,8 @@ namespace numpy template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::true_immediate return_index, - types::false_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::true_immediate return_index, types::false_immediate return_inverse, types::true_immediate return_counts) { std::vector> return_index_res; @@ -336,29 +305,25 @@ namespace numpy types::pshape shp{(long)return_counts_map.size()}; types::ndarray> unique_array(shp, builtins::None); - types::ndarray> return_counts_array( - shp, builtins::None); + types::ndarray> return_counts_array(shp, builtins::None); { long i = 0; - for (auto it = return_counts_map.begin(); it != return_counts_map.end(); - ++i, ++it) { + for (auto it = return_counts_map.begin(); it != return_counts_map.end(); ++i, ++it) { unique_array.fast(i) = it->first; return_counts_array.fast(i) = it->second; } } - return std::make_tuple( - unique_array, - types::ndarray>(return_index_res), - return_counts_array); + return std::make_tuple(unique_array, + types::ndarray>(return_index_res), + return_counts_array); } template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse, types::false_immediate return_counts) { return unique(expr, return_index, return_inverse); @@ -366,10 +331,8 @@ namespace numpy template std::tuple>, - types::ndarray>, - types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::true_immediate return_inverse, + types::ndarray>, types::ndarray>> + unique(E const &expr, types::false_immediate return_index, types::true_immediate return_inverse, types::true_immediate return_counts) { types::ndarray> return_inverse_res( @@ -378,33 +341,29 @@ namespace numpy std::map return_counts_map; { long i = 0; - _unique7(expr.begin(), expr.end(), return_inverse_res, return_counts_map, - i, utils::int_()); + _unique7(expr.begin(), expr.end(), return_inverse_res, return_counts_map, i, + utils::int_()); } types::pshape shp{(long)return_counts_map.size()}; types::ndarray> unique_array(shp, builtins::None); - types::ndarray> return_counts_array( - shp, builtins::None); + types::ndarray> return_counts_array(shp, builtins::None); { long i = 0; - for (auto it = return_counts_map.begin(); it != return_counts_map.end(); - ++i, ++it) { + for (auto it = return_counts_map.begin(); it != return_counts_map.end(); ++i, ++it) { unique_array.fast(i) = it->first; return_counts_array.fast(i) = it->second; } } - return std::make_tuple(unique_array, return_inverse_res, - return_counts_array); + return std::make_tuple(unique_array, return_inverse_res, return_counts_array); } template types::ndarray> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse, types::false_immediate return_counts) { return unique(expr); @@ -413,27 +372,23 @@ namespace numpy template std::tuple>, types::ndarray>> - unique(E const &expr, types::false_immediate return_index, - types::false_immediate return_inverse, + unique(E const &expr, types::false_immediate return_index, types::false_immediate return_inverse, types::true_immediate return_counts) { std::map return_counts_map; { long i = 0; - _unique8(expr.begin(), expr.end(), return_counts_map, i, - utils::int_()); + _unique8(expr.begin(), expr.end(), return_counts_map, i, utils::int_()); } types::pshape shp{(long)return_counts_map.size()}; types::ndarray> unique_array(shp, builtins::None); - types::ndarray> return_counts_array( - shp, builtins::None); + types::ndarray> return_counts_array(shp, builtins::None); { long i = 0; - for (auto it = return_counts_map.begin(); it != return_counts_map.end(); - ++i, ++it) { + for (auto it = return_counts_map.begin(); it != return_counts_map.end(); ++i, ++it) { unique_array.fast(i) = it->first; return_counts_array.fast(i) = it->second; } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/unravel_index.hpp b/contrib/python/pythran/pythran/pythonic/numpy/unravel_index.hpp index 8c885aad4ea..1c2a0fce2f6 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/unravel_index.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/unravel_index.hpp @@ -25,9 +25,7 @@ namespace numpy } // namespace template - typename std::enable_if< - std::is_scalar::value, - types::array_tuple::value>>::type + std::enable_if_t::value, types::array_tuple::value>> unravel_index(E const &expr, S const &shape, types::str const &order) { types::array_tuple::value> ret; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/unwrap.hpp b/contrib/python/pythran/pythran/pythonic/numpy/unwrap.hpp index 23da0b6a7a4..eef7cf828fa 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/unwrap.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/unwrap.hpp @@ -25,9 +25,7 @@ namespace numpy ++ibegin; for (; ibegin != iend; ++ibegin, ++obegin) { if (functor::abs{}(*obegin - *ibegin) > discont) - *(obegin + 1) = - *ibegin + - 2 * pi * functor::round{}((*obegin - *ibegin) / (2 * pi)); + *(obegin + 1) = *ibegin + 2 * pi * functor::round{}((*obegin - *ibegin) / (2 * pi)); else *(obegin + 1) = *ibegin; } @@ -43,14 +41,11 @@ namespace numpy } // namespace template - types::ndarray unwrap(E const &expr, - double discont) + types::ndarray unwrap(E const &expr, double discont) { discont = functor::maximum{}(discont, pi); - types::ndarray out(sutils::getshape(expr), - builtins::None); - _unwrap(expr.begin(), expr.end(), out.begin(), discont, - utils::int_()); + types::ndarray out(sutils::getshape(expr), builtins::None); + _unwrap(expr.begin(), expr.end(), out.begin(), discont, utils::int_()); return out; } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/ushort.hpp b/contrib/python/pythran/pythran/pythonic/numpy/ushort.hpp index d74c77907f8..b56e1591016 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/ushort.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/ushort.hpp @@ -34,4 +34,29 @@ namespace numpy } // namespace numpy PYTHONIC_NS_END +#ifdef ENABLE_PYTHON_MODULE + +#include "numpy/arrayscalars.h" +#include "pythonic/python/core.hpp" + +PYTHONIC_NS_BEGIN + +inline PyObject *to_python::convert(numpy::functor::ushort const &c) +{ + return (PyObject *)&PyUShortArrType_Type; +} + +inline bool from_python::is_convertible(PyObject *obj) +{ + return obj == (PyObject *)&PyUShortArrType_Type; +} + +inline numpy::functor::ushort from_python::convert(PyObject *obj) +{ + return {}; +} + +PYTHONIC_NS_END +#endif + #endif diff --git a/contrib/python/pythran/pythran/pythonic/numpy/var.hpp b/contrib/python/pythran/pythran/pythonic/numpy/var.hpp index 981b6678d9b..2adfc5a6d68 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/var.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/var.hpp @@ -23,14 +23,12 @@ namespace numpy { template - auto var(E const &expr, types::none_type axis, types::none_type dtype, - types::none_type out, + auto var(E const &expr, types::none_type axis, types::none_type dtype, types::none_type out, long ddof) -> decltype(var_type(std::real(mean(expr)))) { auto m = mean(expr); auto t = pythonic::numpy::functor::subtract{}(expr, m); - return sum(builtins::pythran::functor::abssqr{}(t)) / - var_type(expr.flat_size() - ddof); + return sum(builtins::pythran::functor::abssqr{}(t)) / var_type(expr.flat_size() - ddof); } namespace @@ -38,30 +36,24 @@ namespace numpy // this is a workaround for the lack of efficient support for broadcasting // in pythonic template - void _enlarge_copy_minus(T &&t, E const &e, M const &m, long axis, - utils::int_<1>) + void _enlarge_copy_minus(T &&t, E const &e, M const &m, long axis, utils::int_<1>) { - for (long i = 0, n = e.template shape<0>(), p = m.template shape<0>(); - i < n;) + for (long i = 0, n = e.template shape<0>(), p = m.template shape<0>(); i < n;) for (long j = 0; j < p; ++j, ++i) t.fast(i) = e.fast(i) - m.fast(j); } template - void _enlarge_copy_minus(T &&t, E const &e, M const &m, long axis, - utils::int_) + void _enlarge_copy_minus(T &&t, E const &e, M const &m, long axis, utils::int_) { - for (long i = 0, n = e.template shape<0>(), p = m.template shape<0>(); - i < n;) + for (long i = 0, n = e.template shape<0>(), p = m.template shape<0>(); i < n;) for (long j = 0; j < p; ++j, ++i) - _enlarge_copy_minus(t.fast(i), e.fast(i), m.fast(j), axis, - utils::int_()); + _enlarge_copy_minus(t.fast(i), e.fast(i), m.fast(j), axis, utils::int_()); } } // namespace template - auto var(E const &expr, long axis, types::none_type dtype, - types::none_type out, long ddof) -> + auto var(E const &expr, long axis, types::none_type dtype, types::none_type out, long ddof) -> typename assignable() * mean(expr, axis))>::type { auto m = mean(expr, axis); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/vdot.hpp b/contrib/python/pythran/pythran/pythonic/numpy/vdot.hpp index 575d6df38ec..50804d04e44 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/vdot.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/vdot.hpp @@ -16,16 +16,14 @@ namespace numpy template auto vdot(U const &u, V const &v) - -> decltype(functor::dot{}(functor::asarray{}(u).flat(), - functor::asarray{}(v).flat())) + -> decltype(functor::dot{}(functor::asarray{}(u).flat(), functor::asarray{}(v).flat())) { if (types::is_complex::value && types::is_complex::value) { return functor::dot{}(functor::asarray{}(functor::conjugate{}(u)).flat(), functor::asarray{}(v).flat()); } else { - return functor::dot{}(functor::asarray{}(u).flat(), - functor::asarray{}(v).flat()); + return functor::dot{}(functor::asarray{}(u).flat(), functor::asarray{}(v).flat()); } } } // namespace numpy diff --git a/contrib/python/pythran/pythran/pythonic/numpy/vectorize.hpp b/contrib/python/pythran/pythran/pythonic/numpy/vectorize.hpp index 4b0836a6b68..92500240ba6 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/vectorize.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/vectorize.hpp @@ -12,19 +12,17 @@ namespace numpy { template template - auto vectorized::operator()(T &&...args) const -> - typename std::enable_if::type...>::value, - decltype(F{}(std::forward(args)...))>::type + auto vectorized::operator()(T &&...args) const + -> std::enable_if_t...>::value, + decltype(F{}(std::forward(args)...))> { return F{}(std::forward(args)...); } template template - typename std::enable_if< - types::valid_numexpr_parameters::type...>::value, - types::numpy_expr::type...>>::type + std::enable_if_t...>::value, + types::numpy_expr::type...>> vectorized::operator()(E &&...args) const { return {std::forward(args)...}; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/vstack.hpp b/contrib/python/pythran/pythran/pythonic/numpy/vstack.hpp index 3b4de4a0dff..426b24e2e01 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/vstack.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/vstack.hpp @@ -10,20 +10,19 @@ namespace numpy { template - auto vstack(ArraySequence &&seq) -> - typename std::enable_if<(impl::vstack_helper::value > 1), - impl::vstack_helper>::type + auto vstack(ArraySequence &&seq) + -> std::enable_if_t<(impl::vstack_helper::value > 1), + impl::vstack_helper> { return concatenate(std::forward(seq), 0); } template - auto vstack(ArraySequence &&seq) -> - typename std::enable_if< - (impl::vstack_helper::value == 1), - decltype(std::declval>().reshape( - std::declval>()))>::type + auto vstack(ArraySequence &&seq) + -> std::enable_if_t<(impl::vstack_helper::value == 1), + decltype(std::declval>().reshape( + std::declval>()))> { auto &&temp = concatenate(std::forward(seq), 0); long const seq_size = seq.size(), temp_size = temp.size(); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/where.hpp b/contrib/python/pythran/pythran/pythonic/numpy/where.hpp index 7d917562944..20b1f181641 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/where.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/where.hpp @@ -14,8 +14,7 @@ namespace numpy namespace impl { template - typename __combined::type where(E const &cond, F const &true_, - G const &false_) + typename __combined::type where(E const &cond, F const &true_, G const &false_) { if (cond) return true_; @@ -37,20 +36,14 @@ namespace types struct Dereferencer { template - auto operator()(Ts const &iters, utils::index_sequence<0, 1, 2>) -> - typename std::enable_if< + auto operator()(Ts const &iters, std::index_sequence<0, 1, 2>) -> std::enable_if_t< + types::is_dtype< + std::remove_cv_t(iters))>>>::value && types::is_dtype< - typename std::remove_cv(iters))>::type>::type>::value && - types::is_dtype< - typename std::remove_cv(iters))>::type>::type>::value && - types::is_dtype< - typename std::remove_cv(iters))>::type>::type>::value, - decltype(numpy::impl::where(*std::get<0>(iters), - *std::get<1>(iters), - *std::get<2>(iters)))>::type + std::remove_cv_t(iters))>>>::value && + types::is_dtype< + std::remove_cv_t(iters))>>>::value, + decltype(numpy::impl::where(*std::get<0>(iters), *std::get<1>(iters), *std::get<2>(iters)))> { if (*std::get<0>(iters)) return *std::get<1>(iters); @@ -59,7 +52,7 @@ namespace types } template - auto operator()(Ts const &iters, utils::index_sequence, ...) + auto operator()(Ts const &iters, std::index_sequence, ...) -> decltype(numpy::functor::where{}(*std::get(iters)...)) { return numpy::functor::where{}(*std::get(iters)...); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/zeros.hpp b/contrib/python/pythran/pythran/pythonic/numpy/zeros.hpp index 8879fdadd28..26931223975 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/zeros.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/zeros.hpp @@ -19,8 +19,7 @@ namespace numpy } template - types::ndarray> - zeros(pS const &shape, dtype d) + types::ndarray> zeros(pS const &shape, dtype d) { using T = typename dtype::type; // use calloc even if we have a non integer type. This looks ok on modern @@ -30,15 +29,13 @@ namespace numpy } template - types::ndarray> zeros(long size, - dtype d) + types::ndarray> zeros(long size, dtype d) { return zeros(types::pshape(size), d); } template - types::ndarray>> + types::ndarray>> zeros(std::integral_constant, dtype d) { return zeros(types::pshape>({}), d); diff --git a/contrib/python/pythran/pythran/pythonic/numpy/zeros_like.hpp b/contrib/python/pythran/pythran/pythonic/numpy/zeros_like.hpp index 435089004cc..ef5e79cafaa 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/zeros_like.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/zeros_like.hpp @@ -12,16 +12,14 @@ namespace numpy { template - auto zeros_like(E const &expr, - dtype d) -> decltype(zeros(sutils::getshape(expr), d)) + auto zeros_like(E const &expr, dtype d) -> decltype(zeros(sutils::getshape(expr), d)) { return zeros(sutils::getshape(expr), d); } template auto zeros_like(E const &expr, types::none_type) - -> decltype(zeros(sutils::getshape(expr), - types::dtype_t())) + -> decltype(zeros(sutils::getshape(expr), types::dtype_t())) { return zeros(sutils::getshape(expr), types::dtype_t()); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/add.hpp b/contrib/python/pythran/pythran/pythonic/operator_/add.hpp index 1e594a143a1..a993c041f8b 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/add.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/add.hpp @@ -16,10 +16,10 @@ namespace operator_ return std::forward(a) + std::forward(b); } - DEFINE_ALL_OPERATOR_OVERLOADS_IMPL( - add, +, - (((b >= 0) ? (a <= std::numeric_limits::max() - b) - : (std::numeric_limits::min() - b <= a)))) + DEFINE_ALL_OPERATOR_OVERLOADS_IMPL(add, +, + (((b >= 0) + ? (a <= std::numeric_limits::max() - b) + : (std::numeric_limits::min() - b <= a)))) } // namespace operator_ PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/operator_/contains.hpp b/contrib/python/pythran/pythran/pythonic/operator_/contains.hpp index d1f739c7dee..5c84ffe23a5 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/contains.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/contains.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto contains(A &&a, - B &&b) -> decltype(in(std::forward(a), std::forward(b))) + auto contains(A &&a, B &&b) -> decltype(in(std::forward(a), std::forward(b))) { return in(std::forward(a), std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/div.hpp b/contrib/python/pythran/pythran/pythonic/operator_/div.hpp index 6158fdc23de..135632f6b19 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/div.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/div.hpp @@ -13,10 +13,9 @@ namespace operator_ template auto div(A &&a, B &&b) // for ndarrays - -> typename std::enable_if< - !std::is_fundamental::type>::value || - !std::is_fundamental::type>::value, - decltype(std::forward(a) / std::forward(b))>::type + -> std::enable_if_t>::value || + !std::is_fundamental>::value, + decltype(std::forward(a) / std::forward(b))> { return std::forward(a) / std::forward(b); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/icommon.hpp b/contrib/python/pythran/pythran/pythonic/operator_/icommon.hpp index bff2016246d..17a87c4a7a5 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/icommon.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/icommon.hpp @@ -21,9 +21,8 @@ namespace operator_ { template - auto OPERATOR_NAME(bool, A &&a, B &&b, - ...) -> decltype(std::forward(a) - OPERATOR_SYMBOL std::forward(b)) + auto OPERATOR_NAME(bool, A &&a, B &&b, ...) + -> decltype(std::forward(a) OPERATOR_SYMBOL std::forward(b)) { return std::forward(a) OPERATOR_SYMBOL std::forward(b); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/imax.hpp b/contrib/python/pythran/pythran/pythonic/operator_/imax.hpp index 44127928727..182d56fffb4 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/imax.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/imax.hpp @@ -11,21 +11,19 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto imax(A &&a, B &&b) -> - typename std::enable_if< - std::is_const::value || !std::is_assignable::value, - decltype(numpy::functor::maximum{}(std::forward(a), - std::forward(b)))>::type + auto imax(A &&a, B &&b) + -> std::enable_if_t::value || !std::is_assignable::value, + decltype(numpy::functor::maximum{}(std::forward(a), + std::forward(b)))> { return numpy::functor::maximum{}(std::forward(a), std::forward(b)); } template - auto imax(A &&a, B &&b) -> - typename std::enable_if< - !std::is_const::value && std::is_assignable::value, - decltype(a = numpy::functor::maximum{}(std::forward(a), - std::forward(b)))>::type + auto imax(A &&a, B &&b) + -> std::enable_if_t::value && std::is_assignable::value, + decltype(a = numpy::functor::maximum{}(std::forward(a), + std::forward(b)))> { return a = numpy::functor::maximum{}(a, std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/imin.hpp b/contrib/python/pythran/pythran/pythonic/operator_/imin.hpp index e1f32ea1521..4c73d7bd0dd 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/imin.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/imin.hpp @@ -12,21 +12,19 @@ namespace operator_ { template - auto imin(A &&a, B &&b) -> - typename std::enable_if< - std::is_const::value || !std::is_assignable::value, - decltype(numpy::functor::minimum{}(std::forward(a), - std::forward(b)))>::type + auto imin(A &&a, B &&b) + -> std::enable_if_t::value || !std::is_assignable::value, + decltype(numpy::functor::minimum{}(std::forward(a), + std::forward(b)))> { return numpy::functor::minimum{}(std::forward(a), std::forward(b)); } template - auto imin(A &&a, B &&b) -> - typename std::enable_if< - !std::is_const::value && std::is_assignable::value, - decltype(a = numpy::functor::minimum{}(std::forward(a), - std::forward(b)))>::type + auto imin(A &&a, B &&b) + -> std::enable_if_t::value && std::is_assignable::value, + decltype(a = numpy::functor::minimum{}(std::forward(a), + std::forward(b)))> { return a = numpy::functor::minimum{}(a, std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/indexOf.hpp b/contrib/python/pythran/pythran/pythonic/operator_/indexOf.hpp index 28def8bff81..a83dd4103fb 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/indexOf.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/indexOf.hpp @@ -19,8 +19,7 @@ namespace operator_ { auto where = std::find(a.begin(), a.end(), b); if (where == a.end()) - throw types::ValueError(builtins::anonymous::str(b) + - " is not in this sequence"); + throw types::ValueError(builtins::anonymous::str(b) + " is not in this sequence"); return where - a.begin(); } } // namespace operator_ diff --git a/contrib/python/pythran/pythran/pythonic/operator_/is_.hpp b/contrib/python/pythran/pythran/pythonic/operator_/is_.hpp index b9eff92b606..c3eab48a812 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/is_.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/is_.hpp @@ -12,8 +12,8 @@ namespace operator_ { template - auto is_(A &&a, B &&b) -> decltype(builtins::id(std::forward(a)) == - builtins::id(std::forward(b))) + auto is_(A &&a, B &&b) + -> decltype(builtins::id(std::forward(a)) == builtins::id(std::forward(b))) { return builtins::id(std::forward(a)) == builtins::id(std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/is_not.hpp b/contrib/python/pythran/pythran/pythonic/operator_/is_not.hpp index 63c4c9839d5..8842c059725 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/is_not.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/is_not.hpp @@ -11,8 +11,8 @@ namespace operator_ { template - auto is_not(A &&a, B &&b) -> decltype(builtins::id(std::forward(a)) != - builtins::id(std::forward(b))) + auto is_not(A &&a, B &&b) + -> decltype(builtins::id(std::forward(a)) != builtins::id(std::forward(b))) { return builtins::id(std::forward(a)) != builtins::id(std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/itemgetter.hpp b/contrib/python/pythran/pythran/pythonic/operator_/itemgetter.hpp index 7d3bf6a0cbe..367f6d3a3f8 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/itemgetter.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/itemgetter.hpp @@ -28,8 +28,7 @@ namespace operator_ } template - itemgetter_tuple_return::itemgetter_tuple_return(Types... items) - : items(items...) + itemgetter_tuple_return::itemgetter_tuple_return(Types... items) : items(items...) { } @@ -40,8 +39,7 @@ namespace operator_ template template - void itemgetter_tuple_return::helper(T &t, A const &a, - utils::int_) const + void itemgetter_tuple_return::helper(T &t, A const &a, utils::int_) const { std::get(t) = a[std::get(items)]; helper(t, a, utils::int_()); @@ -49,28 +47,24 @@ namespace operator_ template template - void itemgetter_tuple_return::helper(T &t, A const &a, - utils::int_<0>) const + void itemgetter_tuple_return::helper(T &t, A const &a, utils::int_<0>) const { std::get<0>(t) = a[std::get<0>(items)]; } template template - auto itemgetter_tuple_return::operator()(A const &a) const - -> std::tuple()])>::type>::type...> + auto itemgetter_tuple_return::operator()(A const &a) const -> std::tuple< + std::remove_cv_t()])>>...> { - std::tuple()])>::type>::type...> - t; + std::tuple()])>>...> t; helper(t, a, utils::int_()); return t; } template - itemgetter_tuple_return - itemgetter(long const &item1, long const &item2, L... items) + itemgetter_tuple_return itemgetter(long const &item1, long const &item2, + L... items) { return {item1, item2, items...}; } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/itruediv.hpp b/contrib/python/pythran/pythran/pythonic/operator_/itruediv.hpp index ad6feb5b9ce..50df249316c 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/itruediv.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/itruediv.hpp @@ -16,18 +16,15 @@ namespace operator_ return truediv(a, std::forward(b)); } template - auto itruediv(A &a, B &&b) -> - typename std::enable_if< - std::is_same(b)))>::value, - A &>::type + auto itruediv(A &a, B &&b) + -> std::enable_if_t(b)))>::value, A &> { return a = truediv(a, std::forward(b)); } template - auto itruediv(A &a, B &&b) -> - typename std::enable_if< - !std::is_same(b)))>::value, - decltype(truediv(a, std::forward(b)))>::type + auto itruediv(A &a, B &&b) + -> std::enable_if_t(b)))>::value, + decltype(truediv(a, std::forward(b)))> { return truediv(a, std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/lshift.hpp b/contrib/python/pythran/pythran/pythonic/operator_/lshift.hpp index a758fc9afde..e90a5cb3452 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/lshift.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/lshift.hpp @@ -12,8 +12,7 @@ namespace operator_ { template - auto lshift(A &&a, B &&b) -> decltype(std::forward(a) - << std::forward(b)) + auto lshift(A &&a, B &&b) -> decltype(std::forward(a) << std::forward(b)) { return std::forward(a) << std::forward(b); } @@ -25,8 +24,8 @@ namespace operator_ return b ? false : a; } - DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL( - lshift, <<, (a <= (std::numeric_limits::max() >> b))) + DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL(lshift, <<, + (a <= (std::numeric_limits::max() >> b))) } // namespace operator_ PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/operator_/mod.hpp b/contrib/python/pythran/pythran/pythonic/operator_/mod.hpp index 60f0047e8d7..a1502264fd4 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/mod.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/mod.hpp @@ -11,11 +11,9 @@ namespace operator_ { template - auto mod(A &&a, B &&b) -> - typename std::enable_if< - std::is_fundamental::type>::value && - std::is_fundamental::type>::value, - decltype(std::forward(a) % std::forward(b))>::type + auto mod(A &&a, B &&b) -> std::enable_if_t>::value && + std::is_fundamental>::value, + decltype(std::forward(a) % std::forward(b))> { auto t = std::forward(a) % b; return t < 0 ? (t + b) : t; @@ -35,10 +33,9 @@ namespace operator_ template auto mod(A &&a, B &&b) // for ndarrays - -> typename std::enable_if< - !std::is_fundamental::type>::value || - !std::is_fundamental::type>::value, - decltype(std::forward(a) % std::forward(b))>::type + -> std::enable_if_t>::value || + !std::is_fundamental>::value, + decltype(std::forward(a) % std::forward(b))> { return std::forward(a) % std::forward(b); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/mul.hpp b/contrib/python/pythran/pythran/pythonic/operator_/mul.hpp index bc8ba2ed6ba..319f16fe41a 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/mul.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/mul.hpp @@ -27,10 +27,8 @@ namespace operator_ DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL( mul, *, (b == 0 || - (a * b >= 0 && - std::abs(a) <= std::numeric_limits::max() / std::abs(b)) || - (a * b <= 0 && - std::abs(a) >= std::numeric_limits::min() / std::abs(b)))) + (a * b >= 0 && std::abs(a) <= std::numeric_limits::max() / std::abs(b)) || + (a * b <= 0 && std::abs(a) >= std::numeric_limits::min() / std::abs(b)))) } // namespace operator_ PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/operator_/overloads.hpp b/contrib/python/pythran/pythran/pythonic/operator_/overloads.hpp index 1126ba633b8..2818d8bc47e 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/overloads.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/overloads.hpp @@ -4,30 +4,30 @@ #include "pythonic/include/operator_/overloads.hpp" #include -#define PYTHONIC_OPERATOR_OVERLOAD_IMPL(type, opname, op, overflow_check) \ - inline type opname(type a, type b) \ - { \ - assert((overflow_check) && "overflow check"); \ - return a op b; \ +#define PYTHONIC_OPERATOR_OVERLOAD_IMPL(type, opname, op, overflow_check) \ + inline type opname(type a, type b) \ + { \ + assert((overflow_check) && "overflow check"); \ + return a op b; \ } // workaround the fact that char and short computations are done using int in C, // while they are done at their respective type in numpy -#define DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL(opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned char, opname, op, true) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(char, opname, op, true) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed char, opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned short, opname, op, true) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed short, opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned int, opname, op, true) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed int, opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned long, opname, op, true) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed long, opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned long long, opname, op, true) \ +#define DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL(opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned char, opname, op, true) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(char, opname, op, true) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed char, opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned short, opname, op, true) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed short, opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned int, opname, op, true) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed int, opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned long, opname, op, true) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed long, opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(unsigned long long, opname, op, true) \ PYTHONIC_OPERATOR_OVERLOAD_IMPL(signed long long, opname, op, overflow_check) -#define DEFINE_ALL_OPERATOR_OVERLOADS_IMPL(opname, op, overflow_check) \ - PYTHONIC_OPERATOR_OVERLOAD_IMPL(bool, opname, op, true) \ +#define DEFINE_ALL_OPERATOR_OVERLOADS_IMPL(opname, op, overflow_check) \ + PYTHONIC_OPERATOR_OVERLOAD_IMPL(bool, opname, op, true) \ DEFINE_ALL_OPERATOR_OVERLOADS_NO_BOOL_IMPL(opname, op, overflow_check) #endif diff --git a/contrib/python/pythran/pythran/pythonic/operator_/rshift.hpp b/contrib/python/pythran/pythran/pythonic/operator_/rshift.hpp index b656ae28af8..b0834d0d276 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/rshift.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/rshift.hpp @@ -11,8 +11,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto rshift(A &&a, - B &&b) -> decltype(std::forward(a) >> std::forward(b)) + auto rshift(A &&a, B &&b) -> decltype(std::forward(a) >> std::forward(b)) { return std::forward(a) >> std::forward(b); } diff --git a/contrib/python/pythran/pythran/pythonic/operator_/sub.hpp b/contrib/python/pythran/pythran/pythonic/operator_/sub.hpp index a91e3942000..6c97d845f9d 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/sub.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/sub.hpp @@ -17,10 +17,10 @@ namespace operator_ return std::forward(a) - std::forward(b); } - DEFINE_ALL_OPERATOR_OVERLOADS_IMPL( - sub, -, - (((b < 0) ? (a <= std::numeric_limits::max() + b) - : (std::numeric_limits::min() + b <= a)))) + DEFINE_ALL_OPERATOR_OVERLOADS_IMPL(sub, -, + (((b < 0) + ? (a <= std::numeric_limits::max() + b) + : (std::numeric_limits::min() + b <= a)))) } // namespace operator_ PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/operator_/truediv.hpp b/contrib/python/pythran/pythran/pythonic/operator_/truediv.hpp index 285da274894..ce11655cd96 100644 --- a/contrib/python/pythran/pythran/pythonic/operator_/truediv.hpp +++ b/contrib/python/pythran/pythran/pythonic/operator_/truediv.hpp @@ -10,8 +10,7 @@ PYTHONIC_NS_BEGIN namespace operator_ { template - auto truediv(A &&a, B &&b) -> decltype(std::forward(a) / - (double)std::forward(b)) + auto truediv(A &&a, B &&b) -> decltype(std::forward(a) / (double)std::forward(b)) { return std::forward(a) / ((double)std::forward(b)); } diff --git a/contrib/python/pythran/pythran/pythonic/os/path/join.hpp b/contrib/python/pythran/pythran/pythonic/os/path/join.hpp index 4f405268743..ba95c425e25 100644 --- a/contrib/python/pythran/pythran/pythonic/os/path/join.hpp +++ b/contrib/python/pythran/pythran/pythonic/os/path/join.hpp @@ -39,8 +39,7 @@ namespace os { if (((types::str)head)[0] == "/") buffer = std::forward(head); - else if (!buffer || *buffer.chars().rbegin() == OS_SEP || - *buffer.rbegin() == "/") + else if (!buffer || *buffer.chars().rbegin() == OS_SEP || *buffer.rbegin() == "/") buffer += std::forward(head); else { buffer.chars() += OS_SEP; diff --git a/contrib/python/pythran/pythran/pythonic/python/core.hpp b/contrib/python/pythran/pythran/pythonic/python/core.hpp index 4cbe3e0ab1c..86d2f634f71 100644 --- a/contrib/python/pythran/pythran/pythonic/python/core.hpp +++ b/contrib/python/pythran/pythran/pythonic/python/core.hpp @@ -28,13 +28,11 @@ PYTHONIC_NS_END template auto to_python(T &&value) - -> decltype(pythonic::to_python::type>::type>:: - convert(std::forward(value))) + -> decltype(pythonic::to_python>>::convert( + std::forward(value))) { - return pythonic::to_python< - typename std::remove_cv::type>::type>:: - convert(std::forward(value)); + return pythonic::to_python>>::convert( + std::forward(value)); } template T from_python(PyObject *obj) @@ -52,16 +50,54 @@ PYTHONIC_NS_BEGIN namespace python { +#ifdef Py_LIMITED_API + + struct ByteHolder { + PyObject *holder; + friend std::ostream &operator<<(std::ostream &os, ByteHolder const &byte_holder) + { + return os << (char *)(byte_holder); + } + operator char *() const + { + return PyBytes_AsString(holder); + } + ~ByteHolder() + { + Py_DECREF(holder); + } + }; + +#define PyString_AS_STRING(obj) \ + [obj]() { \ + auto *str_obj = PyUnicode_AsEncodedString(obj, "ascii", "strict"); \ + return ::pythonic::python::ByteHolder{str_obj}; \ + }() +#else #ifndef PyString_AS_STRING #define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA +#endif #endif inline void PyObject_TypePrettyPrinter(std::ostream &oss, PyObject *obj) { if (PyTuple_Check(obj)) { oss << '('; - for (long n = PyTuple_GET_SIZE(obj), i = 0; i < n; ++i) { - PyObject_TypePrettyPrinter(oss, PyTuple_GET_ITEM(obj, i)); +#ifdef Py_LIMITED_API + Py_ssize_t obj_size = PyTuple_Size(obj); + // FIXME: should we propagate the error or something? + assert(obj_size != -1); +#else + Py_ssize_t obj_size = PyTuple_GET_SIZE(obj); +#endif + for (long n = obj_size, i = 0; i < n; ++i) { +#ifdef Py_LIMITED_API + PyObject *obj_item = PyTuple_GetItem(obj, i); + assert(obj_item); +#else + PyObject *obj_item = PyTuple_GET_ITEM(obj, i); +#endif + PyObject_TypePrettyPrinter(oss, obj_item); if (i != n - 1) oss << ", "; } @@ -82,8 +118,7 @@ namespace python } oss << ']'; if ((PyArray_FLAGS(arr) & NPY_ARRAY_F_CONTIGUOUS) && - ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && - (PyArray_NDIM(arr) > 1)) { + ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && (PyArray_NDIM(arr) > 1)) { oss << " (with unsupported column-major layout)"; } else if (PyArray_BASE(arr)) { oss << " (is a view)"; @@ -103,7 +138,15 @@ namespace python if (PyObject_Not(obj)) { oss << "empty list"; } else { - PyObject_TypePrettyPrinter(oss, PySequence_Fast_GET_ITEM(obj, 0)); +#ifdef Py_LIMITED_API + PyObject *obj_item = PySequence_GetItem(obj, 0); +#else + PyObject *obj_item = PySequence_Fast_GET_ITEM(obj, 0); +#endif + PyObject_TypePrettyPrinter(oss, obj_item); +#ifdef Py_LIMITED_API + Py_DECREF(obj_item); +#endif oss << " list"; } } else if (PySet_Check(obj)) { @@ -136,14 +179,26 @@ namespace python } } - inline std::nullptr_t raise_invalid_argument(char const name[], - char const alternatives[], + inline std::nullptr_t raise_invalid_argument(char const name[], char const alternatives[], PyObject *args, PyObject *kwargs) { std::ostringstream oss; oss << "Invalid call to pythranized function `" << name << '('; - for (long n = PyTuple_GET_SIZE(args), i = 0; i < n; ++i) { - PyObject_TypePrettyPrinter(oss, PyTuple_GET_ITEM(args, i)); +#ifdef Py_LIMITED_API + Py_ssize_t args_size = PyTuple_Size(args); + // FIXME: should we propagate the error or something? + assert(args_size != -1); +#else + Py_ssize_t args_size = PyTuple_GET_SIZE(args); +#endif + for (long n = args_size, i = 0; i < n; ++i) { +#ifdef Py_LIMITED_API + PyObject *args_item = PyTuple_GetItem(args, i); + assert(args_item); +#else + PyObject *args_item = PyTuple_GET_ITEM(args, i); +#endif + PyObject_TypePrettyPrinter(oss, args_item); if (i != n - 1 || (kwargs && PyDict_Size(kwargs))) oss << ", "; } @@ -153,8 +208,7 @@ namespace python Py_ssize_t pos = 0; for (int next = PyDict_Next(kwargs, &pos, &key, &value); next;) { - PyObject *vrepr = - PyObject_GetAttrString((PyObject *)Py_TYPE(value), "__name__"); + PyObject *vrepr = PyObject_GetAttrString((PyObject *)Py_TYPE(value), "__name__"); oss << PyString_AS_STRING(key) << '=' << PyString_AS_STRING(vrepr); Py_DECREF(vrepr); if ((next = PyDict_Next(kwargs, &pos, &key, &value))) diff --git a/contrib/python/pythran/pythran/pythonic/python/exception_handler.hpp b/contrib/python/pythran/pythran/pythonic/python/exception_handler.hpp index 5f17bbcea48..5ab31c51aed 100644 --- a/contrib/python/pythran/pythran/pythonic/python/exception_handler.hpp +++ b/contrib/python/pythran/pythran/pythonic/python/exception_handler.hpp @@ -18,50 +18,42 @@ PyObject *handle_python_exception(F &&f) } #ifdef PYTHONIC_BUILTIN_SYNTAXWARNING_HPP catch (pythonic::types::SyntaxWarning &e) { - PyErr_SetString(PyExc_SyntaxWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_SyntaxWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_RUNTIMEWARNING_HPP catch (pythonic::types::RuntimeWarning &e) { - PyErr_SetString(PyExc_RuntimeWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_RuntimeWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_DEPRECATIONWARNING_HPP catch (pythonic::types::DeprecationWarning &e) { - PyErr_SetString(PyExc_DeprecationWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_DeprecationWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_IMPORTWARNING_HPP catch (pythonic::types::ImportWarning &e) { - PyErr_SetString(PyExc_ImportWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ImportWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_UNICODEWARNING_HPP catch (pythonic::types::UnicodeWarning &e) { - PyErr_SetString(PyExc_UnicodeWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_UnicodeWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_BYTESWARNING_HPP catch (pythonic::types::BytesWarning &e) { - PyErr_SetString(PyExc_BytesWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_BytesWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_USERWARNING_HPP catch (pythonic::types::UserWarning &e) { - PyErr_SetString(PyExc_UserWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_UserWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_FUTUREWARNING_HPP catch (pythonic::types::FutureWarning &e) { - PyErr_SetString(PyExc_FutureWarning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_FutureWarning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_PENDINGDEPRECATIONWARNING_HPP @@ -72,229 +64,191 @@ PyObject *handle_python_exception(F &&f) #endif #ifdef PYTHONIC_BUILTIN_WARNING_HPP catch (pythonic::types::Warning &e) { - PyErr_SetString(PyExc_Warning, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_Warning, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_UNICODEERROR_HPP catch (pythonic::types::UnicodeError &e) { - PyErr_SetString(PyExc_UnicodeError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_UnicodeError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_VALUEERROR_HPP catch (pythonic::types::ValueError &e) { - PyErr_SetString(PyExc_ValueError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ValueError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_TYPEERROR_HPP catch (pythonic::types::TypeError &e) { - PyErr_SetString(PyExc_TypeError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_TypeError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_SYSTEMERROR_HPP catch (pythonic::types::SystemError &e) { - PyErr_SetString(PyExc_SystemError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_SystemError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_TABERROR_HPP catch (pythonic::types::TabError &e) { - PyErr_SetString(PyExc_TabError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_TabError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_INDENTATIONERROR_HPP catch (pythonic::types::IndentationError &e) { - PyErr_SetString(PyExc_IndentationError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_IndentationError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_SYNTAXERROR_HPP catch (pythonic::types::SyntaxError &e) { - PyErr_SetString(PyExc_SyntaxError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_SyntaxError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_NOTIMPLEMENTEDERROR_HPP catch (pythonic::types::NotImplementedError &e) { - PyErr_SetString(PyExc_NotImplementedError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_NotImplementedError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_RUNTIMEERROR_HPP catch (pythonic::types::RuntimeError &e) { - PyErr_SetString(PyExc_RuntimeError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_RuntimeError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_REFERENCEERROR_HPP catch (pythonic::types::ReferenceError &e) { - PyErr_SetString(PyExc_ReferenceError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ReferenceError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_UNBOUNDLOCALERROR_HPP catch (pythonic::types::UnboundLocalError &e) { - PyErr_SetString(PyExc_UnboundLocalError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_UnboundLocalError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_NAMEERROR_HPP catch (pythonic::types::NameError &e) { - PyErr_SetString(PyExc_NameError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_NameError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_MEMORYERROR_HPP catch (pythonic::types::MemoryError &e) { - PyErr_SetString(PyExc_MemoryError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_MemoryError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_KEYERROR_HPP catch (pythonic::types::KeyError &e) { - PyErr_SetString(PyExc_KeyError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_KeyError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_INDEXERROR_HPP catch (pythonic::types::IndexError &e) { - PyErr_SetString(PyExc_IndexError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_IndexError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_LOOKUPERROR_HPP catch (pythonic::types::LookupError &e) { - PyErr_SetString(PyExc_LookupError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_LookupError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_IMPORTERROR_HPP catch (pythonic::types::ImportError &e) { - PyErr_SetString(PyExc_ImportError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ImportError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_EOFERROR_HPP catch (pythonic::types::EOFError &e) { - PyErr_SetString(PyExc_EOFError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_EOFError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_OSERROR_HPP catch (pythonic::types::OSError &e) { - PyErr_SetString(PyExc_OSError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_OSError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_IOERROR_HPP catch (pythonic::types::IOError &e) { - PyErr_SetString(PyExc_IOError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_IOError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_ENVIRONMENTERROR_HPP catch (pythonic::types::EnvironmentError &e) { - PyErr_SetString(PyExc_EnvironmentError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_EnvironmentError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_ATTRIBUTEERROR_HPP catch (pythonic::types::AttributeError &e) { - PyErr_SetString(PyExc_AttributeError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_AttributeError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_ASSERTIONERROR_HPP catch (pythonic::types::AssertionError &e) { - PyErr_SetString(PyExc_AssertionError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_AssertionError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_ZERODIVISIONERROR_HPP catch (pythonic::types::ZeroDivisionError &e) { - PyErr_SetString(PyExc_ZeroDivisionError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ZeroDivisionError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_OVERFLOWERROR_HPP catch (pythonic::types::OverflowError &e) { - PyErr_SetString(PyExc_OverflowError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_OverflowError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_FLOATINGPOINTERROR_HPP catch (pythonic::types::FloatingPointError &e) { - PyErr_SetString(PyExc_FloatingPointError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_FloatingPointError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_ARITHMETICERROR_HPP catch (pythonic::types::ArithmeticError &e) { - PyErr_SetString(PyExc_ArithmeticError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_ArithmeticError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_FILENOTFOUNDERROR_HPP catch (pythonic::types::FileNotFoundError &e) { - PyErr_SetString(PyExc_FileNotFoundError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_FileNotFoundError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_BUFFERERROR_HPP catch (pythonic::types::BufferError &e) { - PyErr_SetString(PyExc_BufferError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_BufferError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_STANDARDERROR_HPP catch (pythonic::types::StandardError &e) { - PyErr_SetString(PyExc_StandardError, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_StandardError, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_STOPITERATION_HPP catch (pythonic::types::StopIteration &e) { - PyErr_SetString(PyExc_StopIteration, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_StopIteration, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_EXCEPTION_HPP catch (pythonic::types::Exception &e) { - PyErr_SetString(PyExc_Exception, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_Exception, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_GENERATOREXIT_HPP catch (pythonic::types::GeneratorExit &e) { - PyErr_SetString(PyExc_GeneratorExit, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_GeneratorExit, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_KEYBOARDINTERRUPT_HPP catch (pythonic::types::KeyboardInterrupt &e) { - PyErr_SetString(PyExc_KeyboardInterrupt, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_KeyboardInterrupt, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_SYSTEMEXIT_HPP catch (pythonic::types::SystemExit &e) { - PyErr_SetString(PyExc_SystemExit, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_SystemExit, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif #ifdef PYTHONIC_BUILTIN_BASEEXCEPTION_HPP catch (pythonic::types::BaseException &e) { - PyErr_SetString(PyExc_BaseException, - pythonic::builtins::functor::str{}(e.args).c_str()); + PyErr_SetString(PyExc_BaseException, pythonic::builtins::functor::str{}(e.args).c_str()); } #endif catch (...) { - PyErr_SetString(PyExc_RuntimeError, - "Something happened on the way to heaven"); + PyErr_SetString(PyExc_RuntimeError, "Something happened on the way to heaven"); } return nullptr; } diff --git a/contrib/python/pythran/pythran/pythonic/random/choice.hpp b/contrib/python/pythran/pythran/pythonic/random/choice.hpp index ca0e3299ed5..65f1dfdf58a 100644 --- a/contrib/python/pythran/pythran/pythonic/random/choice.hpp +++ b/contrib/python/pythran/pythran/pythonic/random/choice.hpp @@ -16,9 +16,7 @@ namespace random { template - typename std::enable_if::value, - typename Seq::value_type>::type - choice(Seq const &seq) + std::enable_if_t::value, typename Seq::value_type> choice(Seq const &seq) { auto tmp = seq.begin(); // std::advance not usable because it requires operator-- @@ -28,11 +26,9 @@ namespace random } template - typename std::enable_if::value, - typename Seq::value_type>::type - choice(Seq const &seq) + std::enable_if_t::value, typename Seq::value_type> choice(Seq const &seq) { - using dtype = typename std::decay::type; + using dtype = std::decay_t; std::vector> tmp(seq.begin(), seq.end()); return tmp[long(random() * tmp.size())]; } diff --git a/contrib/python/pythran/pythran/pythonic/random/sample.hpp b/contrib/python/pythran/pythran/pythonic/random/sample.hpp index 59389af38c2..420cd0c2243 100644 --- a/contrib/python/pythran/pythran/pythonic/random/sample.hpp +++ b/contrib/python/pythran/pythran/pythonic/random/sample.hpp @@ -15,13 +15,11 @@ namespace random { template types::list::type>:: - type::iterator>::value_type> + typename std::remove_cv_t>::iterator>::value_type> sample(Iterable &&s, size_t k) { - using value_type = typename std::iterator_traits::type>::type::iterator>:: - value_type; + using value_type = typename std::iterator_traits< + typename std::remove_cv_t>::iterator>::value_type; types::list tmp(s.begin(), s.end()); std::vector> indices(tmp.size()); std::iota(indices.begin(), indices.end(), 0); diff --git a/contrib/python/pythran/pythran/pythonic/random/shuffle.hpp b/contrib/python/pythran/pythran/pythonic/random/shuffle.hpp index 43f0366a79b..5703a7c8438 100644 --- a/contrib/python/pythran/pythran/pythonic/random/shuffle.hpp +++ b/contrib/python/pythran/pythran/pythonic/random/shuffle.hpp @@ -52,8 +52,7 @@ namespace random template types::none_type shuffle(T &seq, function &&randf) { - std::shuffle(seq.begin(), seq.end(), - details::URG(std::forward(randf))); + std::shuffle(seq.begin(), seq.end(), details::URG(std::forward(randf))); return builtins::None; } } // namespace random diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/binom.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/binom.hpp index e9182c797a7..cf6d61d3431 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/binom.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/binom.hpp @@ -21,12 +21,10 @@ namespace scipy template double binom(T0 n, T1 k) { - static_assert(std::is_integral::value && - std::is_integral::value, + static_assert(std::is_integral::value && std::is_integral::value, "only support integer case of scipy.special.binom"); using namespace boost::math::policies; - return boost::math::binomial_coefficient( - n, k, make_policy(promote_double())); + return boost::math::binomial_coefficient(n, k, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/gammaincinv.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/gammaincinv.hpp index f972ed8d9b6..1ead08883ff 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/gammaincinv.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/gammaincinv.hpp @@ -22,8 +22,7 @@ namespace scipy double gammaincinv(T0 a, T1 p) { using namespace boost::math::policies; - return boost::math::gamma_p_inv(a, p, - make_policy(promote_double())); + return boost::math::gamma_p_inv(a, p, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/iv.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/iv.hpp index 658a3f3010c..3a8d8d59054 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/iv.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/iv.hpp @@ -22,8 +22,7 @@ namespace scipy double iv(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_i(x, y, - make_policy(promote_double())); + return boost::math::cyl_bessel_i(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/ivp.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/ivp.hpp index db689f15000..fceba8cf86e 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/ivp.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/ivp.hpp @@ -22,8 +22,7 @@ namespace scipy double ivp(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_i_prime( - x, y, make_policy(promote_double())); + return boost::math::cyl_bessel_i_prime(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/jv.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/jv.hpp index 8485907ac90..083a8669a8c 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/jv.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/jv.hpp @@ -22,8 +22,7 @@ namespace scipy double jv(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_j(x, y, - make_policy(promote_double())); + return boost::math::cyl_bessel_j(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/jvp.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/jvp.hpp index c9a674c2a7f..50890521688 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/jvp.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/jvp.hpp @@ -22,8 +22,7 @@ namespace scipy double jvp(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_j_prime( - x, y, make_policy(promote_double())); + return boost::math::cyl_bessel_j_prime(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/kv.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/kv.hpp index 406bb1a96d8..acbc9bb5a3a 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/kv.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/kv.hpp @@ -22,8 +22,7 @@ namespace scipy double kv(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_k(x, y, - make_policy(promote_double())); + return boost::math::cyl_bessel_k(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/kvp.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/kvp.hpp index 3f916ef3620..7c5197f02bd 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/kvp.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/kvp.hpp @@ -22,8 +22,7 @@ namespace scipy double kvp(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_bessel_k_prime( - x, y, make_policy(promote_double())); + return boost::math::cyl_bessel_k_prime(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_jn.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_jn.hpp index da92301c2cb..09c37ba4a0e 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_jn.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_jn.hpp @@ -22,15 +22,12 @@ namespace scipy template double spherical_jn(T0 v, T1 x, bool derivative) { - assert(v == (long)v && - "only supported for integral value as first arg"); + assert(v == (long)v && "only supported for integral value as first arg"); using namespace boost::math::policies; if (derivative) { - return boost::math::sph_bessel_prime( - v, x, make_policy(promote_double())); + return boost::math::sph_bessel_prime(v, x, make_policy(promote_double())); } else { - return boost::math::sph_bessel(v, x, - make_policy(promote_double())); + return boost::math::sph_bessel(v, x, make_policy(promote_double())); } } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_yn.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_yn.hpp index 952587984a2..87f22d2fb70 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_yn.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/spherical_yn.hpp @@ -22,15 +22,12 @@ namespace scipy template double spherical_yn(T0 v, T1 x, bool derivative) { - assert(v == (long)v && - "only supported for integral value as first arg"); + assert(v == (long)v && "only supported for integral value as first arg"); using namespace boost::math::policies; if (derivative) { - return boost::math::sph_neumann_prime( - v, x, make_policy(promote_double())); + return boost::math::sph_neumann_prime(v, x, make_policy(promote_double())); } else { - return boost::math::sph_neumann(v, x, - make_policy(promote_double())); + return boost::math::sph_neumann(v, x, make_policy(promote_double())); } } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/yv.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/yv.hpp index 42462a1edba..0629ea89ca4 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/yv.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/yv.hpp @@ -22,8 +22,7 @@ namespace scipy double yv(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_neumann(x, y, - make_policy(promote_double())); + return boost::math::cyl_neumann(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/scipy/special/yvp.hpp b/contrib/python/pythran/pythran/pythonic/scipy/special/yvp.hpp index b8cb59ab67b..aed9bc349e4 100644 --- a/contrib/python/pythran/pythran/pythonic/scipy/special/yvp.hpp +++ b/contrib/python/pythran/pythran/pythonic/scipy/special/yvp.hpp @@ -22,8 +22,7 @@ namespace scipy double yvp(T0 x, T1 y) { using namespace boost::math::policies; - return boost::math::cyl_neumann_prime( - x, y, make_policy(promote_double())); + return boost::math::cyl_neumann_prime(x, y, make_policy(promote_double())); } } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/time/time.hpp b/contrib/python/pythran/pythran/pythonic/time/time.hpp index 3dac449d7d2..86ba8b5ec97 100644 --- a/contrib/python/pythran/pythran/pythonic/time/time.hpp +++ b/contrib/python/pythran/pythran/pythonic/time/time.hpp @@ -13,11 +13,8 @@ namespace time double time() { - std::chrono::time_point tp = - std::chrono::steady_clock::now(); - return std::chrono::duration_cast( - tp.time_since_epoch()) - .count() / + std::chrono::time_point tp = std::chrono::steady_clock::now(); + return std::chrono::duration_cast(tp.time_since_epoch()).count() / 1000.; } } // namespace time diff --git a/contrib/python/pythran/pythran/pythonic/types/NoneType.hpp b/contrib/python/pythran/pythran/pythonic/types/NoneType.hpp index 3952b8092a9..ca47b5ac508 100644 --- a/contrib/python/pythran/pythran/pythonic/types/NoneType.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/NoneType.hpp @@ -62,8 +62,7 @@ namespace types template none::operator bool() const { - return !is_none && - builtins::functor::bool_{}(static_cast(*this)); + return !is_none && builtins::functor::bool_{}(static_cast(*this)); } template @@ -136,15 +135,15 @@ namespace types } template - decltype(operator_::mod(std::declval(), std::declval())) - operator%(none const &t0, T1 const &t1) + decltype(operator_::mod(std::declval(), std::declval())) operator%(none const &t0, + T1 const &t1) { return operator_::mod(t0.data, t1); } template - decltype(operator_::mod(std::declval(), std::declval())) - operator%(T0 const &t0, none const &t1) + decltype(operator_::mod(std::declval(), std::declval())) operator%(T0 const &t0, + none const &t1) { return operator_::mod(t0, t1.data); } diff --git a/contrib/python/pythran/pythran/pythonic/types/array.hpp b/contrib/python/pythran/pythran/pythonic/types/array.hpp index b10d9405e01..b567f42180c 100644 --- a/contrib/python/pythran/pythran/pythonic/types/array.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/array.hpp @@ -30,8 +30,7 @@ namespace types { } template - sliced_array::sliced_array(sliced_array const &s) - : _data(s._data), slicing(s.slicing) + sliced_array::sliced_array(sliced_array const &s) : _data(s._data), slicing(s.slicing) { } template @@ -41,8 +40,7 @@ namespace types } template template - sliced_array::sliced_array( - utils::shared_ref const &other, Sn const &s) + sliced_array::sliced_array(utils::shared_ref const &other, Sn const &s) : _data(other), slicing(s) { } @@ -83,8 +81,7 @@ namespace types // accessor template - typename sliced_array::const_reference - sliced_array::fast(long i) const + typename sliced_array::const_reference sliced_array::fast(long i) const { assert(0 <= i && i < size()); auto const index = slicing.get(i); @@ -100,8 +97,7 @@ namespace types return (*_data)[index]; } template - typename sliced_array::const_reference - sliced_array::operator[](long i) const + typename sliced_array::const_reference sliced_array::operator[](long i) const { assert(i < size()); auto const index = slicing.get(i); @@ -119,9 +115,8 @@ namespace types template template - typename std::enable_if< - is_slice::value, - sliced_array() * std::declval())>>::type + std::enable_if_t::value, + sliced_array() * std::declval())>> sliced_array::operator[](Sp s) const { return {_data, slicing * s.normalize(this->size())}; @@ -153,8 +148,7 @@ namespace types return std::equal(begin(), end(), other.begin()); } template - inline sliced_array & - sliced_array::operator=(sliced_array const &s) + inline sliced_array &sliced_array::operator=(sliced_array const &s) { if (slicing.step == 1) { // inserting before erasing in case of self-copy @@ -211,21 +205,18 @@ namespace types #ifdef USE_XSIMD template template - typename sliced_array::simd_iterator - sliced_array::vbegin(vectorizer) const + typename sliced_array::simd_iterator sliced_array::vbegin(vectorizer) const { return {_data->data() + slicing.lower}; } template template - typename sliced_array::simd_iterator - sliced_array::vend(vectorizer) const + typename sliced_array::simd_iterator sliced_array::vend(vectorizer) const { using vector_type = typename xsimd::batch; static const std::size_t vector_size = vector_type::size; - return {_data->data() + slicing.lower + - long(size() / vector_size * vector_size)}; + return {_data->data() + slicing.lower + long(size() / vector_size * vector_size)}; } #endif @@ -261,9 +252,8 @@ namespace types template array::array(InputIterator start, InputIterator stop) : _data() { - if (std::is_same< - typename std::iterator_traits::iterator_category, - std::random_access_iterator_tag>::value) + if (std::is_same::iterator_category, + std::random_access_iterator_tag>::value) _data->reserve(std::distance(start, stop)); else _data->reserve(DEFAULT_CAPACITY); @@ -289,8 +279,7 @@ namespace types } template template - array::array(sliced_array const &other) - : _data(other.begin(), other.end()) + array::array(sliced_array const &other) : _data(other.begin(), other.end()) { } @@ -419,14 +408,12 @@ namespace types template bool array::operator<(array const &other) const { - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end()); } template bool array::operator>(array const &other) const { - return std::lexicographical_compare(other.begin(), other.end(), begin(), - end()); + return std::lexicographical_compare(other.begin(), other.end(), begin(), end()); } template bool array::operator<=(array const &other) const @@ -488,8 +475,7 @@ namespace types template template - typename std::enable_if::value, sliced_array>::type - array::operator[](Sp const &s) const + std::enable_if_t::value, sliced_array> array::operator[](Sp const &s) const { return {*this, s}; } @@ -568,8 +554,7 @@ namespace types template template - array::type> - array::operator+(array const &s) const + array::type> array::operator+(array const &s) const { array::type> clone(size() + s.size()); std::copy(s.begin(), s.end(), std::copy(begin(), end(), clone.begin())); @@ -578,12 +563,10 @@ namespace types template template - array() + - std::declval::value_type>())> + array() + std::declval::value_type>())> array::operator+(sliced_array const &s) const { - array() + - std::declval::value_type>())> + array() + std::declval::value_type>())> clone(size() + len(s)); std::copy(s.begin(), s.end(), std::copy(begin(), end(), clone.begin())); return clone; @@ -645,8 +628,7 @@ namespace types template long array::_flat_size(E const &e, utils::int_) const { - return std::distance(e.begin(), e.end()) * - _flat_size(e[0], utils::int_{}); + return std::distance(e.begin(), e.end()) * _flat_size(e[0], utils::int_{}); } template long array::flat_size() const @@ -678,8 +660,7 @@ namespace utils { template - void reserve(types::array &l, From const &f, - typename From::const_iterator *) + void reserve(types::array &l, From const &f, typename From::const_iterator *) { l.reserve(builtins::len(f)); } @@ -690,22 +671,19 @@ PYTHONIC_NS_END namespace std { template - typename pythonic::types::array::reference - get(pythonic::types::array &t) + typename pythonic::types::array::reference get(pythonic::types::array &t) { return t[I]; } template - typename pythonic::types::array::const_reference - get(pythonic::types::array const &t) + typename pythonic::types::array::const_reference get(pythonic::types::array const &t) { return t[I]; } template - typename pythonic::types::array::value_type - get(pythonic::types::array &&t) + typename pythonic::types::array::value_type get(pythonic::types::array &&t) { return std::move(t)[I]; } @@ -739,15 +717,12 @@ PYTHONIC_NS_BEGIN template PyObject *to_python>::convert(types::array const &v) { - throw types::NotImplementedError( - "Pythran cannot efficiently convert array::array values"); + throw types::NotImplementedError("Pythran cannot efficiently convert array::array values"); } template -PyObject *to_python>::convert( - types::sliced_array const &v) +PyObject *to_python>::convert(types::sliced_array const &v) { - throw types::NotImplementedError( - "Pythran cannot efficiently convert array::array values"); + throw types::NotImplementedError("Pythran cannot efficiently convert array::array values"); } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/bool.hpp b/contrib/python/pythran/pythran/pythonic/types/bool.hpp index 35ac01d37d9..22764118708 100644 --- a/contrib/python/pythran/pythran/pythonic/types/bool.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/bool.hpp @@ -18,8 +18,7 @@ inline PyObject *to_python::convert(bool b) inline bool from_python::is_convertible(PyObject *obj) { - return obj == Py_True || obj == Py_False || - PyObject_TypeCheck(obj, &PyBoolArrType_Type); + return obj == Py_True || obj == Py_False || PyObject_TypeCheck(obj, &PyBoolArrType_Type); } inline bool from_python::convert(PyObject *obj) { @@ -28,7 +27,7 @@ inline bool from_python::convert(PyObject *obj) else if (obj == Py_False) return false; else - return PyInt_AsLong(obj); + return PyObject_IsTrue(obj); } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/cfun.hpp b/contrib/python/pythran/pythran/pythonic/types/cfun.hpp index 058f7080ed7..14efd3dc042 100644 --- a/contrib/python/pythran/pythran/pythonic/types/cfun.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/cfun.hpp @@ -25,8 +25,7 @@ PYTHONIC_NS_END PYTHONIC_NS_BEGIN template -PyObject * -to_python>::convert(types::cfun const &v) +PyObject *to_python>::convert(types::cfun const &v) { return PyCapsule_New(v.ptr, nullptr, nullptr); } @@ -38,11 +37,9 @@ bool from_python>::is_convertible(PyObject *obj) } template -types::cfun -from_python>::convert(PyObject *obj) +types::cfun from_python>::convert(PyObject *obj) { - void *ptr = PyCapsule_GetPointer( - obj, PyCapsule_GetName(obj) /* avoid the string check*/); + void *ptr = PyCapsule_GetPointer(obj, PyCapsule_GetName(obj) /* avoid the string check*/); return {reinterpret_cast(ptr)}; } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/complex.hpp b/contrib/python/pythran/pythran/pythonic/types/complex.hpp index 929a3d20068..294f7e6dc40 100644 --- a/contrib/python/pythran/pythran/pythonic/types/complex.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/complex.hpp @@ -13,57 +13,49 @@ namespace std template complex_broadcast_t operator+(std::complex self, S other) { - return (complex_broadcast_t)self + - (typename std::common_type::type)(other); + return (complex_broadcast_t)self + (std::common_type_t)(other); } template complex_broadcast_t operator+(S self, std::complex other) { - return (typename std::common_type::type)(self) + - (complex_broadcast_t)other; + return (std::common_type_t)(self) + (complex_broadcast_t)other; } template complex_broadcast_t operator-(std::complex self, S other) { - return (complex_broadcast_t)self - - (typename std::common_type::type)(other); + return (complex_broadcast_t)self - (std::common_type_t)(other); } template complex_broadcast_t operator-(S self, std::complex other) { - return (typename std::common_type::type)(self) - - (complex_broadcast_t)other; + return (std::common_type_t)(self) - (complex_broadcast_t)other; } template complex_broadcast_t operator*(std::complex self, S other) { - return (complex_broadcast_t)self * - (typename std::common_type::type)(other); + return (complex_broadcast_t)self * (std::common_type_t)(other); } template complex_broadcast_t operator*(S self, std::complex other) { - return (typename std::common_type::type)(self) * - (complex_broadcast_t)other; + return (std::common_type_t)(self) * (complex_broadcast_t)other; } template complex_broadcast_t operator/(std::complex self, S other) { - return (complex_broadcast_t)self / - (typename std::common_type::type)(other); + return (complex_broadcast_t)self / (std::common_type_t)(other); } template complex_broadcast_t operator/(S self, std::complex other) { - return (typename std::common_type::type)(self) / - (complex_broadcast_t)other; + return (std::common_type_t)(self) / (complex_broadcast_t)other; } template @@ -93,29 +85,25 @@ namespace std template bool operator<(std::complex self, std::complex other) { - return self.real() == other.real() ? self.imag() < other.imag() - : self.real() < other.real(); + return self.real() == other.real() ? self.imag() < other.imag() : self.real() < other.real(); } template bool operator<=(std::complex self, std::complex other) { - return self.real() == other.real() ? self.imag() <= other.imag() - : self.real() <= other.real(); + return self.real() == other.real() ? self.imag() <= other.imag() : self.real() <= other.real(); } template bool operator>(std::complex self, std::complex other) { - return self.real() == other.real() ? self.imag() > other.imag() - : self.real() > other.real(); + return self.real() == other.real() ? self.imag() > other.imag() : self.real() > other.real(); } template bool operator>=(std::complex self, std::complex other) { - return self.real() == other.real() ? self.imag() >= other.imag() - : self.real() >= other.real(); + return self.real() == other.real() ? self.imag() >= other.imag() : self.real() >= other.real(); } template @@ -156,18 +144,16 @@ namespace builtins { return std::imag(self); } - inline numpy::functor::complex64 getattr(types::attr::DTYPE, - std::complex const &self) + inline numpy::functor::complex64 getattr(types::attr::DTYPE, std::complex const &self) { return {}; } - inline numpy::functor::complex128 getattr(types::attr::DTYPE, - std::complex const &self) + inline numpy::functor::complex128 getattr(types::attr::DTYPE, std::complex const &self) { return {}; } - inline numpy::functor::complex256 - getattr(types::attr::DTYPE, std::complex const &self) + inline numpy::functor::complex256 getattr(types::attr::DTYPE, + std::complex const &self) { return {}; } @@ -183,31 +169,27 @@ PYTHONIC_NS_END PYTHONIC_NS_BEGIN template <> -inline PyObject *to_python>::convert( - std::complex const &c) +inline PyObject *to_python>::convert(std::complex const &c) { return PyArray_Scalar(const_cast *>(&c), PyArray_DescrFromType(NPY_CLONGDOUBLE), nullptr); } template <> -inline PyObject * -to_python>::convert(std::complex const &c) +inline PyObject *to_python>::convert(std::complex const &c) { return PyComplex_FromDoubles(c.real(), c.imag()); } template <> -inline PyObject * -to_python>::convert(std::complex const &c) +inline PyObject *to_python>::convert(std::complex const &c) { - return PyArray_Scalar(const_cast *>(&c), - PyArray_DescrFromType(NPY_CFLOAT), nullptr); + return PyArray_Scalar(const_cast *>(&c), PyArray_DescrFromType(NPY_CFLOAT), + nullptr); } template <> -inline bool -from_python>::is_convertible(PyObject *obj) +inline bool from_python>::is_convertible(PyObject *obj) { return PyArray_IsScalar(obj, CLongDouble); } @@ -225,25 +207,32 @@ inline bool from_python>::is_convertible(PyObject *obj) } template <> -inline std::complex -from_python>::convert(PyObject *obj) +inline std::complex from_python>::convert(PyObject *obj) { +#ifdef Py_LIMITED_API + npy_clongdouble val; + PyArray_ScalarAsCtype(obj, &val); +#else auto val = PyArrayScalar_VAL(obj, CLongDouble); +#endif return {npy_creall(val), npy_cimagl(val)}; } template <> -inline std::complex -from_python>::convert(PyObject *obj) +inline std::complex from_python>::convert(PyObject *obj) { return {PyComplex_RealAsDouble(obj), PyComplex_ImagAsDouble(obj)}; } template <> -inline std::complex -from_python>::convert(PyObject *obj) +inline std::complex from_python>::convert(PyObject *obj) { +#ifdef Py_LIMITED_API + npy_cfloat val; + PyArray_ScalarAsCtype(obj, &val); +#else auto val = PyArrayScalar_VAL(obj, CFloat); +#endif return {npy_crealf(val), npy_cimagf(val)}; } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/dict.hpp b/contrib/python/pythran/pythran/pythonic/types/dict.hpp index 5bc7cbc89fb..f5eee0a43f8 100644 --- a/contrib/python/pythran/pythran/pythonic/types/dict.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/dict.hpp @@ -26,10 +26,10 @@ namespace types { } template - typename item_iterator_adaptator::value_type - item_iterator_adaptator::operator*() const + typename item_iterator_adaptator::value_type item_iterator_adaptator::operator*() const { - auto &&tmp = *base;; + auto &&tmp = *base; + ; return pythonic::types::make_tuple(tmp.first, tmp.second); } @@ -40,8 +40,7 @@ namespace types } template - typename key_iterator_adaptator::value_type - key_iterator_adaptator::operator*() const + typename key_iterator_adaptator::value_type key_iterator_adaptator::operator*() const { return base->first; } @@ -53,8 +52,7 @@ namespace types } template - typename value_iterator_adaptator::value_type - value_iterator_adaptator::operator*() const + typename value_iterator_adaptator::value_type value_iterator_adaptator::operator*() const { return base->second; } @@ -154,8 +152,7 @@ namespace types } template - dict::dict(std::initializer_list l) - : data(l.begin(), l.end()) + dict::dict(std::initializer_list l) : data(l.begin(), l.end()) { } @@ -166,8 +163,7 @@ namespace types template template - dict::dict(dict const &other) - : data(other.data->begin(), other.data->end()) + dict::dict(dict const &other) : data(other.data->begin(), other.data->end()) { } @@ -187,8 +183,8 @@ namespace types template typename dict::const_iterator dict::begin() const { - return key_iterator_adaptator< - typename dict::container_type::const_iterator>(data->begin()); + return key_iterator_adaptator::container_type::const_iterator>( + data->begin()); } template @@ -200,92 +196,84 @@ namespace types template typename dict::const_iterator dict::end() const { - return key_iterator_adaptator< - typename dict::container_type::const_iterator>(data->end()); + return key_iterator_adaptator::container_type::const_iterator>(data->end()); } template typename dict::item_iterator dict::item_begin() { - return item_iterator_adaptator< - typename dict::container_type::iterator>(data->begin()); + return item_iterator_adaptator::container_type::iterator>(data->begin()); } template typename dict::item_const_iterator dict::item_begin() const { - return item_iterator_adaptator< - typename dict::container_type::const_iterator>(data->begin()); + return item_iterator_adaptator::container_type::const_iterator>( + data->begin()); } template typename dict::item_iterator dict::item_end() { - return item_iterator_adaptator< - typename dict::container_type::iterator>(data->end()); + return item_iterator_adaptator::container_type::iterator>(data->end()); } template typename dict::item_const_iterator dict::item_end() const { - return item_iterator_adaptator< - typename dict::container_type::const_iterator>(data->end()); + return item_iterator_adaptator::container_type::const_iterator>( + data->end()); } template typename dict::key_iterator dict::key_begin() { - return key_iterator_adaptator< - typename dict::container_type::iterator>(data->begin()); + return key_iterator_adaptator::container_type::iterator>(data->begin()); } template typename dict::key_const_iterator dict::key_begin() const { - return key_iterator_adaptator< - typename dict::container_type::const_iterator>(data->begin()); + return key_iterator_adaptator::container_type::const_iterator>( + data->begin()); } template typename dict::key_iterator dict::key_end() { - return key_iterator_adaptator< - typename dict::container_type::iterator>(data->end()); + return key_iterator_adaptator::container_type::iterator>(data->end()); } template typename dict::key_const_iterator dict::key_end() const { - return key_iterator_adaptator< - typename dict::container_type::const_iterator>(data->end()); + return key_iterator_adaptator::container_type::const_iterator>(data->end()); } template typename dict::value_iterator dict::value_begin() { - return value_iterator_adaptator< - typename dict::container_type::iterator>(data->begin()); + return value_iterator_adaptator::container_type::iterator>(data->begin()); } template typename dict::value_const_iterator dict::value_begin() const { - return value_iterator_adaptator< - typename dict::container_type::const_iterator>(data->begin()); + return value_iterator_adaptator::container_type::const_iterator>( + data->begin()); } template typename dict::value_iterator dict::value_end() { - return value_iterator_adaptator< - typename dict::container_type::iterator>(data->end()); + return value_iterator_adaptator::container_type::iterator>(data->end()); } template typename dict::value_const_iterator dict::value_end() const { - return value_iterator_adaptator< - typename dict::container_type::const_iterator>(data->end()); + return value_iterator_adaptator::container_type::const_iterator>( + data->end()); } // dict interface @@ -325,8 +313,8 @@ namespace types template typename dict::item_const_iterator dict::find(K const &key) const { - return item_iterator_adaptator< - typename dict::container_type::const_iterator>(data->find(key)); + return item_iterator_adaptator::container_type::const_iterator>( + data->find(key)); } template diff --git a/contrib/python/pythran/pythran/pythonic/types/dynamic_tuple.hpp b/contrib/python/pythran/pythran/pythonic/types/dynamic_tuple.hpp index 9e516b43f07..2310669a763 100644 --- a/contrib/python/pythran/pythran/pythonic/types/dynamic_tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/dynamic_tuple.hpp @@ -56,8 +56,7 @@ namespace types template bool dynamic_tuple::operator<(dynamic_tuple const &other) const { - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end(), std::less()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end(), std::less()); } template @@ -65,15 +64,14 @@ namespace types { if (size() == other.size() && std::equal(begin(), end(), other.begin())) return true; - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end(), std::less()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end(), std::less()); } template bool dynamic_tuple::operator>(dynamic_tuple const &other) const { - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end(), std::greater()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end(), + std::greater()); } template @@ -81,13 +79,12 @@ namespace types { if (size() == other.size() && std::equal(begin(), end(), other.begin())) return true; - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end(), std::greater()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end(), + std::greater()); } template - dynamic_tuple - dynamic_tuple::operator+(dynamic_tuple const &other) const + dynamic_tuple dynamic_tuple::operator+(dynamic_tuple const &other) const { dynamic_tuple result(begin(), end()); result.data->resize(size() + other.size()); @@ -119,9 +116,12 @@ namespace std PYTHONIC_NS_BEGIN +#ifdef Py_LIMITED_API +#define PyTuple_SET_ITEM PyTuple_SetItem +#endif + template -PyObject * -to_python>::convert(types::dynamic_tuple const &t) +PyObject *to_python>::convert(types::dynamic_tuple const &t) { size_t N = t.size(); PyObject *out = PyTuple_New(N); @@ -130,6 +130,9 @@ to_python>::convert(types::dynamic_tuple const &t) return out; } +#ifdef Py_LIMITED_API +#undef PyTuple_SET_ITEM +#endif PYTHONIC_NS_END #endif diff --git a/contrib/python/pythran/pythran/pythonic/types/exceptions.hpp b/contrib/python/pythran/pythran/pythonic/types/exceptions.hpp index 187498c2c3f..101c0094f6a 100644 --- a/contrib/python/pythran/pythran/pythonic/types/exceptions.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/exceptions.hpp @@ -17,8 +17,7 @@ namespace types { template - BaseException::BaseException(Types const &...types) - : args({builtins::functor::str{}(types)...}) + BaseException::BaseException(Types const &...types) : args({builtins::functor::str{}(types)...}) { } @@ -76,64 +75,60 @@ namespace types PYTHONIC_NS_END #include "pythonic/utils/functor.hpp" -#define PYTHONIC_EXCEPTION_IMPL(name) \ - template \ - types::name name(Types const &...args) \ - { \ - return types::name(args...); \ +#define PYTHONIC_EXCEPTION_IMPL(name) \ + template \ + types::name name(Types const &...args) \ + { \ + return types::name(args...); \ } /* pythran attribute system { */ -#define IMPL_EXCEPTION_GETATTR(name) \ - PYTHONIC_NS_BEGIN \ - namespace builtins \ - { \ - inline types::none> \ - getattr(types::attr::ARGS, types::name const &f) \ - { \ - return f.args; \ - } \ - } \ +#define IMPL_EXCEPTION_GETATTR(name) \ + PYTHONIC_NS_BEGIN \ + namespace builtins \ + { \ + inline types::none> getattr(types::attr::ARGS, \ + types::name const &f) \ + { \ + return f.args; \ + } \ + } \ PYTHONIC_NS_END -#define IMPL_EXCEPTION_GETATTR_FULL(name) \ - PYTHONIC_NS_BEGIN \ - namespace builtins \ - { \ - inline types::none> \ - getattr(types::attr::ARGS, types::name const &e) \ - { \ - if (e.args.size() > 3 || e.args.size() < 2) \ - return e.args; \ - else \ - return types::dynamic_tuple(e.args.begin(), \ - e.args.begin() + 2); \ - } \ - inline types::none getattr(types::attr::ERRNO, \ - types::name const &e) \ - { \ - if (e.args.size() > 3 || e.args.size() < 2) \ - return builtins::None; \ - else \ - return e.args[0]; \ - } \ - inline types::none getattr(types::attr::STRERROR, \ - types::name const &e) \ - { \ - if (e.args.size() > 3 || e.args.size() < 2) \ - return builtins::None; \ - else \ - return e.args[1]; \ - } \ - inline types::none getattr(types::attr::FILENAME, \ - types::name const &e) \ - { \ - if (e.args.size() != 3) \ - return builtins::None; \ - else \ - return e.args[2]; \ - } \ - } \ +#define IMPL_EXCEPTION_GETATTR_FULL(name) \ + PYTHONIC_NS_BEGIN \ + namespace builtins \ + { \ + inline types::none> getattr(types::attr::ARGS, \ + types::name const &e) \ + { \ + if (e.args.size() > 3 || e.args.size() < 2) \ + return e.args; \ + else \ + return types::dynamic_tuple(e.args.begin(), e.args.begin() + 2); \ + } \ + inline types::none getattr(types::attr::ERRNO, types::name const &e) \ + { \ + if (e.args.size() > 3 || e.args.size() < 2) \ + return builtins::None; \ + else \ + return e.args[0]; \ + } \ + inline types::none getattr(types::attr::STRERROR, types::name const &e) \ + { \ + if (e.args.size() > 3 || e.args.size() < 2) \ + return builtins::None; \ + else \ + return e.args[1]; \ + } \ + inline types::none getattr(types::attr::FILENAME, types::name const &e) \ + { \ + if (e.args.size() != 3) \ + return builtins::None; \ + else \ + return e.args[2]; \ + } \ + } \ PYTHONIC_NS_END IMPL_EXCEPTION_GETATTR(BaseException); @@ -211,8 +206,7 @@ namespace types if (e.args.size() == 2) return o << "[Errno " << e.args[0] << "] " << e.args[1]; else if (e.args.size() == 3) - return o << "[Errno " << e.args[0] << "] " << e.args[1] << ": '" - << e.args[2] << "'"; + return o << "[Errno " << e.args[0] << "] " << e.args[1] << ": '" << e.args[2] << "'"; else { // Generate "('a', 'b', 'c', 'd') if a,b,c, && d are in e.args std::string listsep = ""; diff --git a/contrib/python/pythran/pythran/pythonic/types/file.hpp b/contrib/python/pythran/pythran/pythonic/types/file.hpp index 70c9bf2954d..9a6282e0e86 100644 --- a/contrib/python/pythran/pythran/pythonic/types/file.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/file.hpp @@ -63,8 +63,7 @@ namespace types } inline file::file(types::str const &filename, types::str const &strmode) - : file_iterator(), data(utils::no_memory()), mode(strmode), - name(filename), newlines('\n') + : file_iterator(), data(utils::no_memory()), mode(strmode), name(filename), newlines('\n') { open(filename, strmode); if (mode.find_first_of("r+") != -1) @@ -267,14 +266,12 @@ namespace types // Like in : // for line in open("myfile"): // print line - inline file_iterator::file_iterator(file &ref) - : f(&ref), set(false), curr(), position(ref.tell()) + inline file_iterator::file_iterator(file &ref) : f(&ref), set(false), curr(), position(ref.tell()) { } inline file_iterator::file_iterator() - : f(nullptr), set(false), curr(), - position(std::numeric_limits::max()) {}; + : f(nullptr), set(false), curr(), position(std::numeric_limits::max()) {}; inline bool file_iterator::operator==(file_iterator const &f2) const { diff --git a/contrib/python/pythran/pythran/pythonic/types/finfo.hpp b/contrib/python/pythran/pythran/pythonic/types/finfo.hpp index 348d3299bec..c07ea4dd481 100644 --- a/contrib/python/pythran/pythran/pythonic/types/finfo.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/finfo.hpp @@ -30,8 +30,7 @@ PYTHONIC_NS_BEGIN namespace builtins { template - auto getattr(types::attr::EPS, - pythonic::types::finfo const &f) -> decltype(f.eps()) + auto getattr(types::attr::EPS, pythonic::types::finfo const &f) -> decltype(f.eps()) { return f.eps(); } diff --git a/contrib/python/pythran/pythran/pythonic/types/float.hpp b/contrib/python/pythran/pythran/pythonic/types/float.hpp index fcce9a7db25..762c7cc5585 100644 --- a/contrib/python/pythran/pythran/pythonic/types/float.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/float.hpp @@ -35,7 +35,13 @@ inline bool from_python::is_convertible(PyObject *obj) inline long double from_python::convert(PyObject *obj) { +#ifdef Py_LIMITED_API + npy_longdouble val; + PyArray_ScalarAsCtype(obj, &val); + return val; +#else return PyArrayScalar_VAL(obj, LongDouble); +#endif } inline bool from_python::is_convertible(PyObject *obj) @@ -53,7 +59,13 @@ inline bool from_python::is_convertible(PyObject *obj) } inline float from_python::convert(PyObject *obj) { +#ifdef Py_LIMITED_API + npy_float val; + PyArray_ScalarAsCtype(obj, &val); + return val; +#else return PyArrayScalar_VAL(obj, Float); +#endif } PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/generator.hpp b/contrib/python/pythran/pythran/pythonic/types/generator.hpp index 4a3ef67e749..ce9caa118ec 100644 --- a/contrib/python/pythran/pythran/pythonic/types/generator.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/generator.hpp @@ -17,8 +17,7 @@ namespace types } // this represents the end template - generator_iterator::generator_iterator(T const &a_generator) - : the_generator(a_generator) + generator_iterator::generator_iterator(T const &a_generator) : the_generator(a_generator) { } @@ -40,33 +39,24 @@ namespace types } template - bool - generator_iterator::operator!=(generator_iterator const &other) const + bool generator_iterator::operator!=(generator_iterator const &other) const { - assert(other.the_generator.__generator_state == -1 || - the_generator.__generator_state == -1); - return the_generator.__generator_state != - other.the_generator.__generator_state; + assert(other.the_generator.__generator_state == -1 || the_generator.__generator_state == -1); + return the_generator.__generator_state != other.the_generator.__generator_state; } template - bool - generator_iterator::operator==(generator_iterator const &other) const + bool generator_iterator::operator==(generator_iterator const &other) const { - assert(other.the_generator.__generator_state == -1 || - the_generator.__generator_state == -1); - return the_generator.__generator_state == - other.the_generator.__generator_state; + assert(other.the_generator.__generator_state == -1 || the_generator.__generator_state == -1); + return the_generator.__generator_state == other.the_generator.__generator_state; } template - bool - generator_iterator::operator<(generator_iterator const &other) const + bool generator_iterator::operator<(generator_iterator const &other) const { - assert(other.the_generator.__generator_state == -1 || - the_generator.__generator_state == -1); - return the_generator.__generator_state != - other.the_generator.__generator_state; + assert(other.the_generator.__generator_state == -1 || the_generator.__generator_state == -1); + return the_generator.__generator_state != other.the_generator.__generator_state; } } // namespace types PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/types/int.hpp b/contrib/python/pythran/pythran/pythonic/types/int.hpp index d7fdaa27eb9..44da0ada1c4 100644 --- a/contrib/python/pythran/pythran/pythonic/types/int.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/int.hpp @@ -9,14 +9,12 @@ PYTHONIC_NS_BEGIN namespace builtins { template - typename std::enable_if::value, T>::type - getattr(types::attr::REAL, T self) + std::enable_if_t::value, T> getattr(types::attr::REAL, T self) { return self; } template - typename std::enable_if::value, T>::type - getattr(types::attr::IMAG, T self) + std::enable_if_t::value, T> getattr(types::attr::IMAG, T self) { return T(0); } @@ -31,13 +29,11 @@ PYTHONIC_NS_END PYTHONIC_NS_BEGIN template -struct c_type_to_numpy_type - : c_type_to_numpy_type()())> { +struct c_type_to_numpy_type : c_type_to_numpy_type()())> { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> @@ -49,13 +45,11 @@ struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type> - : std::integral_constant { +struct c_type_to_numpy_type> : std::integral_constant { }; template <> -struct c_type_to_numpy_type> - : std::integral_constant { +struct c_type_to_numpy_type> : std::integral_constant { }; template <> @@ -64,23 +58,19 @@ struct c_type_to_numpy_type> }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> @@ -88,18 +78,15 @@ struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> @@ -107,13 +94,11 @@ struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> -struct c_type_to_numpy_type - : std::integral_constant { +struct c_type_to_numpy_type : std::integral_constant { }; template <> @@ -131,12 +116,10 @@ struct c_type_to_numpy_type : std::integral_constant { #endif #endif -#define PYTHONIC_INT_TO_PYTHON(TYPE) \ - inline PyObject *to_python::convert(TYPE l) \ - { \ - return PyArray_Scalar( \ - &l, PyArray_DescrFromType(c_type_to_numpy_type::value), \ - nullptr); \ +#define PYTHONIC_INT_TO_PYTHON(TYPE) \ + inline PyObject *to_python::convert(TYPE l) \ + { \ + return PyArray_Scalar(&l, PyArray_DescrFromType(c_type_to_numpy_type::value), nullptr); \ } PYTHONIC_INT_TO_PYTHON(char) @@ -156,15 +139,14 @@ PYTHONIC_INT_TO_PYTHON(signed long long) #undef PYTHONIC_INT_TO_PYTHON -#define PYTHONIC_INT_FROM_PYTHON(TYPE, NTYPE) \ - inline bool from_python::is_convertible(PyObject *obj) \ - { \ - return PyInt_CheckExact(obj) || \ - PyObject_TypeCheck(obj, &Py##NTYPE##ArrType_Type); \ - } \ - inline TYPE from_python::convert(PyObject *obj) \ - { \ - return PyInt_AsLong(obj); \ +#define PYTHONIC_INT_FROM_PYTHON(TYPE, NTYPE) \ + inline bool from_python::is_convertible(PyObject *obj) \ + { \ + return PyInt_CheckExact(obj) || PyObject_TypeCheck(obj, &Py##NTYPE##ArrType_Type); \ + } \ + inline TYPE from_python::convert(PyObject *obj) \ + { \ + return PyInt_AsLong(obj); \ } PYTHONIC_INT_FROM_PYTHON(unsigned char, UByte) diff --git a/contrib/python/pythran/pythran/pythonic/types/list.hpp b/contrib/python/pythran/pythran/pythonic/types/list.hpp index 076b5e701de..9f4b3d4ea48 100644 --- a/contrib/python/pythran/pythran/pythonic/types/list.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/list.hpp @@ -28,8 +28,7 @@ namespace types { } template - sliced_list::sliced_list(sliced_list const &s) - : _data(s._data), slicing(s.slicing) + sliced_list::sliced_list(sliced_list const &s) : _data(s._data), slicing(s.slicing) { } template @@ -39,8 +38,7 @@ namespace types } template template - sliced_list::sliced_list(utils::shared_ref const &other, - Sn const &s) + sliced_list::sliced_list(utils::shared_ref const &other, Sn const &s) : _data(other), slicing(s) { } @@ -81,8 +79,7 @@ namespace types // accessor template - typename sliced_list::const_reference - sliced_list::fast(long i) const + typename sliced_list::const_reference sliced_list::fast(long i) const { assert(0 <= i && i < size()); auto const index = slicing.get(i); @@ -90,8 +87,7 @@ namespace types return (*_data)[index]; } template - typename sliced_list::const_reference - sliced_list::operator[](long i) const + typename sliced_list::const_reference sliced_list::operator[](long i) const { assert(i < size()); auto const index = slicing.get(i); @@ -109,9 +105,8 @@ namespace types template template - typename std::enable_if< - is_slice::value, - sliced_list() * std::declval())>>::type + std::enable_if_t::value, + sliced_list() * std::declval())>> sliced_list::operator[](Sp s) const { return {_data, slicing * s.normalize(this->size())}; @@ -148,13 +143,20 @@ namespace types return size() == 0; } template - inline sliced_list & - sliced_list::operator=(sliced_list const &s) + inline sliced_list &sliced_list::operator=(sliced_list const &s) { if (slicing.step == 1) { - // inserting before erasing in case of self-copy - auto insert_pt = _data->begin() + slicing.lower; - _data->insert(insert_pt, s.begin(), s.end()); + // no sharing + if (_data->data() != s._data->data()) { + auto insert_pt = _data->begin() + slicing.lower; + _data->insert(insert_pt, s.begin(), s.end()); + } + // sharing + else { + std::vector tmp{s.begin(), s.end()}; + auto insert_pt = _data->begin() + slicing.lower; + _data->insert(insert_pt, tmp.begin(), tmp.end()); + } auto erase_pt = _data->begin() + s.size(); _data->erase(erase_pt + slicing.lower, erase_pt + slicing.upper); } else @@ -165,9 +167,17 @@ namespace types sliced_list &sliced_list::operator=(list const &seq) { if (slicing.step == 1) { - // inserting before erasing in case of self-copy - auto insert_pt = _data->begin() + slicing.lower; - _data->insert(insert_pt, seq.begin(), seq.end()); + // no sharing + if (_data->data() != seq._data->data()) { + auto insert_pt = _data->begin() + slicing.lower; + _data->insert(insert_pt, seq.begin(), seq.end()); + } + // sharing + else { + std::vector tmp{seq.begin(), seq.end()}; + auto insert_pt = _data->begin() + slicing.lower; + _data->insert(insert_pt, tmp.begin(), tmp.end()); + } auto erase_pt = _data->begin() + seq.size(); _data->erase(erase_pt + slicing.lower, erase_pt + slicing.upper); } else @@ -206,21 +216,18 @@ namespace types #ifdef USE_XSIMD template template - typename sliced_list::simd_iterator - sliced_list::vbegin(vectorizer) const + typename sliced_list::simd_iterator sliced_list::vbegin(vectorizer) const { return {_data->data() + slicing.lower}; } template template - typename sliced_list::simd_iterator - sliced_list::vend(vectorizer) const + typename sliced_list::simd_iterator sliced_list::vend(vectorizer) const { using vector_type = typename xsimd::batch; static const std::size_t vector_size = vector_type::size; - return {_data->data() + slicing.lower + - long(size() / vector_size * vector_size)}; + return {_data->data() + slicing.lower + long(size() / vector_size * vector_size)}; } #endif @@ -256,9 +263,8 @@ namespace types template list::list(InputIterator start, InputIterator stop) : _data() { - if (std::is_same< - typename std::iterator_traits::iterator_category, - std::random_access_iterator_tag>::value) + if (std::is_same::iterator_category, + std::random_access_iterator_tag>::value) _data->reserve(std::distance(start, stop)); else _data->reserve(DEFAULT_CAPACITY); @@ -292,8 +298,7 @@ namespace types } template template - list::list(sliced_list const &other) - : _data(other.begin(), other.end()) + list::list(sliced_list const &other) : _data(other.begin(), other.end()) { } @@ -458,14 +463,12 @@ namespace types template bool list::operator<(list const &other) const { - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end()); } template bool list::operator>(list const &other) const { - return std::lexicographical_compare(other.begin(), other.end(), begin(), - end()); + return std::lexicographical_compare(other.begin(), other.end(), begin(), end()); } template bool list::operator<=(list const &other) const @@ -527,8 +530,7 @@ namespace types template template - typename std::enable_if::value, sliced_list>::type - list::operator[](Sp const &s) const + std::enable_if_t::value, sliced_list> list::operator[](Sp const &s) const { return {*this, s}; } @@ -607,8 +609,7 @@ namespace types template template - list::type> - list::operator+(list const &s) const + list::type> list::operator+(list const &s) const { list::type> clone(size() + s.size()); std::copy(s.begin(), s.end(), std::copy(begin(), end(), clone.begin())); @@ -617,12 +618,10 @@ namespace types template template - list() + - std::declval::value_type>())> + list() + std::declval::value_type>())> list::operator+(sliced_list const &s) const { - list() + - std::declval::value_type>())> + list() + std::declval::value_type>())> clone(size() + len(s)); std::copy(s.begin(), s.end(), std::copy(begin(), end(), clone.begin())); return clone; @@ -690,8 +689,7 @@ namespace types template long list::_flat_size(E const &e, utils::int_) const { - return std::distance(e.begin(), e.end()) * - _flat_size(e[0], utils::int_{}); + return std::distance(e.begin(), e.end()) * _flat_size(e[0], utils::int_{}); } template long list::flat_size() const @@ -738,8 +736,7 @@ namespace types return empty_list(); } template - typename std::enable_if::value, - list>::type + std::enable_if_t::value, list> empty_list::operator+(F s) const { return {s.begin(), s.end()}; @@ -770,8 +767,7 @@ namespace utils { template - void reserve(types::list &l, From const &f, - typename From::const_iterator *) + void reserve(types::list &l, From const &f, typename From::const_iterator *) { l.reserve(builtins::len(f)); } @@ -788,22 +784,19 @@ namespace std } template - typename pythonic::types::list::const_reference - get(pythonic::types::list const &t) + typename pythonic::types::list::const_reference get(pythonic::types::list const &t) { return t[I]; } template - typename pythonic::types::list::value_type - get(pythonic::types::list &&t) + typename pythonic::types::list::value_type get(pythonic::types::list &&t) { return std::move(t)[I]; } template - typename pythonic::types::sliced_list::reference - get(pythonic::types::sliced_list &t) + typename pythonic::types::sliced_list::reference get(pythonic::types::sliced_list &t) { return t[I]; } @@ -827,15 +820,19 @@ namespace std PYTHONIC_NS_BEGIN +#ifdef Py_LIMITED_API +#define PyList_SET_ITEM PyList_SetItem +#endif + inline PyObject *to_python::reference>::convert( typename std::vector::reference const &v) { return ::to_python((bool)v); } -inline PyObject *to_python::const_reference>::value, - phantom_type, typename std::vector::const_reference>::type>:: +inline PyObject * +to_python::const_reference>::value, + phantom_type, typename std::vector::const_reference>>:: convert(typename std::vector::const_reference const &v) { return ::to_python((bool)v); @@ -851,8 +848,7 @@ PyObject *to_python>::convert(types::list const &v) return ret; } template -PyObject * -to_python>::convert(types::sliced_list const &v) +PyObject *to_python>::convert(types::sliced_list const &v) { Py_ssize_t n = v.size(); PyObject *ret = PyList_New(n); @@ -861,8 +857,7 @@ to_python>::convert(types::sliced_list const &v) return ret; } -inline PyObject * -to_python::convert(types::empty_list const &) +inline PyObject *to_python::convert(types::empty_list const &) { return PyList_New(0); } @@ -870,23 +865,48 @@ to_python::convert(types::empty_list const &) template bool from_python>::is_convertible(PyObject *obj) { - return PyList_Check(obj) && - (PyObject_Not(obj) || - ::is_convertible(PySequence_Fast_GET_ITEM(obj, 0))); + if (!PyList_Check(obj)) + return false; + if (PyObject_Not(obj)) + return true; +#ifdef Py_LIMITED_API + PyObject *Item = PySequence_GetItem(obj, 0); + bool result = ::is_convertible(Item); + Py_DECREF(Item); + return result; +#else + return ::is_convertible(PySequence_Fast_GET_ITEM(obj, 0)); +#endif } template types::list from_python>::convert(PyObject *obj) { +#ifdef Py_LIMITED_API + Py_ssize_t l = PySequence_Size(obj); +#else Py_ssize_t l = PySequence_Fast_GET_SIZE(obj); +#endif types::list v(l); +#ifdef Py_LIMITED_API + for (Py_ssize_t i = 0; i < l; ++i) { + PyObject *item = PySequence_GetItem(obj, i); + v.fast(i) = ::from_python(item); + Py_DECREF(item); + } +#else PyObject **core = PySequence_Fast_ITEMS(obj); - std::transform(core, core + l, v.begin(), - [](PyObject *o) { return ::from_python(o); }); + std::transform(core, core + l, v.begin(), [](PyObject *o) { return ::from_python(o); }); +#endif return v; } + +#ifdef Py_LIMITED_API +#undef PyList_SET_ITEM +#endif + PYTHONIC_NS_END #endif diff --git a/contrib/python/pythran/pythran/pythonic/types/ndarray.hpp b/contrib/python/pythran/pythran/pythonic/types/ndarray.hpp index d3fecbed70d..77e9287bb7d 100644 --- a/contrib/python/pythran/pythran/pythonic/types/ndarray.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/ndarray.hpp @@ -73,8 +73,8 @@ PYTHONIC_NS_BEGIN namespace types { template - array_tuple::value> - make_strides(pS const &shape, utils::index_sequence) + array_tuple::value> make_strides(pS const &shape, + std::index_sequence) { array_tuple::value> out; out[std::tuple_size::value - 1] = 1; @@ -88,8 +88,7 @@ namespace types template array_tuple::value> make_strides(pS const &shape) { - return make_strides( - shape, utils::make_index_sequence::value - 1>()); + return make_strides(shape, std::make_index_sequence::value - 1>()); } template @@ -108,16 +107,14 @@ namespace types template template - T *type_helper>::initialize_from_iterable(S &shape, T *from, - Iter &&iter) + T *type_helper>::initialize_from_iterable(S &shape, T *from, Iter &&iter) { - return type_helper const &>::initialize_from_iterable( - shape, from, std::forward(iter)); + return type_helper const &>::initialize_from_iterable(shape, from, + std::forward(iter)); } template - numpy_iexpr> - type_helper>::get(ndarray &&self, long i) + numpy_iexpr> type_helper>::get(ndarray &&self, long i) { return {std::move(self), i}; } @@ -131,24 +128,20 @@ namespace types template typename type_helper const &>::const_iterator - type_helper const &>::make_iterator(ndarray const &n, - long i) + type_helper const &>::make_iterator(ndarray const &n, long i) { return {n, i}; } template template - T *type_helper const &>::initialize_from_iterable(S &shape, - T *from, - Iter &&iter) + T *type_helper const &>::initialize_from_iterable(S &shape, T *from, Iter &&iter) { - sutils::assign( - std::get::value - std::tuple_size::value>(shape), - iter.size()); + sutils::assign(std::get::value - std::tuple_size::value>(shape), + iter.size()); for (auto content : iter) - from = type_helper> const - &>::initialize_from_iterable(shape, from, content); + from = type_helper> const &>::initialize_from_iterable( + shape, from, content); return from; } @@ -161,25 +154,21 @@ namespace types template typename type_helper>>::iterator - type_helper>>::make_iterator(ndarray> &n, - long i) + type_helper>>::make_iterator(ndarray> &n, long i) { return n.buffer + i; } template typename type_helper>>::const_iterator - type_helper>>::make_iterator( - ndarray> const &n, long i) + type_helper>>::make_iterator(ndarray> const &n, long i) { return n.buffer + i; } template template - T *type_helper>>::initialize_from_iterable(S &shape, - T *from, - Iter &&iter) + T *type_helper>>::initialize_from_iterable(S &shape, T *from, Iter &&iter) { sutils::assign(std::get::value - 1>(shape), iter.size()); return std::copy(iter.begin(), iter.end(), from); @@ -187,16 +176,14 @@ namespace types template typename type_helper>>::type - type_helper>>::get(ndarray> &&self, - long i) + type_helper>>::get(ndarray> &&self, long i) { return self.buffer[i]; } template typename type_helper> const &>::iterator - type_helper> const &>::make_iterator( - ndarray> &n, long i) + type_helper> const &>::make_iterator(ndarray> &n, long i) { return n.buffer + i; } @@ -210,8 +197,8 @@ namespace types template template - T *type_helper> const &>::initialize_from_iterable( - S &shape, T *from, Iter &&iter) + T *type_helper> const &>::initialize_from_iterable(S &shape, T *from, + Iter &&iter) { sutils::assign(std::get::value - 1>(shape), iter.size()); return std::copy(iter.begin(), iter.end(), from); @@ -219,16 +206,15 @@ namespace types template typename type_helper> const &>::type & - type_helper> const &>::get( - ndarray> const &self, long i) + type_helper> const &>::get(ndarray> const &self, long i) { return self.buffer[i]; } template typename type_helper>>::iterator - type_helper>>::make_iterator( - ndarray> &n, long i) + type_helper>>::make_iterator(ndarray> &n, + long i) { return n.buffer + i; } @@ -243,8 +229,8 @@ namespace types template template - T *type_helper>>::initialize_from_iterable( - S &shape, T *from, Iter &&iter) + T *type_helper>>::initialize_from_iterable(S &shape, T *from, + Iter &&iter) { sutils::assign(std::get::value - 1>(shape), iter.size()); return std::copy(iter.begin(), iter.end(), from); @@ -252,8 +238,7 @@ namespace types template typename type_helper>>::type - type_helper>>::get( - ndarray> &&self, long i) + type_helper>>::get(ndarray> &&self, long i) { return self.buffer[i]; } @@ -275,8 +260,9 @@ namespace types template template - T *type_helper> const &>:: - initialize_from_iterable(S &shape, T *from, Iter &&iter) + T *type_helper> const &>::initialize_from_iterable(S &shape, + T *from, + Iter &&iter) { sutils::assign(std::get::value - 1>(shape), iter.size()); return std::copy(iter.begin(), iter.end(), from); @@ -302,12 +288,9 @@ namespace types template template - long noffset::operator()(S const &strides, - array_tuple const &indices) const + long noffset::operator()(S const &strides, array_tuple const &indices) const { - auto index = patch_index( - indices[M - L], - typename std::tuple_element::type()); + auto index = patch_index(indices[M - L], std::tuple_element_t()); auto offset = noffset{}(strides, indices); auto stride = strides.template strides(); return offset + stride * index; @@ -315,13 +298,10 @@ namespace types template template - long noffset::operator()(S const &strides, - array_tuple const &indices, + long noffset::operator()(S const &strides, array_tuple const &indices, pS const &shape) const { - auto index = patch_index( - indices[M - L], - typename std::tuple_element::type()); + auto index = patch_index(indices[M - L], std::tuple_element_t()); if (index < 0) index += std::get(shape); assert(0 <= index and index < std::get(shape)); @@ -332,24 +312,18 @@ namespace types template <> template - long noffset<1>::operator()(S const &strides, - array_tuple const &indices) const + long noffset<1>::operator()(S const &strides, array_tuple const &indices) const { - auto index = patch_index( - indices[M - 1], - typename std::tuple_element::type()); + auto index = patch_index(indices[M - 1], std::tuple_element_t()); return strides.template strides() * index; } template <> template - long noffset<1>::operator()(S const &strides, - array_tuple const &indices, + long noffset<1>::operator()(S const &strides, array_tuple const &indices, pS const &shape) const { - auto index = patch_index( - indices[M - 1], - typename std::tuple_element::type()); + auto index = patch_index(indices[M - 1], std::tuple_element_t()); if (index < 0) index += std::get(shape); assert(0 <= index && index < std::get(shape)); @@ -359,24 +333,19 @@ namespace types /* constructors */ template - ndarray::ndarray() - : mem(utils::no_memory()), buffer(nullptr), _shape(), _strides() + ndarray::ndarray() : mem(utils::no_memory()), buffer(nullptr), _shape(), _strides() { } /* from other memory */ template - ndarray::ndarray(utils::shared_ref> const &mem, - pS const &shape) - : mem(mem), buffer(mem->data), _shape(shape), - _strides(make_strides(shape)) + ndarray::ndarray(utils::shared_ref> const &mem, pS const &shape) + : mem(mem), buffer(mem->data), _shape(shape), _strides(make_strides(shape)) { } template - ndarray::ndarray(utils::shared_ref> &&mem, - pS const &shape) - : mem(std::move(mem)), buffer(this->mem->data), _shape(shape), - _strides(make_strides(shape)) + ndarray::ndarray(utils::shared_ref> &&mem, pS const &shape) + : mem(std::move(mem)), buffer(this->mem->data), _shape(shape), _strides(make_strides(shape)) { } @@ -384,29 +353,24 @@ namespace types template template ndarray::ndarray(ndarray const &other) - : mem(other.flat_size()), buffer(mem->data), _shape(other._shape), - _strides(other._strides) + : mem(other.flat_size()), buffer(mem->data), _shape(other._shape), _strides(other._strides) { - static_assert(std::tuple_size::value == std::tuple_size::value, - "compatible shapes"); + static_assert(std::tuple_size::value == std::tuple_size::value, "compatible shapes"); std::copy(other.fbegin(), other.fend(), fbegin()); } template template ndarray::ndarray(ndarray const &other) - : mem(other.mem), buffer(mem->data), _shape(other._shape), - _strides(other._strides) + : mem(other.mem), buffer(mem->data), _shape(other._shape), _strides(other._strides) { - static_assert(std::tuple_size::value == std::tuple_size::value, - "compatible shapes"); + static_assert(std::tuple_size::value == std::tuple_size::value, "compatible shapes"); } /* from a seed */ template ndarray::ndarray(pS const &shape, none_type init) - : mem(sutils::sprod(shape)), buffer(mem->data), _shape(shape), - _strides(make_strides(shape)) + : mem(sutils::sprod(shape)), buffer(mem->data), _shape(shape), _strides(make_strides(shape)) { } @@ -453,12 +417,11 @@ namespace types template template ndarray::ndarray(Iterable &&iterable) - : mem(utils::nested_container_size::flat_size( - std::forward(iterable))), + : mem(utils::nested_container_size::flat_size(std::forward(iterable))), buffer(mem->data), _shape() { - type_helper::initialize_from_iterable( - _shape, mem->data, std::forward(iterable)); + type_helper::initialize_from_iterable(_shape, mem->data, + std::forward(iterable)); _strides = make_strides(_shape); } @@ -470,15 +433,14 @@ namespace types assert(buffer); utils::broadcast_copy::value>( - *this, expr); + std::is_same::value>(*this, expr); } template template ndarray::ndarray(numpy_expr const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -486,8 +448,8 @@ namespace types template template ndarray::ndarray(numpy_texpr const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -495,8 +457,8 @@ namespace types template template ndarray::ndarray(numpy_texpr_2 const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -504,8 +466,8 @@ namespace types template template ndarray::ndarray(numpy_gexpr const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -513,8 +475,8 @@ namespace types template template ndarray::ndarray(numpy_iexpr const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -522,8 +484,8 @@ namespace types template template ndarray::ndarray(numpy_vexpr const &expr) - : mem(expr.flat_size()), buffer(mem->data), - _shape(sutils::getshape(expr)), _strides(make_strides(_shape)) + : mem(expr.flat_size()), buffer(mem->data), _shape(sutils::getshape(expr)), + _strides(make_strides(_shape)) { initialize_from_expr(expr); } @@ -534,18 +496,14 @@ namespace types template ndarray &ndarray::update_(Expr const &expr) { - using BExpr = - typename std::conditional::value, - broadcast, Expr const &>::type; + using BExpr = std::conditional_t::value, broadcast, Expr const &>; BExpr bexpr = expr; utils::broadcast_update< Op, ndarray &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && - types::is_vectorizable::type>::type>::value && - std::is_same::type>::type>::value>(*this, bexpr); + types::is_vectorizable>>::value && + std::is_same>::type>::value>(*this, bexpr); return *this; } @@ -604,7 +562,7 @@ namespace types template template - typename std::enable_if::value, T &>::type + std::enable_if_t::value, T &> ndarray::fast(array_tuple const &indices) { assert(inbound_indices(indices)); @@ -613,7 +571,7 @@ namespace types template template - typename std::enable_if::value, T>::type + std::enable_if_t::value, T> ndarray::fast(array_tuple const &indices) const { assert(inbound_indices(indices)); @@ -622,57 +580,48 @@ namespace types template template - auto ndarray::fast(array_tuple const &indices) const & -> - typename std::enable_if::value, - decltype(nget().fast(*this, - indices))>::type + auto ndarray::fast(array_tuple const &indices) const & -> std::enable_if_t< + std::is_integral::value, decltype(nget().fast(*this, indices))> { return nget().fast(*this, indices); } template template - auto ndarray::fast(array_tuple const &indices) && -> - typename std::enable_if::value, - decltype(nget().fast(std::move(*this), - indices))>::type + auto ndarray::fast(array_tuple const &indices) && -> std::enable_if_t< + std::is_integral::value, decltype(nget().fast(std::move(*this), indices))> { return nget().fast(std::move(*this), indices); } template template - typename std::enable_if::value, T const &>::type + std::enable_if_t::value, T const &> ndarray::operator[](array_tuple const &indices) const { - return *(buffer + - noffset::value>{}(*this, indices, _shape)); + return *(buffer + noffset::value>{}(*this, indices, _shape)); } template template - typename std::enable_if::value, T &>::type + std::enable_if_t::value, T &> ndarray::operator[](array_tuple const &indices) { - return *(buffer + - noffset::value>{}(*this, indices, _shape)); + return *(buffer + noffset::value>{}(*this, indices, _shape)); } template template - auto ndarray::operator[](array_tuple const &indices) const & -> - typename std::enable_if::value, - decltype(nget()(*this, indices))>::type + auto ndarray::operator[](array_tuple const &indices) const + & -> std::enable_if_t::value, decltype(nget()(*this, indices))> { return nget()(*this, indices); } template template - auto ndarray::operator[](array_tuple const &indices) && -> - typename std::enable_if::value, - decltype(nget()(std::move(*this), - indices))>::type + auto ndarray::operator[](array_tuple const &indices) && -> std::enable_if_t< + std::is_integral::value, decltype(nget()(std::move(*this), indices))> { return nget()(std::move(*this), indices); } @@ -680,8 +629,7 @@ namespace types #ifdef USE_XSIMD template template - typename ndarray::simd_iterator - ndarray::vbegin(vectorizer) const + typename ndarray::simd_iterator ndarray::vbegin(vectorizer) const { return {buffer}; } @@ -703,17 +651,14 @@ namespace types ndarray::operator[](none_type) const { sutils::push_front_t> new_shape; - sutils::copy_shape<1, -1>( - new_shape, *this, - utils::make_index_sequence::value>()); + sutils::copy_shape<1, -1>(new_shape, *this, + std::make_index_sequence::value>()); return reshape(new_shape); } template template - typename std::enable_if< - is_slice::value, - numpy_gexpr const &, normalize_t>>::type + std::enable_if_t::value, numpy_gexpr const &, normalize_t>> ndarray::operator[](S const &s) const & { return make_gexpr(*this, s); @@ -721,8 +666,7 @@ namespace types template template - typename std::enable_if::value, - numpy_gexpr, normalize_t>>::type + std::enable_if_t::value, numpy_gexpr, normalize_t>> ndarray::operator[](S const &s) && { return make_gexpr(std::move(*this), s); @@ -737,9 +681,8 @@ namespace types /* extended slice indexing */ template template - auto ndarray::operator()(S0 const &s0, S const &...s) const - & -> decltype(extended_slice::value>{}((*this), - s0, s...)) + auto ndarray::operator()(S0 const &s0, S const &...s) + const & -> decltype(extended_slice::value>{}((*this), s0, s...)) { return extended_slice::value>{}((*this), s0, s...); } @@ -747,8 +690,7 @@ namespace types template template auto ndarray::operator()(S0 const &s0, S const &...s) - & -> decltype(extended_slice::value>{}((*this), - s0, s...)) + & -> decltype(extended_slice::value>{}((*this), s0, s...)) { return extended_slice::value>{}((*this), s0, s...); } @@ -756,21 +698,17 @@ namespace types template template auto ndarray::operator()(S0 const &s0, S const &...s) - && -> decltype(extended_slice::value>{}( - std::move(*this), s0, s...)) + && -> decltype(extended_slice::value>{}(std::move(*this), s0, s...)) { - return extended_slice::value>{}(std::move(*this), - s0, s...); + return extended_slice::value>{}(std::move(*this), s0, s...); } /* element filtering */ template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr, ndarray>>> ndarray::fast(F const &filter) const { long sz = filter.template shape<0>(); @@ -780,41 +718,33 @@ namespace types if (filter.fast(i)) raw[n++] = i; // reallocate(raw, n); - return this->fast(ndarray>(raw, pshape(n), - types::ownership::owned)); + return this->fast(ndarray>(raw, pshape(n), types::ownership::owned)); } template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr, ndarray>>> ndarray::operator[](F const &filter) const { return fast(filter); } template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value != 1 && - !is_pod_array::value, - numpy_vexpr>, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> ndarray::fast(F const &filter) const { - return flat()[ndarray(filter) - .flat()]; + return flat()[ndarray(filter).flat()]; } template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value != 1 && - !is_pod_array::value, - numpy_vexpr>, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr>, ndarray>>> ndarray::operator[](F const &filter) const { return fast(filter); @@ -822,11 +752,9 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, F>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, F>> ndarray::operator[](F const &filter) const { return {*this, filter}; @@ -834,11 +762,9 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, F>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, F>> ndarray::fast(F const &filter) const { return {*this, filter}; @@ -846,14 +772,12 @@ namespace types template template - auto ndarray::operator[]( - std::tuple const &indices) const -> - typename std::enable_if< - is_numexpr_arg::value, - decltype(this->_fwdindex( - indices, utils::make_index_sequence<2 + sizeof...(Tys)>()))>::type + auto ndarray::operator[](std::tuple const &indices) const + -> std::enable_if_t::value, + decltype(this->_fwdindex(indices, + std::make_index_sequence<2 + sizeof...(Tys)>()))> { - return _fwdindex(indices, utils::make_index_sequence<2 + sizeof...(Tys)>()); + return _fwdindex(indices, std::make_index_sequence<2 + sizeof...(Tys)>()); } /* through iterators */ @@ -997,12 +921,11 @@ namespace types { std::array::value> strides; auto shape = sutils::getshape(e); - strides[std::tuple_size::value - 1] = - std::get::value - 1>(shape); + strides[std::tuple_size::value - 1] = std::get::value - 1>(shape); if (strides[std::tuple_size::value - 1] == 0) return os << "[]"; - std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin() + 1, - strides.rbegin() + 1, std::multiplies()); + std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin() + 1, strides.rbegin() + 1, + std::multiplies()); size_t depth = std::tuple_size::value; int step = -1; size_t size = impl::get_spacing(e); @@ -1015,16 +938,14 @@ namespace types if (depth == 1) { os.width(size); os << *iter++; - for (int i = 1; i < std::get::value - 1>(shape); - i++) { + for (int i = 1; i < std::get::value - 1>(shape); i++) { os.width(size + 1); os << *iter++; } step = 1; depth++; - max_modulo = std::lower_bound( - strides.begin(), strides.end(), iter - e.buffer, - [](int comp, int val) { return val % comp != 0; }) - + max_modulo = std::lower_bound(strides.begin(), strides.end(), iter - e.buffer, + [](int comp, int val) { return val % comp != 0; }) - strides.begin(); } else if (max_modulo + depth == std::tuple_size::value + 1) { depth--; @@ -1048,8 +969,7 @@ namespace types } template - typename std::enable_if::value, std::ostream &>::type - operator<<(std::ostream &os, E const &e) + std::enable_if_t::value, std::ostream &> operator<<(std::ostream &os, E const &e) { return os << ndarray{e}; } @@ -1070,11 +990,9 @@ namespace std { template - auto get(E &&a) -> - typename std::enable_if< - pythonic::types::is_array::type>::type>::value, - decltype(std::forward(a)[I])>::type + auto get(E &&a) -> std::enable_if_t< + pythonic::types::is_array>>::value, + decltype(std::forward(a)[I])> { return std::forward(a)[I]; } @@ -1090,16 +1008,13 @@ namespace builtins template template auto _build_gexpr::operator()(E const &a, S const &...slices) - -> decltype(_build_gexpr{}(a, types::cstride_slice<1>(), - slices...)) + -> decltype(_build_gexpr{}(a, types::cstride_slice<1>(), slices...)) { - return _build_gexpr{}(a, types::cstride_slice<1>(0, a.size()), - slices...); + return _build_gexpr{}(a, types::cstride_slice<1>(0, a.size()), slices...); } template - auto _build_gexpr<1>::operator()(E const &a, S const &...slices) - -> decltype(E(a)(slices...)) + auto _build_gexpr<1>::operator()(E const &a, S const &...slices) -> decltype(E(a)(slices...)) { return E(a)(slices...); } @@ -1111,128 +1026,113 @@ namespace builtins } template - auto _make_real(E const &a, utils::int_<1>) - -> decltype(_build_gexpr{}( - types::ndarray::type, - types::array_tuple>{}, - types::slice())) + auto _make_real(E const &a, utils::int_<1>) -> decltype(_build_gexpr{}( + types::ndarray::type, + types::array_tuple>{}, + types::slice())) { using stype = typename types::is_complex::type; auto new_shape = sutils::getshape(a); std::get(new_shape) *= 2; // this is tricky and dangerous! auto translated_mem = - reinterpret_cast> const &>( - a.mem); - types::ndarray> translated{ - translated_mem, new_shape}; - return _build_gexpr{}( - translated, types::slice{0, std::get(new_shape), 2}); + reinterpret_cast> const &>(a.mem); + types::ndarray> translated{translated_mem, + new_shape}; + return _build_gexpr{}(translated, + types::slice{0, std::get(new_shape), 2}); } template auto _make_real(types::numpy_expr const &a, utils::int_<1>) - -> decltype(_make_real( - types::ndarray::dtype, - typename types::numpy_expr::shape_t>(a), - utils::int_<1>{})) + -> decltype(_make_real(types::ndarray::dtype, + typename types::numpy_expr::shape_t>(a), + utils::int_<1>{})) { - return _make_real( - types::ndarray::dtype, - typename types::numpy_expr::shape_t>(a), - utils::int_<1>{}); + return _make_real(types::ndarray::dtype, + typename types::numpy_expr::shape_t>(a), + utils::int_<1>{}); } template auto _make_real(types::numpy_iexpr const &a, utils::int_<1>) -> decltype(_build_gexpr::value>{}( std::declval::dtype>::type, + typename types::is_complex::dtype>::type, types::array_tuple::value + 1>>>(), long(), types::slice())) { constexpr size_t value = types::numpy_iexpr::value; - using stype = typename types::is_complex< - typename types::numpy_iexpr::dtype>::type; + using stype = typename types::is_complex::dtype>::type; auto new_shape = sutils::getshape(a.arg); std::get(new_shape) *= 2; // this is tricky and dangerous! auto translated_mem = - reinterpret_cast> const &>( - a.arg.mem); - types::ndarray> translated{ - translated_mem, new_shape}; + reinterpret_cast> const &>(a.arg.mem); + types::ndarray> translated{translated_mem, + new_shape}; long offset = (a.buffer - a.arg.buffer) / a.arg.template strides<0>(); - return _build_gexpr{}( - translated, offset, types::slice{0, std::get(new_shape), 2}); + return _build_gexpr{}(translated, offset, + types::slice{0, std::get(new_shape), 2}); } template - types::ndarray - _make_imag(E const &a, utils::int_<0>) + types::ndarray _make_imag(E const &a, utils::int_<0>) { // cannot use numpy.zero: forward declaration issue - return {utils::callocate(a.flat_size()), - sutils::getshape(a), types::ownership::owned}; + return {utils::callocate(a.flat_size()), sutils::getshape(a), + types::ownership::owned}; } template auto _make_imag(types::numpy_expr const &a, utils::int_<1>) - -> decltype(_make_imag( - types::ndarray::dtype, - typename types::numpy_expr::shape_t>(a), - utils::int_<1>{})) + -> decltype(_make_imag(types::ndarray::dtype, + typename types::numpy_expr::shape_t>(a), + utils::int_<1>{})) { - return _make_imag( - types::ndarray::dtype, - typename types::numpy_expr::shape_t>(a), - utils::int_<1>{}); + return _make_imag(types::ndarray::dtype, + typename types::numpy_expr::shape_t>(a), + utils::int_<1>{}); } template auto _make_imag(types::numpy_iexpr const &a, utils::int_<1>) -> decltype(_build_gexpr::value>{}( std::declval::dtype>::type, + typename types::is_complex::dtype>::type, types::array_tuple::value + 1>>>(), long(), types::slice())) { constexpr size_t value = types::numpy_iexpr::value; - using stype = typename types::is_complex< - typename types::numpy_iexpr::dtype>::type; + using stype = typename types::is_complex::dtype>::type; auto new_shape = sutils::getshape(a.arg); std::get::value>(new_shape) *= 2; // this is tricky and dangerous! auto translated_mem = - reinterpret_cast> const &>( - a.arg.mem); - types::ndarray> translated{ - translated_mem, new_shape}; + reinterpret_cast> const &>(a.arg.mem); + types::ndarray> translated{translated_mem, + new_shape}; long offset = (a.buffer - a.arg.buffer) / a.arg.template strides<0>(); - return _build_gexpr{}( - translated, offset, types::slice{1, std::get(new_shape), 2}); + return _build_gexpr{}(translated, offset, + types::slice{1, std::get(new_shape), 2}); } template - auto _make_imag(E const &a, utils::int_<1>) - -> decltype(_build_gexpr{}( - types::ndarray::type, - types::array_tuple>{}, - types::slice())) + auto _make_imag(E const &a, utils::int_<1>) -> decltype(_build_gexpr{}( + types::ndarray::type, + types::array_tuple>{}, + types::slice())) { using stype = typename types::is_complex::type; auto new_shape = sutils::getshape(a); std::get(new_shape) *= 2; // this is tricky and dangerous! auto translated_mem = - reinterpret_cast> const &>( - a.mem); - types::ndarray> translated{ - translated_mem, new_shape}; - return _build_gexpr{}( - translated, types::slice{1, std::get(new_shape), 2}); + reinterpret_cast> const &>(a.mem); + types::ndarray> translated{translated_mem, + new_shape}; + return _build_gexpr{}(translated, + types::slice{1, std::get(new_shape), 2}); } } // namespace details @@ -1260,8 +1160,8 @@ namespace builtins types::array_tuple strides; strides[E::value - 1] = sizeof(typename E::dtype); auto shape = sutils::getshape(a); - std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin(), - strides.rbegin() + 1, std::multiplies()); + std::transform(strides.rbegin(), strides.rend() - 1, shape.rbegin(), strides.rbegin() + 1, + std::multiplies()); return strides; } @@ -1278,8 +1178,8 @@ namespace builtins } template - std::integral_constant - getattr(types::attr::ITEMSIZE, E *const &a) + std::integral_constant getattr(types::attr::ITEMSIZE, + E *const &a) { return {}; } @@ -1298,39 +1198,32 @@ namespace builtins template auto getattr(types::attr::REAL, types::ndarray const &a) - -> decltype(details::_make_real( - a, utils::int_::value>{})) + -> decltype(details::_make_real(a, utils::int_::value>{})) { return details::_make_real(a, utils::int_::value>{}); } template - auto getattr(types::attr::REAL, types::numpy_iexpr const &e) - -> decltype(details::_make_real( - e, utils::int_::dtype>::value>{})) + auto getattr(types::attr::REAL, types::numpy_iexpr const &e) -> decltype(details::_make_real( + e, utils::int_::dtype>::value>{})) { return details::_make_real( - e, - utils::int_< - types::is_complex::dtype>::value>{}); + e, utils::int_::dtype>::value>{}); } template auto getattr(types::attr::REAL, types::numpy_expr const &a) -> decltype(details::_make_real( - a, utils::int_::dtype>::value>{})) + a, + utils::int_::dtype>::value>{})) { return details::_make_real( - a, utils::int_::dtype>::value>{}); + a, utils::int_::dtype>::value>{}); } template auto getattr(types::attr::REAL, types::numpy_texpr const &a) - -> decltype(types::numpy_texpr{ + -> decltype(types::numpy_texpr{ getattr(types::attr::REAL{}, a.arg)}) { auto ta = getattr(types::attr::REAL{}, a.arg); @@ -1339,8 +1232,7 @@ namespace builtins template auto getattr(types::attr::IMAG, types::ndarray const &a) - -> decltype(details::_make_imag( - a, utils::int_::value>{})) + -> decltype(details::_make_imag(a, utils::int_::value>{})) { return details::_make_imag(a, utils::int_::value>{}); } @@ -1348,18 +1240,16 @@ namespace builtins template auto getattr(types::attr::IMAG, types::numpy_expr const &a) -> decltype(details::_make_imag( - a, utils::int_::dtype>::value>{})) + a, + utils::int_::dtype>::value>{})) { return details::_make_imag( - a, utils::int_::dtype>::value>{}); + a, utils::int_::dtype>::value>{}); } template auto getattr(types::attr::IMAG, types::numpy_texpr const &a) - -> decltype(types::numpy_texpr{ + -> decltype(types::numpy_texpr{ getattr(types::attr::IMAG{}, a.arg)}) { auto ta = getattr(types::attr::IMAG{}, a.arg); @@ -1367,8 +1257,7 @@ namespace builtins } template - types::dtype_t::type> getattr(types::attr::DTYPE, - E const &a) + types::dtype_t::type> getattr(types::attr::DTYPE, E const &a) { return {}; } @@ -1396,13 +1285,12 @@ struct pyarray_new { static_assert(!std::is_same::value, "correctly specialized"); - PyObject *from_descr(PyTypeObject *subtype, PyArray_Descr *descr, T *dims, - void *data, int flags, PyObject *obj) + PyObject *from_descr(PyTypeObject *subtype, PyArray_Descr *descr, T *dims, void *data, int flags, + PyObject *obj) { npy_intp shape[N]; std::copy(dims, dims + N, shape); - return pyarray_new{}.from_descr(subtype, descr, shape, data, - flags, obj); + return pyarray_new{}.from_descr(subtype, descr, shape, data, flags, obj); } PyObject *from_data(T *dims, int typenum, void *data) { @@ -1415,11 +1303,10 @@ struct pyarray_new { template struct pyarray_new { - PyObject *from_descr(PyTypeObject *subtype, PyArray_Descr *descr, - npy_intp *dims, void *data, int flags, PyObject *obj) + PyObject *from_descr(PyTypeObject *subtype, PyArray_Descr *descr, npy_intp *dims, void *data, + int flags, PyObject *obj) { - return PyArray_NewFromDescr(subtype, descr, N, dims, nullptr, data, flags, - obj); + return PyArray_NewFromDescr(subtype, descr, N, dims, nullptr, data, flags, obj); } PyObject *from_data(npy_intp *dims, int typenum, void *data) @@ -1436,9 +1323,7 @@ inline void wrapfree(PyObject *capsule) }; template -PyObject * -to_python>::convert(types::ndarray const &cn, - bool transpose) +PyObject *to_python>::convert(types::ndarray const &cn, bool transpose) { types::ndarray &n = const_cast &>(cn); if (PyObject *p = n.mem.get_foreign()) { @@ -1449,8 +1334,7 @@ to_python>::convert(types::ndarray const &cn, // handle complex trick :-/ if ((long)sizeof(T) != PyArray_ITEMSIZE((PyArrayObject *)(arr))) { arr = (PyArrayObject *)PyArray_View( - (PyArrayObject *)(arr), - PyArray_DescrFromType(c_type_to_numpy_type::value), nullptr); + (PyArrayObject *)(arr), PyArray_DescrFromType(c_type_to_numpy_type::value), nullptr); } if (sutils::equals(n, pshape)) { @@ -1469,14 +1353,13 @@ to_python>::convert(types::ndarray const &cn, return Transposed; } } else { - Py_INCREF(PyArray_DESCR(arr)); + Py_INCREF((PyObject *)PyArray_DESCR(arr)); auto array = sutils::array(n._shape); auto *res = pyarray_new::value>{}.from_descr( - Py_TYPE(arr), PyArray_DESCR(arr), array.data(), PyArray_DATA(arr), + Py_TYPE((PyObject *)arr), PyArray_DESCR(arr), array.data(), PyArray_DATA(arr), PyArray_FLAGS(arr) & ~NPY_ARRAY_OWNDATA, p); if (transpose && (PyArray_FLAGS(arr) & NPY_ARRAY_F_CONTIGUOUS)) { - PyObject *Transposed = - PyArray_Transpose(reinterpret_cast(arr), nullptr); + PyObject *Transposed = PyArray_Transpose(reinterpret_cast(arr), nullptr); Py_DECREF(arr); return Transposed; } else @@ -1484,30 +1367,26 @@ to_python>::convert(types::ndarray const &cn, } } else { auto array = sutils::array(n._shape); - PyObject *result = - pyarray_new::value>{}.from_data( - array.data(), c_type_to_numpy_type::value, n.buffer); + PyObject *result = pyarray_new::value>{}.from_data( + array.data(), c_type_to_numpy_type::value, n.buffer); if (!result) return nullptr; // Take responsibility for n.buffer by wrapping it in a capsule and // setting result.base to the capsule - PyObject *capsule = PyCapsule_New(n.buffer, "wrapped_data", - (PyCapsule_Destructor)&wrapfree); + PyObject *capsule = PyCapsule_New(n.buffer, "wrapped_data", (PyCapsule_Destructor)&wrapfree); if (!capsule) { Py_DECREF(result); return nullptr; } n.mark_memory_external(result); Py_INCREF(result); // because it's going to be decrefed when n is destroyed - if (PyArray_SetBaseObject(reinterpret_cast(result), - capsule) == -1) { + if (PyArray_SetBaseObject(reinterpret_cast(result), capsule) == -1) { Py_DECREF(result); Py_DECREF(capsule); // will free n.buffer return nullptr; } if (transpose) { - PyObject *Transposed = - PyArray_Transpose(reinterpret_cast(result), nullptr); + PyObject *Transposed = PyArray_Transpose(reinterpret_cast(result), nullptr); Py_DECREF(result); return Transposed; } else @@ -1516,16 +1395,13 @@ to_python>::convert(types::ndarray const &cn, } template -PyObject * -to_python>::convert(types::numpy_iexpr const &v, - bool transpose) +PyObject *to_python>::convert(types::numpy_iexpr const &v, + bool transpose) { - PyObject *res = - ::to_python(types::ndarray::dtype, - typename types::numpy_iexpr::shape_t>(v)); + PyObject *res = ::to_python(types::ndarray::dtype, + typename types::numpy_iexpr::shape_t>(v)); if (transpose) { - PyObject *Transposed = - PyArray_Transpose(reinterpret_cast(res), nullptr); + PyObject *Transposed = PyArray_Transpose(reinterpret_cast(res), nullptr); Py_DECREF(res); return Transposed; } else @@ -1533,18 +1409,17 @@ to_python>::convert(types::numpy_iexpr const &v, } template -PyObject *to_python>::convert( - types::numpy_gexpr const &v, bool transpose) +PyObject *to_python>::convert(types::numpy_gexpr const &v, + bool transpose) { - PyObject *slices = (sizeof...(S) == 1) ? ::to_python(std::get<0>(v.slices)) - : ::to_python(v.slices); + PyObject *slices = + (sizeof...(S) == 1) ? ::to_python(std::get<0>(v.slices)) : ::to_python(v.slices); PyObject *base = ::to_python(v.arg); PyObject *res = PyObject_GetItem(base, slices); Py_DECREF(slices); Py_DECREF(base); if (transpose) { - PyObject *Transposed = - PyArray_Transpose(reinterpret_cast(res), nullptr); + PyObject *Transposed = PyArray_Transpose(reinterpret_cast(res), nullptr); Py_DECREF(res); return Transposed; } else @@ -1561,19 +1436,16 @@ namespace impl }; template - bool check_shape(T const *dims, utils::index_sequence) + bool check_shape(T const *dims, std::index_sequence) { types::array_tuple dims_match = { - (is_integral_constant::type>::value + (is_integral_constant>::value ? (dims[Is] == - std::conditional< - is_integral_constant< - typename std::tuple_element::type>::value, - typename std::tuple_element::type, - std::integral_constant>::type::value) + std::conditional_t>::value, + std::tuple_element_t, + std::integral_constant>::value) : true)...}; - return std::find(dims_match.begin(), dims_match.end(), false) == - dims_match.end(); + return std::find(dims_match.begin(), dims_match.end(), false) == dims_match.end(); } template @@ -1591,21 +1463,20 @@ namespace impl } template - void fill_slice(Slice &slice, long const *strides, long const *offsets, - S const *dims, utils::int_<0>) + void fill_slice(Slice &slice, long const *strides, long const *offsets, S const *dims, + utils::int_<0>) { } template - inline void set_slice(types::cstride_normalized_slice &cs, long lower, - long upper, long step) + inline void set_slice(types::cstride_normalized_slice &cs, long lower, long upper, + long step) { cs.lower = lower; cs.upper = upper; assert(cs.step == step && "consistent steps"); } - inline void set_slice(types::normalized_slice &s, long lower, long upper, - long step) + inline void set_slice(types::normalized_slice &s, long lower, long upper, long step) { s.lower = lower; s.upper = upper; @@ -1613,13 +1484,12 @@ namespace impl } template - void fill_slice(Slice &slice, long const *strides, long const *offsets, - S const *dims, utils::int_) + void fill_slice(Slice &slice, long const *strides, long const *offsets, S const *dims, + utils::int_) { set_slice(std::get::value - N>(slice), *offsets, *offsets + *dims * *strides, *strides); - fill_slice(slice, strides + 1, offsets + 1, dims + 1, - utils::int_()); + fill_slice(slice, strides + 1, offsets + 1, dims + 1, utils::int_()); } } // namespace impl @@ -1643,15 +1513,13 @@ bool from_python>::is_convertible(PyObject *obj) } // this is supposed to be a texpr if ((PyArray_FLAGS(arr) & NPY_ARRAY_F_CONTIGUOUS) && - ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && - (std::tuple_size::value > 1)) { + ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && (std::tuple_size::value > 1)) { return false; } } // check if dimension size match - return impl::check_shape( - dims, utils::make_index_sequence::value>()); + return impl::check_shape(dims, std::make_index_sequence::value>()); } template types::ndarray from_python>::convert(PyObject *obj) @@ -1663,16 +1531,14 @@ types::ndarray from_python>::convert(PyObject *obj) } template -bool from_python, - S...>>::is_convertible(PyObject *obj) +bool from_python, S...>>::is_convertible(PyObject *obj) { PyArrayObject *arr = impl::check_array_type_and_dims(obj); if (!arr) return false; if ((PyArray_FLAGS(arr) & NPY_ARRAY_F_CONTIGUOUS) && - ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && - (std::tuple_size::value > 1)) { + ((PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS) == 0) && (std::tuple_size::value > 1)) { return false; } @@ -1713,12 +1579,10 @@ bool from_python, template types::numpy_gexpr, S...> -from_python, S...>>::convert( - PyObject *obj) +from_python, S...>>::convert(PyObject *obj) { PyArrayObject *arr = reinterpret_cast(obj); - PyArrayObject *base_arr = - reinterpret_cast(PyArray_BASE(arr)); + PyArrayObject *base_arr = reinterpret_cast(PyArray_BASE(arr)); /* from the base array pointer && this array pointer, we can recover the * full slice informations @@ -1736,24 +1600,20 @@ from_python, S...>>::convert( auto full_offset = (PyArray_BYTES(arr) - PyArray_BYTES(base_arr)) / sizeof(T); auto const *arr_strides = PyArray_STRIDES(arr); long accumulated_dim = 1; - offsets[std::tuple_size::value - 1] = - full_offset % base_dims[std::tuple_size::value - 1]; - strides[std::tuple_size::value - 1] = - arr_strides[std::tuple_size::value - 1] / sizeof(T); + offsets[std::tuple_size::value - 1] = full_offset % base_dims[std::tuple_size::value - 1]; + strides[std::tuple_size::value - 1] = arr_strides[std::tuple_size::value - 1] / sizeof(T); for (ssize_t i = std::tuple_size::value - 2; i >= 0; --i) { accumulated_dim *= base_dims[i + 1]; offsets[i] = full_offset / accumulated_dim; strides[i] = arr_strides[i] / sizeof(T) / accumulated_dim; } - types::ndarray base_array((T *)PyArray_BYTES(base_arr), - PyArray_DIMS(base_arr), + types::ndarray base_array((T *)PyArray_BYTES(base_arr), PyArray_DIMS(base_arr), (PyObject *)base_arr); std::tuple slices; - impl::fill_slice(slices, strides, offsets, PyArray_DIMS(arr), - utils::int_()); + impl::fill_slice(slices, strides, offsets, PyArray_DIMS(arr), utils::int_()); types::numpy_gexpr, S...> r(base_array, slices); - Py_INCREF(base_arr); + Py_INCREF((PyObject *)base_arr); return r; } @@ -1763,9 +1623,7 @@ bool from_python>:: is_convertible(PyObject *obj) { constexpr auto N = E::value; - PyArrayObject *arr = - impl::check_array_type_and_dims( - obj); + PyArrayObject *arr = impl::check_array_type_and_dims(obj); if (!arr) return false; // check strides. Note that because it's a texpr, the check is done in the @@ -1795,8 +1653,7 @@ types::numpy_texpr from_python>::convert(PyObject *obj) sutils::assign(std::get<1>(shape), std::get<0>(dims)); PyObject *tobj = PyArray_Transpose(arr, nullptr); - types::ndarray base_array((T *)PyArray_BYTES(arr), - shape, tobj); + types::ndarray base_array((T *)PyArray_BYTES(arr), shape, tobj); types::numpy_texpr> r(base_array); return r; } diff --git a/contrib/python/pythran/pythran/pythonic/types/nditerator.hpp b/contrib/python/pythran/pythran/pythonic/types/nditerator.hpp index 2cb2b904798..8388e3e17cd 100644 --- a/contrib/python/pythran/pythran/pythonic/types/nditerator.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/nditerator.hpp @@ -97,6 +97,24 @@ namespace types return index < other.index; } + template + bool nditerator::operator>(nditerator const &other) const + { + return index > other.index; + } + + template + bool nditerator::operator<=(nditerator const &other) const + { + return !(index > other.index); + } + + template + bool nditerator::operator>=(nditerator const &other) const + { + return !(index < other.index); + } + template nditerator &nditerator::operator=(nditerator const &other) { @@ -109,8 +127,7 @@ namespace types * element */ template - const_nditerator::const_nditerator(E const &data, long index) - : data(data), index(index) + const_nditerator::const_nditerator(E const &data, long index) : data(data), index(index) { } @@ -189,29 +206,43 @@ namespace types } template - const_nditerator & - const_nditerator::operator=(const_nditerator const &other) + bool const_nditerator::operator>(const_nditerator const &other) const + { + return index > other.index; + } + + template + bool const_nditerator::operator<=(const_nditerator const &other) const + { + return !(index > other.index); + } + + template + bool const_nditerator::operator>=(const_nditerator const &other) const + { + return !(index < other.index); + } + + template + const_nditerator &const_nditerator::operator=(const_nditerator const &other) { index = other.index; return *this; } #ifdef USE_XSIMD template - const_simd_nditerator::const_simd_nditerator(typename E::dtype const *data) - : data(data) + const_simd_nditerator::const_simd_nditerator(typename E::dtype const *data) : data(data) { } template - auto const_simd_nditerator::operator*() const - -> decltype(xsimd::load_unaligned(data)) + auto const_simd_nditerator::operator*() const -> decltype(xsimd::load_unaligned(data)) { return xsimd::load_unaligned(data); } template - void - const_simd_nditerator::store(xsimd::batch const &val) + void const_simd_nditerator::store(xsimd::batch const &val) { val.store_unaligned(const_cast(data)); } @@ -244,36 +275,49 @@ namespace types } template - long const_simd_nditerator::operator-( - const_simd_nditerator const &other) const + long const_simd_nditerator::operator-(const_simd_nditerator const &other) const { return (data - other.data) / vector_size; } template - bool const_simd_nditerator::operator!=( - const_simd_nditerator const &other) const + bool const_simd_nditerator::operator!=(const_simd_nditerator const &other) const { return data != other.data; } template - bool const_simd_nditerator::operator==( - const_simd_nditerator const &other) const + bool const_simd_nditerator::operator==(const_simd_nditerator const &other) const { return data == other.data; } template - bool const_simd_nditerator::operator<( - const_simd_nditerator const &other) const + bool const_simd_nditerator::operator<(const_simd_nditerator const &other) const { return data < other.data; } template - const_simd_nditerator & - const_simd_nditerator::operator=(const_simd_nditerator const &other) + bool const_simd_nditerator::operator>(const_simd_nditerator const &other) const + { + return data > other.data; + } + + template + bool const_simd_nditerator::operator<=(const_simd_nditerator const &other) const + { + return !(data > other.data); + } + + template + bool const_simd_nditerator::operator>=(const_simd_nditerator const &other) const + { + return !(data < other.data); + } + + template + const_simd_nditerator &const_simd_nditerator::operator=(const_simd_nditerator const &other) { data = other.data; return *this; @@ -304,8 +348,7 @@ namespace types } template - typename T::dtype const * - make_const_nditerator::operator()(T const &self, long i) const + typename T::dtype const *make_const_nditerator::operator()(T const &self, long i) const { return self.buffer + i; } diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_binary_op.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_binary_op.hpp index e8891b9ca37..1c24429f4b1 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_binary_op.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_binary_op.hpp @@ -6,12 +6,9 @@ #endif template -typename std::enable_if< - types::valid_numop_parameters::type, - typename std::decay::type>::value, - types::numpy_expr::type, - typename types::adapt_type::type>>::type +std::enable_if_t, std::decay_t>::value, + types::numpy_expr::type, + typename types::adapt_type::type>> NUMPY_BINARY_FUNC_NAME(E0 &&self, E1 &&other) { return {std::forward(self), std::forward(other)}; diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_broadcast.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_broadcast.hpp index 6f63445a095..4d8b2e02544 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_broadcast.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_broadcast.hpp @@ -28,8 +28,7 @@ namespace types #ifdef USE_XSIMD template template - typename broadcasted::simd_iterator - broadcasted::vbegin(vectorizer) const + typename broadcasted::simd_iterator broadcasted::vbegin(vectorizer) const { return {*this}; } @@ -54,8 +53,8 @@ namespace types template template auto broadcasted::operator()(S arg0, Arg1 &&arg1, Args &&...args) const - -> broadcast_or_broadcasted_t(arg1), std::forward(args)...))>::type> + -> broadcast_or_broadcasted_t< + std::decay_t(arg1), std::forward(args)...))>> { return {ref(std::forward(arg1), std::forward(args)...)}; } @@ -96,8 +95,7 @@ namespace types template template - typename broadcast::dtype - broadcast::operator[](array_tuple) const + typename broadcast::dtype broadcast::operator[](array_tuple) const { return _base._value; } @@ -110,8 +108,7 @@ namespace types template template - typename broadcast::dtype - broadcast::operator()(Args &&...args) const + typename broadcast::dtype broadcast::operator()(Args &&...args) const { return _base._value; } diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_expr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_expr.hpp index 20331cd9a9c..2ecfdd2ea8e 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_expr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_expr.hpp @@ -29,7 +29,7 @@ namespace types } template - long init_shape_element(Args const &args, utils::index_sequence) + long init_shape_element(Args const &args, std::index_sequence) { return best_of(std::get(args).template shape()...); } @@ -43,37 +43,31 @@ namespace types template template typename numpy_expr::const_iterator - numpy_expr::_begin(utils::index_sequence) const + numpy_expr::_begin(std::index_sequence) const { - return { - {make_step(size(), std::get(args).template shape<0>())...}, - const_cast::type const &>(std::get(args)) - .begin()...}; + return {{make_step(size(), std::get(args).template shape<0>())...}, + const_cast const &>(std::get(args)).begin()...}; } template - typename numpy_expr::const_iterator - numpy_expr::begin() const + typename numpy_expr::const_iterator numpy_expr::begin() const { - return _begin(utils::make_index_sequence{}); + return _begin(std::make_index_sequence{}); } template template typename numpy_expr::const_iterator - numpy_expr::_end(utils::index_sequence) const + numpy_expr::_end(std::index_sequence) const { - return { - {make_step(size(), std::get(args).template shape<0>())...}, - const_cast::type const &>(std::get(args)) - .end()...}; + return {{make_step(size(), std::get(args).template shape<0>())...}, + const_cast const &>(std::get(args)).end()...}; } template - typename numpy_expr::const_iterator - numpy_expr::end() const + typename numpy_expr::const_iterator numpy_expr::end() const { - return _end(utils::make_index_sequence{}); + return _end(std::make_index_sequence{}); } template @@ -92,7 +86,7 @@ namespace types template template - bool numpy_expr::_no_broadcast(utils::index_sequence) const + bool numpy_expr::_no_broadcast(std::index_sequence) const { bool child_broadcast = false; (void)std::initializer_list{ @@ -109,8 +103,7 @@ namespace types template template - bool - numpy_expr::_no_broadcast_ex(utils::index_sequence) const + bool numpy_expr::_no_broadcast_ex(std::index_sequence) const { bool child_broadcast = false; (void)std::initializer_list{ @@ -128,94 +121,86 @@ namespace types template template - bool numpy_expr::_no_broadcast_vectorize( - utils::index_sequence) const + bool numpy_expr::_no_broadcast_vectorize(std::index_sequence) const { bool child_broadcast = false; (void)std::initializer_list{ - (child_broadcast |= - !utils::no_broadcast_vectorize(std::get(args)))...}; + (child_broadcast |= !utils::no_broadcast_vectorize(std::get(args)))...}; if (child_broadcast) return false; bool same_shape = true; (void)std::initializer_list{ - (same_shape &= - ((long)std::get(args).template shape<0>() == size()))...}; + (same_shape &= ((long)std::get(args).template shape<0>() == size()))...}; return same_shape; } template bool numpy_expr::no_broadcast() const { - return _no_broadcast(utils::make_index_sequence{}); + return _no_broadcast(std::make_index_sequence{}); } template bool numpy_expr::no_broadcast_ex() const { - return _no_broadcast_ex(utils::make_index_sequence{}); + return _no_broadcast_ex(std::make_index_sequence{}); } template bool numpy_expr::no_broadcast_vectorize() const { - return _no_broadcast_vectorize( - utils::make_index_sequence{}); + return _no_broadcast_vectorize(std::make_index_sequence{}); } template template typename numpy_expr::iterator - numpy_expr::_begin(utils::index_sequence) + numpy_expr::_begin(std::index_sequence) { return {{make_step(size(), std::get(args).template shape<0>())...}, - const_cast::type &>(std::get(args)) - .begin()...}; + const_cast &>(std::get(args)).begin()...}; } template typename numpy_expr::iterator numpy_expr::begin() { - return _begin(utils::make_index_sequence{}); + return _begin(std::make_index_sequence{}); } template template typename numpy_expr::iterator - numpy_expr::_end(utils::index_sequence) + numpy_expr::_end(std::index_sequence) { return {{make_step(size(), std::get(args).template shape<0>())...}, - const_cast::type &>(std::get(args)) - .end()...}; + const_cast &>(std::get(args)).end()...}; } template typename numpy_expr::iterator numpy_expr::end() { - return _end(utils::make_index_sequence{}); + return _end(std::make_index_sequence{}); } template auto numpy_expr::fast(long i) const - -> decltype(this->_fast(i, utils::make_index_sequence{})) + -> decltype(this->_fast(i, std::make_index_sequence{})) { - return _fast(i, utils::make_index_sequence{}); + return _fast(i, std::make_index_sequence{}); } template template auto numpy_expr::map_fast(Indices... indices) const - -> decltype(this->_map_fast( - array_tuple{{indices...}}, - utils::make_index_sequence{})) + -> decltype(this->_map_fast(array_tuple{{indices...}}, + std::make_index_sequence{})) { static_assert(sizeof...(Indices) == sizeof...(Args), "compatible call"); return _map_fast(array_tuple{{indices...}}, - utils::make_index_sequence{}); + std::make_index_sequence{}); } template - auto - numpy_expr::operator[](long i) const -> decltype(this->fast(i)) + auto numpy_expr::operator[](long i) const -> decltype(this->fast(i)) { if (i < 0) i += size(); @@ -226,27 +211,24 @@ namespace types template template typename numpy_expr::simd_iterator - numpy_expr::_vbegin(vectorize, utils::index_sequence) const + numpy_expr::_vbegin(vectorize, std::index_sequence) const { - return { - {make_step(size(), std::get(args).template shape<0>())...}, - std::make_tuple(xsimd::batch< - typename std::remove_reference::type::value_type>( - *std::get(args).begin())...), - std::get(args).vbegin(vectorize{})...}; + return {{make_step(size(), std::get(args).template shape<0>())...}, + std::make_tuple(xsimd::batch::value_type>( + *std::get(args).begin())...), + std::get(args).vbegin(vectorize{})...}; } template - typename numpy_expr::simd_iterator - numpy_expr::vbegin(vectorize) const + typename numpy_expr::simd_iterator numpy_expr::vbegin(vectorize) const { - return _vbegin(vectorize{}, utils::make_index_sequence{}); + return _vbegin(vectorize{}, std::make_index_sequence{}); } template template typename numpy_expr::simd_iterator - numpy_expr::_vend(vectorize, utils::index_sequence) const + numpy_expr::_vend(vectorize, std::index_sequence) const { return {{make_step(size(), std::get(args).template shape<0>())...}, {}, @@ -254,17 +236,15 @@ namespace types } template - typename numpy_expr::simd_iterator - numpy_expr::vend(vectorize) const + typename numpy_expr::simd_iterator numpy_expr::vend(vectorize) const { - return _vend(vectorize{}, utils::make_index_sequence{}); + return _vend(vectorize{}, std::make_index_sequence{}); } template template typename numpy_expr::simd_iterator_nobroadcast - numpy_expr::_vbegin(vectorize_nobroadcast, - utils::index_sequence) const + numpy_expr::_vbegin(vectorize_nobroadcast, std::index_sequence) const { return {std::get(args).vbegin(vectorize_nobroadcast{})...}; } @@ -273,15 +253,13 @@ namespace types typename numpy_expr::simd_iterator_nobroadcast numpy_expr::vbegin(vectorize_nobroadcast) const { - return _vbegin(vectorize_nobroadcast{}, - utils::make_index_sequence{}); + return _vbegin(vectorize_nobroadcast{}, std::make_index_sequence{}); } template template typename numpy_expr::simd_iterator_nobroadcast - numpy_expr::_vend(vectorize_nobroadcast, - utils::index_sequence) const + numpy_expr::_vend(vectorize_nobroadcast, std::index_sequence) const { return {std::get(args).vend(vectorize_nobroadcast{})...}; } @@ -290,8 +268,7 @@ namespace types typename numpy_expr::simd_iterator_nobroadcast numpy_expr::vend(vectorize_nobroadcast) const { - return _vend(vectorize_nobroadcast{}, - utils::make_index_sequence{}); + return _vend(vectorize_nobroadcast{}, std::make_index_sequence{}); } #endif @@ -299,19 +276,16 @@ namespace types template template auto numpy_expr::operator()(S const &...s) const - -> decltype(this->_get(utils::make_index_sequence{}, - s...)) + -> decltype(this->_get(std::make_index_sequence{}, s...)) { - return _get(utils::make_index_sequence{}, s...); + return _get(std::make_index_sequence{}, s...); } template template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_expr::fast(F const &filter) const { long sz = filter.template shape<0>(); @@ -322,28 +296,23 @@ namespace types raw[n++] = i; // reallocate(raw, n); long shp[1] = {n}; - return this->fast( - ndarray>(raw, shp, types::ownership::owned)); + return this->fast(ndarray>(raw, shp, types::ownership::owned)); } template template - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_expr::operator[](F const &filter) const { return fast(filter); } template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, F>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, F>> numpy_expr::operator[](F const &filter) const { return {*this, filter}; @@ -351,11 +320,9 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, F>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, F>> numpy_expr::fast(F const &filter) const { return {*this, filter}; @@ -374,7 +341,7 @@ namespace types template long numpy_expr::flat_size() const { - return prod_helper(*this, utils::make_index_sequence()); + return prod_helper(*this, std::make_index_sequence()); } template diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_gexpr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_gexpr.hpp index f5b61fdf4af..72695f3f3b9 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_gexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_gexpr.hpp @@ -62,8 +62,7 @@ namespace types template intptr_t baseid(T const &e) { - return baseid_helper( - e, std::integral_constant::value>{}); + return baseid_helper(e, std::integral_constant::value>{}); } template @@ -98,22 +97,20 @@ namespace types template bool may_overlap(E0 const &e0, types::numpy_expr const &e1, - utils::index_sequence) + std::index_sequence) { bool overlaps[] = {may_overlap(e0, std::get(e1.args))...}; - return std::any_of(std::begin(overlaps), std::end(overlaps), - [](bool b) { return b; }); + return std::any_of(std::begin(overlaps), std::end(overlaps), [](bool b) { return b; }); } template bool may_overlap(E0 const &e0, types::numpy_expr const &e1) { - return may_overlap(e0, e1, utils::make_index_sequence()); + return may_overlap(e0, e1, std::make_index_sequence()); } template - bool may_overlap(E0 const &e0, - pythonic::numpy::details::arange_index const &e1) + bool may_overlap(E0 const &e0, pythonic::numpy::details::arange_index const &e1) { return false; } @@ -124,8 +121,8 @@ namespace types return false; } template - typename std::enable_if::value, bool>::type - may_overlap(numpy_gexpr const &gexpr, E1 const &) + std::enable_if_t::value, bool> may_overlap(numpy_gexpr const &gexpr, + E1 const &) { return false; } @@ -142,8 +139,7 @@ namespace types if (gexpr.arg.id() != expr.arg.id()) { return false; } - if (!slices_may_overlap(std::get<0>(gexpr.slices), - std::get<0>(expr.slices))) + if (!slices_may_overlap(std::get<0>(gexpr.slices), std::get<0>(expr.slices))) return false; return true; } @@ -188,8 +184,7 @@ namespace types return value; } - inline cstride_normalized_slice<1> - to_normalized_slice::operator()(none_type) + inline cstride_normalized_slice<1> to_normalized_slice::operator()(none_type) { return {0, 1}; } @@ -210,108 +205,95 @@ namespace types { template - std::tuple<> merge_gexpr, std::tuple<>>::run( - S const &, std::tuple<> const &t0, std::tuple<> const &) + std::tuple<> merge_gexpr, std::tuple<>>::run(S const &, std::tuple<> const &t0, + std::tuple<> const &) { return t0; } template template - std::tuple merge_gexpr, std::tuple<>>::run( - S const &, std::tuple const &t0, std::tuple<>) + std::tuple merge_gexpr, std::tuple<>>::run(S const &, + std::tuple const &t0, + std::tuple<>) { return t0; } template - constexpr long count_new_axis_helper(utils::index_sequence) + constexpr long count_new_axis_helper(std::index_sequence) { - return count_new_axis::type...>::value; + return count_new_axis...>::value; } template - auto normalize_all(S const &s, T const &t, utils::index_sequence) + auto normalize_all(S const &s, T const &t, std::index_sequence) -> decltype(std::make_tuple(normalize( std::get(t), s.template shape( - utils::make_index_sequence<1 + Is>())>())...)) + count_new_axis_helper(std::make_index_sequence<1 + Is>())>())...)) { return std::make_tuple(normalize( std::get(t), s.template shape( - utils::make_index_sequence<1 + Is>())>())...); + count_new_axis_helper(std::make_index_sequence<1 + Is>())>())...); } template template std::tuple...> - merge_gexpr, std::tuple>::run( - S const &s, std::tuple<>, std::tuple const &t1) + merge_gexpr, std::tuple>::run(S const &s, std::tuple<>, + std::tuple const &t1) { - return normalize_all(s, t1, - utils::make_index_sequence()); + return normalize_all(s, t1, std::make_index_sequence()); } template - typename std::enable_if::value == 0, - numpy_gexpr>::type + std::enable_if_t::value == 0, numpy_gexpr> _make_gexpr(Arg arg, std::tuple const &t) { return {arg, t}; } template - numpy_gexpr::type>::type...> - _make_gexpr_helper(Arg arg, S const &s, utils::index_sequence) + numpy_gexpr>::type...> + _make_gexpr_helper(Arg arg, S const &s, std::index_sequence) { - return {arg, - to_normalized_slice::type>{}( - std::get(s))...}; + return {arg, to_normalized_slice>{}(std::get(s))...}; } template - auto _make_gexpr(Arg arg, std::tuple const &s) -> - typename std::enable_if< - count_new_axis::value != 0, - decltype(_make_gexpr_helper( - arg.reshape(make_reshape::value>( - arg, std::tuple::is_new_axis>...>())), - s, utils::make_index_sequence()))>::type + auto _make_gexpr(Arg arg, std::tuple const &s) -> std::enable_if_t< + count_new_axis::value != 0, + decltype(_make_gexpr_helper( + arg.reshape(make_reshape::value>( + arg, std::tuple::is_new_axis>...>())), + s, std::make_index_sequence()))> { return _make_gexpr_helper( arg.reshape(make_reshape::value>( - arg, std::tuple::is_new_axis>...>())), - s, utils::make_index_sequence()); + arg, std::tuple::is_new_axis>...>())), + s, std::make_index_sequence()); } template template numpy_gexpr...> - make_gexpr::operator()(Arg arg, std::tuple s, - utils::index_sequence) + make_gexpr::operator()(Arg arg, std::tuple s, std::index_sequence) { return {arg, normalize(std::get(s), arg.template shape())...}; } template - numpy_gexpr...> - make_gexpr::operator()(Arg arg, S const &...s) + numpy_gexpr...> make_gexpr::operator()(Arg arg, S const &...s) { - return operator()(arg, std::tuple(s...), - utils::make_index_sequence()); + return operator()(arg, std::tuple(s...), std::make_index_sequence()); } } // namespace details template auto make_gexpr(Arg &&arg, S const &...s) - -> decltype(details::make_gexpr{}(std::forward(arg), - s...)) + -> decltype(details::make_gexpr{}(std::forward(arg), s...)) { return details::make_gexpr{}(std::forward(arg), s...); } @@ -325,48 +307,40 @@ namespace types template // not using the default one, to make it possible to // accept reference && non reference version of Argp numpy_gexpr::numpy_gexpr(numpy_gexpr const &other) - : arg(other.arg), slices(other.slices), _shape(other._shape), - buffer(other.buffer), _strides(other._strides) + : arg(other.arg), slices(other.slices), _shape(other._shape), buffer(other.buffer), + _strides(other._strides) { - static_assert(std::is_same::type, - typename returnable::type>::value, - "this constructor is only here to adapt reference / non " - "reference type, nothing else"); + static_assert( + std::is_same::type, typename returnable::type>::value, + "this constructor is only here to adapt reference / non " + "reference type, nothing else"); assert(buffer); } template template - typename std::enable_if::value, void>::type - numpy_gexpr::init_shape(Slice const &s, utils::int_<1>, - utils::int_) + std::enable_if_t::value, void> + numpy_gexpr::init_shape(Slice const &s, utils::int_<1>, utils::int_) { buffer += s.lower * arg.template strides(); - sutils::assign(std::get(_strides), - s.step * arg.template strides()); - sutils::assign(std::get(_shape), - std::get(slices).size()); + sutils::assign(std::get(_strides), s.step * arg.template strides()); + sutils::assign(std::get(_shape), std::get(slices).size()); } template template - typename std::enable_if::value, void>::type - numpy_gexpr::init_shape(Slice const &s, utils::int_, - utils::int_) + std::enable_if_t::value, void> + numpy_gexpr::init_shape(Slice const &s, utils::int_, utils::int_) { - sutils::assign(std::get(_shape), - std::get(slices).size()); + sutils::assign(std::get(_shape), std::get(slices).size()); buffer += s.lower * arg.template strides(); - sutils::assign(std::get(_strides), - s.step * arg.template strides()); - init_shape(std::get(slices), utils::int_(), - utils::int_()); + sutils::assign(std::get(_strides), s.step * arg.template strides()); + init_shape(std::get(slices), utils::int_(), utils::int_()); } template template - void numpy_gexpr::init_shape(long cs, utils::int_<1>, - utils::int_) + void numpy_gexpr::init_shape(long cs, utils::int_<1>, utils::int_) { assert(cs >= 0 && "normalized"); buffer += cs * arg.template strides(); @@ -374,35 +348,26 @@ namespace types template template - void numpy_gexpr::init_shape(long cs, utils::int_, - utils::int_) + void numpy_gexpr::init_shape(long cs, utils::int_, utils::int_) { assert(cs >= 0 && "normalized"); buffer += cs * arg.template strides(); - init_shape(std::get(slices), utils::int_(), - utils::int_()); + init_shape(std::get(slices), utils::int_(), utils::int_()); } template - numpy_gexpr::numpy_gexpr(Arg const &arg, - std::tuple const &values) + numpy_gexpr::numpy_gexpr(Arg const &arg, std::tuple const &values) : arg(arg), slices(values), buffer(const_cast(this->arg.buffer)) { assert(buffer); - init_shape(std::get<0>(slices), utils::int_(), - utils::int_<0>()); + init_shape(std::get<0>(slices), utils::int_(), utils::int_<0>()); - sutils::copy_shape::value, - count_long::value>( - _shape, arg, - utils::make_index_sequence::value)>()); + sutils::copy_shape::value, count_long::value>( + _shape, arg, std::make_index_sequence::value)>()); - sutils::copy_strides::value, - count_long::value>( + sutils::copy_strides::value, count_long::value>( _strides, arg, - utils::make_index_sequence::value)>()); + std::make_index_sequence::value)>()); } template @@ -412,34 +377,29 @@ namespace types } template template - numpy_gexpr::numpy_gexpr(numpy_gexpr const &expr, - Arg arg) + numpy_gexpr::numpy_gexpr(numpy_gexpr const &expr, Arg arg) : arg(arg), slices(tuple_pop(expr.slices)), buffer(expr.buffer) { assert(buffer); - sutils::copy_shape<0, 1>(_shape, expr, utils::make_index_sequence()); + sutils::copy_shape<0, 1>(_shape, expr, std::make_index_sequence()); buffer += arg.buffer - expr.arg.buffer; - sutils::copy_strides<0, 1>(_strides, expr, - utils::make_index_sequence()); + sutils::copy_strides<0, 1>(_strides, expr, std::make_index_sequence()); } template template numpy_gexpr::numpy_gexpr(G const &expr, Arg &&arg) - : arg(std::forward(arg)), slices(tuple_pop(expr.slices)), - buffer(expr.buffer) + : arg(std::forward(arg)), slices(tuple_pop(expr.slices)), buffer(expr.buffer) { assert(buffer); - sutils::copy_shape<0, 1>(_shape, expr, utils::make_index_sequence()); + sutils::copy_shape<0, 1>(_shape, expr, std::make_index_sequence()); buffer += (arg.buffer - expr.arg.buffer); - sutils::copy_strides<0, 1>(_strides, expr, - utils::make_index_sequence()); + sutils::copy_strides<0, 1>(_strides, expr, std::make_index_sequence()); } template template - typename std::enable_if::value, - numpy_gexpr &>::type + std::enable_if_t::value, numpy_gexpr &> numpy_gexpr::_copy(E const &expr) { static_assert(value >= utils::dim_of::value, "dimensions match"); @@ -449,27 +409,23 @@ namespace types * perform a fuzzy alias check dynamically! */ assert(buffer); - constexpr bool vectorize = - is_vectorizable && - std::is_same::type>::value && - is_vectorizable_array::value; + constexpr bool vectorize = is_vectorizable && + std::is_same::type>::value && + is_vectorizable_array::value; if (may_overlap(*this, expr)) { - return utils::broadcast_copy< - numpy_gexpr &, ndarray, value, - value - utils::dim_of::value, vectorize>( + return utils::broadcast_copy, + value, value - utils::dim_of::value, vectorize>( *this, ndarray(expr)); } else { // 100% sure there's no overlap - return utils::broadcast_copy::value, vectorize>( - *this, expr); + return utils::broadcast_copy::value, + vectorize>(*this, expr); } } template template - typename std::enable_if::value, - numpy_gexpr &>::type + std::enable_if_t::value, numpy_gexpr &> numpy_gexpr::_copy(E const &expr) { return _copy_restrict(expr); @@ -479,13 +435,11 @@ namespace types template numpy_gexpr &numpy_gexpr::_copy_restrict(E const &expr) { - constexpr bool vectorize = - is_vectorizable && - std::is_same::type>::value && - is_vectorizable_array::value; + constexpr bool vectorize = is_vectorizable && + std::is_same::type>::value && + is_vectorizable_array::value; assert(buffer); - return utils::broadcast_copy::value, + return utils::broadcast_copy::value, vectorize>(*this, expr); } @@ -497,19 +451,17 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator=(numpy_gexpr const &expr) { if (buffer == nullptr) { // arg = expr.arg; - const_cast::type &>(arg) = expr.arg; + const_cast &>(arg) = expr.arg; slices = expr.slices; assert(expr.buffer); buffer = arg.buffer + (expr.buffer - expr.arg.buffer); _shape = expr._shape; _strides = expr._strides; - assert(sutils::getshape(*this) == sutils::getshape(expr) && - "compatible sizes"); + assert(sutils::getshape(*this) == sutils::getshape(expr) && "compatible sizes"); return *this; } else { return _copy(expr); @@ -518,12 +470,11 @@ namespace types template template - numpy_gexpr & - numpy_gexpr::operator=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator=(numpy_gexpr const &expr) { if (buffer == nullptr) { // arg = expr.arg; - const_cast::type &>(arg) = expr.arg; + const_cast &>(arg) = expr.arg; slices = expr.slices; assert(expr.buffer); buffer = arg.buffer + (expr.buffer - expr.arg.buffer); @@ -537,54 +488,42 @@ namespace types template template - typename std::enable_if::value, - numpy_gexpr &>::type + std::enable_if_t::value, numpy_gexpr &> numpy_gexpr::update_(E const &expr) { - using BExpr = - typename std::conditional::value, broadcast, - E const &>::type; + using BExpr = std::conditional_t::value, broadcast, E const &>; BExpr bexpr = expr; // 100% sure there's no overlap return utils::broadcast_update < Op, numpy_gexpr &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && - types::is_vectorizable::type>::type>::value && - std::is_same::type>::type>::value > + types::is_vectorizable>>::value && + std::is_same>::type>::value > (*this, bexpr); } template template - typename std::enable_if::value, - numpy_gexpr &>::type + std::enable_if_t::value, numpy_gexpr &> numpy_gexpr::update_(E const &expr) { - using BExpr = - typename std::conditional::value, broadcast, - E const &>::type; + using BExpr = std::conditional_t::value, broadcast, E const &>; BExpr bexpr = expr; if (may_overlap(*this, expr)) { - using NBExpr = - ndarray::type::dtype, - typename std::remove_reference::type::shape_t>; + using NBExpr = ndarray::dtype, + typename std::remove_reference_t::shape_t>; return utils::broadcast_update < Op, numpy_gexpr &, NBExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && types::is_vectorizable::value && - std::is_same::type::dtype>::value > + std::is_same::dtype>::value > (*this, NBExpr(bexpr)); } else { // 100% sure there's no overlap return utils::broadcast_update < Op, numpy_gexpr &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && types::is_vectorizable::value && - std::is_same::type::dtype>::value > - (*this, bexpr); + std::is_same::dtype>::value > (*this, bexpr); } } @@ -596,8 +535,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator+=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator+=(numpy_gexpr const &expr) { return update_(expr); } @@ -610,8 +548,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator-=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator-=(numpy_gexpr const &expr) { return update_(expr); } @@ -624,8 +561,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator*=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator*=(numpy_gexpr const &expr) { return update_(expr); } @@ -638,8 +574,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator/=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator/=(numpy_gexpr const &expr) { return update_(expr); } @@ -652,8 +587,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator|=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator|=(numpy_gexpr const &expr) { return update_(expr); } @@ -666,8 +600,7 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator&=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator&=(numpy_gexpr const &expr) { return update_(expr); } @@ -680,51 +613,46 @@ namespace types } template - numpy_gexpr & - numpy_gexpr::operator^=(numpy_gexpr const &expr) + numpy_gexpr &numpy_gexpr::operator^=(numpy_gexpr const &expr) { return update_(expr); } template - typename numpy_gexpr::const_iterator - numpy_gexpr::begin() const + typename numpy_gexpr::const_iterator numpy_gexpr::begin() const { - return make_const_nditerator < is_strided || value != 1 > ()(*this, 0); + return make_const_nditerator()(*this, 0); } template - typename numpy_gexpr::const_iterator - numpy_gexpr::end() const + typename numpy_gexpr::const_iterator numpy_gexpr::end() const { - return make_const_nditerator < is_strided || value != 1 > ()(*this, size()); + return make_const_nditerator()(*this, size()); } template typename numpy_gexpr::iterator numpy_gexpr::begin() { - return make_nditerator < is_strided || value != 1 > ()(*this, 0); + return make_nditerator()(*this, 0); } template typename numpy_gexpr::iterator numpy_gexpr::end() { - return make_nditerator < is_strided || value != 1 > ()(*this, size()); + return make_nditerator()(*this, size()); } #ifdef USE_XSIMD template template - typename numpy_gexpr::simd_iterator - numpy_gexpr::vbegin(vectorizer) const + typename numpy_gexpr::simd_iterator numpy_gexpr::vbegin(vectorizer) const { return {buffer}; } template template - typename numpy_gexpr::simd_iterator - numpy_gexpr::vend(vectorizer) const + typename numpy_gexpr::simd_iterator numpy_gexpr::vend(vectorizer) const { using vector_type = typename xsimd::batch; static const std::size_t vector_size = vector_type::size; @@ -734,8 +662,7 @@ namespace types #endif template - auto - numpy_gexpr::operator[](long i) const -> decltype(this->fast(i)) + auto numpy_gexpr::operator[](long i) const -> decltype(this->fast(i)) { if (i < 0) i += std::get<0>(_shape); @@ -752,25 +679,23 @@ namespace types template template - auto numpy_gexpr::operator()(Sp const &...s) const - -> decltype(make_gexpr(*this, s...)) + auto numpy_gexpr::operator()(Sp const &...s) const -> decltype(make_gexpr(*this, s...)) { return make_gexpr(*this, s...); } template template - auto numpy_gexpr::operator[](Sp const &s) const -> - typename std::enable_if::value, - decltype(make_gexpr(*this, (s.lower, s)))>::type + auto numpy_gexpr::operator[](Sp const &s) const + -> std::enable_if_t::value, decltype(make_gexpr(*this, (s.lower, s)))> { return make_gexpr(*this, s); } template template - auto numpy_gexpr::fast(array_tuple const &indices) - const & -> decltype(nget().fast(*this, indices)) + auto numpy_gexpr::fast( + array_tuple const &indices) const & -> decltype(nget().fast(*this, indices)) { return nget().fast(*this, indices); } @@ -785,25 +710,24 @@ namespace types template template - auto numpy_gexpr::operator[](array_tuple const &indices) - const & -> decltype(nget()(*this, indices)) + auto numpy_gexpr::operator[]( + array_tuple const &indices) const & -> decltype(nget()(*this, indices)) { return nget()(*this, indices); } template template - auto numpy_gexpr::operator[](array_tuple const &indices) - && -> decltype(nget()(std::move(*this), indices)) + auto numpy_gexpr::operator[]( + array_tuple const &indices) && -> decltype(nget()(std::move(*this), indices)) { return nget()(std::move(*this), indices); } template template - typename std::enable_if< - is_numexpr_arg::value && std::is_same::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr, ndarray>>> numpy_gexpr::fast(F const &filter) const { long sz = filter.template shape<0>(); @@ -814,15 +738,13 @@ namespace types raw[n++] = i; // reallocate(raw, n); long shp[1] = {n}; - return this->fast( - ndarray>(raw, shp, types::ownership::owned)); + return this->fast(ndarray>(raw, shp, types::ownership::owned)); } template template - typename std::enable_if< - is_numexpr_arg::value && std::is_same::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr, ndarray>>> numpy_gexpr::operator[](F const &filter) const { return fast(filter); diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_iexpr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_iexpr.hpp index 5f44a4ae1bc..b1f8128a479 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_iexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_iexpr.hpp @@ -43,8 +43,7 @@ namespace types template // not using the default one, to make it possible to // accept reference and non reference version of Argp numpy_iexpr::numpy_iexpr(numpy_iexpr const &other) - : arg(const_cast::type &>(other.arg)), - buffer(other.buffer) + : arg(const_cast &>(other.arg)), buffer(other.buffer) { assert(buffer); } @@ -67,10 +66,8 @@ namespace types numpy_iexpr &numpy_iexpr::operator=(E const &expr) { assert(buffer); - return utils::broadcast_copy < numpy_iexpr &, E, value, - value - utils::dim_of::value, - is_vectorizable && - std::is_same::type>::value && + return utils::broadcast_copy < numpy_iexpr &, E, value, value - utils::dim_of::value, + is_vectorizable && std::is_same::type>::value && types::is_vectorizable::value > (*this, expr); } @@ -86,8 +83,7 @@ namespace types return utils::broadcast_copy < numpy_iexpr &, numpy_iexpr const &, value, value - utils::dim_of::value, is_vectorizable && numpy_iexpr::is_vectorizable && - std::is_same::dtype>::value > - (*this, expr); + std::is_same::dtype>::value > (*this, expr); } template @@ -102,8 +98,7 @@ namespace types return utils::broadcast_copy < numpy_iexpr &, numpy_iexpr const &, value, value - utils::dim_of::value, is_vectorizable && numpy_iexpr::is_vectorizable && - std::is_same::dtype>::value > - (*this, expr); + std::is_same::dtype>::value > (*this, expr); } template @@ -111,18 +106,15 @@ namespace types numpy_iexpr &numpy_iexpr::update_(Expr const &expr) { using BExpr = - typename std::conditional::value, - broadcast, Expr const &>::type; + std::conditional_t::value, broadcast, Expr const &>; assert(buffer); BExpr bexpr = expr; utils::broadcast_update< Op, numpy_iexpr &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && - types::is_vectorizable::type>::type>::value && - std::is_same::type>::type>::value>(*this, bexpr); + types::is_vectorizable>>::value && + std::is_same>::type>::value>(*this, bexpr); return *this; } @@ -219,25 +211,25 @@ namespace types template typename numpy_iexpr::const_iterator numpy_iexpr::begin() const { - return make_const_nditerator < is_strided || value != 1 > ()(*this, 0); + return make_const_nditerator()(*this, 0); } template typename numpy_iexpr::const_iterator numpy_iexpr::end() const { - return make_const_nditerator < is_strided || value != 1 > ()(*this, size()); + return make_const_nditerator()(*this, size()); } template typename numpy_iexpr::iterator numpy_iexpr::begin() { - return make_nditerator < is_strided || value != 1 > ()(*this, 0); + return make_nditerator()(*this, 0); } template typename numpy_iexpr::iterator numpy_iexpr::end() { - return make_nditerator < is_strided || value != 1 > ()(*this, size()); + return make_nditerator()(*this, size()); } template @@ -265,15 +257,15 @@ namespace types } template - size_t compute_fast_offset(size_t offset, long mult, T0 const &indices, - T1 const &shape, std::integral_constant) + size_t compute_fast_offset(size_t offset, long mult, T0 const &indices, T1 const &shape, + std::integral_constant) { return offset; } template - size_t compute_fast_offset(size_t offset, long mult, T0 const &indices, - T1 const &shape, std::integral_constant) + size_t compute_fast_offset(size_t offset, long mult, T0 const &indices, T1 const &shape, + std::integral_constant) { return compute_fast_offset(offset + std::get(indices) * mult, mult * shape.template shape(), indices, shape, @@ -284,24 +276,20 @@ namespace types typename numpy_iexpr::dtype const & numpy_iexpr::fast(array_tuple const &indices) const { - return buffer[compute_fast_offset( - indices[value - 1], arg.template shape(), indices, arg, - std::integral_constant())]; + return buffer[compute_fast_offset(indices[value - 1], arg.template shape(), indices, arg, + std::integral_constant())]; } template - typename numpy_iexpr::dtype & - numpy_iexpr::fast(array_tuple const &indices) + typename numpy_iexpr::dtype &numpy_iexpr::fast(array_tuple const &indices) { - return const_cast( - const_cast(*this).fast(indices)); + return const_cast(const_cast(*this).fast(indices)); } template template - typename std::enable_if< - is_numexpr_arg::value && std::is_same::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr, ndarray>>> numpy_iexpr::fast(F const &filter) const { long sz = filter.template shape<0>(); @@ -312,23 +300,20 @@ namespace types raw[n++] = i; // reallocate(raw, n); long shp[1] = {n}; - return this->fast( - ndarray>(raw, shp, types::ownership::owned)); + return this->fast(ndarray>(raw, shp, types::ownership::owned)); } #ifdef USE_XSIMD template template - typename numpy_iexpr::simd_iterator - numpy_iexpr::vbegin(vectorizer) const + typename numpy_iexpr::simd_iterator numpy_iexpr::vbegin(vectorizer) const { return {buffer}; } template template - typename numpy_iexpr::simd_iterator - numpy_iexpr::vend(vectorizer) const + typename numpy_iexpr::simd_iterator numpy_iexpr::vend(vectorizer) const { using vector_type = typename xsimd::batch; static const std::size_t vector_size = vector_type::size; @@ -353,8 +338,7 @@ namespace types } template - auto - numpy_iexpr::operator[](long i) && -> decltype(std::move(*this).fast(i)) + auto numpy_iexpr::operator[](long i) && -> decltype(std::move(*this).fast(i)) { if (i < 0) i += size(); @@ -363,8 +347,7 @@ namespace types template template - typename std::enable_if::value, - numpy_gexpr, normalize_t>>::type + std::enable_if_t::value, numpy_gexpr, normalize_t>> numpy_iexpr::operator[](Sp const &s0) const { return make_gexpr(*this, s0); @@ -372,9 +355,8 @@ namespace types template template - typename std::enable_if< - is_slice::value, - numpy_gexpr, normalize_t, normalize_t...>>::type + std::enable_if_t::value, + numpy_gexpr, normalize_t, normalize_t...>> numpy_iexpr::operator()(Sp const &s0, S const &...s) const { return make_gexpr(*this, s0, s...); @@ -382,44 +364,40 @@ namespace types template template - typename std::enable_if< - is_numexpr_arg::value && std::is_same::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value, + numpy_vexpr, ndarray>>> numpy_iexpr::operator[](F const &filter) const { return fast(filter); } template - size_t compute_offset(size_t offset, long mult, T0 const &indices, - T1 const &shape, std::integral_constant) + size_t compute_offset(size_t offset, long mult, T0 const &indices, T1 const &shape, + std::integral_constant) { return offset; } template - size_t compute_offset(size_t offset, long mult, T0 const &indices, - T1 const &shape, std::integral_constant) + size_t compute_offset(size_t offset, long mult, T0 const &indices, T1 const &shape, + std::integral_constant) { - return compute_offset( - offset + (std::get(indices) < 0 - ? std::get(indices) + shape.template shape() - : std::get(indices)) * - mult, - mult * shape.template shape(), indices, shape, - std::integral_constant()); + return compute_offset(offset + (std::get(indices) < 0 + ? std::get(indices) + shape.template shape() + : std::get(indices)) * + mult, + mult * shape.template shape(), indices, shape, + std::integral_constant()); } template typename numpy_iexpr::dtype const & numpy_iexpr::operator[](array_tuple const &indices) const { - return buffer[compute_offset(indices[value - 1] < 0 - ? indices[value - 1] + - arg.template shape() - : indices[value - 1], - arg.template shape(), indices, arg, - std::integral_constant())]; + return buffer[compute_offset( + indices[value - 1] < 0 ? indices[value - 1] + arg.template shape() + : indices[value - 1], + arg.template shape(), indices, arg, std::integral_constant())]; } template @@ -439,31 +417,28 @@ namespace types } template - long prod_helper(S const &shape, utils::index_sequence) + long prod_helper(S const &shape, std::index_sequence) { long res = 1; - (void)std::initializer_list{ - (res *= (long)(shape.template shape()))...}; + (void)std::initializer_list{(res *= (long)(shape.template shape()))...}; return res; } template long numpy_iexpr::flat_size() const { - return prod_helper(*this, utils::make_index_sequence()); + return prod_helper(*this, std::make_index_sequence()); } template - long numpy_iexpr::buffer_offset(Arg const &arg, long index, - utils::int_<0>) + long numpy_iexpr::buffer_offset(Arg const &arg, long index, utils::int_<0>) { return index; } template template - long numpy_iexpr::buffer_offset(ndarray const &arg, long index, - utils::int_) + long numpy_iexpr::buffer_offset(ndarray const &arg, long index, utils::int_) { return index * arg.template strides<0>(); } diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_nary_expr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_nary_expr.hpp index 66644875fc4..5c36a435ddc 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_nary_expr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_nary_expr.hpp @@ -18,21 +18,17 @@ namespace functor { template - auto NUMPY_NARY_FUNC_NAME::operator()(T &&...args) const -> - typename std::enable_if< - !types::valid_numexpr_parameters< - typename std::decay::type...>::value, - decltype(NUMPY_NARY_FUNC_SYM(std::forward(args)...))>::type + auto NUMPY_NARY_FUNC_NAME::operator()(T &&...args) const + -> std::enable_if_t...>::value, + decltype(NUMPY_NARY_FUNC_SYM(std::forward(args)...))> { return NUMPY_NARY_FUNC_SYM(std::forward(args)...); } template - typename std::enable_if< - types::valid_numexpr_parameters::type...>::value, - types::numpy_expr< - NUMPY_NARY_FUNC_NAME, - typename types::NUMPY_NARY_RESHAPE_MODE::type...>>::type + std::enable_if_t...>::value, + types::numpy_expr::type...>> NUMPY_NARY_FUNC_NAME::operator()(E &&...args) const { return {std::forward(args)...}; diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_texpr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_texpr.hpp index 47c47881b6d..1b71d0a3409 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_texpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_texpr.hpp @@ -56,40 +56,30 @@ namespace types } template - auto numpy_texpr_2::fast(long i) const - -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - i)) + auto numpy_texpr_2::fast(long i) const -> decltype(this->arg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), i)) { - return arg( - cstride_slice<1>(pythonic::builtins::None, pythonic::builtins::None), - i); + return arg(cstride_slice<1>(pythonic::builtins::None, pythonic::builtins::None), i); } template - auto numpy_texpr_2::fast(long i) - -> decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - i)) + auto numpy_texpr_2::fast(long i) -> decltype(this->arg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), i)) { - return arg( - cstride_slice<1>(pythonic::builtins::None, pythonic::builtins::None), - i); + return arg(cstride_slice<1>(pythonic::builtins::None, pythonic::builtins::None), i); } #ifdef USE_XSIMD template template - typename numpy_texpr_2::simd_iterator - numpy_texpr_2::vbegin(vectorizer) const + typename numpy_texpr_2::simd_iterator numpy_texpr_2::vbegin(vectorizer) const { return {*this}; } template template - typename numpy_texpr_2::simd_iterator - numpy_texpr_2::vend(vectorizer) const + typename numpy_texpr_2::simd_iterator numpy_texpr_2::vend(vectorizer) const { return {*this}; // not vectorizable anyway } @@ -113,38 +103,26 @@ namespace types template template - auto numpy_texpr_2::operator[](S const &s0) const - -> numpy_texpr< - decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - (s0.step, s0)))> + auto numpy_texpr_2::operator[](S const &s0) const -> numpy_texprarg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), (s0.step, s0)))> { - return {arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - s0)}; + return {arg(fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), s0)}; } template template - auto numpy_texpr_2::operator[](S const &s0) - -> numpy_texpr< - decltype(this->arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - (s0.step, s0)))> + auto numpy_texpr_2::operator[](S const &s0) -> numpy_texprarg( + fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), (s0.step, s0)))> { - return {arg(fast_contiguous_slice(pythonic::builtins::None, - pythonic::builtins::None), - s0)}; + return {arg(fast_contiguous_slice(pythonic::builtins::None, pythonic::builtins::None), s0)}; } /* element filtering */ template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_texpr_2::fast(F const &filter) const { long sz = filter.template shape<0>(); @@ -154,17 +132,14 @@ namespace types if (filter.fast(i)) raw[n++] = i; // reallocate(raw, n); - return this->fast(ndarray>(raw, pshape(n), - types::ownership::owned)); + return this->fast(ndarray>(raw, pshape(n), types::ownership::owned)); } template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value != 1 && - !is_pod_array::value, - numpy_vexpr::dtype, pshape>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr::dtype, pshape>, + ndarray>>> numpy_texpr_2::fast(F const &filter) const { return numpy::functor::array{}(*this) @@ -173,11 +148,9 @@ namespace types template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value == 1 && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value == 1 && !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_texpr_2::operator[](F const &filter) const { return fast(filter); @@ -185,12 +158,10 @@ namespace types template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && F::value != 1 && - !is_pod_array::value, - numpy_vexpr::dtype, pshape>, - ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + F::value != 1 && !is_pod_array::value, + numpy_vexpr::dtype, pshape>, + ndarray>>> numpy_texpr_2::operator[](F const &filter) const { return fast(filter); @@ -198,51 +169,41 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if< - is_numexpr_arg::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && !std::is_same::value && + !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_texpr_2::operator[](F const &filter) const { - static_assert(F::value == 1, - "advanced indexing only supporint with 1D index"); + static_assert(F::value == 1, "advanced indexing only supporint with 1D index"); return {*this, filter}; } template template // indexing through an array of indices -- a view - typename std::enable_if< - is_numexpr_arg::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && !std::is_same::value && + !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_texpr_2::fast(F const &filter) const { - static_assert(F::value == 1, - "advanced indexing only supported with 1D index"); + static_assert(F::value == 1, "advanced indexing only supported with 1D index"); return {*this, filter}; } template template - auto numpy_texpr_2::operator()(S0 const &s0, S const &...s) const -> - typename std::enable_if< - !is_numexpr_arg::value, - decltype(this->_reverse_index( - std::tuple{s0, s...}, - utils::make_reversed_index_sequence<1 + sizeof...(S)>()))>::type + auto numpy_texpr_2::operator()(S0 const &s0, S const &...s) const -> std::enable_if_t< + !is_numexpr_arg::value, + decltype(this->_reverse_index(std::tuple{s0, s...}, + utils::make_reversed_index_sequence<1 + sizeof...(S)>()))> { - return _reverse_index( - std::tuple{s0, s...}, - utils::make_reversed_index_sequence<1 + sizeof...(S)>()); + return _reverse_index(std::tuple{s0, s...}, + utils::make_reversed_index_sequence<1 + sizeof...(S)>()); } template template - auto numpy_texpr_2::operator()(S0 const &s0, S const &...s) const -> - typename std::enable_if::value, - decltype(this->copy()(s0, s...))>::type + auto numpy_texpr_2::operator()(S0 const &s0, S const &...s) const + -> std::enable_if_t::value, decltype(this->copy()(s0, s...))> { return copy()(s0, s...); } @@ -269,16 +230,13 @@ namespace types template numpy_texpr_2 &numpy_texpr_2::operator=(Expr const &expr) { - return utils::broadcast_copy < numpy_texpr_2 &, Expr, value, - value - utils::dim_of::value, - is_vectorizable && - std::is_same::type>::value && + return utils::broadcast_copy < numpy_texpr_2 &, Expr, value, value - utils::dim_of::value, + is_vectorizable && std::is_same::type>::value && types::is_vectorizable::value > (*this, expr); } template template - numpy_texpr_2 & - numpy_texpr_2::operator=(numpy_texpr const &expr) + numpy_texpr_2 &numpy_texpr_2::operator=(numpy_texpr const &expr) { arg = expr.arg; return *this; @@ -289,17 +247,14 @@ namespace types numpy_texpr_2 &numpy_texpr_2::update_(Expr const &expr) { using BExpr = - typename std::conditional::value, - broadcast, Expr const &>::type; + std::conditional_t::value, broadcast, Expr const &>; BExpr bexpr = expr; utils::broadcast_update< Op, numpy_texpr_2 &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && - types::is_vectorizable::type>::type>::value && - std::is_same::type>::type>::value>(*this, bexpr); + types::is_vectorizable>>::value && + std::is_same>::type>::value>(*this, bexpr); return *this; } @@ -355,8 +310,7 @@ namespace types // only implemented for N = 2 template - numpy_texpr>>::numpy_texpr( - ndarray> const &arg) + numpy_texpr>>::numpy_texpr(ndarray> const &arg) : numpy_texpr_2>>{arg} { } @@ -369,8 +323,7 @@ namespace types } template - numpy_texpr>::numpy_texpr( - numpy_gexpr const &arg) + numpy_texpr>::numpy_texpr(numpy_gexpr const &arg) : numpy_texpr_2>{arg} { } diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_unary_op.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_unary_op.hpp index ee1371c2022..26c86486f3f 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_unary_op.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_unary_op.hpp @@ -6,9 +6,8 @@ #endif template -typename std::enable_if< - types::valid_numop_parameters::type>::value, - types::numpy_expr>::type +std::enable_if_t>::value, + types::numpy_expr> NUMPY_UNARY_FUNC_NAME(E &&self) { return {std::forward(self)}; diff --git a/contrib/python/pythran/pythran/pythonic/types/numpy_vexpr.hpp b/contrib/python/pythran/pythran/pythonic/types/numpy_vexpr.hpp index 9bb66b6e177..6ab8ff1e3c0 100644 --- a/contrib/python/pythran/pythran/pythonic/types/numpy_vexpr.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/numpy_vexpr.hpp @@ -10,7 +10,7 @@ namespace types template template - typename std::enable_if::value, numpy_vexpr &>::type + std::enable_if_t::value, numpy_vexpr &> numpy_vexpr::operator=(E const &expr) { // TODO: avoid the tmp copy when no aliasing @@ -21,7 +21,7 @@ namespace types } template template - typename std::enable_if::value, numpy_vexpr &>::type + std::enable_if_t::value, numpy_vexpr &> numpy_vexpr::operator=(E const &expr) { for (long i = 0, n = shape<0>(); i < n; ++i) @@ -68,16 +68,14 @@ namespace types #ifdef USE_XSIMD template template - typename numpy_vexpr::simd_iterator - numpy_vexpr::vbegin(vectorizer) const + typename numpy_vexpr::simd_iterator numpy_vexpr::vbegin(vectorizer) const { return {*this, 0}; } template template - typename numpy_vexpr::simd_iterator - numpy_vexpr::vend(vectorizer) const + typename numpy_vexpr::simd_iterator numpy_vexpr::vend(vectorizer) const { return {*this, 0}; } @@ -86,11 +84,9 @@ namespace types /* element filtering */ template template // indexing through an array of boolean -- a mask - typename std::enable_if< - is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && std::is_same::value && + !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_vexpr::fast(E const &filter) const { long sz = filter.template shape<0>(); @@ -101,17 +97,14 @@ namespace types raw[n++] = i; // reallocate(raw, n); long shp[1] = {n}; - return this->fast( - ndarray>(raw, shp, types::ownership::owned)); + return this->fast(ndarray>(raw, shp, types::ownership::owned)); } template template // indexing through an array of boolean -- a mask - typename std::enable_if< - !is_slice::value && is_numexpr_arg::value && - std::is_same::value && - !is_pod_array::value, - numpy_vexpr, ndarray>>>::type + std::enable_if_t::value && is_numexpr_arg::value && + std::is_same::value && !is_pod_array::value, + numpy_vexpr, ndarray>>> numpy_vexpr::operator[](E const &filter) const { return fast(filter); @@ -119,11 +112,9 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, E>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, E>> numpy_vexpr::operator[](E const &filter) const { return {*this, filter}; @@ -131,11 +122,9 @@ namespace types template template // indexing through an array of indices -- a view - typename std::enable_if::value && - !is_array_index::value && - !std::is_same::value && - !is_pod_array::value, - numpy_vexpr, E>>::type + std::enable_if_t::value && !is_array_index::value && + !std::is_same::value && !is_pod_array::value, + numpy_vexpr, E>> numpy_vexpr::fast(E const &filter) const { return (*this)[filter]; @@ -145,17 +134,14 @@ namespace types numpy_vexpr &numpy_vexpr::update_(Expr const &expr) { using BExpr = - typename std::conditional::value, - broadcast, Expr const &>::type; + std::conditional_t::value, broadcast, Expr const &>; BExpr bexpr = expr; utils::broadcast_update< Op, numpy_vexpr &, BExpr, value, value - (std::is_scalar::value + utils::dim_of::value), is_vectorizable && - types::is_vectorizable::type>::type>::value && - std::is_same::type>::type>::value>(*this, bexpr); + types::is_vectorizable>>::value && + std::is_same>::type>::value>(*this, bexpr); return *this; } template diff --git a/contrib/python/pythran/pythran/pythonic/types/pointer.hpp b/contrib/python/pythran/pythran/pythonic/types/pointer.hpp index b55efcdf57e..fdb26d96ece 100644 --- a/contrib/python/pythran/pythran/pythonic/types/pointer.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/pointer.hpp @@ -37,22 +37,19 @@ PYTHONIC_NS_END namespace std { template - typename pythonic::types::pointer::reference - get(pythonic::types::pointer &t) + typename pythonic::types::pointer::reference get(pythonic::types::pointer &t) { return t[I]; } template - typename pythonic::types::pointer::value_type - get(pythonic::types::pointer const &t) + typename pythonic::types::pointer::value_type get(pythonic::types::pointer const &t) { return t[I]; } template - typename pythonic::types::pointer::value_type - get(pythonic::types::pointer &&t) + typename pythonic::types::pointer::value_type get(pythonic::types::pointer &&t) { return t[I]; } diff --git a/contrib/python/pythran/pythran/pythonic/types/raw_array.hpp b/contrib/python/pythran/pythran/pythonic/types/raw_array.hpp index bf79843b3b0..53a4460b42d 100644 --- a/contrib/python/pythran/pythran/pythonic/types/raw_array.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/raw_array.hpp @@ -21,8 +21,7 @@ namespace types } template - raw_array::raw_array(size_t n) - : data(utils::allocate(n)), external(false) + raw_array::raw_array(size_t n) : data(utils::allocate(n)), external(false) { if (!data) { std::ostringstream oss; @@ -32,8 +31,7 @@ namespace types } template - raw_array::raw_array(T *d, ownership o) - : data(d), external(o == ownership::external) + raw_array::raw_array(T *d, ownership o) : data(d), external(o == ownership::external) { } diff --git a/contrib/python/pythran/pythran/pythonic/types/set.hpp b/contrib/python/pythran/pythran/pythonic/types/set.hpp index 7c31ada0ec0..6be2d7f5334 100644 --- a/contrib/python/pythran/pythran/pythonic/types/set.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/set.hpp @@ -85,30 +85,6 @@ namespace types return data->end(); } - template - typename set::reverse_iterator set::rbegin() - { - return data->rbegin(); - } - - template - typename set::const_reverse_iterator set::rbegin() const - { - return data->rbegin(); - } - - template - typename set::reverse_iterator set::rend() - { - return data->rend(); - } - - template - typename set::const_reverse_iterator set::rend() const - { - return data->rend(); - } - // modifiers template T set::pop() @@ -154,8 +130,7 @@ namespace types // Remove element elem from the set. Raises KeyError if elem is ! // contained in the set. if (!data->erase(elem)) - throw std::runtime_error( - "set.delete() : couldn't delete element ! in the set."); + throw std::runtime_error("set.delete() : couldn't delete element ! in the set."); } // set interface @@ -184,7 +159,7 @@ namespace types bool set::isdisjoint(U const &other) const { // Return true if the this has no elements in common with other. - for (iterator it = begin(); it != end(); ++it) { + for (const_iterator it = begin(); it != end(); ++it) { if (in(other, *it)) return false; } @@ -196,7 +171,7 @@ namespace types bool set::issubset(U const &other) const { // Test whether every element in the set is in other. - for (iterator it = begin(); it != end(); ++it) { + for (const_iterator it = begin(); it != end(); ++it) { if (!in(other, *it)) return false; } @@ -219,11 +194,9 @@ namespace types template template - typename __combined, U, Types...>::type - set::union_(U &&other, Types &&...others) const + typename __combined, U, Types...>::type set::union_(U &&other, Types &&...others) const { - typename __combined, U, Types...>::type tmp = - union_(std::forward(others)...); + typename __combined, U, Types...>::type tmp = union_(std::forward(others)...); tmp.data->insert(other.begin(), other.end()); return tmp; } @@ -244,16 +217,14 @@ namespace types template template - typename __combined, U, Types...>::type - set::intersection(U const &other, Types const &...others) const + typename __combined, U, Types...>::type set::intersection(U const &other, + Types const &...others) const { // Return a new set with elements common to the set && all others. - typename __combined, U, Types...>::type tmp = - intersection(others...); + typename __combined, U, Types...>::type tmp = intersection(others...); for (auto it = begin(); it != end(); ++it) { if (!in(other, *it)) - tmp.discard( - *it); // faster than remove() but ! direct interaction with data + tmp.discard(*it); // faster than remove() but ! direct interaction with data } return tmp; } @@ -284,8 +255,7 @@ namespace types } */ // This algo will do several times the same find(), because // std::set::erase() calls find. Lame! - for (typename U::const_iterator it = other.begin(); it != other.end(); - ++it) { + for (typename U::const_iterator it = other.begin(); it != other.end(); ++it) { tmp.discard(*it); } return tmp; @@ -307,8 +277,7 @@ namespace types template template - set::type> - set::symmetric_difference(set const &other) const + set::type> set::symmetric_difference(set const &other) const { // Return a new set with elements in either the set || other but ! both. // return ((*this-other) | (other-*this)); @@ -320,12 +289,11 @@ namespace types template template - typename __combined>::type - set::symmetric_difference(U const &other) const + typename __combined>::type set::symmetric_difference(U const &other) const { // Return a new set with elements in either the set || other but ! both. - set::value_type> tmp( - other.begin(), other.end()); + set::value_type> tmp(other.begin(), + other.end()); // We must use fcts && ! operators because fcts have to handle any // iterable objects && operators only sets (cf python ref) @@ -381,8 +349,7 @@ namespace types template template - set::type> - set::operator|(set const &other) const + set::type> set::operator|(set const &other) const { return union_(other); } @@ -396,8 +363,7 @@ namespace types template template - set::type> - set::operator&(set const &other) const + set::type> set::operator&(set const &other) const { return intersection(other); } @@ -425,8 +391,7 @@ namespace types template template - set::type> - set::operator^(set const &other) const + set::type> set::operator^(set const &other) const { return symmetric_difference(other); } diff --git a/contrib/python/pythran/pythran/pythonic/types/slice.hpp b/contrib/python/pythran/pythran/pythonic/types/slice.hpp index 5d053247e3e..5c7050b1c6f 100644 --- a/contrib/python/pythran/pythran/pythonic/types/slice.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/slice.hpp @@ -33,19 +33,16 @@ namespace types { } - inline normalized_slice - normalized_slice::operator*(normalized_slice const &other) const + inline normalized_slice normalized_slice::operator*(normalized_slice const &other) const { - return {lower + step * other.lower, lower + step * other.upper, - step * other.step}; + return {lower + step * other.lower, lower + step * other.upper, step * other.step}; } template - inline normalized_slice normalized_slice::operator*( - cstride_normalized_slice const &other) const + inline normalized_slice + normalized_slice::operator*(cstride_normalized_slice const &other) const { - return {lower + step * other.lower, lower + step * other.upper, - step * other.step}; + return {lower + step * other.lower, lower + step * other.upper, step * other.step}; } inline normalized_slice normalized_slice::operator*(slice const &other) const { @@ -53,8 +50,7 @@ namespace types } template - inline normalized_slice - normalized_slice::operator*(cstride_slice const &other) const + inline normalized_slice normalized_slice::operator*(cstride_slice const &other) const { return (*this) * other.normalize(size()); } @@ -74,8 +70,7 @@ namespace types { } - inline slice::slice() - : lower(builtins::None), upper(builtins::None), step(builtins::None) + inline slice::slice() : lower(builtins::None), upper(builtins::None), step(builtins::None) { } @@ -86,10 +81,10 @@ namespace types // TODO: We can skip these constraints if we know begin, end && step. long sstep = (step.is_none()) ? 1 : (long)step; long ostep = (other.step.is_none()) ? 1 : (long)other.step; - assert(!((ostep < 0 || static_cast(other.upper) < 0 || - static_cast(other.lower) < 0) && - sstep != 1 && sstep != -1) && - "not implemented"); + assert( + !((ostep < 0 || static_cast(other.upper) < 0 || static_cast(other.lower) < 0) && + sstep != 1 && sstep != -1) && + "not implemented"); bound new_lower; if (other.lower.is_none() || (long)other.lower == 0) { if (ostep > 0) @@ -217,57 +212,46 @@ namespace types // template - inline cstride_normalized_slice::cstride_normalized_slice(long lower, - long upper, - long) + inline cstride_normalized_slice::cstride_normalized_slice(long lower, long upper, long) : lower(lower), upper(upper) { } template - inline normalized_slice cstride_normalized_slice::operator*( - normalized_slice const &other) const + inline normalized_slice + cstride_normalized_slice::operator*(normalized_slice const &other) const { - return {lower + step * other.lower, lower + step * other.upper, - step * other.step}; + return {lower + step * other.lower, lower + step * other.upper, step * other.step}; } template template - inline - typename std::conditional<(stride < 256 && other_stride < 256), - cstride_normalized_slice, - normalized_slice>::type - cstride_normalized_slice::operator*( - cstride_normalized_slice const &other) const + inline std::conditional_t<(stride < 256 && other_stride < 256), + cstride_normalized_slice, normalized_slice> + cstride_normalized_slice::operator*( + cstride_normalized_slice const &other) const { - return {lower + step * other.lower, lower + step * other.upper, - step * other.step}; + return {lower + step * other.lower, lower + step * other.upper, step * other.step}; } template - inline normalized_slice - cstride_normalized_slice::operator*(slice const &other) const + inline normalized_slice cstride_normalized_slice::operator*(slice const &other) const { return (*this) * other.normalize(size()); } template inline cstride_normalized_slice - cstride_normalized_slice::operator*( - fast_contiguous_slice const &other) const + cstride_normalized_slice::operator*(fast_contiguous_slice const &other) const { return (*this) * other.normalize(size()); } template template - inline - typename std::conditional<(stride < 256 && other_stride < 256), - cstride_normalized_slice, - normalized_slice>::type - cstride_normalized_slice::operator*( - cstride_slice const &other) const + inline std::conditional_t<(stride < 256 && other_stride < 256), + cstride_normalized_slice, normalized_slice> + cstride_normalized_slice::operator*(cstride_slice const &other) const { return (*this) * other.normalize(size()); } @@ -285,15 +269,13 @@ namespace types } template - inline cstride_slice::cstride_slice(none lower, - none upper) + inline cstride_slice::cstride_slice(none lower, none upper) : lower(lower), upper(upper) { } template - inline cstride_slice::cstride_slice() - : lower(builtins::None), upper(builtins::None) + inline cstride_slice::cstride_slice() : lower(builtins::None), upper(builtins::None) { } @@ -346,11 +328,9 @@ namespace types template template - inline typename std::conditional<(stride < 256 && other_stride < 256), - cstride_slice, - slice>::type - cstride_slice::operator*( - cstride_slice const &other) const + inline std::conditional_t<(stride < 256 && other_stride < 256), + cstride_slice, slice> + cstride_slice::operator*(cstride_slice const &other) const { bound new_lower; if (other.lower.is_none() || (long)other.lower == 0) { @@ -384,8 +364,7 @@ namespace types container */ template - inline cstride_normalized_slice - cstride_slice::normalize(long max_size) const + inline cstride_normalized_slice cstride_slice::normalize(long max_size) const { long normalized_upper; if (upper.is_none()) { @@ -467,8 +446,7 @@ namespace types return {new_lower, new_upper}; } - inline fast_contiguous_slice::fast_contiguous_slice(none lower, - none upper) + inline fast_contiguous_slice::fast_contiguous_slice(none lower, none upper) : lower(lower.is_none ? 0 : (long)lower), upper(upper) { } @@ -533,8 +511,7 @@ namespace types It also check for value bigger than len(a) to fit the size of the container */ - inline cstride_normalized_slice<1> - fast_contiguous_slice::normalize(long max_size) const + inline cstride_normalized_slice<1> fast_contiguous_slice::normalize(long max_size) const { long normalized_upper; if (upper.is_none()) @@ -565,11 +542,9 @@ namespace types return (b.is_none() ? (os << "None") : (os << (T)b)); } template - typename std::enable_if::value, std::ostream &>::type - operator<<(std::ostream &os, S const &s) + std::enable_if_t::value, std::ostream &> operator<<(std::ostream &os, S const &s) { - return os << "slice(" << s.lower << ", " << s.upper << ", " << s.step - << ")"; + return os << "slice(" << s.lower << ", " << s.upper << ", " << s.step << ")"; } } // namespace types PYTHONIC_NS_END @@ -590,28 +565,23 @@ template inline PyObject *to_python>::convert( types::cstride_normalized_slice const &v) { - return PySlice_New(::to_python(v.lower), ::to_python(v.upper), - ::to_python(v.step)); + return PySlice_New(::to_python(v.lower), ::to_python(v.upper), ::to_python(v.step)); } template -inline PyObject *to_python>::convert( - types::cstride_slice const &v) +inline PyObject * +to_python>::convert(types::cstride_slice const &v) { - return PySlice_New(::to_python(v.lower), ::to_python(v.upper), - ::to_python(v.step)); + return PySlice_New(::to_python(v.lower), ::to_python(v.upper), ::to_python(v.step)); } -inline PyObject * -to_python::convert(types::normalized_slice const &v) +inline PyObject *to_python::convert(types::normalized_slice const &v) { if (v.step > 0) { - return PySlice_New(::to_python(v.lower), ::to_python(v.upper), - ::to_python(v.step)); + return PySlice_New(::to_python(v.lower), ::to_python(v.upper), ::to_python(v.step)); } else { return PySlice_New(::to_python(v.lower), - v.upper < 0 ? ::to_python(types::none_type{}) - : ::to_python(v.upper), + v.upper < 0 ? ::to_python(types::none_type{}) : ::to_python(v.upper), ::to_python(v.step)); } } @@ -619,12 +589,10 @@ to_python::convert(types::normalized_slice const &v) inline PyObject *to_python::convert(types::slice const &v) { if (v.step > 0) { - return PySlice_New(::to_python(v.lower), ::to_python(v.upper), - ::to_python(v.step)); + return PySlice_New(::to_python(v.lower), ::to_python(v.upper), ::to_python(v.step)); } else { return PySlice_New(::to_python(v.lower), - v.upper < 0 ? ::to_python(types::none_type{}) - : ::to_python(v.upper), + v.upper < 0 ? ::to_python(types::none_type{}) : ::to_python(v.upper), ::to_python(v.step)); } } @@ -637,15 +605,14 @@ inline bool from_python::is_convertible(PyObject *obj) inline types::slice from_python::convert(PyObject *obj) { Py_ssize_t start, stop, step; -#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 6) || \ - (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && \ - PY_MICRO_VERSION >= 1 && !defined(PYPY_VERSION)) +#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 6) || \ + (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION == 6 && PY_MICRO_VERSION >= 1 && \ + !defined(PYPY_VERSION)) PySlice_Unpack(obj, &start, &stop, &step); #elif PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 1 PySlice_GetIndices((PyObject *)obj, PY_SSIZE_T_MAX, &start, &stop, &step); #else - PySlice_GetIndices((PySliceObject *)obj, PY_SSIZE_T_MAX, &start, &stop, - &step); + PySlice_GetIndices((PySliceObject *)obj, PY_SSIZE_T_MAX, &start, &stop, &step); #endif types::none nstart, nstop, nstep; if (start != PY_SSIZE_T_MAX) diff --git a/contrib/python/pythran/pythran/pythonic/types/str.hpp b/contrib/python/pythran/pythran/pythonic/types/str.hpp index e5dbe6083b1..a7dd51af849 100644 --- a/contrib/python/pythran/pythran/pythonic/types/str.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/str.hpp @@ -27,8 +27,7 @@ namespace types } /// const_sliced_str_iterator implementation - inline const_sliced_str_iterator::const_sliced_str_iterator(char const *data, - long step) + inline const_sliced_str_iterator::const_sliced_str_iterator(char const *data, long step) : data(data), step(step) { } @@ -39,20 +38,17 @@ namespace types return *this; } - inline bool const_sliced_str_iterator::operator<( - const_sliced_str_iterator const &other) const + inline bool const_sliced_str_iterator::operator<(const_sliced_str_iterator const &other) const { return (step > 0) ? (data < other.data) : (data > other.data); } - inline bool const_sliced_str_iterator::operator==( - const_sliced_str_iterator const &other) const + inline bool const_sliced_str_iterator::operator==(const_sliced_str_iterator const &other) const { return data == other.data; } - inline bool const_sliced_str_iterator::operator!=( - const_sliced_str_iterator const &other) const + inline bool const_sliced_str_iterator::operator!=(const_sliced_str_iterator const &other) const { return data != other.data; } @@ -62,16 +58,14 @@ namespace types return (*data); } - inline const_sliced_str_iterator - const_sliced_str_iterator::operator-(long n) const + inline const_sliced_str_iterator const_sliced_str_iterator::operator-(long n) const { const_sliced_str_iterator other(*this); other.data -= step * n; return other; } - inline long const_sliced_str_iterator::operator-( - const_sliced_str_iterator const &other) const + inline long const_sliced_str_iterator::operator-(const_sliced_str_iterator const &other) const { return (data - other.data) / step; } @@ -84,21 +78,18 @@ namespace types } template - sliced_str::sliced_str(sliced_str const &s) - : data(s.data), slicing(s.slicing) + sliced_str::sliced_str(sliced_str const &s) : data(s.data), slicing(s.slicing) { } template - sliced_str::sliced_str(sliced_str const &s, - typename S::normalized_type const &sl) + sliced_str::sliced_str(sliced_str const &s, typename S::normalized_type const &sl) : data(s.data), slicing(s.slicing * sl) { } template - sliced_str::sliced_str(str const &other, - typename S::normalized_type const &s) + sliced_str::sliced_str(str const &other, typename S::normalized_type const &s) : data(other.data), slicing(s) { } @@ -120,15 +111,13 @@ namespace types template typename sliced_str::const_iterator sliced_str::begin() const { - return typename sliced_str::const_iterator(data->c_str() + slicing.lower, - slicing.step); + return typename sliced_str::const_iterator(data->c_str() + slicing.lower, slicing.step); } template typename sliced_str::const_iterator sliced_str::end() const { - return typename sliced_str::const_iterator(data->c_str() + slicing.upper, - slicing.step); + return typename sliced_str::const_iterator(data->c_str() + slicing.upper, slicing.step); } // size @@ -156,8 +145,7 @@ namespace types template template - typename std::enable_if::value, sliced_str>::type - sliced_str::operator[](Sp const &s) const + std::enable_if_t::value, sliced_str> sliced_str::operator[](Sp const &s) const { return {*this, s.normalize(size())}; } @@ -206,8 +194,7 @@ namespace types { if (size() != v.size()) return false; - for (char const *iter = data->c_str() + slicing.lower, - *end = data->c_str() + slicing.upper, + for (char const *iter = data->c_str() + slicing.lower, *end = data->c_str() + slicing.upper, *oter = v.data->c_str(); iter < end; iter += slicing.step, ++oter) if (*iter != *oter) @@ -369,8 +356,7 @@ namespace types if (other_size > size()) resize(other_size); - for (long i = other_slice.lower; i < other_slice.upper; - i = i + other_slice.step, j++) + for (long i = other_slice.lower; i < other_slice.upper; i = i + other_slice.step, j++) my_data[j] = other_data[i]; if (j < size()) resize(j); @@ -525,8 +511,7 @@ namespace types { if (size() != other.size()) return false; - for (long i = other.get_slice().lower, j = 0L; j < size(); - i = i + other.get_slice().step, j++) + for (long i = other.get_slice().lower, j = 0L; j < size(); i = i + other.get_slice().step, j++) if (other.get_data()[i] != chars()[j]) return false; return true; @@ -537,8 +522,7 @@ namespace types } template - typename std::enable_if::value, sliced_str>::type - str::operator()(S const &s) const + std::enable_if_t::value, sliced_str> str::operator()(S const &s) const { return operator[](s); } @@ -556,8 +540,7 @@ namespace types } template - typename std::enable_if::value, sliced_str>::type - str::operator[](S const &s) const + std::enable_if_t::value, sliced_str> str::operator[](S const &s) const { return {*this, s.normalize(size())}; } @@ -689,8 +672,7 @@ namespace operator_ { template - auto mod(const char (&fmt)[N], - Arg &&arg) -> decltype(types::str(fmt) % std::forward(arg)) + auto mod(const char (&fmt)[N], Arg &&arg) -> decltype(types::str(fmt) % std::forward(arg)) { return types::str(fmt) % std::forward(arg); } @@ -717,14 +699,12 @@ PYTHONIC_NS_END namespace std { - inline size_t - hash::operator()(const pythonic::types::str &x) const + inline size_t hash::operator()(const pythonic::types::str &x) const { return hash()(x.chars()); } - inline size_t - hash::operator()(const pythonic::types::chr &x) const + inline size_t hash::operator()(const pythonic::types::chr &x) const { return x.c; } @@ -739,13 +719,26 @@ namespace std #ifndef PyString_FromStringAndSize #define PyString_FromStringAndSize PyUnicode_FromStringAndSize +#endif +#ifdef Py_LIMITED_API +#define PyString_Check(x) \ + (PyUnicode_Check(x) && [x]() { \ + PyObject *tmp = PyUnicode_AsASCIIString(x); \ + bool res = tmp != nullptr; \ + Py_DECREF(tmp); \ + PyErr_Clear(); \ + return res; \ + }()) +#else #ifndef PyString_Check -#define PyString_Check(x) PyUnicode_Check(x) && PyUnicode_IS_COMPACT_ASCII(x) +#define PyString_Check(x) (PyUnicode_Check(x) && PyUnicode_IS_COMPACT_ASCII(x)) #endif -#ifndef PyString_AS_STRING -#define PyString_AS_STRING (char *)_PyUnicode_COMPACT_DATA #endif + +#ifdef Py_LIMITED_API +#define PyString_GET_SIZE PyUnicode_GetLength +#else #ifndef PyString_GET_SIZE #define PyString_GET_SIZE PyUnicode_GET_LENGTH #endif @@ -764,8 +757,7 @@ inline PyObject *to_python::convert(types::chr const &v) } template -PyObject * -to_python>::convert(types::sliced_str const &v) +PyObject *to_python>::convert(types::sliced_str const &v) { return ::to_python(types::str(v)); } diff --git a/contrib/python/pythran/pythran/pythonic/types/tuple.hpp b/contrib/python/pythran/pythran/pythonic/types/tuple.hpp index a91670a2f1c..10222a7fbef 100644 --- a/contrib/python/pythran/pythran/pythonic/types/tuple.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/tuple.hpp @@ -51,11 +51,9 @@ std::tuple operator+(std::tuple const &t0, } template -std::tuple operator+(std::tuple &&t0, - std::tuple &&t1) +std::tuple operator+(std::tuple &&t0, std::tuple &&t1) { - return std::tuple_cat(std::forward(t0), - std::forward(t1)); + return std::tuple_cat(std::forward(t0), std::forward(t1)); } PYTHONIC_NS_BEGIN @@ -69,12 +67,11 @@ namespace types template std::tuple tuple_tail(std::tuple const &t) { - return make_tuple_tail<0>(t, - utils::make_index_sequence{}); + return make_tuple_tail<0>(t, std::make_index_sequence{}); } template - array_base array_to_array(A const &a, utils::index_sequence) + array_base array_to_array(A const &a, std::index_sequence) { return {(T)std::get(a)...}; } @@ -120,8 +117,7 @@ namespace types } template - typename array_base::const_iterator - array_base::begin() const noexcept + typename array_base::const_iterator array_base::begin() const noexcept { return {data()}; } @@ -133,79 +129,68 @@ namespace types } template - typename array_base::const_iterator - array_base::end() const noexcept + typename array_base::const_iterator array_base::end() const noexcept { return {data() + N}; } template - typename array_base::reverse_iterator - array_base::rbegin() noexcept + typename array_base::reverse_iterator array_base::rbegin() noexcept { return reverse_iterator(end()); } template - typename array_base::const_reverse_iterator - array_base::rbegin() const noexcept + typename array_base::const_reverse_iterator array_base::rbegin() const noexcept { return const_reverse_iterator(end()); } template - typename array_base::reverse_iterator - array_base::rend() noexcept + typename array_base::reverse_iterator array_base::rend() noexcept { return reverse_iterator(begin()); } template - typename array_base::const_reverse_iterator - array_base::rend() const noexcept + typename array_base::const_reverse_iterator array_base::rend() const noexcept { return const_reverse_iterator(begin()); } template - typename array_base::const_iterator - array_base::cbegin() const noexcept + typename array_base::const_iterator array_base::cbegin() const noexcept { return {&(buffer[0])}; } template - typename array_base::const_iterator - array_base::cend() const noexcept + typename array_base::const_iterator array_base::cend() const noexcept { return {&(buffer[N])}; } template - typename array_base::const_reverse_iterator - array_base::crbegin() const noexcept + typename array_base::const_reverse_iterator array_base::crbegin() const noexcept { return const_reverse_iterator(end()); } template - typename array_base::const_reverse_iterator - array_base::crend() const noexcept + typename array_base::const_reverse_iterator array_base::crend() const noexcept { return const_reverse_iterator(begin()); } // Capacity. template - constexpr typename array_base::size_type - array_base::size() const noexcept + constexpr typename array_base::size_type array_base::size() const noexcept { return N; } template - constexpr typename array_base::size_type - array_base::max_size() const noexcept + constexpr typename array_base::size_type array_base::max_size() const noexcept { return N; } @@ -225,8 +210,7 @@ namespace types } template - typename array_base::const_reference - array_base::fast(long n) const noexcept + typename array_base::const_reference array_base::fast(long n) const noexcept { assert(n < (long)size()); return buffer[n]; @@ -235,16 +219,14 @@ namespace types #ifdef USE_XSIMD template template - typename array_base::simd_iterator - array_base::vbegin(vectorizer) const + typename array_base::simd_iterator array_base::vbegin(vectorizer) const { return {&buffer[0]}; } template template - typename array_base::simd_iterator - array_base::vend(vectorizer) const + typename array_base::simd_iterator array_base::vend(vectorizer) const { using vector_type = typename xsimd::batch; static const std::size_t vector_size = vector_type::size; @@ -253,8 +235,7 @@ namespace types #endif template - typename array_base::reference - array_base::operator[](long __n) + typename array_base::reference array_base::operator[](long __n) { auto const index = __n < 0 ? (__n + size()) : __n; assert(0 <= index && index < size()); @@ -277,8 +258,7 @@ namespace types } template - typename array_base::const_reference - array_base::front() const + typename array_base::const_reference array_base::front() const { return *begin(); } @@ -290,8 +270,7 @@ namespace types } template - typename array_base::const_reference - array_base::back() const + typename array_base::const_reference array_base::back() const { return N ? *(end() - 1) : *end(); } @@ -303,8 +282,7 @@ namespace types } template - typename array_base::const_pointer - array_base::data() const noexcept + typename array_base::const_pointer array_base::data() const noexcept { return &(buffer[0]); } @@ -327,8 +305,7 @@ namespace types template bool array_base::operator<(array_base const &other) const { - return std::lexicographical_compare(begin(), end(), other.begin(), - other.end()); + return std::lexicographical_compare(begin(), end(), other.begin(), other.end()); } template @@ -345,23 +322,22 @@ namespace types template array_base::operator std::tuple() const { - return array_to_tuple(*this, utils::make_index_sequence{}, + return array_to_tuple(*this, std::make_index_sequence{}, typename utils::type_sequence{}); } template template array_base::operator array_base() const { - return array_to_array(*this, utils::make_index_sequence{}); + return array_to_array(*this, std::make_index_sequence{}); } template auto array_base::to_tuple() const - -> decltype(array_to_tuple(*this, utils::make_index_sequence{}, + -> decltype(array_to_tuple(*this, std::make_index_sequence{}, utils::make_repeated_type())) { - return array_to_tuple(*this, utils::make_index_sequence{}, - utils::make_repeated_type()); + return array_to_tuple(*this, std::make_index_sequence{}, utils::make_repeated_type()); } template @@ -373,8 +349,7 @@ namespace types /* array */ template - std::ostream &operator<<(std::ostream &os, - types::array_base const &v) + std::ostream &operator<<(std::ostream &os, types::array_base const &v) { os << "(["[std::is_same::value]; auto iter = v.begin(); @@ -387,24 +362,21 @@ namespace types } template - auto operator+(std::tuple const &t, - types::array_base const <) + auto operator+(std::tuple const &t, types::array_base const <) -> decltype(std::tuple_cat(t, lt.to_tuple())) { return std::tuple_cat(t, lt.to_tuple()); } template - auto operator+(types::array_base const <, - std::tuple const &t) + auto operator+(types::array_base const <, std::tuple const &t) -> decltype(std::tuple_cat(lt.to_tuple(), t)) { return std::tuple_cat(lt.to_tuple(), t); } template - dynamic_tuple array_base_slicer::operator()(array_tuple const &b, - slice const &s) + dynamic_tuple array_base_slicer::operator()(array_tuple const &b, slice const &s) { normalized_slice ns = s.normalize(b.size()); array_tuple tmp; @@ -450,22 +422,18 @@ namespace } template - size_t - hash_impl::operator()(size_t a, - const std::tuple &t) const + size_t hash_impl::operator()(size_t a, const std::tuple &t) const { - using nexttype = - typename std::tuple_element>::type; + using nexttype = std::tuple_element_t>; hash_impl next; size_t b = std::hash()(std::get(t)); return next(hash_combiner(a, b), t); } template - size_t hash_impl<0, types...>::operator()(size_t a, - const std::tuple &t) const + size_t hash_impl<0, types...>::operator()(size_t a, const std::tuple &t) const { - using nexttype = typename std::tuple_element<0, std::tuple>::type; + using nexttype = std::tuple_element_t<0, std::tuple>; size_t b = std::hash()(std::get<0>(t)); return hash_combiner(a, b); } @@ -475,8 +443,7 @@ namespace namespace std { template - size_t - hash>::operator()(std::tuple const &t) const + size_t hash>::operator()(std::tuple const &t) const { const size_t begin = std::tuple_size>::value - 1; return hash_impl()(1, t); // 1 should be some largervalue @@ -519,8 +486,7 @@ namespace std ostream &operator<<(ostream &os, tuple const &t) { os << '('; - pythonic::types::print_tuple(os, t, - pythonic::utils::int_()); + pythonic::types::print_tuple(os, t, pythonic::utils::int_()); return os << ')'; } } // namespace std @@ -532,6 +498,11 @@ namespace std PYTHONIC_NS_BEGIN +#ifdef Py_LIMITED_API +#define PyTuple_SET_ITEM PyTuple_SetItem +#define PyList_SET_ITEM PyList_SetItem +#endif + template PyObject *to_python>::convert(std::pair const &t) { @@ -542,8 +513,7 @@ PyObject *to_python>::convert(std::pair const &t) } template -PyObject * -to_python>::convert(types::pshape const &t) +PyObject *to_python>::convert(types::pshape const &t) { return ::to_python(t.array()); } @@ -552,7 +522,7 @@ template template PyObject *to_python>:: - do_convert(std::tuple const &t, utils::index_sequence) + do_convert(std::tuple const &t, std::index_sequence) { PyObject *out = PyTuple_New(sizeof...(Types)); (void)std::initializer_list{ @@ -561,16 +531,15 @@ PyObject *to_python>:: } template -PyObject * -to_python>::convert(std::tuple const &t) +PyObject *to_python>::convert(std::tuple const &t) { - return do_convert(t, utils::make_index_sequence()); + return do_convert(t, std::make_index_sequence()); } template template -PyObject *to_python>::do_convert( - types::array_tuple const &t, utils::index_sequence) +PyObject *to_python>::do_convert(types::array_tuple const &t, + std::index_sequence) { PyObject *out = PyTuple_New(N); (void)std::initializer_list{ @@ -580,8 +549,8 @@ PyObject *to_python>::do_convert( template template -PyObject *to_python>::do_convert( - types::static_list const &t, utils::index_sequence) +PyObject *to_python>::do_convert(types::static_list const &t, + std::index_sequence) { PyObject *out = PyList_New(N); (void)std::initializer_list{ @@ -590,40 +559,44 @@ PyObject *to_python>::do_convert( } template -PyObject * -to_python>::convert(types::array_tuple const &t) +PyObject *to_python>::convert(types::array_tuple const &t) { - return do_convert(t, utils::make_index_sequence()); + return do_convert(t, std::make_index_sequence()); } template -PyObject * -to_python>::convert(types::static_list const &t) +PyObject *to_python>::convert(types::static_list const &t) { - return do_convert(t, utils::make_index_sequence()); + return do_convert(t, std::make_index_sequence()); } template template bool from_python> - ::do_is_convertible(PyObject *obj, typename utils::index_sequence) + ::do_is_convertible(PyObject *obj, typename std::index_sequence) { - bool checks[] = {::is_convertible< - typename std::tuple_element>::type>( - PyTuple_GET_ITEM(obj, S))...}; - return std::find(std::begin(checks), std::end(checks), false) == - std::end(checks); + bool checks[] = {::is_convertible>>( +#ifdef Py_LIMITED_API + PyTuple_GetItem(obj, S) +#else + PyTuple_GET_ITEM(obj, S) +#endif + )...}; + return std::find(std::begin(checks), std::end(checks), false) == std::end(checks); } template bool from_python>::is_convertible(PyObject *obj) { if (PyTuple_Check(obj)) { +#ifdef Py_LIMITED_API + auto n = PyTuple_Size(obj); +#else auto n = PyTuple_GET_SIZE(obj); +#endif if (n == sizeof...(Types)) { - return do_is_convertible(obj, - utils::make_index_sequence()); + return do_is_convertible(obj, std::make_index_sequence()); } } return false; @@ -631,17 +604,21 @@ bool from_python>::is_convertible(PyObject *obj) template template -std::tuple from_python>::do_convert( - PyObject *obj, typename utils::index_sequence) +std::tuple +from_python>::do_convert(PyObject *obj, typename std::index_sequence) { - return std::tuple{ - ::from_python>::type>( - PyTuple_GET_ITEM(obj, S))...}; + return std::tuple{::from_python>>( +#ifdef Py_LIMITED_API + PyTuple_GetItem(obj, S) +#else + PyTuple_GET_ITEM(obj, S) +#endif + )...}; } template std::tuple from_python>::convert(PyObject *obj) { - return do_convert(obj, utils::make_index_sequence()); + return do_convert(obj, std::make_index_sequence()); } template @@ -650,9 +627,19 @@ bool from_python>:: is_convertible(PyObject *obj) { if (PyTuple_Check(obj)) { +#ifdef Py_LIMITED_API + auto n = PyTuple_Size(obj); +#else auto n = PyTuple_GET_SIZE(obj); +#endif if (n == N) { - return ::is_convertible(PyTuple_GET_ITEM(obj, 0)); + return ::is_convertible( +#ifdef Py_LIMITED_API + PyTuple_GetItem(obj, 0) +#else + PyTuple_GET_ITEM(obj, 0) +#endif + ); } } return false; @@ -660,18 +647,29 @@ bool from_python>:: template template -types::array_tuple from_python>::do_convert( - PyObject *obj, typename utils::index_sequence) +types::array_tuple +from_python>::do_convert(PyObject *obj, typename std::index_sequence) { - return {::from_python(PyTuple_GET_ITEM(obj, S))...}; + return {::from_python( +#ifdef Py_LIMITED_API + PyTuple_GetItem(obj, S) +#else + PyTuple_GET_ITEM(obj, S) +#endif + )...}; } template types::array_tuple from_python>:: convert(PyObject *obj) { - return do_convert(obj, utils::make_index_sequence()); + return do_convert(obj, std::make_index_sequence()); } + +#ifdef Py_LIMITED_API +#undef PyTuple_SET_ITEM +#undef PyList_SET_ITEM +#endif PYTHONIC_NS_END #endif diff --git a/contrib/python/pythran/pythran/pythonic/types/type.hpp b/contrib/python/pythran/pythran/pythonic/types/type.hpp new file mode 100644 index 00000000000..97e75c467bc --- /dev/null +++ b/contrib/python/pythran/pythran/pythonic/types/type.hpp @@ -0,0 +1,161 @@ +#ifndef PYTHONIC_TYPES_TYPE_HPP +#define PYTHONIC_TYPES_TYPE_HPP + +#include "pythonic/include/types/type.hpp" + +#include "pythonic/builtins/bool_.hpp" +#include "pythonic/builtins/complex.hpp" +#include "pythonic/builtins/dict.hpp" +#include "pythonic/builtins/float_.hpp" +#include "pythonic/builtins/int_.hpp" +#include "pythonic/builtins/list.hpp" +#include "pythonic/builtins/set.hpp" +#include "pythonic/builtins/slice.hpp" +#include "pythonic/builtins/str.hpp" +#include "pythonic/builtins/tuple.hpp" +#include "pythonic/numpy/array.hpp" +#include "pythonic/numpy/byte.hpp" +#include "pythonic/numpy/complex256.hpp" +#include "pythonic/numpy/complex64.hpp" +#include "pythonic/numpy/float128.hpp" +#include "pythonic/numpy/float32.hpp" +#include "pythonic/numpy/int_.hpp" +#include "pythonic/numpy/intc.hpp" +#include "pythonic/numpy/longlong.hpp" +#include "pythonic/numpy/short_.hpp" +#include "pythonic/numpy/ubyte.hpp" +#include "pythonic/numpy/uint.hpp" +#include "pythonic/numpy/uintc.hpp" +#include "pythonic/numpy/ulonglong.hpp" +#include "pythonic/numpy/ushort.hpp" + +PYTHONIC_NS_BEGIN + +namespace types +{ + template <> + struct type_functor { + using type = builtins::functor::bool_; + }; + template <> + struct type_functor { + using type = builtins::functor::float_; + }; + template <> + struct type_functor { + using type = builtins::functor::str; + }; + template <> + struct type_functor> { + using type = numpy::functor::complex64; + }; + template <> + struct type_functor> { + using type = builtins::functor::complex; + }; + template <> + struct type_functor> { + using type = numpy::functor::complex256; + }; + template <> + struct type_functor { + using type = builtins::functor::set; + }; + template + struct type_functor> { + using type = builtins::functor::set; + }; + template <> + struct type_functor { + using type = builtins::functor::slice; + }; + template <> + struct type_functor { + using type = builtins::functor::list; + }; + template + struct type_functor> { + using type = builtins::functor::list; + }; + template + struct type_functor> { + using type = builtins::functor::list; + }; + template <> + struct type_functor { + using type = builtins::functor::dict; + }; + template + struct type_functor> { + using type = builtins::functor::dict; + }; + template + struct type_functor> { + using type = builtins::functor::tuple; + }; + template + struct type_functor> { + using type = builtins::functor::tuple; + }; + template + struct type_functor> { + using type = numpy::functor::array; + }; + template <> + struct type_functor { + using type = numpy::functor::byte; + }; + template <> + struct type_functor { + using type = numpy::functor::ubyte; + }; + template <> + struct type_functor { + using type = numpy::functor::short_; + }; + template <> + struct type_functor { + using type = numpy::functor::ushort; + }; + template <> + struct type_functor { + using type = numpy::functor::intc; + }; + template <> + struct type_functor { + using type = numpy::functor::uintc; + }; + template <> + struct type_functor { + using type = numpy::functor::int_; + }; + template <> + struct type_functor { + using type = numpy::functor::uint; + }; + template <> + struct type_functor { + using type = numpy::functor::longlong; + }; + template <> + struct type_functor { + using type = numpy::functor::ulonglong; + }; + template <> + struct type_functor { + using type = numpy::functor::float32; + }; + template <> + struct type_functor { + using type = numpy::functor::float128; + }; + + template + typename type_functor::type type(T const &) + { + return {}; + } +} // namespace types +PYTHONIC_NS_END + +#endif diff --git a/contrib/python/pythran/pythran/pythonic/types/variant_functor.hpp b/contrib/python/pythran/pythran/pythonic/types/variant_functor.hpp index 75dfcd11f11..bab78c4a5b1 100644 --- a/contrib/python/pythran/pythran/pythonic/types/variant_functor.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/variant_functor.hpp @@ -23,15 +23,13 @@ namespace types template template - variant_functor_impl::variant_functor_impl(char mem[], - OtherType const &t) - : fun(nullptr) + variant_functor_impl::variant_functor_impl(char mem[], OtherType const &t) : fun(nullptr) { } template - variant_functor_impl::variant_functor_impl( - char mem[], variant_functor_impl const &t) + variant_functor_impl::variant_functor_impl(char mem[], + variant_functor_impl const &t) : fun(t.fun ? new(mem) Type(*t.fun) : nullptr) { } @@ -53,9 +51,7 @@ namespace types } template - void - variant_functor_impl::assign(char mem[], - variant_functor_impl const &other) + void variant_functor_impl::assign(char mem[], variant_functor_impl const &other) { if (fun != nullptr) fun->~Type(); @@ -63,16 +59,16 @@ namespace types fun = new (mem) Type(*other.fun); } template - void variant_functor_impl::assign(char mem[], - variant_functor const &other) + void variant_functor_impl::assign(char mem[], variant_functor const &other) { assign(mem, static_cast const &>(other)); } template template - void variant_functor_impl::assign( - char mem[], variant_functor_impl const &other) + void + variant_functor_impl::assign(char mem[], + variant_functor_impl const &other) { assign(mem, other.head); assign(mem, other.tail); @@ -80,26 +76,22 @@ namespace types template template - void variant_functor_impl::assign( - char mem[], variant_functor const &other) + void variant_functor_impl::assign(char mem[], + variant_functor const &other) { - assign(mem, - static_cast const &>( - other)); + assign(mem, static_cast const &>(other)); } template template - void variant_functor_impl::assign( - char mem[], variant_functor_impl const &other) + void variant_functor_impl::assign(char mem[], + variant_functor_impl const &other) { } template template - void - variant_functor_impl::assign(char mem[], - variant_functor const &other) + void variant_functor_impl::assign(char mem[], variant_functor const &other) { } @@ -144,8 +136,7 @@ namespace types template template - variant_functor_impl::variant_functor_impl( - char mem[], OtherTypes const &...t) + variant_functor_impl::variant_functor_impl(char mem[], OtherTypes const &...t) : head(mem, t...), tail(mem, t...) { } @@ -159,8 +150,9 @@ namespace types } template - void variant_functor_impl::assign( - char mem[], variant_functor_impl const &other) + void + variant_functor_impl::assign(char mem[], + variant_functor_impl const &other) { head.assign(mem, other); tail.assign(mem, other); @@ -168,8 +160,7 @@ namespace types template template - void variant_functor_impl::assign(char mem[], - OtherType const &other) + void variant_functor_impl::assign(char mem[], OtherType const &other) { head.assign(mem, other); tail.assign(mem, other); @@ -178,10 +169,8 @@ namespace types template template auto variant_functor_impl::operator()(Args &&...args) -> - typename __combined< - decltype(std::declval()(std::forward(args)...)), - decltype(std::declval()( - std::forward(args)...))...>::type + typename __combined()(std::forward(args)...)), + decltype(std::declval()(std::forward(args)...))...>::type { if (head.fun) return head(std::forward(args)...); @@ -191,12 +180,9 @@ namespace types template template - auto - variant_functor_impl::operator()(Args &&...args) const -> - typename __combined< - decltype(std::declval()(std::forward(args)...)), - decltype(std::declval()( - std::forward(args)...))...>::type + auto variant_functor_impl::operator()(Args &&...args) const -> + typename __combined()(std::forward(args)...)), + decltype(std::declval()(std::forward(args)...))...>::type { if (head.fun) return head(std::forward(args)...); @@ -208,8 +194,7 @@ namespace types template variant_functor::variant_functor(variant_functor const &other) : details::variant_functor_impl( - mem, - static_cast const &>(other)) + mem, static_cast const &>(other)) { } @@ -223,8 +208,8 @@ namespace types template template - variant_functor &variant_functor::operator=( - variant_functor const &other) + variant_functor & + variant_functor::operator=(variant_functor const &other) { details::variant_functor_impl::assign(mem, other); return *this; @@ -232,12 +217,10 @@ namespace types template template - variant_functor & - variant_functor::operator=(OtherType const &other) + variant_functor &variant_functor::operator=(OtherType const &other) { - static_assert( - utils::any_of::value...>::value, - "consistent assign"); + static_assert(utils::any_of::value...>::value, + "consistent assign"); details::variant_functor_impl::assign(mem, other); return *this; } @@ -251,12 +234,9 @@ namespace types template template - variant_functor::variant_functor( - variant_functor const &t) + variant_functor::variant_functor(variant_functor const &t) : details::variant_functor_impl( - mem, - static_cast const &>( - t)) + mem, static_cast const &>(t)) { } } // namespace types diff --git a/contrib/python/pythran/pythran/pythonic/types/vectorizable_type.hpp b/contrib/python/pythran/pythran/pythonic/types/vectorizable_type.hpp index 01f61e462ce..1860cc53eb5 100644 --- a/contrib/python/pythran/pythran/pythonic/types/vectorizable_type.hpp +++ b/contrib/python/pythran/pythran/pythonic/types/vectorizable_type.hpp @@ -108,9 +108,8 @@ namespace types static const bool value = !std::is_same::value && (!std::is_same::value || - utils::all_of()( - std::declval()...))>::value...>::value) && + utils::all_of()( + std::declval()...))>::value...>::value) && !std::is_same::value && // Return type for generic function should be generic !std::is_same::value && @@ -131,8 +130,7 @@ namespace types !std::is_same::value && !std::is_same::value && // not supported for complex numbers - !(utils::any_of< - is_complex::type>::value...>::value && + !(utils::any_of::type>::value...>::value && (std::is_same::value || std::is_same::value || std::is_same::value || @@ -150,8 +148,7 @@ namespace types !std::is_same::value && !std::is_same::value && // not supported for integral numbers - !(utils::any_of::type>::value...>::value && + !(utils::any_of::type>::value...>::value && (std::is_same::value || std::is_same::value || std::is_same::value || diff --git a/contrib/python/pythran/pythran/pythonic/utils/array_helper.hpp b/contrib/python/pythran/pythran/pythonic/utils/array_helper.hpp index 35d5352c9e1..94d79953416 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/array_helper.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/array_helper.hpp @@ -24,8 +24,7 @@ template auto nget::fast(A &&self, types::array_tuple const &indices) -> decltype(nget().fast(std::forward(self).fast(0), indices)) { - return nget().fast(std::forward(self).fast(indices[M - L - 1]), - indices); + return nget().fast(std::forward(self).fast(indices[M - L - 1]), indices); } template diff --git a/contrib/python/pythran/pythran/pythonic/utils/broadcast_copy.hpp b/contrib/python/pythran/pythran/pythonic/utils/broadcast_copy.hpp index d892e4d580d..d63546e30ed 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/broadcast_copy.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/broadcast_copy.hpp @@ -43,21 +43,18 @@ namespace utils template <> struct _broadcast_copy { - template - void helper(E &&self, F const &other, SelfIndices &&self_indices, - OtherIndices &&other_indices, utils::index_sequence) + template + void helper(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices, + std::index_sequence) { std::forward(self).store( - (typename std::decay::type::dtype)other.load( - (long)std::get(other_indices)...), + (typename std::decay_t::dtype)other.load((long)std::get(other_indices)...), (long)std::get(self_indices)...); } template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template @@ -65,8 +62,7 @@ namespace utils OtherIndices &&other_indices) { helper(std::forward(self), other, self_indices, other_indices, - utils::make_index_sequence::type>::value>()); + std::make_index_sequence>::value>()); } }; template @@ -74,28 +70,23 @@ namespace utils template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template void operator()(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices) { - long const other_size = - other.template shape::type::value - N>(); - long const self_size = - self.template shape::type::value - N>(); + long const other_size = other.template shape::type::value - N>(); + long const self_size = self.template shape::type::value - N>(); if (self_size == other_size) for (long i = 0; i < self_size; ++i) _broadcast_copy{}( - std::forward(self), other, - std::tuple_cat(self_indices, std::make_tuple(i)), + std::forward(self), other, std::tuple_cat(self_indices, std::make_tuple(i)), std::tuple_cat(other_indices, std::make_tuple(i))); else for (long i = 0; i < self_size; ++i) _broadcast_copy{}( - std::forward(self), other, - std::tuple_cat(self_indices, std::make_tuple(i)), + std::forward(self), other, std::tuple_cat(self_indices, std::make_tuple(i)), std::tuple_cat(other_indices, std::make_tuple(0))); } }; @@ -105,21 +96,18 @@ namespace utils template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template void operator()(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices) { - using broadcaster = typename std::conditional< - types::is_dtype::value, - types::broadcast::type::dtype>, - types::broadcasted>::type; - _broadcast_copy{}( - std::forward(self), broadcaster(other), - std::forward(self_indices), - std::forward(other_indices)); + using broadcaster = std::conditional_t::value, + types::broadcast::dtype>, + types::broadcasted>; + _broadcast_copy{}(std::forward(self), broadcaster(other), + std::forward(self_indices), + std::forward(other_indices)); } }; @@ -179,8 +167,7 @@ namespace utils const long other_size = other.size(); const long vbound = other_size / vN; - for (auto iter = vectorizer::vbegin(self), end = iter + vbound; iter != end; - ++iter, ++oiter) { + for (auto iter = vectorizer::vbegin(self), end = iter + vbound; iter != end; ++iter, ++oiter) { iter.store(*oiter); } @@ -212,8 +199,7 @@ namespace utils template void operator()(E &&self, F const &other) { - return vbroadcast_copy( - std::forward(self), other); + return vbroadcast_copy(std::forward(self), other); } }; @@ -243,8 +229,7 @@ namespace utils }; template - E &broadcast_copy_helper(E &self, F const &other, - std::integral_constant, + E &broadcast_copy_helper(E &self, F const &other, std::integral_constant, std::integral_constant) { static_assert(D >= 0, "downcasting already happened"); @@ -261,8 +246,7 @@ namespace utils } template - E &broadcast_copy_helper(E &self, F const &other, - std::integral_constant, + E &broadcast_copy_helper(E &self, F const &other, std::integral_constant, std::integral_constant) { if (D == 0) { @@ -270,14 +254,12 @@ namespace utils return self; } else { return broadcast_copy_helper( - self, other, std::integral_constant(), - std::integral_constant{}); + self, other, std::integral_constant(), std::integral_constant{}); } } template - E &broadcast_copy_helper(E &self, F const &other, - std::integral_constant, + E &broadcast_copy_helper(E &self, F const &other, std::integral_constant, std::integral_constant is_plain) { auto reshaped = other.reshape(sutils::getshape(self)); @@ -298,10 +280,8 @@ namespace utils E &broadcast_copy(E &self, F const &other) { return broadcast_copy_helper( - self, other, std::integral_constant= 0)>(), - std::integral_constant < bool, - std::decay::type::is_flat - &&is_flat::type>::value > {}); + self, other, std::integral_constant= 0)>(), std::integral_constant < bool, + std::decay::type::is_flat &&is_flat>::value > {}); } /* update @@ -359,10 +339,9 @@ namespace utils template struct _broadcast_update { - template - void helper(E &&self, F const &other, SelfIndices &&self_indices, - OtherIndices &&other_indices, utils::index_sequence) + template + void helper(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices, + std::index_sequence) { self.template update(other.load((long)std::get(other_indices)...), (long)std::get(self_indices)...); @@ -370,8 +349,7 @@ namespace utils template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template @@ -379,8 +357,7 @@ namespace utils OtherIndices &&other_indices) { helper(std::forward(self), other, self_indices, other_indices, - utils::make_index_sequence::type>::value>()); + std::make_index_sequence>::value>()); } }; @@ -389,28 +366,23 @@ namespace utils template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template void operator()(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices) { - auto const other_size = - other.template shape::type::value - N>(); - auto const self_size = - self.template shape::type::value - N>(); + auto const other_size = other.template shape::type::value - N>(); + auto const self_size = self.template shape::type::value - N>(); if (self_size == other_size) for (long i = 0; i < self_size; ++i) _broadcast_update{}( - std::forward(self), other, - std::tuple_cat(self_indices, std::make_tuple(i)), + std::forward(self), other, std::tuple_cat(self_indices, std::make_tuple(i)), std::tuple_cat(other_indices, std::make_tuple(i))); else for (long i = 0; i < self_size; ++i) _broadcast_update{}( - std::forward(self), other, - std::tuple_cat(self_indices, std::make_tuple(i)), + std::forward(self), other, std::tuple_cat(self_indices, std::make_tuple(i)), std::tuple_cat(other_indices, std::make_tuple(0))); } }; @@ -419,20 +391,17 @@ namespace utils template void operator()(E &&self, F const &other) { - return (*this)(std::forward(self), other, std::tuple<>(), - std::tuple<>()); + return (*this)(std::forward(self), other, std::tuple<>(), std::tuple<>()); } template void operator()(E &&self, F const &other, SelfIndices &&self_indices, OtherIndices &&other_indices) { - using broadcaster = typename std::conditional< - types::is_dtype::value, - types::broadcast::type::dtype>, - types::broadcasted>::type; + using broadcaster = std::conditional_t::value, + types::broadcast::dtype>, + types::broadcasted>; _broadcast_update{}( - std::forward(self), broadcaster(other), - std::forward(self_indices), + std::forward(self), broadcaster(other), std::forward(self_indices), std::forward(other_indices)); } }; @@ -493,8 +462,7 @@ namespace utils template void operator()(Args &&...args) { - vbroadcast_update( - std::forward(args)...); + vbroadcast_update(std::forward(args)...); } }; @@ -517,8 +485,7 @@ namespace utils void operator()(E &self, F const &other) { if (utils::no_broadcast_vectorize(other)) - _broadcast_update{}(self, - other); + _broadcast_update{}(self, other); else _broadcast_update{}(self, other); } diff --git a/contrib/python/pythran/pythran/pythonic/utils/iterator.hpp b/contrib/python/pythran/pythran/pythonic/utils/iterator.hpp index cda0e6b2e17..a16e2f4e761 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/iterator.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/iterator.hpp @@ -35,8 +35,7 @@ namespace utils } template - iterator_reminder::iterator_reminder( - T const &v, Others const &...others) + iterator_reminder::iterator_reminder(T const &v, Others const &...others) : values(v, others...) { } diff --git a/contrib/python/pythran/pythran/pythonic/utils/meta.hpp b/contrib/python/pythran/pythran/pythonic/utils/meta.hpp index 71bc19eed77..bdb9c4c88fd 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/meta.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/meta.hpp @@ -9,7 +9,7 @@ struct static_assert_check { static constexpr bool value = C; }; -#define pythran_static_assert(value, str, ...) \ +#define pythran_static_assert(value, str, ...) \ static_assert(static_assert_check::value, str) #endif diff --git a/contrib/python/pythran/pythran/pythonic/utils/nested_container.hpp b/contrib/python/pythran/pythran/pythonic/utils/nested_container.hpp index 2996e4e2e18..b14d4bc1371 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/nested_container.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/nested_container.hpp @@ -15,11 +15,11 @@ namespace utils long nested_container_size::flat_size(T const &t) { auto n = t.size(); - return n ? n * nested_container_size::value, bool, - typename Type::value_type>::type>::flat_size(*t.begin()) + typename Type::value_type>>::flat_size(*t.begin()) : 0; } diff --git a/contrib/python/pythran/pythran/pythonic/utils/numpy_conversion.hpp b/contrib/python/pythran/pythran/pythonic/utils/numpy_conversion.hpp index 82c1638b114..1768706303f 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/numpy_conversion.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/numpy_conversion.hpp @@ -5,28 +5,26 @@ #include "pythonic/utils/numpy_traits.hpp" #if _MSC_VER && !__clang__ -#define NUMPY_EXPR_TO_NDARRAY0_IMPL(fname) \ - template ::value && \ - types::is_numexpr_arg::value, \ - E>::type * = nullptr> \ - auto fname(E const &expr, Types &&...others) \ - { \ - return fname(types::ndarray{expr}, \ - std::forward(others)...); \ +#define NUMPY_EXPR_TO_NDARRAY0_IMPL(fname) \ + template ::value && types::is_numexpr_arg::value, E> \ + * = nullptr> \ + auto fname(E const &expr, Types &&...others) \ + { \ + return fname(types::ndarray{expr}, \ + std::forward(others)...); \ } #else -#define NUMPY_EXPR_TO_NDARRAY0_IMPL(fname) \ - template \ - auto fname(E const &expr, Types &&...others) -> \ - typename std::enable_if< \ - !types::is_ndarray::value && types::is_numexpr_arg::value, \ - decltype(fname( \ - types::ndarray{expr}, \ - std::forward(others)...))>::type \ - { \ - return fname(types::ndarray{expr}, \ - std::forward(others)...); \ +#define NUMPY_EXPR_TO_NDARRAY0_IMPL(fname) \ + template \ + auto fname(E const &expr, Types &&...others) \ + -> std::enable_if_t::value && types::is_numexpr_arg::value, \ + decltype(fname( \ + types::ndarray{expr}, \ + std::forward(others)...))> \ + { \ + return fname(types::ndarray{expr}, \ + std::forward(others)...); \ } #endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/utils/pdqsort.hpp b/contrib/python/pythran/pythran/pythonic/utils/pdqsort.hpp index 7fce8403d8d..3763327d191 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/pdqsort.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/pdqsort.hpp @@ -243,8 +243,7 @@ namespace pdqsort_detail // pivot is a median of at least 3 elements and that [begin, end) is at least // insertion_sort_threshold long. Uses branchless partitioning. template - inline std::pair partition_right_branchless(Iter begin, Iter end, - Compare comp) + inline std::pair partition_right_branchless(Iter begin, Iter end, Compare comp) { typedef typename std::iterator_traits::value_type T; @@ -346,8 +345,7 @@ namespace pdqsort_detail // Swap elements and update block sizes and first/last boundaries. int num = std::min(num_l, num_r); - swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, num, - num_l == num_r); + swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, num, num_l == num_r); num_l -= num; num_r -= num; start_l += num; @@ -359,8 +357,7 @@ namespace pdqsort_detail } int l_size = 0, r_size = 0; - int unknown_left = - (int)(last - first) - ((num_r || num_l) ? block_size : 0); + int unknown_left = (int)(last - first) - ((num_r || num_l) ? block_size : 0); if (num_r) { // Handle leftover block by assigning the unknown elements to the other // block. @@ -395,8 +392,7 @@ namespace pdqsort_detail } int num = std::min(num_l, num_r); - swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, num, - num_l == num_r); + swap_offsets(first, last, offsets_l + start_l, offsets_r + start_r, num, num_l == num_r); num_l -= num; num_r -= num; start_l += num; @@ -438,8 +434,7 @@ namespace pdqsort_detail // pivot is a median of at least 3 elements and that [begin, end) is at least // insertion_sort_threshold long. template - inline std::pair partition_right(Iter begin, Iter end, - Compare comp) + inline std::pair partition_right(Iter begin, Iter end, Compare comp) { typedef typename std::iterator_traits::value_type T; @@ -577,9 +572,8 @@ namespace pdqsort_detail } // Partition and get results. - std::pair part_result = - Branchless ? partition_right_branchless(begin, end, comp) - : partition_right(begin, end, comp); + std::pair part_result = Branchless ? partition_right_branchless(begin, end, comp) + : partition_right(begin, end, comp); Iter pivot_pos = part_result.first; bool already_partitioned = part_result.second; @@ -626,8 +620,7 @@ namespace pdqsort_detail // If we were decently balanced and we tried to sort an already // partitioned // sequence try to use insertion sort. - if (already_partitioned && - partial_insertion_sort(begin, pivot_pos, comp) && + if (already_partitioned && partial_insertion_sort(begin, pivot_pos, comp) && partial_insertion_sort(pivot_pos + 1, end, comp)) return; } @@ -635,8 +628,7 @@ namespace pdqsort_detail // Sort the left partition first using recursion and do tail recursion // elimination for // the right-hand partition. - pdqsort_loop(begin, pivot_pos, comp, - bad_allowed, leftmost); + pdqsort_loop(begin, pivot_pos, comp, bad_allowed, leftmost); begin = pivot_pos + 1; leftmost = false; } @@ -652,14 +644,12 @@ inline void pdqsort(Iter begin, Iter end, Compare comp) #if __cplusplus >= 201103L pdqsort_detail::pdqsort_loop< Iter, Compare, - pdqsort_detail::is_default_compare< - typename std::decay::type>::value && - std::is_arithmetic< - typename std::iterator_traits::value_type>::value>( + pdqsort_detail::is_default_compare>::value && + std::is_arithmetic::value_type>::value>( begin, end, comp, pdqsort_detail::log2(end - begin)); #else - pdqsort_detail::pdqsort_loop( - begin, end, comp, pdqsort_detail::log2(end - begin)); + pdqsort_detail::pdqsort_loop(begin, end, comp, + pdqsort_detail::log2(end - begin)); #endif } @@ -675,8 +665,8 @@ inline void pdqsort_branchless(Iter begin, Iter end, Compare comp) { if (begin == end) return; - pdqsort_detail::pdqsort_loop( - begin, end, comp, pdqsort_detail::log2(end - begin)); + pdqsort_detail::pdqsort_loop(begin, end, comp, + pdqsort_detail::log2(end - begin)); } template diff --git a/contrib/python/pythran/pythran/pythonic/utils/shared_ref.hpp b/contrib/python/pythran/pythran/pythonic/utils/shared_ref.hpp index 44ec82982c2..c8b7bb5ab26 100644 --- a/contrib/python/pythran/pythran/pythonic/utils/shared_ref.hpp +++ b/contrib/python/pythran/pythran/pythonic/utils/shared_ref.hpp @@ -39,8 +39,7 @@ namespace utils template template shared_ref::shared_ref(Types &&...args) - : mem(new(utils::allocate(1)) - memory(std::forward(args)...)) + : mem(new(utils::allocate(1)) memory(std::forward(args)...)) { } diff --git a/contrib/python/pythran/pythran/pythran-darwin.cfg b/contrib/python/pythran/pythran/pythran-darwin.cfg index 87aaeaf5333..240327b5a5f 100644 --- a/contrib/python/pythran/pythran/pythran-darwin.cfg +++ b/contrib/python/pythran/pythran/pythran-darwin.cfg @@ -4,7 +4,7 @@ undefs= include_dirs= libs= library_dirs= -cflags=-std=c++11 -fno-math-errno -Wno-unused-function +cflags=-std=c++14 -fno-math-errno -Wno-unused-function ldflags= blas=blas CC= diff --git a/contrib/python/pythran/pythran/pythran-default.cfg b/contrib/python/pythran/pythran/pythran-default.cfg index 01e1003edc0..950a788ea81 100644 --- a/contrib/python/pythran/pythran/pythran-default.cfg +++ b/contrib/python/pythran/pythran/pythran-default.cfg @@ -4,7 +4,7 @@ undefs= include_dirs= libs= library_dirs= -cflags=-std=c++11 +cflags=-std=c++14 ldflags= blas=blas CC= diff --git a/contrib/python/pythran/pythran/pythran-linux.cfg b/contrib/python/pythran/pythran/pythran-linux.cfg index a5ea2093d83..51c55f77e98 100644 --- a/contrib/python/pythran/pythran/pythran-linux.cfg +++ b/contrib/python/pythran/pythran/pythran-linux.cfg @@ -4,7 +4,7 @@ undefs= include_dirs= libs= library_dirs= -cflags=-std=c++11 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option +cflags=-std=c++14 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option ldflags=-fvisibility=hidden -Wl,-strip-all blas=blas CC= diff --git a/contrib/python/pythran/pythran/pythran-linux2.cfg b/contrib/python/pythran/pythran/pythran-linux2.cfg index a5ea2093d83..51c55f77e98 100644 --- a/contrib/python/pythran/pythran/pythran-linux2.cfg +++ b/contrib/python/pythran/pythran/pythran-linux2.cfg @@ -4,7 +4,7 @@ undefs= include_dirs= libs= library_dirs= -cflags=-std=c++11 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option +cflags=-std=c++14 -fno-math-errno -fvisibility=hidden -fno-wrapv -Wno-unused-function -Wno-int-in-bool-context -Wno-unknown-warning-option ldflags=-fvisibility=hidden -Wl,-strip-all blas=blas CC= diff --git a/contrib/python/pythran/pythran/pythran.cfg b/contrib/python/pythran/pythran/pythran.cfg index 3665a6e8d56..ed0885b26da 100644 --- a/contrib/python/pythran/pythran/pythran.cfg +++ b/contrib/python/pythran/pythran/pythran.cfg @@ -63,3 +63,7 @@ annotation_kind = 'comment' # make generated module compatible with freethreading, see # https://py-free-threading.github.io/ freethreading_compatible = true + +# Use limited API, see https://docs.python.org/3/c-api/stable.html#limited-c-api. +# Set to "3.7" or more to enable. +limited_api = false diff --git a/contrib/python/pythran/pythran/spec.py b/contrib/python/pythran/pythran/spec.py index 838f99ccd0e..afa07a0003b 100644 --- a/contrib/python/pythran/pythran/spec.py +++ b/contrib/python/pythran/pythran/spec.py @@ -10,7 +10,7 @@ import re import ply.lex as lex import ply.yacc as yacc -from pythran.typing import List, Set, Dict, NDArray, Tuple, Pointer, Fun +from pythran.typing import List, Set, Dict, NDArray, Tuple, Pointer, Fun, Type from pythran.syntax import PythranSyntaxError from pythran.config import cfg @@ -166,6 +166,8 @@ class SpecParser(object): 'ufunc': 'UFUNC', 'or': 'OR', 'list': 'LIST', + 'type': 'TYPE', + 'tuple': 'TUPLE', 'set': 'SET', 'dict': 'DICT', 'slice': 'SLICE', @@ -340,6 +342,8 @@ class SpecParser(object): p[0] = tuple(List[t] for t in p[1]) elif len(p) == 3 and p[2] == 'set': p[0] = tuple(Set[t] for t in p[1]) + elif len(p) == 3 and p[2] == 'type': + p[0] = tuple(Type[t] for t in p[1]) elif len(p) == 3: if p[2] is None: expanded = [] @@ -380,6 +384,7 @@ class SpecParser(object): | pointer_type | type LIST | type SET + | generic_type TYPE | type LPAREN opt_types RPAREN | type COLUMN type DICT | LPAREN types RPAREN @@ -387,6 +392,26 @@ class SpecParser(object): | type OR type ''' + def p_generic_type(self, p): + if len(p) == 2: + p[0] = {'list': list, 'set': set, 'dict': dict, 'tuple': tuple}.get(p[1], p[1]), + elif len(p) == 3 and p[2] == 'type': + p[0] = tuple(Type[t] for t in p[1]) + elif len(p) == 4 and p[2] == 'or': + p[0] = p[1] + p[3] + else: + msg = "Invalid Pythran spec. Unknown text '{0}'".format(p.value) + self.p_error(p, msg) + + p_generic_type.__doc__ = '''generic_type : term + | LIST + | SET + | generic_type TYPE + | DICT + | TUPLE + | generic_type OR generic_type + ''' + def p_opt_order(self, p): if len(p) > 1: if p[3] not in 'CF': diff --git a/contrib/python/pythran/pythran/tables.py b/contrib/python/pythran/pythran/tables.py index a61709d198b..a9f57122259 100644 --- a/contrib/python/pythran/pythran/tables.py +++ b/contrib/python/pythran/pythran/tables.py @@ -45,7 +45,9 @@ cxx_keywords = { 'using', 'virtual', 'void', 'volatile', 'wchar_t', 'while', 'xor', 'xor_eq', # C++11 additions - 'constexpr', 'decltype', 'noexcept', 'nullptr', 'static_assert', + 'constexpr', 'decltype', 'thread_local', 'noexcept', 'nullptr', 'static_assert', + 'alignof', 'alignas', + # C++14 additions (nothing) # reserved namespaces 'std', } @@ -3752,10 +3754,13 @@ MODULES = { "fmin": UFunc(REDUCED_BINARY_UFUNC), "fmod": UFunc(BINARY_UFUNC), "frexp": ConstFunctionIntr(), + "frombuffer": ConstFunctionIntr(), "fromfunction": ConstFunctionIntr(), "fromiter": ConstFunctionIntr(args=("iterable", "dtype", "count"), defaults=(-1,)), - "fromstring": ConstFunctionIntr(), + "fromstring": ConstFunctionIntr(args=('string', 'dtype', 'count',), + kwonlyargs=('sep', 'like'), + defaults=(float, -1, '', None)), "fromfile": FunctionIntr(args=('file', 'dtype', 'count', "sep", "offset"), defaults=(None, None, -1, None, 0), global_effects=True), @@ -4641,7 +4646,9 @@ def save_arguments(module_name, elements): defaults = list(spec.defaults or []) args += [ast.Name(arg, ast.Param(), None, None) for arg in spec.kwonlyargs] - defaults += [spec.kwonlydefaults[kw] for kw in spec.kwonlyargs] + if spec.kwonlydefaults: + defaults += [spec.kwonlydefaults[kw] for kw in + spec.kwonlyargs[-len(spec.kwonlydefaults):]] # Check if we already have a pythran description for that object if signature.args.args: diff --git a/contrib/python/pythran/pythran/toolchain.py b/contrib/python/pythran/pythran/toolchain.py index 42dcc072ad2..498cff92503 100644 --- a/contrib/python/pythran/pythran/toolchain.py +++ b/contrib/python/pythran/pythran/toolchain.py @@ -331,11 +331,8 @@ def compile_cxxfile(module_name, cxxfile, output_binary=None, **kwargs): # local import so that we don't depend on setuptools for the code generation # part from pythran.dist import PythranExtension, PythranBuildExt - try: - # `numpy.distutils is deprecated, may not be present, or broken - from numpy.distutils.core import setup - except Exception: - from setuptools import setup + + from setuptools import setup builddir = mkdtemp() buildtmp = mkdtemp() @@ -367,6 +364,10 @@ def compile_cxxfile(module_name, cxxfile, output_binary=None, **kwargs): dest.write(src.read()) ext = sysconfig.get_config_var('EXT_SUFFIX') + if getattr(extension, 'py_limited_api', False): + _, ext = os.path.splitext(ext) + ext = f".abi3{ext}" + # Copy all generated files including the module name prefix (.pdb, ...) for f in glob.glob(os.path.join(builddir, module_name + "*")): if f.endswith(ext): diff --git a/contrib/python/pythran/pythran/transformations/remove_named_arguments.py b/contrib/python/pythran/pythran/transformations/remove_named_arguments.py index b70c278e141..48bec09269d 100644 --- a/contrib/python/pythran/pythran/transformations/remove_named_arguments.py +++ b/contrib/python/pythran/pythran/transformations/remove_named_arguments.py @@ -1,10 +1,13 @@ """ RemoveNamedArguments turns named arguments into regular ones. """ -from pythran.analyses import Aliases +from pythran.analyses import Aliases, DefUseChains +from pythran.conversion import PYTHRAN_IMPORT_MANGLING +from pythran.errors import PythranInternalError from pythran.passmanager import Transformation from pythran.syntax import PythranSyntaxError from pythran.tables import MODULES + import gast as ast from copy import deepcopy @@ -15,7 +18,20 @@ def handle_special_calls(func_alias, node): node.args.insert(0, ast.Constant(0, None)) -class RemoveNamedArguments(Transformation[Aliases]): +def same_nodes(n0, n1): + if type(n0) is not type(n1): + return False + if isinstance(n0, ast.Constant): + return type(n0.value) is type(n1.value) and n0.value == n1.value + if isinstance(n0, ast.Attribute): + return n0.attr == n1.attr and same_nodes(n0.value, n1.value) + if isinstance(n0, ast.Name): + assert n0.id.startswith(PYTHRAN_IMPORT_MANGLING), "should be an import" + return n0.id == n1.id + raise NotImplementedError((n0, n1)) + + +class RemoveNamedArguments(Transformation[Aliases, DefUseChains]): ''' Replace call with named arguments to regular calls @@ -92,6 +108,10 @@ class RemoveNamedArguments(Transformation[Aliases]): return replacements + def visit_FunctionDef(self, node): + self.current_function = node + return super().generic_visit(node) + def visit_Call(self, node): if node.keywords: self.update = True @@ -102,22 +122,59 @@ class RemoveNamedArguments(Transformation[Aliases]): # all aliases should have the same structural type... # call to self.handle_keywords raises an exception otherwise try: - replacements = {} - for func_alias in aliases: - handle_special_calls(func_alias, node) - - if func_alias is None: # aliasing computation failed - pass - elif isinstance(func_alias, ast.Call): # nested function - # func_alias looks like functools.partial(foo, a) - # so we reorder using alias for 'foo' - offset = len(func_alias.args) - 1 - call = func_alias.args[0] - for func_alias in self.aliases[call]: - replacements = self.handle_keywords(func_alias, - node, offset) + def visit_aliases(aliases): + all_replacements = [] + for func_alias in aliases: + handle_special_calls(func_alias, node) + + if func_alias is None: # aliasing computation failed + pass + elif isinstance(func_alias, ast.Call): # nested function + # func_alias looks like functools.partial(foo, a) + # so we reorder using alias for 'foo' + offset = len(func_alias.args) - 1 + call = func_alias.args[0] + for func_alias in self.aliases[call]: + all_replacements.append(self.handle_keywords(func_alias, + node, + offset)) + elif isinstance(func_alias, ast.Name): + if not isinstance(func_alias.ctx, ast.Param): + raise PythranInternalError( + "Unexpected non-parameter reference in call") + index = self.current_function.args.args.index(func_alias) + def_ = self.def_use_chains.chains[self.current_function] + for def_user in def_.users(): + for user in def_user.users(): + if not isinstance(user.node, ast.Call): + continue + effective_arg = user.node.args[index] + arg_aliases = self.aliases[effective_arg] + all_replacements.append(visit_aliases(arg_aliases)) + + + else: + all_replacements.append(self.handle_keywords(func_alias, + node)) + + if not all_replacements: + return {} + elif len(all_replacements) == 1: + return all_replacements[0] else: - replacements = self.handle_keywords(func_alias, node) + replacement = {} + for candidate in all_replacements: + for k, v in candidate.items(): + if k not in replacement: + replacement[k] = v + else: + if not same_nodes(v, replacement[k]): + raise PythranSyntaxError( + "different default argument values depending on the call site for this node", node) + + return replacement + + replacements = visit_aliases(aliases) # if we reach this point, we should have a replacement # candidate, or nothing structural typing issues would have diff --git a/contrib/python/pythran/pythran/types/conversion.py b/contrib/python/pythran/pythran/types/conversion.py index e149b7fb47d..d90f82cbec5 100644 --- a/contrib/python/pythran/pythran/types/conversion.py +++ b/contrib/python/pythran/pythran/types/conversion.py @@ -4,11 +4,12 @@ from numpy import int8, int16, int32, int64, intp, intc from numpy import uint8, uint16, uint32, uint64, uintp, uintc from numpy import float64, float32, complex64, complex128 import numpy -from pythran.typing import List, Dict, Set, Tuple, NDArray, Pointer, Fun +from pythran.typing import List, Dict, Set, Tuple, NDArray, Pointer, Fun, Type PYTYPE_TO_CTYPE_TABLE = { numpy.uint: 'npy_uint', # + bytes: 'pythonic::types::str', # FIXME: using types::str as backend complex: 'std::complex', bool: 'bool', int: 'long', @@ -53,10 +54,20 @@ TYPE_TO_SUFFIX = { def pytype_to_ctype(t): """ Python -> pythonic type binding. """ - if isinstance(t, List): + if t in (list, set): + return f'pythonic::types::{t.__name__}' + elif t is dict: + return f'pythonic::types::{t.__name__}' + elif t is tuple: + return f'std::tuple' + elif isinstance(t, List): return 'pythonic::types::list<{0}>'.format( pytype_to_ctype(t.__args__[0]) ) + elif isinstance(t, Type): + return 'pythonic::types::type_t<{0}>'.format( + pytype_to_ctype(t.__args__[0]) + ) elif isinstance(t, Set): return 'pythonic::types::set<{0}>'.format( pytype_to_ctype(t.__args__[0]) @@ -105,8 +116,12 @@ def pytype_to_ctype(t): def pytype_to_pretty_type(t): """ Python -> docstring type. """ - if isinstance(t, List): + if t in (list, set, dict, tuple): + return t.__name__ + elif isinstance(t, List): return '{0} list'.format(pytype_to_pretty_type(t.__args__[0])) + elif isinstance(t, Type): + return '{0} type'.format(pytype_to_pretty_type(t.__args__[0])) elif isinstance(t, Set): return '{0} set'.format(pytype_to_pretty_type(t.__args__[0])) elif isinstance(t, Dict): diff --git a/contrib/python/pythran/pythran/types/signature.py b/contrib/python/pythran/pythran/types/signature.py index c56f20ed3f7..fd44a0c40a0 100644 --- a/contrib/python/pythran/pythran/types/signature.py +++ b/contrib/python/pythran/pythran/types/signature.py @@ -1,4 +1,4 @@ -from pythran.typing import List, Dict, Set, Fun, TypeVar +from pythran.typing import List, Dict, Set, Fun, TypeVar, Type from pythran.typing import Union, Iterable @@ -20,7 +20,7 @@ def dep_builder(type_var, ppal_index, index, t, self, node): return lambda arg: (arg if index == ppal_index else self.result[node.args[index]]) - elif isinstance(t, (List, Set, Iterable, Dict)): + elif isinstance(t, (List, Set, Iterable, Dict, Type)): return lambda arg: self.builder.IteratorContentType( dep_builder(type_var, ppal_index, @@ -41,6 +41,9 @@ def path_to(self, t, deps_builders, node): return deps_builders[t] else: raise InfeasibleCombiner() + if isinstance(t, Type): + return lambda arg: self.builder.TypeType( + path_to(self, t.__args__[0], deps_builders, node)(arg)) if isinstance(t, List): return lambda arg: self.builder.ListType( path_to(self, t.__args__[0], deps_builders, node)(arg)) diff --git a/contrib/python/pythran/pythran/types/type_dependencies.py b/contrib/python/pythran/pythran/types/type_dependencies.py index 15674ceecec..8edc40c68db 100644 --- a/contrib/python/pythran/pythran/types/type_dependencies.py +++ b/contrib/python/pythran/pythran/types/type_dependencies.py @@ -9,14 +9,18 @@ from pythran.errors import PythranInternalError from pythran.passmanager import ModuleAnalysis from pythran.types.conversion import PYTYPE_TO_CTYPE_TABLE from pythran.utils import get_variable -from pythran.typing import List, Set, Dict, NDArray, Tuple, Pointer, Fun +from pythran.typing import List, Set, Dict, NDArray, Tuple, Pointer, Fun, Type from pythran.graph import DiGraph def pytype_to_deps_hpp(t): """python -> pythonic type hpp filename.""" - if isinstance(t, List): + if t in (list, set, dict, tuple): + return {f"{t.__name__}.hpp"} + elif isinstance(t, List): return {'list.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) + elif isinstance(t, Type): + return {'type.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Set): return {'set.hpp'}.union(pytype_to_deps_hpp(t.__args__[0])) elif isinstance(t, Dict): diff --git a/contrib/python/pythran/pythran/types/types.py b/contrib/python/pythran/pythran/types/types.py index 40cfcdf0308..a6c0752f6f3 100644 --- a/contrib/python/pythran/pythran/types/types.py +++ b/contrib/python/pythran/pythran/types/types.py @@ -17,7 +17,7 @@ from pythran.tables import operator_to_lambda, MODULES from pythran.typing import List, Dict, Set, Tuple, NDArray, Union from pythran.types.conversion import pytype_to_ctype, PYTYPE_TO_CTYPE_TABLE from pythran.types.reorder import Reorder -from pythran.utils import attr_to_path, cxxid, isnum, isextslice +from pythran.utils import attr_to_path, isnum, isextslice from collections import defaultdict from functools import reduce @@ -76,7 +76,7 @@ def alias_key(a): if isinstance(a, ast.Call): return ('call:',) + alias_key(a.func) if isinstance(a, ContainerOf): - return sum((alias_key(c) for c in sorted(a.containees, key=alias_key)), ()) + return sum((alias_key(c) for c in sorted(a.containees, key=alias_key)), (str(a.index),)) if isinstance(a, ast.Constant): return ('cst:', str(a.value)) # FIXME: how could we order those? @@ -353,9 +353,9 @@ class Types(ModuleAnalysis[Reorder, StrictAliases, LazynessAnalysis, # integral index make it possible to correctly # update tuple type if isinstance(index, int): - kty = self.builder.NamedType( - 'std::integral_constant' - .format(index)) + kty = self.builder.IntegralConstant( + self.builder.NamedType("long"), + index) return self.builder.IndexableContainerType(kty, ty) elif isinstance(index, float): @@ -368,20 +368,24 @@ class Types(ModuleAnalysis[Reorder, StrictAliases, LazynessAnalysis, for node_alias in self.sorted_strict_aliases(name, extra=[name]): - def traverse_alias(alias, l): + def traverse_alias(alias, depth, l): + # not interested in aliases too deep + if len(depth) <= l: + return if isinstance(alias, ContainerOf): - for containee in sorted(alias.containees, - key=alias_key): - traverse_alias(containee, l + 1) + d = depth[l] + if d is None or np.isnan(alias.index) or d == alias.index: + for containee in sorted(alias.containees, key=alias_key): + traverse_alias(containee, depth, l + 1) else: def local_op(*args): - return reduce(merge_container_type, - depth[:-l] if l else depth, + t = reduce(merge_container_type, + depth[l:], former_op(*args)) - if len(depth) > l: - self.combine_(alias, local_op, othernode) + return t + self.combine_(alias, local_op, othernode) - traverse_alias(node_alias, 0) + traverse_alias(node_alias, depth, 0) return except UnboundableRValue: pass @@ -394,6 +398,12 @@ class Types(ModuleAnalysis[Reorder, StrictAliases, LazynessAnalysis, if isinstance(container_type, (self.builder.ListType, self.builder.SetType)): return container_type.of + if isinstance(container_type, self.builder.IndexableContainerType): + if np.isnan(node.index): + return container_type.of_val + elif isinstance(container_type.of_key, self.builder.IntegralConstant): + if container_type.of_key.index != node.index: + raise NotImplementedError return self.builder.ElementType( 0 if np.isnan(node.index) else node.index, container_type) @@ -710,11 +720,16 @@ class Types(ModuleAnalysis[Reorder, StrictAliases, LazynessAnalysis, sty = pytype_to_ctype(ty) if node in self.immediates: if sty == 'pythonic::types::chr': - sty = "std::integral_constant" % (node.value) + sty = self.builder.IntegralConstant( + self.builder.NamedType("char"), + f"'{node.value}'") else: - sty = "std::integral_constant<%s, %s>" % (sty, - str(node.value).lower()) - self.result[node] = self.builder.NamedType(sty) + sty = self.builder.IntegralConstant( + self.builder.NamedType(sty), + node.value) + else: + sty = self.builder.NamedType(sty) + self.result[node] = sty def visit_Attribute(self, node): """ Compute typing for an attribute node. """ @@ -724,8 +739,7 @@ class Types(ModuleAnalysis[Reorder, StrictAliases, LazynessAnalysis, typename = pytype_to_ctype(obj.signature) self.result[node] = self.builder.NamedType(typename) else: - path = '::'.join(map(cxxid, path)) + '{}' - self.result[node] = self.builder.DeclType(path) + self.result[node] = self.builder.FunctionType(*path) def visit_Slice(self, node): """ diff --git a/contrib/python/pythran/pythran/typing.py b/contrib/python/pythran/pythran/typing.py index 3ead03a1927..01a3ebc4a87 100644 --- a/contrib/python/pythran/pythran/typing.py +++ b/contrib/python/pythran/pythran/typing.py @@ -28,6 +28,12 @@ class ListMeta(type): return List(item) +class TypeMeta(type): + + def __getitem__(cls, item): + return Type(item) + + class IterableMeta(type): def __getitem__(cls, item): @@ -64,7 +70,7 @@ class PointerMeta(type): return Pointer(item) -class Type(type): +class TypeBase(type): def __new__(cls, args): return type.__new__( @@ -78,47 +84,47 @@ class Type(type): pass -class Fun(Type, metaclass=FunMeta): +class Fun(TypeBase, metaclass=FunMeta): pass -class Dict(Type, metaclass=DictMeta): +class Dict(TypeBase, metaclass=DictMeta): pass -class Union(Type, metaclass=UnionMeta): +class Union(TypeBase, metaclass=UnionMeta): pass -class Set(Type, metaclass=SetMeta): +class Set(TypeBase, metaclass=SetMeta): pass -class List(Type, metaclass=ListMeta): +class List(TypeBase, metaclass=ListMeta): pass -class Iterable(Type, metaclass=IterableMeta): +class Iterable(TypeBase, metaclass=IterableMeta): pass -class Generator(Type, metaclass=GeneratorMeta): +class Generator(TypeBase, metaclass=GeneratorMeta): pass -class Tuple(Type, metaclass=TupleMeta): +class Tuple(TypeBase, metaclass=TupleMeta): pass -class Optional(Type, metaclass=OptionalMeta): +class Optional(TypeBase, metaclass=OptionalMeta): pass -class NDArray(Type, metaclass=NDArrayMeta): +class NDArray(TypeBase, metaclass=NDArrayMeta): pass -class Pointer(Type, metaclass=PointerMeta): +class Pointer(TypeBase, metaclass=PointerMeta): pass @@ -138,3 +144,7 @@ class Any(object): class File(object): pass + + +class Type(TypeBase, metaclass=TypeMeta): + pass diff --git a/contrib/python/pythran/pythran/utils.py b/contrib/python/pythran/pythran/utils.py index 55a7e8ad6f9..f60aec447e8 100644 --- a/contrib/python/pythran/pythran/utils.py +++ b/contrib/python/pythran/pythran/utils.py @@ -105,8 +105,8 @@ def get_variable(assignable): ... ctx=ast.Load()), ... slice=ast.Name('j', ast.Load(), None, None), ... ctx=ast.Load()) - >>> ast.dump(get_variable(ref)) - "Name(id='a', ctx=Load())" + >>> get_variable(ref).id + 'a' """ msg = "Only name and subscript can be assigned." assert isinstance(assignable, (ast.Name, ast.Subscript)), msg diff --git a/contrib/python/pythran/pythran/version.py b/contrib/python/pythran/pythran/version.py index f083a1bd668..062ca1d78a6 100644 --- a/contrib/python/pythran/pythran/version.py +++ b/contrib/python/pythran/pythran/version.py @@ -1,2 +1,2 @@ -__version__ = '0.18.0' +__version__ = '0.18.1' __descr__ = 'Ahead of Time compiler for numeric kernels' diff --git a/contrib/python/pythran/pythran/xsimd/arch/xsimd_avx.hpp b/contrib/python/pythran/pythran/xsimd/arch/xsimd_avx.hpp index f41702babac..e6b4f296d7f 100644 --- a/contrib/python/pythran/pythran/xsimd/arch/xsimd_avx.hpp +++ b/contrib/python/pythran/pythran/xsimd/arch/xsimd_avx.hpp @@ -355,7 +355,7 @@ namespace xsimd { return _mm256_castsi256_pd(self); } - template ::type>::value, void>::type> + template >::value, void>::type> XSIMD_INLINE batch bitwise_cast(batch const& self, batch const&, requires_arch) noexcept { return batch(self.data); diff --git a/contrib/python/pythran/ya.make b/contrib/python/pythran/ya.make index ace834763b2..2263f1298d0 100644 --- a/contrib/python/pythran/ya.make +++ b/contrib/python/pythran/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(0.18.0) +VERSION(0.18.1) LICENSE(BSD-3-Clause) -- cgit v1.3

::value ? I : 0), P>; }; template @@ -1443,111 +1351,80 @@ namespace sutils template <> struct copy_new_axis_helper<0> { template - typename std::enable_if< - (0 != std::tuple_size::value) && - std::tuple_element<0, S2>::type::value, - sutils::push_front_t>>::type - doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) + std::enable_if_t<(0 != std::tuple_size::value) && std::tuple_element_t<0, S2>::value, + sutils::push_front_t>> + doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) { - return {std::tuple_cat(std::tuple>(), - s.values)}; + return {std::tuple_cat(std::tuple>(), s.values)}; } template - typename std::enable_if< - (0 != std::tuple_size::value) && - !std::tuple_element<0, S2>::type::value, - sutils::push_front_t::type>>::type - doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) + std::enable_if_t<(0 != std::tuple_size::value) && !std::tuple_element_t<0, S2>::value, + sutils::push_front_t>> + doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) { - return { - std::tuple_cat(std::make_tuple(shape.template shape<0>()), s.values)}; + return {std::tuple_cat(std::make_tuple(shape.template shape<0>()), s.values)}; } template - typename std::enable_if< - (0 == std::tuple_size::value), - sutils::push_front_t::type>>::type - doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) + std::enable_if_t<(0 == std::tuple_size::value), + sutils::push_front_t>> + doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) { - return { - std::tuple_cat(std::make_tuple(shape.template shape()), s.values)}; + return {std::tuple_cat(std::make_tuple(shape.template shape()), s.values)}; } }; template struct copy_new_axis_helper { template - auto doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) -> - typename std::enable_if< - (I < std::tuple_size::value) && - safe_tuple_element::type::value, - decltype(copy_new_axis_helper{}.doit( - sutils::push_front_t>(), - shape, new_axis, std::integral_constant()))>::type + auto doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) + -> std::enable_if_t<(I < std::tuple_size::value) && + safe_tuple_element::type::value, + decltype(copy_new_axis_helper{}.doit( + sutils::push_front_t>(), shape, + new_axis, std::integral_constant()))> { return copy_new_axis_helper{}.doit( sutils::push_front_t>( - std::tuple_cat(std::tuple>(), - s.values)), + std::tuple_cat(std::tuple>(), s.values)), shape, new_axis, std::integral_constant()); } template - auto doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) -> - typename std::enable_if< + auto doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) + -> std::enable_if_t< (I >= std::tuple_size::value), decltype(copy_new_axis_helper{}.doit( - sutils::push_front_t::type>(), - shape, new_axis, - std::integral_constant()))>::type + sutils::push_front_t>(), shape, + new_axis, std::integral_constant()))> { return copy_new_axis_helper{}.doit( - sutils::push_front_t< - S0, typename std::tuple_element::type>( - std::tuple_cat(std::make_tuple(shape.template shape()), - s.values)), - shape, new_axis, std::integral_constant < size_t, - J == 0 ? J : J - 1 > ()); + sutils::push_front_t>( + std::tuple_cat(std::make_tuple(shape.template shape()), s.values)), + shape, new_axis, std::integral_constant()); } template - auto doit(S0 s, S1 const &shape, S2 const &new_axis, - std::integral_constant) -> - typename std::enable_if< - (I < std::tuple_size::value) && - !safe_tuple_element::type::value, + auto doit(S0 s, S1 const &shape, S2 const &new_axis, std::integral_constant) + -> std::enable_if_t< + (I < std::tuple_size::value) && !safe_tuple_element::type::value, decltype(copy_new_axis_helper{}.doit( - sutils::push_front_t::type>(), - shape, new_axis, - std::integral_constant()))>::type + sutils::push_front_t>(), shape, + new_axis, std::integral_constant()))> { return copy_new_axis_helper{}.doit( - sutils::push_front_t< - S0, typename std::tuple_element::type>( - std::tuple_cat(std::make_tuple(shape.template shape()), - s.values)), - shape, new_axis, std::integral_constant < size_t, - J == 0 ? J : J - 1 > ()); + sutils::push_front_t>( + std::tuple_cat(std::make_tuple(shape.template shape()), s.values)), + shape, new_axis, std::integral_constant()); } }; template auto copy_new_axis(S1 const &shape, S2 const &new_axis) -> decltype(copy_new_axis_helper{}.doit( - types::pshape<>(), shape, new_axis, - std::integral_constant())) + types::pshape<>(), shape, new_axis, std::integral_constant())) { - return copy_new_axis_helper{}.doit( - types::pshape<>(), shape, new_axis, - std::integral_constant()); + return copy_new_axis_helper{}.doit(types::pshape<>(), shape, new_axis, + std::integral_constant()); } } // namespace sutils @@ -1623,8 +1500,7 @@ template struct to_python> { template - static PyObject *do_convert(std::tuple const &t, - utils::index_sequence); + static PyObject *do_convert(std::tuple const &t, std::index_sequence); static PyObject *convert(std::tuple const &t); }; @@ -1632,8 +1508,7 @@ struct to_python> { template struct to_python> { template - static PyObject *do_convert(types::array_tuple const &t, - utils::index_sequence); + static PyObject *do_convert(types::array_tuple const &t, std::index_sequence); static PyObject *convert(types::array_tuple const &t); }; @@ -1641,8 +1516,7 @@ struct to_python> { template struct to_python> { template - static PyObject *do_convert(types::static_list const &t, - utils::index_sequence); + static PyObject *do_convert(types::static_list const &t, std::index_sequence); static PyObject *convert(types::static_list const &t); }; @@ -1651,14 +1525,12 @@ template struct from_python> { template - static bool do_is_convertible(PyObject *obj, - typename utils::index_sequence); + static bool do_is_convertible(PyObject *obj, typename std::index_sequence); static bool is_convertible(PyObject *obj); template - static std::tuple do_convert(PyObject *obj, - typename utils::index_sequence); + static std::tuple do_convert(PyObject *obj, typename std::index_sequence); static std::tuple convert(PyObject *obj); }; @@ -1668,8 +1540,7 @@ struct from_python> { static bool is_convertible(PyObject *obj); template - static types::array_tuple - do_convert(PyObject *obj, typename utils::index_sequence); + static types::array_tuple do_convert(PyObject *obj, typename std::index_sequence); static types::array_tuple convert(PyObject *obj); }; PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/types/type.hpp b/contrib/python/pythran/pythran/pythonic/include/types/type.hpp new file mode 100644 index 00000000000..fbc4c2353fc --- /dev/null +++ b/contrib/python/pythran/pythran/pythonic/include/types/type.hpp @@ -0,0 +1,17 @@ +#ifndef PYTHONIC_INCLUDE_TYPES_TYPE_HPP +#define PYTHONIC_INCLUDE_TYPES_TYPE_HPP + +PYTHONIC_NS_BEGIN + +namespace types +{ + template + struct type_functor; + + template + using type_t = typename type_functor::type; +} // namespace types + +PYTHONIC_NS_END + +#endif diff --git a/contrib/python/pythran/pythran/pythonic/include/types/variant_functor.hpp b/contrib/python/pythran/pythran/pythonic/include/types/variant_functor.hpp index 46df29576d8..c22e205bf56 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/variant_functor.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/variant_functor.hpp @@ -46,12 +46,10 @@ namespace types variant_functor_impl(char mem[], variant_functor_impl const &t); template - variant_functor_impl(char mem[], - variant_functor_impl const &t); + variant_functor_impl(char mem[], variant_functor_impl const &t); template - variant_functor_impl( - char mem[], variant_functor_impl const &t); + variant_functor_impl(char mem[], variant_functor_impl const &t); template variant_functor_impl(char mem[], OtherType const &t); @@ -67,8 +65,7 @@ namespace types void assign(char mem[], OtherType const &); template - void assign(char mem[], - variant_functor_impl const &); + void assign(char mem[], variant_functor_impl const &); template void assign(char mem[], variant_functor const &); @@ -101,8 +98,7 @@ namespace types variant_functor_impl(char mem[], OtherTypes const &...t); template - variant_functor_impl(char mem[], - variant_functor_impl const &t); + variant_functor_impl(char mem[], variant_functor_impl const &t); variant_functor_impl &operator=(variant_functor_impl const &) = delete; @@ -112,18 +108,14 @@ namespace types void assign(char mem[], OtherType const &); template - auto operator()(Args &&...args) -> - typename __combined< - decltype(std::declval()(std::forward(args)...)), - decltype(std::declval()( - std::forward(args)...))...>::type; + auto operator()(Args &&...args) -> typename __combined< + decltype(std::declval()(std::forward(args)...)), + decltype(std::declval()(std::forward(args)...))...>::type; template - auto operator()(Args &&...args) const -> - typename __combined< - decltype(std::declval()(std::forward(args)...)), - decltype(std::declval()( - std::forward(args)...))...>::type; + auto operator()(Args &&...args) const -> typename __combined< + decltype(std::declval()(std::forward(args)...)), + decltype(std::declval()(std::forward(args)...))...>::type; }; } // namespace details diff --git a/contrib/python/pythran/pythran/pythonic/include/types/vectorizable_type.hpp b/contrib/python/pythran/pythran/pythonic/include/types/vectorizable_type.hpp index e8a3f773426..adbdc565c38 100644 --- a/contrib/python/pythran/pythran/pythonic/include/types/vectorizable_type.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/types/vectorizable_type.hpp @@ -14,14 +14,12 @@ namespace types }; struct vectorizer { template - static auto - vbegin(E &&expr) -> decltype(std::forward(expr).vbegin(vectorize{})) + static auto vbegin(E &&expr) -> decltype(std::forward(expr).vbegin(vectorize{})) { return std::forward(expr).vbegin(vectorize{}); } template - static auto - vend(E &&expr) -> decltype(std::forward(expr).vend(vectorize{})) + static auto vend(E &&expr) -> decltype(std::forward(expr).vend(vectorize{})) { return std::forward(expr).vend(vectorize{}); } @@ -30,14 +28,12 @@ namespace types }; struct vectorizer_nobroadcast { template - static auto vbegin(E &&expr) - -> decltype(std::forward(expr).vbegin(vectorize_nobroadcast{})) + static auto vbegin(E &&expr) -> decltype(std::forward(expr).vbegin(vectorize_nobroadcast{})) { return std::forward(expr).vbegin(vectorize_nobroadcast{}); } template - static auto vend(E &&expr) - -> decltype(std::forward(expr).vend(vectorize_nobroadcast{})) + static auto vend(E &&expr) -> decltype(std::forward(expr).vend(vectorize_nobroadcast{})) { return std::forward(expr).vend(vectorize_nobroadcast{}); } @@ -45,10 +41,9 @@ namespace types template struct is_vectorizable_dtype { - static const bool value = - is_dtype::value && !std::is_same::value && - !std::is_same::value && - !std::is_same>::value; + static const bool value = is_dtype::value && !std::is_same::value && + !std::is_same::value && + !std::is_same>::value; }; /* trait to check if is T is an array-like type that supports vectorization @@ -67,9 +62,8 @@ namespace types template struct is_vectorizable { - static const bool value = - std::conditional::value, is_vectorizable_dtype, - is_vectorizable_array>::type::value; + static const bool value = std::conditional_t::value, is_vectorizable_dtype, + is_vectorizable_array>::value; }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/allocate.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/allocate.hpp index 3af878d4685..731f55d5dd7 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/allocate.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/allocate.hpp @@ -14,10 +14,9 @@ namespace utils #ifdef PYTHRAN_TRACE_ALLOCATION extern size_t pythran_allocation_site; #define pythran_trace_lineno(n) pythonic::utils::pythran_allocation_site = n; -#define pythran_trace_allocation(n) \ - do { \ - fprintf(stderr, ":%d: Allocating %d bytes\n", \ - pythonic::utils::pythran_allocation_site, n); \ +#define pythran_trace_allocation(n) \ + do { \ + fprintf(stderr, ":%d: Allocating %d bytes\n", pythonic::utils::pythran_allocation_site, n); \ } while (0) #else #define pythran_trace_lineno(s) diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/broadcast_copy.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/broadcast_copy.hpp index 1e43648925b..38250787715 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/broadcast_copy.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/broadcast_copy.hpp @@ -22,15 +22,14 @@ namespace utils }; template - struct dim_of::value>::type> { + struct dim_of::value>> { static const size_t value = 0; }; -#define SPECIALIZE_DIM_OF(TYPE) \ - template <> \ - struct dim_of { \ - static const size_t value = 0; \ +#define SPECIALIZE_DIM_OF(TYPE) \ + template <> \ + struct dim_of { \ + static const size_t value = 0; \ } SPECIALIZE_DIM_OF(std::complex); diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/functor.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/functor.hpp index 260e4d597a4..b4a9f229a1a 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/functor.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/functor.hpp @@ -5,32 +5,31 @@ // create a function named `name' using function `f' -#define DEFINE_FUNCTOR_2(name, f) \ - namespace functor \ - { \ - struct name { \ - using callable = void; \ - template \ - auto operator()(Types &&...types) const \ - -> decltype(f(std::forward(types)...)) \ - { \ - return f(std::forward(types)...); \ - } \ - \ - friend std::ostream &operator<<(std::ostream &os, name) \ - { \ - return os << #name; \ - } \ - }; \ +#define DEFINE_FUNCTOR_2(name, f) \ + namespace functor \ + { \ + struct name { \ + using callable = void; \ + template \ + auto operator()(Types &&...types) const -> decltype(f(std::forward(types)...)) \ + { \ + return f(std::forward(types)...); \ + } \ + \ + friend std::ostream &operator<<(std::ostream &os, name) \ + { \ + return os << #name; \ + } \ + }; \ } // create a functor named `f' using function `ns::f' #define DEFINE_FUNCTOR(ns, f) DEFINE_FUNCTOR_2(f, ns::f) -#define USING_FUNCTOR(f, alias) \ - namespace functor \ - { \ - using f = alias; \ +#define USING_FUNCTOR(f, alias) \ + namespace functor \ + { \ + using f = alias; \ } #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/iterator.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/iterator.hpp index 306d96376a5..49d7c3579f5 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/iterator.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/iterator.hpp @@ -55,10 +55,10 @@ namespace utils template struct iterator_min { - using type = typename std::conditional< - std::is_same::iterator_category, - std::forward_iterator_tag>::value, - std::forward_iterator_tag, typename iterator_min::type>::type; + using type = + std::conditional_t::iterator_category, + std::forward_iterator_tag>::value, + std::forward_iterator_tag, typename iterator_min::type>; }; } // namespace utils PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/nested_container.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/nested_container.hpp index e53703a1ce3..ff4ea9a8f34 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/nested_container.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/nested_container.hpp @@ -41,8 +41,7 @@ namespace utils template struct nested_container_depth { - static const int value = - nested_container_depth_helper::value>::value; + static const int value = nested_container_depth_helper::value>::value; }; template @@ -82,12 +81,11 @@ namespace utils /* Get the size of a container, using recursion on inner container if any * FIXME: should be a constexpr? - * FIXME: why a class && ! a function? + * FIXME: why a class and not a function? */ template struct nested_container_size { - using Type = - typename std::remove_cv::type>::type; + using Type = std::remove_cv_t>; static long flat_size(T const &t); }; @@ -115,8 +113,7 @@ namespace utils template struct nested_container_value_type { - using type = typename nested_container_value_type_helper< - T, types::is_array::value>::type; + using type = typename nested_container_value_type_helper::value>::type; }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/neutral.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/neutral.hpp index 21eecd2b8d7..88dfd1a8c46 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/neutral.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/neutral.hpp @@ -50,8 +50,7 @@ namespace utils }; template - T const neutral::value = - std::numeric_limits::lowest(); + T const neutral::value = std::numeric_limits::lowest(); template struct neutral { @@ -59,8 +58,7 @@ namespace utils }; template - T const neutral::value = - std::numeric_limits::max(); + T const neutral::value = std::numeric_limits::max(); template struct neutral { diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/numpy_conversion.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/numpy_conversion.hpp index 8fafd52d791..b5f3c1bec8d 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/numpy_conversion.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/numpy_conversion.hpp @@ -6,20 +6,18 @@ #include #if _MSC_VER && !__clang__ -#define NUMPY_EXPR_TO_NDARRAY0_DECL(fname) \ - template ::value && \ - types::is_numexpr_arg::value, \ - E>::type * = nullptr> \ +#define NUMPY_EXPR_TO_NDARRAY0_DECL(fname) \ + template ::value && types::is_numexpr_arg::value, E> \ + * = nullptr> \ auto fname(E const &expr, Types &&...others); #else -#define NUMPY_EXPR_TO_NDARRAY0_DECL(fname) \ - template \ - auto fname(E const &expr, Types &&...others) -> \ - typename std::enable_if< \ - !types::is_ndarray::value && types::is_numexpr_arg::value, \ - decltype(fname( \ - types::ndarray{expr}, \ - std::forward(others)...))>::type; +#define NUMPY_EXPR_TO_NDARRAY0_DECL(fname) \ + template \ + auto fname(E const &expr, Types &&...others) \ + -> std::enable_if_t::value && types::is_numexpr_arg::value, \ + decltype(fname( \ + types::ndarray{expr}, \ + std::forward(others)...))>; #endif #endif diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/numpy_traits.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/numpy_traits.hpp index 2ab8e72f66c..4ae52bdc011 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/numpy_traits.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/numpy_traits.hpp @@ -131,8 +131,7 @@ namespace types template struct is_numexpr_arg> { - static constexpr bool value = - is_numexpr_arg::value || is_dtype::value; + static constexpr bool value = is_numexpr_arg::value || is_dtype::value; }; template @@ -149,32 +148,27 @@ namespace types }; template - struct is_numexpr_arg> - : is_numexpr_arg> { + struct is_numexpr_arg> : is_numexpr_arg> { }; template struct is_numexpr_arg> { - static constexpr bool value = - is_numexpr_arg::value || is_dtype::value; + static constexpr bool value = is_numexpr_arg::value || is_dtype::value; }; template struct is_numexpr_arg> { - static constexpr bool value = - is_numexpr_arg::value || is_dtype::value; + static constexpr bool value = is_numexpr_arg::value || is_dtype::value; }; template struct is_numexpr_arg> { - static constexpr bool value = - is_numexpr_arg::value || is_dtype::value; + static constexpr bool value = is_numexpr_arg::value || is_dtype::value; }; template struct is_numexpr_arg> { - static constexpr bool value = - is_numexpr_arg::value || is_dtype::value; + static constexpr bool value = is_numexpr_arg::value || is_dtype::value; }; template @@ -197,7 +191,7 @@ namespace types }; template - struct has_buffer> : has_buffer{ + struct has_buffer> : has_buffer { }; template diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/seq.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/seq.hpp index 576141cb7ef..1fb1e866b32 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/seq.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/seq.hpp @@ -1,76 +1,27 @@ #ifndef PYTHONIC_INCLUDE_UTILS_SEQ_HPP #define PYTHONIC_INCLUDE_UTILS_SEQ_HPP +#include + PYTHONIC_NS_BEGIN namespace utils { - // make_integer_sequence() = integer_sequence<0, ..., N-1> - - template - struct integer_sequence { - }; - - template - using index_sequence = integer_sequence; - namespace details { - template - struct make_integer_sequence_join; - template - struct make_integer_sequence_join, - integer_sequence> { - using type = integer_sequence; - }; - - template - struct make_integer_sequence - : make_integer_sequence_join< - typename make_integer_sequence::type, - typename make_integer_sequence::type> { - }; - template - struct make_integer_sequence { - using type = integer_sequence; - }; - template - struct make_integer_sequence { - using type = integer_sequence; - }; - } // namespace details + template + constexpr std::integer_sequence + reverse_integer_sequence(std::integer_sequence); - template - using make_integer_sequence = - typename details::make_integer_sequence::type; - template - using make_index_sequence = - typename details::make_integer_sequence::type; - - // make_reversed_integer_sequence() = integer_sequence - - namespace details - { - - template - struct make_reversed_integer_sequence - : make_reversed_integer_sequence { - }; - - template - struct make_reversed_integer_sequence { - using type = integer_sequence; - }; } // namespace details template using make_reversed_integer_sequence = - typename details::make_reversed_integer_sequence::type; + decltype(details::reverse_integer_sequence(std::make_integer_sequence())); template - using make_reversed_index_sequence = - typename details::make_reversed_integer_sequence::type; + using make_reversed_index_sequence = make_reversed_integer_sequence; // make_repeated_type() => type_sequence template diff --git a/contrib/python/pythran/pythran/pythonic/include/utils/tags.hpp b/contrib/python/pythran/pythran/pythonic/include/utils/tags.hpp index 593bfcdbd1d..f9e764b4e1b 100644 --- a/contrib/python/pythran/pythran/pythonic/include/utils/tags.hpp +++ b/contrib/python/pythran/pythran/pythonic/include/utils/tags.hpp @@ -16,9 +16,7 @@ namespace purity template struct purity_of { - using type = - typename std::conditional::value, purity::pure_tag, - purity::unknown_tag>::type; + using type = std::conditional_t::value, purity::pure_tag, purity::unknown_tag>; }; PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/itertools/combinations.hpp b/contrib/python/pythran/pythran/pythonic/itertools/combinations.hpp index b64e5780e17..c8a074a3875 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/combinations.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/combinations.hpp @@ -17,8 +17,7 @@ namespace itertools template template combination_iterator::combination_iterator(Iter &&pool, long r) - : pool(pool.begin(), pool.end()), indices(r), r(r), - stopped(r > long(this->pool.size())) + : pool(pool.begin(), pool.end()), indices(r), r(r), stopped(r > long(this->pool.size())) { assert(r >= 0 && "r must be non-negative"); if (!stopped) { @@ -33,8 +32,7 @@ namespace itertools } template - types::dynamic_tuple - combination_iterator::operator*() const + types::dynamic_tuple combination_iterator::operator*() const { assert(!stopped && "! stopped"); return {result.begin(), result.end()}; @@ -72,24 +70,21 @@ namespace itertools } template - bool - combination_iterator::operator!=(combination_iterator const &other) const + bool combination_iterator::operator!=(combination_iterator const &other) const { assert(stopped || other.stopped); return !(*this == other); } template - bool - combination_iterator::operator==(combination_iterator const &other) const + bool combination_iterator::operator==(combination_iterator const &other) const { assert(stopped || other.stopped); return other.stopped == stopped; } template - bool - combination_iterator::operator<(combination_iterator const &other) const + bool combination_iterator::operator<(combination_iterator const &other) const { return stopped != other.stopped; } @@ -121,9 +116,8 @@ namespace itertools } // namespace details template - details::combination< - typename std::remove_cv::type>::type> - combinations(T0 &&iter, long num_elts) + details::combination>> combinations(T0 &&iter, + long num_elts) { return {std::forward(iter), num_elts}; } diff --git a/contrib/python/pythran/pythran/pythonic/itertools/count.hpp b/contrib/python/pythran/pythran/pythonic/itertools/count.hpp index c549bb46152..1c90256b481 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/count.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/count.hpp @@ -13,8 +13,7 @@ namespace itertools namespace details { template - count_iterator::count_iterator(T value, T step) - : value(value), step(step) + count_iterator::count_iterator(T value, T step) : value(value), step(step) { } diff --git a/contrib/python/pythran/pythran/pythonic/itertools/ifilter.hpp b/contrib/python/pythran/pythran/pythonic/itertools/ifilter.hpp index b0fe9ab46ff..87ba185e98d 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/ifilter.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/ifilter.hpp @@ -10,10 +10,8 @@ namespace itertools { template - details::filter::type>::type, - typename std::remove_cv< - typename std::remove_reference::type>::type> + details::filter>, + std::remove_cv_t>> ifilter(Operator &&_op, List0 &&_seq) { return {std::forward(_op), std::forward(_seq)}; diff --git a/contrib/python/pythran/pythran/pythonic/itertools/islice.hpp b/contrib/python/pythran/pythran/pythonic/itertools/islice.hpp index 5220c0f15da..75889b5cbff 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/islice.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/islice.hpp @@ -17,20 +17,18 @@ namespace itertools } template - islice_iterator::islice_iterator(Iterable const &iterable, - builtins::range const &xr) - : iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr), - state(xr_ref.begin()), prev(*state) + islice_iterator::islice_iterator(Iterable const &iterable, builtins::range const &xr) + : iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr), state(xr_ref.begin()), + prev(*state) { std::advance(this->iterable, *state); } template - islice_iterator::islice_iterator(npos const &n, - Iterable const &iterable, + islice_iterator::islice_iterator(npos const &n, Iterable const &iterable, builtins::range const &xr) - : iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr), - state(xr_ref.end()), prev(0) + : iterable_ref(iterable), iterable(iterable_ref.begin()), xr_ref(xr), state(xr_ref.end()), + prev(0) { } @@ -50,29 +48,25 @@ namespace itertools } template - bool islice_iterator::operator==( - islice_iterator const &other) const + bool islice_iterator::operator==(islice_iterator const &other) const { return (state == other.state); } template - bool islice_iterator::operator!=( - islice_iterator const &other) const + bool islice_iterator::operator!=(islice_iterator const &other) const { return state != other.state; } template - bool islice_iterator::operator<( - islice_iterator const &other) const + bool islice_iterator::operator<(islice_iterator const &other) const { return state != other.state; } template - int islice_iterator::operator-( - islice_iterator const &other) const + int islice_iterator::operator-(islice_iterator const &other) const { return state - other.state; } @@ -83,8 +77,7 @@ namespace itertools } template - _islice::_islice(Iterable const &iterable, - builtins::range const &xr) + _islice::_islice(Iterable const &iterable, builtins::range const &xr) : iterator(iterable, xr), end_iter(npos(), iterable, xr) { } @@ -108,17 +101,15 @@ namespace itertools } template - _islice::type>::type> + _islice>> islice(Iterable &&iterable, long start, long stop, long step) { return {iterable, builtins::range(start, stop, step)}; } template - _islice::type>::type> - islice(Iterable &&iterable, long stop) + _islice>> islice(Iterable &&iterable, + long stop) { return {iterable, builtins::range(0, stop, 1)}; } diff --git a/contrib/python/pythran/pythran/pythonic/itertools/permutations.hpp b/contrib/python/pythran/pythran/pythonic/itertools/permutations.hpp index cba48890fde..c6114545879 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/permutations.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/permutations.hpp @@ -19,8 +19,8 @@ namespace itertools } template - permutations_iterator::permutations_iterator(pool_type const &iter, - size_t num_elts, bool end) + permutations_iterator::permutations_iterator(pool_type const &iter, size_t num_elts, + bool end) : pool(iter), curr_permut(pool.size()), _size(num_elts), end(end) { std::iota(curr_permut.begin(), curr_permut.end(), 0); @@ -37,8 +37,7 @@ namespace itertools return res; } template - types::array_tuple init_permut_from(size_t n, - types::array_tuple *) + types::array_tuple init_permut_from(size_t n, types::array_tuple *) { assert(N == n && "consistent init"); return {}; @@ -55,14 +54,12 @@ namespace itertools } template - types::dynamic_tuple init_permut_from(I begin, I end, - types::dynamic_tuple *) + types::dynamic_tuple init_permut_from(I begin, I end, types::dynamic_tuple *) { return {begin, end}; } template - types::array_tuple init_permut_from(I begin, I end, - types::array_tuple *) + types::array_tuple init_permut_from(I begin, I end, types::array_tuple *) { types::array_tuple res; std::copy(begin, end, res.begin()); @@ -77,14 +74,13 @@ namespace itertools // than the the pool size // FIXME a better implementation would be to avoid // std::next_permutation, but only in the slow path - H prev_permut = init_permut_from( - curr_permut.begin(), curr_permut.begin() + _size, (H *)nullptr); - while ((end = std::next_permutation(curr_permut.begin(), - curr_permut.end()))) { + H prev_permut = + init_permut_from(curr_permut.begin(), curr_permut.begin() + _size, (H *)nullptr); + while ((end = std::next_permutation(curr_permut.begin(), curr_permut.end()))) { // Check if the prefix of the new permutation is // different of the previous one - H new_permut = init_permut_from( - curr_permut.begin(), curr_permut.begin() + _size, (H *)nullptr); + H new_permut = + init_permut_from(curr_permut.begin(), curr_permut.begin() + _size, (H *)nullptr); if (!(prev_permut == new_permut)) break; } @@ -94,25 +90,21 @@ namespace itertools } template - bool permutations_iterator::operator!=( - permutations_iterator const &other) const + bool permutations_iterator::operator!=(permutations_iterator const &other) const { return !(*this == other); } template - bool permutations_iterator::operator==( - permutations_iterator const &other) const + bool permutations_iterator::operator==(permutations_iterator const &other) const { if (other.end != end) return false; - return std::equal(curr_permut.begin(), curr_permut.end(), - other.curr_permut.begin()); + return std::equal(curr_permut.begin(), curr_permut.end(), other.curr_permut.begin()); } template - bool permutations_iterator::operator<( - permutations_iterator const &other) const + bool permutations_iterator::operator<(permutations_iterator const &other) const { if (end != other.end) return end > other.end; @@ -136,8 +128,7 @@ namespace itertools } template - typename _permutations::iterator const & - _permutations::begin() const + typename _permutations::iterator const &_permutations::begin() const { return *this; } @@ -155,15 +146,14 @@ namespace itertools } template - _permutations> - permutations(T0 iter, long num_elts) + _permutations> permutations(T0 iter, + long num_elts) { return {iter, num_elts}; } template - _permutations> - permutations(T0 iter) + _permutations> permutations(T0 iter) { return {iter, std::distance(iter.begin(), iter.end())}; } diff --git a/contrib/python/pythran/pythran/pythonic/itertools/product.hpp b/contrib/python/pythran/pythran/pythonic/itertools/product.hpp index 7572ed249f5..3265b778f4a 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/product.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/product.hpp @@ -19,20 +19,18 @@ namespace itertools template template - product_iterator::product_iterator( - std::tuple &_iters, utils::index_sequence const &) - : it_begin(std::get(_iters).begin()...), - it_end(std::get(_iters).end()...), + product_iterator::product_iterator(std::tuple &_iters, + std::index_sequence const &) + : it_begin(std::get(_iters).begin()...), it_end(std::get(_iters).end()...), it(std::get(_iters).begin()...), end(it_begin == it_end) { } template template - product_iterator::product_iterator( - npos, std::tuple &_iters, utils::index_sequence const &) - : it_begin(std::get(_iters).end()...), - it_end(std::get(_iters).end()...), + product_iterator::product_iterator(npos, std::tuple &_iters, + std::index_sequence const &) + : it_begin(std::get(_iters).end()...), it_end(std::get(_iters).end()...), it(std::get(_iters).end()...), end(true) { } @@ -40,17 +38,15 @@ namespace itertools template template types::make_tuple_t - product_iterator::get_value( - utils::index_sequence const &) const + product_iterator::get_value(std::index_sequence const &) const { return types::make_tuple(*std::get(it)...); } template - types::make_tuple_t - product_iterator::operator*() const + types::make_tuple_t product_iterator::operator*() const { - return get_value(utils::make_index_sequence{}); + return get_value(std::make_index_sequence{}); } template @@ -78,22 +74,19 @@ namespace itertools } template - bool product_iterator::operator==( - product_iterator const &other) const + bool product_iterator::operator==(product_iterator const &other) const { return end == other.end; } template - bool product_iterator::operator!=( - product_iterator const &other) const + bool product_iterator::operator!=(product_iterator const &other) const { return end != other.end; } template - bool product_iterator::operator<( - product_iterator const &other) const + bool product_iterator::operator<(product_iterator const &other) const { return end != other.end; } @@ -105,10 +98,8 @@ namespace itertools template product::product(Iters const &..._iters) : utils::iterator_reminder(_iters...), - iterator(this->values, - utils::make_index_sequence{}), - end_iter(npos(), this->values, - utils::make_index_sequence{}) + iterator(this->values, std::make_index_sequence{}), + end_iter(npos(), this->values, std::make_index_sequence{}) { } @@ -132,9 +123,7 @@ namespace itertools } // namespace details template - details::product::type>::type...> - product(Iter &&...iters) + details::product>...> product(Iter &&...iters) { return {std::forward(iters)...}; } diff --git a/contrib/python/pythran/pythran/pythonic/itertools/repeat.hpp b/contrib/python/pythran/pythran/pythonic/itertools/repeat.hpp index 7e9f3ab6743..e5347254791 100644 --- a/contrib/python/pythran/pythran/pythonic/itertools/repeat.hpp +++ b/contrib/python/pythran/pythran/pythonic/itertools/repeat.hpp @@ -11,8 +11,7 @@ namespace itertools { template - repeat_iterator::repeat_iterator(T value, long count) - : value_(value), count_(count) + repeat_iterator::repeat_iterator(T value, long count) : value_(value), count_(count) { } @@ -30,27 +29,23 @@ namespace itertools } template - bool repeat_iterator::operator!=( - repeat_iterator const &other) const + bool repeat_iterator::operator!=(repeat_iterator const &other) const { return Endless || count_ != other.count_; } template - bool repeat_iterator::operator==( - repeat_iterator const &other) const + bool repeat_iterator::operator==(repeat_iterator const &other) const { return !Endless && count_ == other.count_; } template - bool repeat_iterator::operator<( - repeat_iterator const &other) const + bool repeat_iterator::operator<(repeat_iterator const &other) const { return !Endless && count_ < other.count_; } template - _repeat::_repeat(T value, long count) - : repeat_iterator(value, count) + _repeat::_repeat(T value, long count) : repeat_iterator(value, count) { } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/all.hpp b/contrib/python/pythran/pythran/pythonic/numpy/all.hpp index 516e0dff9d3..13dfec2276b 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/all.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/all.hpp @@ -15,10 +15,8 @@ namespace numpy template bool _all(E begin, E end, utils::int_<1>) { - return std::all_of( - begin, end, [](typename std::iterator_traits::value_type e) -> bool { - return e; - }); + return std::all_of(begin, end, + [](typename std::iterator_traits::value_type e) -> bool { return e; }); } template @@ -31,25 +29,22 @@ namespace numpy } template - typename std::enable_if::value, bool>::type - all(E const &expr, types::none_type) + std::enable_if_t::value, bool> all(E const &expr, types::none_type) { return _all(expr.begin(), expr.end(), utils::int_()); } template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, bool>::type + std::enable_if_t::value || types::is_complex::value, bool> all(E const &expr, types::none_type) { return expr; } template - auto all(E const &array, long axis) -> - typename std::enable_if::value || - types::is_complex::value, - decltype(all(array))>::type + auto all(E const &array, long axis) + -> std::enable_if_t::value || types::is_complex::value, + decltype(all(array))> { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -57,8 +52,7 @@ namespace numpy } template - auto all(E const &array, long axis) -> - typename std::enable_if::type + auto all(E const &array, long axis) -> std::enable_if_t { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -66,10 +60,8 @@ namespace numpy } template - typename std::enable_if< - E::value != 1, - types::ndarray>>::type + std::enable_if_t>> all(E const &array, long axis) { constexpr long N = E::value; @@ -78,20 +70,17 @@ namespace numpy throw types::ValueError("axis out of bounds"); if (axis == 0) { types::array_tuple shp; - sutils::copy_shape<0, 1>(shp, array, utils::make_index_sequence()); + sutils::copy_shape<0, 1>(shp, array, std::make_index_sequence()); types::ndarray> out(shp, true); - return std::accumulate(array.begin(), array.end(), out, - functor::multiply()); + return std::accumulate(array.begin(), array.end(), out, functor::multiply()); } else { types::array_tuple shp; - sutils::copy_shape<0, 0>(shp, array, utils::make_index_sequence()); - types::ndarray> ally( - shp, builtins::None); - std::transform( - array.begin(), array.end(), ally.begin(), - [=](types::ndarray> const &other) { - return all(other, axis - 1); - }); + sutils::copy_shape<0, 0>(shp, array, std::make_index_sequence()); + types::ndarray> ally(shp, builtins::None); + std::transform(array.begin(), array.end(), ally.begin(), + [=](types::ndarray> const &other) { + return all(other, axis - 1); + }); return ally; } } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/allclose.hpp b/contrib/python/pythran/pythran/pythonic/numpy/allclose.hpp index d630a99ba2f..ad5e808a62c 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/allclose.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/allclose.hpp @@ -15,8 +15,7 @@ namespace numpy namespace { template - bool _allclose(I0 begin, I0 end, I1 ibegin, double rtol, double atol, - utils::int_<1>) + bool _allclose(I0 begin, I0 end, I1 ibegin, double rtol, double atol, utils::int_<1>) { for (; begin != end; ++begin, ++ibegin) { auto u = *begin; @@ -31,12 +30,11 @@ namespace numpy } template - bool _allclose(I0 begin, I0 end, I1 ibegin, double rtol, double atol, - utils::int_) + bool _allclose(I0 begin, I0 end, I1 ibegin, double rtol, double atol, utils::int_) { for (; begin != end; ++begin, ++ibegin) - if (!_allclose((*begin).begin(), (*begin).end(), (*ibegin).begin(), - rtol, atol, utils::int_())) + if (!_allclose((*begin).begin(), (*begin).end(), (*ibegin).begin(), rtol, atol, + utils::int_())) return false; return true; } @@ -45,8 +43,7 @@ namespace numpy template bool allclose(U const &u, V const &v, double rtol, double atol) { - return _allclose(u.begin(), u.end(), v.begin(), rtol, atol, - utils::int_()); + return _allclose(u.begin(), u.end(), v.begin(), rtol, atol, utils::int_()); } } // namespace numpy PYTHONIC_NS_END diff --git a/contrib/python/pythran/pythran/pythonic/numpy/angle_in_rad.hpp b/contrib/python/pythran/pythran/pythonic/numpy/angle_in_rad.hpp index 5bcbfc39d8b..1fe20860090 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/angle_in_rad.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/angle_in_rad.hpp @@ -20,8 +20,7 @@ namespace numpy namespace wrapper { template - auto angle_in_rad(T const &t) -> decltype(std::atan2(std::imag(t), - std::real(t))) + auto angle_in_rad(T const &t) -> decltype(std::atan2(std::imag(t), std::real(t))) { return std::atan2(std::imag(t), std::real(t)); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/any.hpp b/contrib/python/pythran/pythran/pythonic/numpy/any.hpp index a234db5b37e..8032677234a 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/any.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/any.hpp @@ -15,8 +15,7 @@ namespace numpy template bool _any(E const &e, utils::int_<1>) { - return std::any_of(e.begin(), e.end(), - [](typename E::dtype elt) -> bool { return elt; }); + return std::any_of(e.begin(), e.end(), [](typename E::dtype elt) -> bool { return elt; }); } template @@ -30,25 +29,22 @@ namespace numpy } template - typename std::enable_if::value, bool>::type - any(E const &expr, types::none_type) + std::enable_if_t::value, bool> any(E const &expr, types::none_type) { return _any(expr, utils::int_()); } template - typename std::enable_if< - std::is_scalar::value || types::is_complex::value, bool>::type + std::enable_if_t::value || types::is_complex::value, bool> any(E const &expr, types::none_type) { return expr; } template - auto any(E const &array, long axis) -> - typename std::enable_if::value || - types::is_complex::value, - decltype(any(array))>::type + auto any(E const &array, long axis) + -> std::enable_if_t::value || types::is_complex::value, + decltype(any(array))> { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -56,8 +52,7 @@ namespace numpy } template - auto any(E const &array, long axis) -> - typename std::enable_if::type + auto any(E const &array, long axis) -> std::enable_if_t { if (axis != 0) throw types::ValueError("axis out of bounds"); @@ -65,10 +60,8 @@ namespace numpy } template - typename std::enable_if< - E::value != 1, - types::ndarray>>::type + std::enable_if_t>> any(E const &array, long axis) { constexpr long N = E::value; @@ -78,20 +71,17 @@ namespace numpy if (axis == 0) { types::array_tuple shp; shp[0] = 1; - sutils::copy_shape<1, 0>(shp, array, utils::make_index_sequence()); + sutils::copy_shape<1, 0>(shp, array, std::make_index_sequence()); types::ndarray> out(shp, false); - return std::accumulate(array.begin(), array.end(), *out.begin(), - numpy::functor::add()); + return std::accumulate(array.begin(), array.end(), *out.begin(), numpy::functor::add()); } else { types::array_tuple shp; - sutils::copy_shape<0, 0>(shp, array, utils::make_index_sequence()); - types::ndarray> anyy( - shp, builtins::None); - std::transform( - array.begin(), array.end(), anyy.begin(), - [=](types::ndarray> const &other) { - return any(other, axis - 1); - }); + sutils::copy_shape<0, 0>(shp, array, std::make_index_sequence()); + types::ndarray> anyy(shp, builtins::None); + std::transform(array.begin(), array.end(), anyy.begin(), + [=](types::ndarray> const &other) { + return any(other, axis - 1); + }); return anyy; } } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/append.hpp b/contrib/python/pythran/pythran/pythonic/numpy/append.hpp index 82779af5521..6f15f8ef9b7 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/append.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/append.hpp @@ -12,35 +12,29 @@ PYTHONIC_NS_BEGIN namespace numpy { template - typename std::enable_if< - !types::is_dtype::value, - types::ndarray< - typename __combined::type>::type, - types::pshape>>::type + std::enable_if_t::value, + types::ndarray::type>::type, + types::pshape>> append(types::ndarray const &nto, F const &data) { auto ndata = numpy::functor::asarray{}(data); long nsize = nto.flat_size() + ndata.flat_size(); - types::ndarray< - typename __combined::type>::type, - types::pshape> + types::ndarray::type>::type, + types::pshape> out(types::pshape(nsize), builtins::None); auto out_back = std::copy(nto.fbegin(), nto.fend(), out.fbegin()); std::copy(ndata.fbegin(), ndata.fend(), out_back); return out; } template - typename std::enable_if< - types::is_dtype::value, - types::ndarray< - typename __combined::type>::type, - types::pshape>>::type + std::enable_if_t::value, + types::ndarray::type>::type, + types::pshape>> append(types::ndarray const &nto, F const &data) { long nsize = nto.flat_size() + 1; - types::ndarray< - typename __combined::type>::type, - types::pshape> + types::ndarray::type>::type, + types::pshape> out(types::pshape(nsize), builtins::None); auto out_back = std::copy(nto.fbegin(), nto.fend(), out.fbegin()); *out_back = data; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/arange.hpp b/contrib/python/pythran/pythran/pythonic/numpy/arange.hpp index a483e1dba3c..fe1ff2fb780 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/arange.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/arange.hpp @@ -12,8 +12,7 @@ PYTHONIC_NS_BEGIN namespace numpy { template - types::numpy_expr> + types::numpy_expr> arange(T begin, U end, S step, dtype d) { using R = typename dtype::type; diff --git a/contrib/python/pythran/pythran/pythonic/numpy/argmax.hpp b/contrib/python/pythran/pythran/pythonic/numpy/argmax.hpp index 4be4ce60447..8189a7c5d10 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/argmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/argmax.hpp @@ -36,8 +36,7 @@ namespace numpy } template - types::ndarray> - argmax(E const &expr, long axis) + types::ndarray> argmax(E const &expr, long axis) { return argminmax>(expr, axis); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/argmin.hpp b/contrib/python/pythran/pythran/pythonic/numpy/argmin.hpp index e146da20d82..055e310b0cc 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/argmin.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/argmin.hpp @@ -37,8 +37,7 @@ namespace numpy } template - types::ndarray> - argmin(E const &expr, long axis) + types::ndarray> argmin(E const &expr, long axis) { return argminmax>(expr, axis); } diff --git a/contrib/python/pythran/pythran/pythonic/numpy/argminmax.hpp b/contrib/python/pythran/pythran/pythonic/numpy/argminmax.hpp index 11aca63b3ac..8d667afd815 100644 --- a/contrib/python/pythran/pythran/pythonic/numpy/argminmax.hpp +++ b/contrib/python/pythran/pythran/pythonic/numpy/argminmax.hpp @@ -13,7 +13,7 @@ namespace numpy namespace details { template - P iota(utils::index_sequence) + P iota(std::index_sequence) { return {static_cast(Is)...}; } @@ -21,7 +21,7 @@ namespace numpy template P iota() { - return iota