Skip to content

Commit

Permalink
Merge pull request #1162 from drgrice1/fix-vec_dot
Browse files Browse the repository at this point in the history
Fix `vec_dot` in the PGmatrixmacros.pl so issue #440 can be closed.
  • Loading branch information
Alex-Jordan authored Dec 17, 2024
2 parents cda6a90 + 04f3b6a commit 5ad9f53
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions macros/math/PGmatrixmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand 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)
Expand Down

0 comments on commit 5ad9f53

Please sign in to comment.