WeBWorK Problems

MathObject bug with identity matrix?

MathObject bug with identity matrix?

by Peter Selinger -
Number of replies: 1

The following simple problem gives the strange error message "The evaluated answer is not an answer hash : ||." There is also no answer shown under "Correct Answers".

DOCUMENT();
loadMacros(
  "PGbasicmacros.pl",
  "MathObjects.pl",
);
TEXT(beginproblem());
Context("Matrix");

$A = Value::Matrix->I(2);

Context()->texStrings;
BEGIN_TEXT
  Enter the matrix \($A\). $PAR
  Answer: \{ $A->ans_array(2) \}
END_TEXT
Context()->normalStrings;

ANS($A->cmp());

ENDDOCUMENT();        

If I instead write $A = Matrix([[1,0],[0,1]]) or even $A = Value::Matrix->I(2) + Matrix([[0,0],[0,0]]), there is no error message, and the correct answer is shown correctly.

It seems there is something wrong with the encoding of the identity matrix, perhaps?