Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix vec_dot in the PGmatrixmacros.pl so issue #440 can be closed. #1162

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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