Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: RFC: 100 PDL Exercises (ported from numpy)

by mxb (Pilgrim)
on May 04, 2018 at 07:37 UTC ( [id://1214039]=note: print w/replies, xml ) Need Help??


in reply to Re: RFC: 100 PDL Exercises (ported from numpy)
in thread RFC: 100 PDL Exercises (ported from numpy)

Thanks for all of these

I assume you wouldn't mind me merging the solutions into my 'master' POD, with credit of course.

Just from reading your solutions I learned a number of new functions, including maximum_ind (and it's sister functions maximum_n_ind, minimum_ind, minimum_n_ind and max2d_ind) and lags. This is what I hoped would happen, as everyone seems to know a different subset of PDL functionality.

Replies are listed 'Best First'.
Re^3: RFC: 100 PDL Exercises (ported from numpy)
by vr (Curate) on May 04, 2018 at 10:51 UTC

    Hi, mxb, of course I woudn't mind.

    + Note, your recipe #66 doesn't do what's expected, -- but to shift bytes left manually, as Python guys do, isn't nice neither. I'd do this:

    pdl> $x = sequence 2,2,3 # "2x2 planar RGB" image, 4 unique colors pdl> $x = $x-> glue( 0, $x ) # "4x2 RGB" image, 4 unique colors pdl> $x = $x-> glue( 1, $x ) # "4x4 RGB" image, still 4 unique colors pdl> $x-> set( 2,2,2, 100 ) # make them 5 pdl> p$x [ [ [0 1 0 1] [2 3 2 3] [0 1 0 1] [2 3 2 3] ] [ [4 5 4 5] [6 7 6 7] [4 5 4 5] [6 7 6 7] ] [ [ 8 9 8 9] [ 10 11 10 11] [ 8 9 100 9] [ 10 11 10 11] ] ] pdl> p $x-> clump(2)-> transpose-> uniqvec-> getdim( 1 ) 5

    -----------------

    As to combined assignment operators working in-place, here is simple experiment (Windows), either line #1 or #2 un-commented on different runs:

    use strict; use warnings; use feature 'say'; use PDL; my $x = zeroes 1e8; my $y = ones 1e8; $x = $x + $y; # 1 #$x += $y; # 2 say qx{ typeperf "\\Process(perl)\\Working Set Peak" -sc 1 } =~ /.+"(.+)"/s; __END__ >perl pdl180504.pl 2427752448.000000 >perl pdl180504.pl 1627779072.000000

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214039]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-18 00:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found