This is a fairly nice solution to double-underlines for matrices and single-underline for vectors:
\def\mat#1{\underline{\underline{#1}}}
\def\v#1{\underline{#1}}
However, it doesn’t work well when you have multiple matrices or vectors in a row, since it underlines them all continuously:
\mat{X}\mat{X}\mat{Y}
\v{X}\v{X}\v{Y}
How do I get the above kluge to treat the matrix/vector elements as separate?
I understand that potentially may have to use different solutions/macros instead of the basic \underline.

