[pythran] Re: copy small into larger array in pythran c++ again

  • From: Jochen S <cycomanic@xxxxxxxxx>
  • To: pythran@xxxxxxxxxxxxx
  • Date: Mon, 25 Jan 2021 08:52:30 +0100

Yes, I thought about that, but what do I do if I don't know the number of
dimensions beforehand? I guess I have to use templates, but what do I do
for the slices, can I use a list of continguous slices to access the
relevant dimensions?

On Mon, Jan 25, 2021 at 7:21 AM Serge Guelton <
serge.guelton@xxxxxxxxxxxxxxxxxxx> wrote:

On Sun, Jan 24, 2021 at 10:55:53PM +0100, Jochen S wrote:
I'm still banging my head against how to copy a smaller array into a
larger
array in c++ with pythran's ndarray (I'm trying to implement the nd fft
functions). Neal showed my how this can be done using xtensor and I
thought
could adjust that method, but I can't get it to work.

So again what I'm trying to do is to copy a (N-n)x(M-m)x(K-k) array into
a
NxM,K array (however I might have more than 3 dimensions). So in python
I would
do something like: out[:n,:m,:k] = in, is there some way to do this using
pythran functions?

You can write the code you want in python and use pythran -e to generate
the C++
code, and then use that :-)

out(types::contiguous_slice(0, n, types::none_type()),
    types::contiguous_slice(0, m, types::none_type()),
    types::contiguous_slice(0, k, types::none_type()))

Should be close to what you need


Other related posts: