code: def _pnorm_diagweight(x, p, w):
      
      # Ravel both in the same order (w is a numpy array)
      order = 'F' if all(a.flags.f_contiguous for a in (x.data, w)) else 'C'
  
      # This is faster than first applying the weights and then summing with
      # BLAS dot or nrm2
      xp = np.abs(x.data.ravel(order))
      if p == float('inf'):
          xp *= w.ravel(order)
          return np.max(xp)
      else:
          xp = np.power(xp, p, out=xp)
          xp *= w.ravel(order)
          return np.sum(xp) ** (1 / p)
docs: Diagonally weighted p-norm implementation.