function _resize(matrix, size, defaultValue) {
    // check size
    if (size.length === 0) {
      // first value in matrix
      var v = matrix._data; // go deep

      while (isArray(v)) {
        v = v[0];
      }

      return v;
    } // resize matrix


    matrix._size = size.slice(0); // copy the array

    matrix._data = array.resize(matrix._data, matrix._size, defaultValue); // return matrix

    return matrix;
  }
Resize the matrix to the given size. Returns a copy of the matrix when
`copy=true`, otherwise return the matrix itself (resize in place).

@memberof DenseMatrix
@param {number[]} size           The new size the matrix should have.
@param {*} [defaultValue=0]      Default value, filled in on new entries.
                                 If not provided, the matrix elements will
                                 be filled with zeros.
@param {boolean} [copy]          Return a resized copy of the matrix

@return {Matrix}                 The resized matrix