Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Can't figure out simple transformation with PDL

by fglock (Vicar)
on Mar 19, 2013 at 09:17 UTC ( #1024243=note: print w/replies, xml ) Need Help??


in reply to Can't figure out simple transformation with PDL

I'm starting with your original statements, and then setting the selected elements to '-1' here:

perldl> p $b = pdl (10..25)->reshape(4,4); [ [10 11 12 13] [14 15 16 17] [18 19 20 21] [22 23 24 25] ] perldl> p $pos = whichND($b == 21); [ [3 2] ] perldl> $xfrm = pdl [-1,0],[0,-1],[1,0],[0,1]; perldl> p $around = $b->indexND($pos + $xfrm, 'truncate'); [20 17 0 25] perldl> p $odd = $around->where( $around % 2 ); [17 25] perldl> $odd .= -1; # set original matrix through dataflow perldl> p $b [ [10 11 12 13] [14 15 16 -1] # odd elements around 21 are set to -1 [18 19 20 21] [22 23 24 -1] ]

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1024243]
help
Chatterbox?
[shmem]: apt-get install exuberant-ctags
[Lady_Aleena]: I think I heard vim has a big learning curve.
[shmem]: then in the root of your source tree run: ctags -R
[shmem]: you get a file named tags where all symbols and the places where they are used are listed
[Lady_Aleena]: geany may not support that.
[shmem]: I see that there is a plugin geany-plugin- codenav
[shmem]: maybe that supports ctags, check the documentation
[Lady_Aleena]: I'd have to talk to a geany person to see.

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2017-04-27 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (506 votes). Check out past polls.