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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.