The more efficient approach is not to copy a Mat back into an OutputArray output, but to get a reference to the (previously sized) matrix and populate it:
cv::Mat& A = output.getMatRef();