in reply to Re: Calculate log of matrix values
in thread Calculate log of matrix values

i solved the problem using this:
LINE: for (my $i=0; $i<20; $i++){ for (my $j=0; $j<20; $j++){ if ($matrix[$i][$j] =~ /[^0.00]/){ $lnpam[$i][$j] = log $matrix[$i][$j]; }else{ next LINE; } } }
thanks a lot for the quick answer!

Replies are listed 'Best First'.
Re^3: Calculate log of matrix values
by SuicideJunkie (Vicar) on Aug 09, 2013 at 15:04 UTC
    if ($matrix[$i][$j] =~ /[^0.00]/){

    This does not do what you think it does, but it is at least close. You are really only doing if ($matrix[$i][$j] =~ /[^0.]/){ IE: does the string have at least one character that is not a literal '0' or a '.'

    See: Bracketed Character Classes

    Why not make the test if ($matrix[$i][$j] > 0)? That's much simpler and faster, and will not fail on "-0.00 " or " 0.00" or regular negative numbers.

      thanks! you are right :)