jo37 has asked for the wisdom of the Perl Monks concerning the following question:
Dear monks and nuns,
when playing with PDL's range function I stumbled across a problem. While for dimensions up to 3 everything looks good, at d=4 something seems to be seriously broken. There is some memory corruption causing a segfault.
Looking at d=3 everything looks as expected:
my $p = zeroes(4,4,4); say 'p: ', $p->info; say 'ndcoords: ', ndcoords($p)->info; say 'range: ', $p->range(ndcoords($p), 2, 't')->info;
produces:
p: PDL: Double D [4,4,4] ndcoords: PDL: Double D [3,4,4,4] range: PDL: Double D [4,4,4,2,2,2]
The first dimensions of range correspond to the second to last dimensions of the index piddle, i.e. [4,4,4]. The following dimensions correspond to the shape of the selected slices, i.e. [2,2,2].
With d=4 things become weird.
my $q = zeroes(5,5,5,5); say 'q: ', $q->info; say 'ndcoords: ', ndcoords($q)->info; say 'range: ', $q->range(ndcoords($q), 2, 't')->info;
produces:
q: PDL: Double D [5,5,5,5] ndcoords: PDL: Double D [4,5,5,5,5] range: PDL: Double D [5,5,5,5,2,2,1,5]
Here we have - as expected - the second to last dimensions of the index piddle coming first. But then, instead of the expected [2,2,2,2] remainder, there comes [2,2,1,5]. Memory is corrupted afterwards, as it appears here on my Debian 11. So here is the full example script:
#!/usr/bin/perl use v5.24; use warnings; use PDL; my $p = zeroes(4,4,4); say 'p: ', $p->info; say 'ndcoords: ', ndcoords($p)->info; say 'range: ', $p->range(ndcoords($p), 2, 't')->info; say ones(4); my $q = zeroes(5,5,5,5); say 'q: ', $q->info; say 'ndcoords: ', ndcoords($q)->info; say 'range: ', $q->range(ndcoords($q), 2, 't')->info; say ones(5); __DATA__ p: PDL: Double D [4,4,4] ndcoords: PDL: Double D [3,4,4,4] range: PDL: Double D [4,4,4,2,2,2] [1 1 1 1] q: PDL: Double D [5,5,5,5] ndcoords: PDL: Double D [4,5,5,5,5] range: PDL: Double D [5,5,5,5,2,2,1,5] Segmentation fault
Can anybody reproduce this behaviour? If so, I'd report a bug.
Greetings,
-jo
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: PDL range on 4-d piddles
by choroba (Cardinal) on Oct 19, 2023 at 18:05 UTC | |
by jo37 (Curate) on Oct 19, 2023 at 19:00 UTC | |
Re: PDL range on 4-d piddles
by jo37 (Curate) on Oct 19, 2023 at 20:14 UTC | |
by etj (Priest) on Jan 30, 2024 at 21:40 UTC | |
by etj (Priest) on Jan 31, 2024 at 01:32 UTC | |
Re: PDL range on 4-d piddles
by jo37 (Curate) on Oct 20, 2023 at 16:10 UTC | |
Re: PDL range on 4-d piddles
by Anonymous Monk on Oct 20, 2023 at 10:59 UTC |