function _norm(x, p) {
    // size
    var sizeX = x.size(); // check if it is a vector

    if (sizeX.length === 1) {
      // check p
      if (p === Number.POSITIVE_INFINITY || p === 'inf') {
        // norm(x, Infinity) = max(abs(x))
        var pinf = 0; // skip zeros since abs(0) === 0

        x.forEach(function (value) {
          var v = abs(value);

          if (larger(v, pinf)) {
            pinf = v;
          }
        }, true);
        return pinf;
      }

      if (p === Number.NEGATIVE_INFINITY || p === '-inf') {
        // norm(x, -Infinity) = min(abs(x))
        var ninf; // skip zeros since abs(0) === 0

        x.forEach(function (value) {
          var v = abs(value);

          if (!ninf || smaller(v, ninf)) {
            ninf = v;
          }
        }, true);
        return ninf || 0;
      }

      if (p === 'fro') {
        return _norm(x, 2);
      }

      if (typeof p === 'number' && !isNaN(p)) {
        // check p != 0
        if (!equalScalar(p, 0)) {
          // norm(x, p) = sum(abs(xi) ^ p) ^ 1/p
          var n = 0; // skip zeros since abs(0) === 0

          x.forEach(function (value) {
            n = add(pow(abs(value), p), n);
          }, true);
          return pow(n, 1 / p);
        }

        return Number.POSITIVE_INFINITY;
      } // invalid parameter value


      throw new Error('Unsupported parameter value');
    } // MxN matrix


    if (sizeX.length === 2) {
      // check p
      if (p === 1) {
        // norm(x) = the largest column sum
        var c = []; // result

        var maxc = 0; // skip zeros since abs(0) == 0

        x.forEach(function (value, index) {
          var j = index[1];
          var cj = add(c[j] || 0, abs(value));

          if (larger(cj, maxc)) {
            maxc = cj;
          }

          c[j] = cj;
        }, true);
        return maxc;
      }

      if (p === Number.POSITIVE_INFINITY || p === 'inf') {
        // norm(x) = the largest row sum
        var r = []; // result

        var maxr = 0; // skip zeros since abs(0) == 0

        x.forEach(function (value, index) {
          var i = index[0];
          var ri = add(r[i] || 0, abs(value));

          if (larger(ri, maxr)) {
            maxr = ri;
          }

          r[i] = ri;
        }, true);
        return maxr;
      }

      if (p === 'fro') {
        // norm(x) = sqrt(sum(diag(x'x)))
        var fro = 0;
        x.forEach(function (value, index) {
          fro = add(fro, multiply(value, conj(value)));
        });
        return abs(sqrt(fro));
      }

      if (p === 2) {
        // not implemented
        throw new Error('Unsupported parameter value, missing implementation of matrix singular value decomposition');
      } // invalid parameter value


      throw new Error('Unsupported parameter value');
    }
  }
Calculate the norm for an array
@param {Matrix} x
@param {number | string} p
@returns {number} Returns the norm
@private