function _getSubmatrix (data, index) {
    const maxDepth = index.size().length - 1
    const size = Array(maxDepth)
    return { data: getSubmatrixRecursive(data), size }

    function getSubmatrixRecursive (data, depth = 0) {
      const ranges = index.dimension(depth)
      size[depth] = ranges.size()[0]
      if (depth < maxDepth) {
        return ranges.map(rangeIndex => {
          validateIndex(rangeIndex, data.length)
          return getSubmatrixRecursive(data[rangeIndex], depth + 1)
        }).valueOf()
      } else {
        return ranges.map(rangeIndex => {
          validateIndex(rangeIndex, data.length)
          return data[rangeIndex]
        }).valueOf()
      }
    }
  }
Get a submatrix of a multi dimensional matrix.
Index is not checked for correct number or length of dimensions.
@memberof DenseMatrix
@param {Array} data
@param {Index} index
@return {Array} submatrix
@private