function _setSubmatrix (data, index, submatrix) {
    const maxDepth = index.size().length - 1

    setSubmatrixRecursive(data, submatrix)

    function setSubmatrixRecursive (data, submatrix, depth = 0) {
      const range = index.dimension(depth)
      if (depth < maxDepth) {
        range.forEach((rangeIndex, i) => {
          validateIndex(rangeIndex, data.length)
          setSubmatrixRecursive(data[rangeIndex], submatrix[i[0]], depth + 1)
        })
      } else {
        range.forEach((rangeIndex, i) => {
          validateIndex(rangeIndex, data.length)
          data[rangeIndex] = submatrix[i[0]]
        })
      }
    }
  }
Replace a submatrix of a multi dimensional matrix.
@memberof DenseMatrix
@param {Array} data
@param {Index} index
@param {Array} submatrix
@private