code: private static double snorm(double[] sx) {
          int n = sx.length;
  
          double ans = 0.0;
          for (int i = 0; i < n; i++) {
              ans += sx[i] * sx[i];
          }
          return Math.sqrt(ans);
      }
docs: Compute squared root of L2 norms for a vector.