diff options
author | mattip <matti.picus@gmail.com> | 2023-01-18 08:17:59 +0200 |
---|---|---|
committer | mattip <matti.picus@gmail.com> | 2023-01-30 21:32:35 +0200 |
commit | 90243f53f8efa200e22ee13ef1f0a8e1120b1c3a (patch) | |
tree | 9620fed3c704c944cb8e4314b7a69719d14f6d3c | |
parent | c662a712a30b1b640a80421619bb97556ffe965b (diff) | |
download | numpy-90243f53f8efa200e22ee13ef1f0a8e1120b1c3a.tar.gz |
ENH: add indexed loops
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 12 | ||||
-rw-r--r-- | numpy/core/src/umath/loops_arithm_fp.dispatch.c.src | 12 |
2 files changed, 24 insertions, 0 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 2b70a4b9a..085712f38 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -540,6 +540,18 @@ NPY_NO_EXPORT NPY_GCC_OPT_3 @ATTR@ void BINARY_LOOP_FAST(@type@, @type@, *out = in1 @OP@ in2); } } + +NPY_NO_EXPORT NPY_GCC_OPT_3 @ATTR@ void +@TYPE@_@kind@@isa@_indexed(char const *ip1, npy_intp const *indx, char *value, + npy_intp const *dimensions, npy_intp const *steps) { + npy_intp is1 = steps[0], is2 = steps[1], os1 = steps[2]; + npy_intp n = dimensions[0]; + npy_intp i; + for(i = 0; i < n; i++, indx += is2, value += os1) { + @type@ op1 = *(@type@ *)(ip1 + is1 * indx[0]) + value[0]; + } +} + #endif /**end repeat2**/ diff --git a/numpy/core/src/umath/loops_arithm_fp.dispatch.c.src b/numpy/core/src/umath/loops_arithm_fp.dispatch.c.src index c1bfaa63a..1436c46f4 100644 --- a/numpy/core/src/umath/loops_arithm_fp.dispatch.c.src +++ b/numpy/core/src/umath/loops_arithm_fp.dispatch.c.src @@ -546,6 +546,18 @@ NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@) } } } + +NPY_NO_EXPORT void NPY_CPU_DISPATCH_CURFX(@TYPE@_@kind@_indexed) +(char const *ip1, npy_intp const *indx, char *value, + npy_intp const *dimensions, npy_intp const *steps) { + npy_intp is1 = steps[0], is2 = steps[1], os1 = steps[2]; + npy_intp n = dimensions[0]; + npy_intp i; + for(i = 0; i < n; i++, indx += is2, value += os1) { + @type@ op1 = *(@type@ *)(ip1 + is1 * indx[0]) + value[0]; + } +} + /**end repeat1**/ /**end repeat**/ |