Log Message:
-----------
Modified Files:
--------------
pg/lib/Value:
Matrix.pm
Point.pm
Real.pm
Vector.pm
Revision Data
-------------
Index: Vector.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/Vector.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -Llib/Value/Vector.pm -Llib/Value/Vector.pm -u -r1.11 -r1.12
--- lib/Value/Vector.pm
+++ lib/Value/Vector.pm
@@ -39,6 +39,7 @@
elsif ($pclass eq 'Matrix' && scalar(@d) == 1) {$p = [$p->value]}
elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[0] == 1) {$p = ($p->value)[0]}
elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[1] == 1) {$p = ($p->transpose->value)[0]}
+ elsif (defined($p) && ref($p) eq "") {return $self->parseFormula($p)}
else {
$p = [$p] if (defined($p) && ref($p) ne 'ARRAY');
Value::Error("Vectors must have at least one coordinate") unless defined($p) && scalar(@{$p}) > 0;
Index: Real.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/Real.pm,v
retrieving revision 1.10
retrieving revision 1.11
diff -Llib/Value/Real.pm -Llib/Value/Real.pm -u -r1.10 -r1.11
--- lib/Value/Real.pm
+++ lib/Value/Real.pm
@@ -42,8 +42,7 @@
$x = [$x] unless ref($x) eq 'ARRAY';
Value::Error("Can't convert ARRAY of length ".scalar(@{$x})." to a Real Number")
unless (scalar(@{$x}) == 1);
- Value::Error("Real Number can't be ".Value::showClass($x->[0]))
- unless (Value::isRealNumber($x->[0]));
+ return $self->parseFormula(@{$x}) unless Value::isRealNumber($x->[0]);
return $self->formula($x->[0]) if Value::isFormula($x->[0]);
bless {data => $x}, $class;
}
Index: Point.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/Point.pm,v
retrieving revision 1.9
retrieving revision 1.10
diff -Llib/Value/Point.pm -Llib/Value/Point.pm -u -r1.9 -r1.10
--- lib/Value/Point.pm
+++ lib/Value/Point.pm
@@ -39,6 +39,7 @@
elsif ($pclass eq 'Matrix' && scalar(@d) == 1) {$p = [$p->value]}
elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[0] == 1) {$p = ($p->value)[0]}
elsif ($pclass eq 'Matrix' && scalar(@d) == 2 && $d[1] == 1) {$p = ($p->transpose->value)[0]}
+ elsif (defined($p) && ref($p) eq "") {return $self->parseFormula($p)}
else {
$p = [$p] if (defined($p) && ref($p) ne 'ARRAY');
Value::Error("Points must have at least one coordinate")
Index: Matrix.pm
===================================================================
RCS file: /webwork/cvs/system/pg/lib/Value/Matrix.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -Llib/Value/Matrix.pm -Llib/Value/Matrix.pm -u -r1.13 -r1.14
--- lib/Value/Matrix.pm
+++ lib/Value/Matrix.pm
@@ -28,21 +28,24 @@
#
# Convert a value to a matrix. The value can be:
# a list of numbers or list of (nested) references to arrays of numbers
-# a point, vector or matrix object
+# a point, vector or matrix object, a matrix-valued formula, or a string
+# containing a matrix expression in the current context.
#
sub new {
my $self = shift; my $class = ref($self) || $self;
my $M = shift;
return bless {data => $M->data}, $class
if (Value::class($M) =~ m/Point|Vector|Matrix/ && scalar(@_) == 0);
+ return $M if (Value::isFormula($M) && $M->type eq "Matrix");
$M = [$M,@_] if ((defined($M) && ref($M) ne 'ARRAY') || scalar(@_) > 0);
Value::Error("Matrices must have at least one entry") unless defined($M) && scalar(@{$M}) > 0;
return $self->numberMatrix(@{$M}) if Value::isNumber($M->[0]);
- return $self->matrixMatrix(@{$M});
+ return $self->matrixMatrix(@{$M}) if ref($M->[0]) =~ m/ARRAY|Matrix/;
+ return $self->parseFormula(@{$M});
}
#
-# (Recusrively) make a matrix from a list of array refs
+# (Recursively) make a matrix from a list of array refs
# and report errors about the entry types
#
sub matrixMatrix {
|