update_total_iters()
sub update_total_iters
{
my $state = shift;
# $r is the result of this scan.
my $r = $state->idx_slice();
# return $self->main()->scans_data()->slice(":,".$self->scan_idx())
# Add the total iterations for all the states that were solved by
# this scan.
$state->main()->add('total_iters',
PDL::sum((($r <= $state->quota()) & ($r > 0)) * $r)
);
# Find all the states that weren't solved.
my $indexes = PDL::which(($r > $state->quota()) | ($r < 0));
# Add the iterations for all the states that have not been solved
# yet.
$state->main()->add('total_iters', ($indexes->nelem() * $state->quota()));
# Keep only the states that have not been solved yet.
$state->main()->scans_data(
$state->main()->scans_data()->dice($indexes, "X")->copy()
);
}