Dear All,
I played further with this example
http://mailman.jach.hawaii.edu/pipermail/perldl/2013-August/008102.html
and run into the following issue now.
The below code should generate a 2D piddle of random 0 and 1, then take a
random row, calculate a sum of it, then cut this row off the piddle and do so
again until there are rows.
I run "out of memory" if the initial piddle has more than 900 rows. In fact, I
wanted to take a lot more :)
Where is my mistake?
Thank you in advance!
VE
The code:
#!/perl
use strict;
use warnings;
use PDL;
use PDL::NiceSlice;
use PDL::Math;
my $size = 900; # the initial number of rows.
my $table = random 10, $size;
$table = rint $table;
my @sums;
for ( 1 .. $size)
{
my ( $col, $row ) = dims $table;
my $row_x = $row > 1 ? int(rand($row)) : 0;
my $chosen = $table->dice_axis(1, $row_x);
push @sums, sum $chosen;
my $rows_to_remove = pdl($row_x); # rows to be removed
my $rvals = sequence($table->dim(1)); # all rows indexes
my $rkeep = setops($rows_to_remove, 'XOR', $rvals); # rows to keep
$table = $table(,$rkeep);
}
# print scalar @sums, $/; # or whatever...
---
[email protected]
01.09.2013
_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl