function _identity(rows, cols, format) {
    // BigNumber constructor with the right precision
    var Big = type.isBigNumber(rows) || type.isBigNumber(cols) ? type.BigNumber : null;
    if (type.isBigNumber(rows)) rows = rows.toNumber();
    if (type.isBigNumber(cols)) cols = cols.toNumber();

    if (!isInteger(rows) || rows < 1) {
      throw new Error('Parameters in function identity must be positive integers');
    }

    if (!isInteger(cols) || cols < 1) {
      throw new Error('Parameters in function identity must be positive integers');
    }

    var one = Big ? new type.BigNumber(1) : 1;
    var defaultValue = Big ? new Big(0) : 0;
    var size = [rows, cols]; // check we need to return a matrix

    if (format) {
      // get matrix storage constructor
      var F = type.Matrix.storage(format); // create diagonal matrix (use optimized implementation for storage format)

      return F.diagonal(size, one, 0, defaultValue);
    } // create and resize array


    var res = array.resize([], size, defaultValue); // fill in ones on the diagonal

    var minimum = rows < cols ? rows : cols; // fill diagonal

    for (var d = 0; d < minimum; d++) {
      res[d][d] = one;
    }

    return res;
  }
Create an identity matrix
@param {number | BigNumber} rows
@param {number | BigNumber} cols
@param {string} [format]
@returns {Matrix}
@private