function _validateMatrixDimensions(size1, size2) {
    // check left operand dimensions
    switch (size1.length) {
      case 1:
        // check size2
        switch (size2.length) {
          case 1:
            // Vector x Vector
            if (size1[0] !== size2[0]) {
              // throw error
              throw new RangeError('Dimension mismatch in multiplication. Vectors must have the same length');
            }

            break;

          case 2:
            // Vector x Matrix
            if (size1[0] !== size2[0]) {
              // throw error
              throw new RangeError('Dimension mismatch in multiplication. Vector length (' + size1[0] + ') must match Matrix rows (' + size2[0] + ')');
            }

            break;

          default:
            throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)');
        }

        break;

      case 2:
        // check size2
        switch (size2.length) {
          case 1:
            // Matrix x Vector
            if (size1[1] !== size2[0]) {
              // throw error
              throw new RangeError('Dimension mismatch in multiplication. Matrix columns (' + size1[1] + ') must match Vector length (' + size2[0] + ')');
            }

            break;

          case 2:
            // Matrix x Matrix
            if (size1[1] !== size2[0]) {
              // throw error
              throw new RangeError('Dimension mismatch in multiplication. Matrix A columns (' + size1[1] + ') must match Matrix B rows (' + size2[0] + ')');
            }

            break;

          default:
            throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix B has ' + size2.length + ' dimensions)');
        }

        break;

      default:
        throw new Error('Can only multiply a 1 or 2 dimensional matrix (Matrix A has ' + size1.length + ' dimensions)');
    }
  }
Multiply two or more values, `x * y`.
For matrices, the matrix product is calculated.

Syntax:

   math.multiply(x, y)
   math.multiply(x, y, z, ...)

Examples:

   math.multiply(4, 5.2)        // returns number 20.8
   math.multiply(2, 3, 4)       // returns number 24

   const a = math.complex(2, 3)
   const b = math.complex(4, 1)
   math.multiply(a, b)          // returns Complex 5 + 14i

   const c = [[1, 2], [4, 3]]
   const d = [[1, 2, 3], [3, -4, 7]]
   math.multiply(c, d)          // returns Array [[7, -6, 17], [13, -4, 33]]

   const e = math.unit('2.1 km')
   math.multiply(3, e)          // returns Unit 6.3 km

See also:

   divide, prod, cross, dot

@param  {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} x First value to multiply
@param  {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} y Second value to multiply
@return {number | BigNumber | Fraction | Complex | Unit | Array | Matrix} Multiplication of `x` and `y`