From dc07cb2f45172f598f349f582b93b7feef394b7b Mon Sep 17 00:00:00 2001 From: Alex Jordan Date: Wed, 17 Jan 2024 18:06:16 -0800 Subject: [PATCH 1/2] new context flag to require constant entries --- lib/Parser/List/Vector.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Parser/List/Vector.pm b/lib/Parser/List/Vector.pm index 21145d0026..d02afa310e 100644 --- a/lib/Parser/List/Vector.pm +++ b/lib/Parser/List/Vector.pm @@ -22,6 +22,9 @@ sub _check { $type = (($type =~ m/^[aeiou]/i) ? "an " : "a ") . $type; $self->{equation}->Error([ "Coordinates of Vectors must be Numbers, not %s", $type ]); } + if ($self->context->flag("requireConstantEntries") && !($x->{isConstant})) { + $self->{equation}->Error("Coordinates of Vectors must be constant"); + } } } From 0a2d16ff4d6df21a4800a8174b11e697b1a8b0fe Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Sat, 3 Feb 2024 18:25:59 -0800 Subject: [PATCH 2/2] more efficient check for constant entries --- lib/Parser/List/Matrix.pm | 2 ++ lib/Parser/List/Point.pm | 2 ++ lib/Parser/List/Vector.pm | 5 ++--- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Parser/List/Matrix.pm b/lib/Parser/List/Matrix.pm index 73071afbb3..6bdfc26b6a 100644 --- a/lib/Parser/List/Matrix.pm +++ b/lib/Parser/List/Matrix.pm @@ -24,6 +24,8 @@ sub _check { $self->{equation}->Error("Entries in a Matrix must be Numbers or Lists of Numbers") unless ($x->type =~ m/Number|Matrix/); } + $self->{equation}->Error("Entries of a Matrix must be constant") + if ($self->context->flag("requireConstantMatrices") && !($self->{isConstant})); } # diff --git a/lib/Parser/List/Point.pm b/lib/Parser/List/Point.pm index 93e515b3f4..0b8fee4ff1 100644 --- a/lib/Parser/List/Point.pm +++ b/lib/Parser/List/Point.pm @@ -20,6 +20,8 @@ sub _check { $self->{equation}->Error([ "Coordinates of Points must be Numbers, not %s", $type ]); } } + $self->{equation}->Error("Coordinates of a Point must be constant") + if ($self->context->flag("requireConstantPoints") && !($self->{isConstant})); } ######################################################################### diff --git a/lib/Parser/List/Vector.pm b/lib/Parser/List/Vector.pm index d02afa310e..476f793d51 100644 --- a/lib/Parser/List/Vector.pm +++ b/lib/Parser/List/Vector.pm @@ -22,10 +22,9 @@ sub _check { $type = (($type =~ m/^[aeiou]/i) ? "an " : "a ") . $type; $self->{equation}->Error([ "Coordinates of Vectors must be Numbers, not %s", $type ]); } - if ($self->context->flag("requireConstantEntries") && !($x->{isConstant})) { - $self->{equation}->Error("Coordinates of Vectors must be constant"); - } } + $self->{equation}->Error("Coordinates of a Vector must be constant") + if ($self->context->flag("requireConstantVectors") && !($self->{isConstant})); } sub ijk {