function checkEqualDimensions(x, y) {
  var xsize = x.size();
  var ysize = y.size();

  if (xsize.length !== ysize.length) {
    throw new DimensionError(xsize.length, ysize.length);
  }
}
Check whether matrix x and y have the same number of dimensions.
Throws a DimensionError when dimensions are not equal
@param {Matrix} x
@param {Matrix} y