code: public static double[] selectByPredicate (double[] values, boolean[] predicate) {
          // Define the filtered list:
          List<Double> filtered = new ArrayList<>();
  
          // Iterate and populate:
          for (int i = 0; i < predicate.length; i++) {
              if (predicate[i]) {
                  filtered.add(values[i]);
              }
          }
  
          // Save the value:
          return ArrayUtils.toPrimitive(filtered.toArray(new Double[filtered.size()]));
      }
docs: Creates a new array by selecting those elements marked as true in the predicate array.
  
  @param values The array where the elements are going to be selected from.
  @param predicate The selection mapper.
  @return The new array with selected items.