Dimension check on dot product and more idiomatic