As suggested by choroba, I upgraded to 2.084. It doesn't crash anymore, but it does not seem to work right. I have a little problem with 4-d piddles, though - they are just a bit beyond my imagination. However, there are things where you just can feel they are wrong. So let's take a 5x5x5x5 piddle filled with the sequence 0..(5^4-1). From this piddle we take a 2x2x2x2 slice around every piddle element and take take the sum over the slice's elements. Obviously, no such sum can ever be less than 28 as the sum of 0..7. However:

#!/usr/bin/perl use v5.24; use warnings; use PDL; my $q = sequence(5,5,5,5); say 'q: ', $q->info; say 'ndcoords: ', ndcoords($q)->info; say 'range: ', $q->range(ndcoords($q), 2, 't')->info; say '2x2x2x2 sum:', $q->range(ndcoords($q), 2, 't')->reorder(4,5,6,7,0 +,1,2,3)->clump(4)->sumover; __DATA__ 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] 2x2x2x2 sum: [ [ [ [ 0 1 2 3 4] [ 5 6 7 588 296] [604 612 620 628 316] [644 652 660 668 336] [332 336 340 344 173] ] [ [724 732 740 748 376] [764 772 780 788 396] [804 812 820 828 416] [844 852 860 868 436] [432 436 440 444 223] ] ...

Update:

The problem is much easier to see if we use a all-ones piddle and take periodic boundaries. Then all slices are made of ones and the sum over a 2^D slice is (or: should be) always 2^D.

However:

#!/usr/bin/perl use v5.24; use warnings; use PDL; my $q = ones(5,5,5,5); say 'q: ', $q->info; say 'ndcoords: ', ndcoords($q)->info; say 'range: ', $q->range(ndcoords($q), 2, 'p')->info; say '2x2x2x2 sum:', $q->range(ndcoords($q), 2, 'p')->reorder(4,5,6,7,0 +,1,2,3)->clump(4)->sumover; __DATA__ [ [ [ [9 9 9 9 9] [9 9 9 8 8] [8 8 8 8 8] [8 8 8 8 8] [8 8 8 8 8] ] [ [8 8 8 8 8] [8 8 8 8 8] [8 8 8 8 8] [8 8 8 8 8] [8 8 8 8 8] ] ...

Greetings,
-jo

$gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

In reply to Re: PDL range on 4-d piddles by jo37
in thread PDL range on 4-d piddles by jo37

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.