Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, Can you suggest any means to access individual element of a piddle (PDL) wihout using the PDL:slices module?

Replies are listed 'Best First'.
Re: Access element of a piddle
by etj (Priest) on May 22, 2022 at 18:40 UTC
    syphilis provides the "correct" answer to the question as asked. However, unless that is the final stage of processing, bringing data outside of PDL-land is a sign one is risking not getting the best out of PDL: its array-programming uses. See https://en.wikipedia.org/wiki/Array_programming for more.
Re: Access element of a piddle
by syphilis (Archbishop) on Mar 14, 2013 at 00:30 UTC
    There are probably people here who can give a better answer than me. There are *certainly* people on the PDL mailing list who can provide a better answer than I can.

    As a quick stab, you could try at():
    pdl> help at Module PDL::Core at Returns a single value inside a piddle as perl scalar. $z = at($piddle, @position); $z=$piddle->at(@position); @position is a coordinate list, of size equal to the number of dimensions in the piddle. Occasionally useful in a general context +, quite useful too inside PDL internals. pdl> $x = sequence 3,4 pdl> p $x->at(1,2) 7 at converts any bad values into the string 'BAD'. # line 3108 "Basic/Core/Core.pm.PL (i.e. PDL::Core.pm)" pdl>
    but I don't know if that's the best option.

    Cheers,
    Rob
Re: Access element of a piddle
by Anonymous Monk on Mar 13, 2013 at 21:24 UTC