Fix `diagmat()` for matrices
I noticed that I implemented diagmat(Mat)
incorrectly! This MR fixes that and adds corresponding tests. While I was in there, I also noticed some bugs with the code to handle conversions after a diagvec()
or diagmat()
call, so I fixed that too.