code: public static int countNaN(double[] v) {
      int c = 0;
      for (double d : v) {
        if (Double.isNaN(d)) {
          c++;
        }
      }
      return c;
    }
docs: methods for filtering vectors ------------------------------------------