in reply to Re: This runs WAY too slow
in thread This runs WAY too slow

You could save another few lines like this
#prepopulate copy error array; sub popfilea { foreach my $ya ( 0 .. $gener ) { foreach my $xa ( 0 .. $total ) { $aoa[$xa][$ya] = (int rand(1+2*$copyerr)-$copyerr ) /$PCNT; } } }
and here
sub popnum1 { ( $x, $y ) = @_; if ( ($y==0) || ($aod[$x][ $y-1 ] ne 'a') ) { return $initial + $aoa[$x][0]; } else { return $aoa[$x][$y] + $aob[$x][ $y-1 ]; } }
moving the sprintf's to this line
$coper = sprintf '%.2f', popnum1( $x, $y )
or consider combining the two subs into one so that you have
$coper = sprintf '%.2f', popnum( $model, $x, $y )
hth poj

Replies are listed 'Best First'.
Re^3: This runs WAY too slow
by Dandello (Monk) on Jan 18, 2011 at 20:52 UTC

    Shaved off another 15 lines. :)

    Sometimes you're just to close to a project to see the obvious (to everyone else) inefficiencies.