Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by vr (Deacon)
on May 04, 2018 at 10:51 UTC ( #1214046=note: print w/replies, xml ) Need Help??


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

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
Node Status?
node history
Node Type: note [id://1214046]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2020-04-01 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (186 votes). Check out past polls.

    Notices?