$A->ans_array
but have used the answer hecker for $LA
instead of $A
. The and_array
sets up the Matrix to know how to collect all the elements of the array, but $LA
hasn't had that setup. So it only is tied to the single answer blank that is the upper left-hand entry.See if switching
$A->ans_array
to $LA->ans_array
helps.Davide
First, my understanding is that LR decomposition is only value for square matrices, which yours isn't. Perhaps you want to keep A separate from the augmented form of A and work with that?
If you want to have the students enter the augmented matrix, you will need to use $A->ans_array
as you have done, but then you will need to use $A->cmp
with a custom checker, not $LA->cmp
. The custom checker can use $LA
internally (and ignore $correct
) if you want, or you could wait to compute $LA
within the answer checker (from the correct answer). Whatever you prefer.
I think you will need to remove the last column of the correct and student answer. There is no really convenient way to do that, however. Here is one possibility for deleting the fifth column from a matrix $M
.
$Mt = $M->transpose; $MM = Matrix( $Mt->extract(1), $Mt->extract(2), $Mt->extract(3), $Mt->extract(4), )->transpose;So you could use that to get the square matrix whose LR decomposition you would need to compute.
There are a couple of other minor issues as well: I would recommend using \rm
in your chemical equations to get the right font for the chemicals:
$chem[0] ="\rm Sn O_2 + H_2 \rightarrow Sn + H_2 O"; $chemxs[0] ="x_1{\rm Sn O_2} + x_2{\rm H_2} \rightarrow x_3{\rm Sn} + x_4{\rm H_2 O}";Also, creating
$A
dynamically from your row arrays is easy:
$A = Matrix([@ar1],[@ar2],[@ar3]);
See if any of that helps.
Davide