code: def norm(x, pnorm='2'):
      
      # TODO check dimensions of x
      # TODO speedup complex case
  
      x = np.ravel(x)
  
      if pnorm == '2':
          return np.sqrt(np.inner(x.conj(), x).real)
      elif pnorm == 'inf':
          return np.max(np.abs(x))
      else:
          raise ValueError('Only the 2-norm and infinity-norm are supported')
docs: 2-norm of a vector.
  
      Parameters
      ----------
      x : array_like
          Vector of complex or real values
  
      pnorm : string
          '2' calculates the 2-norm
          'inf' calculates the infinity-norm
  
      Returns
      -------
      n : float
          2-norm of a vector
  
      Notes
      -----
      - currently 1+ order of magnitude faster than scipy.linalg.norm(x), which
        calls sqrt(numpy.sum(real((conjugate(x)*x)),axis=0)) resulting in an
        extra copy
      - only handles the 2-norm and infinity-norm for vectors
  
      See Also
      --------
      scipy.linalg.norm : scipy general matrix or vector norm