in reply to Re^2: Viterbi application
in thread Viterbi application
"min() is a subroutine that I did not include. It does exactly what it sounds like, returns the minimum of two values in a list."
I did consider that might have been something like that (e.g. similar to List::Util's min() function); however, you're only providing a single value after min( in the code you posted.
Here's an example of how ${$vit_dist[$i-1]}[$j]+${$distance_mat[$i]}[$j] might be evaluated:
$ perl -Mstrict -Mwarnings -le ' my (@vit_dist, @distance_mat); $vit_dist[0][0] = 30; $distance_mat[1][0] = 12; my ($i, $j) = (1, 0); print ${$vit_dist[$i-1]}[$j]+${$distance_mat[$i]}[$j]; ' 42
Perhaps you need a comma instead of a plus:
min(${$vit_dist[$i-1]}[$j], ${$distance_mat[$i]}[$j])
A liberalsplinklingofwhitespace may improve the readability of your code and reduce errors. :-)
-- Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Viterbi application
by azheid (Sexton) on Apr 06, 2014 at 23:28 UTC | |
by kcott (Archbishop) on Apr 06, 2014 at 23:47 UTC | |
by azheid (Sexton) on Apr 07, 2014 at 16:09 UTC |