Fix bug where comparing/checking lead to a segfault for dynamic-sized

matrices with at least one dimension being zero.
nit: no need to check for lhs and rhs, since we have made sure at this point that their dimensions are equal