for my $aref ( @lnPAM ) { $_ /= ( $mutRate * 100 ) for @$aref; } #### @a = map[ map int(rand$_), 1 .. 10],1..10;; cmpthese -1,{ a=>q[ map $_ /= 1, @$_ for @a; ], b=>q[ for my $r( @a ){ $_ /= 1 for @$r } ], };; Rate b a b 52726/s -- -25% a 70388/s 33% -- #### while( abs( $mutRate - 0.01) > 1e-16 ) { ++$iter; $k *= $mutRate * 100; map $_ /= ( $mutRate * 100), @$_ for @lnPAM; @matrix = map[ map exp( $_ ), @$_ ], @lnPAM; $mutRate = sum map{ $freq[ $_ ] * ( 1 - $matrix[ $_ ][ $_ ] ) } 0..19; printf "After %d iteration(s), k=%f, RateMutation=%f\n", $iter, $k, $mutRate; } #### while abs(RateMutation - 0.01) > DBL_EPSILON do iter := iter + 1; k:= k * RateMutation * 100: lnPAM1 := lnPAM1 / (RateMutation * 100): PAM1 := exp(lnPAM1): RateMutation := sum(Freq[i] * (1 - PAM1[i,i]), i= 1..20); printf('After %d iteration(s), k=%f, RateMutation=%f', iter, k, RateMutation); od: