From 04f3b6af6090990e0030e9da722c1d3012c7d98e Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Fri, 13 Dec 2024 22:36:17 -0600 Subject: [PATCH] Fix `vec_dot` in the PGmatrixmacros.pl so issue #440 can be closed. Not much here. Just add the `=cut` suggested in the issue and one other issue that the Perl language server I use revealed. --- macros/math/PGmatrixmacros.pl | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/macros/math/PGmatrixmacros.pl b/macros/math/PGmatrixmacros.pl index 9622b276b..649c47f24 100644 --- a/macros/math/PGmatrixmacros.pl +++ b/macros/math/PGmatrixmacros.pl @@ -805,7 +805,7 @@ =head2 check_matrix_from_ans_box_cmp sub check_matrix_from_ans_box_cmp { my $correctMatrix = shift; my $string_matrix_cmp = sub { - $string = shift @_; + my $string = shift; my $studentMatrix; $studentMatrix = Matrix(create2d_matrix($string)); die "I give up"; @@ -852,18 +852,20 @@ sub zero_check { =head2 vec_dot() (deprecated -- use MathObjects vectors and matrices) -sub vec_dot{ - my $vec1 = shift; - my $vec2 = shift; - warn "vectors must have the same length" unless @$vec1 == @$vec2; # the vectors must have the same length. - my @vec1=@$vec1; - my @vec2=@$vec2; - my $sum = 0; - - while(@vec1) { - $sum += shift(@vec1)*shift(@vec2); - } - $sum; +=cut + +sub vec_dot { + my $vec1 = shift; + my $vec2 = shift; + warn "vectors must have the same length" unless @$vec1 == @$vec2; # the vectors must have the same length. + my @vec1 = @$vec1; + my @vec2 = @$vec2; + my $sum = 0; + + while (@vec1) { + $sum += shift(@vec1) * shift(@vec2); + } + $sum; } =head2 proj_vect (deprecated -- use MathObjects vectors and matrices)