code: public static double norm2(double[] x) {
          double norm = 0.0;
  
          for (double n : x) {
              norm += n * n;
          }
  
          norm = Math.sqrt(norm);
  
          return norm;
      }
docs: L2 vector norm.