Obviously the logic is the same, but using vectors is much clearer code-wise and mathematically.my @vector1 = ( 2, -4, 2 ); my @vector2 = ( 5, -3, -6);
return unless $ct1 && $ct1 == $ct2 && $ct2 == $ct3;
Another:my $sum = 0; foreach my $i ( 0 .. $#$x ){ $sum += $x->[$i] * $y->[$i] * $z->[$i]; } return $sum;
my $sum = 0; $sum += $x->[$_] * $y->[$_] * $z->[$_] for 0 .. $#$x; return $sum;
In reply to Re: Dot product of three matrices
by davidrw
in thread Dot product of three matrices
by Angharad
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |