$answerAi = $B->normalize(Matrix($v)->transpose);to avoid the error message. You will need to do the same for
$answerGi = $D->solve_LR($v);making it
$answerGi = $D->solve_LR(Matrix($v)->transpose);but there is a problem here, since
$D
is 2 x 2, while $v
is three-dimensional. So something needs to be adjusted there.