anchor.diff:         LocateCandidate, MAX_LOCATE_SUBDIVISIONS, LOCATE_STD_CAP, &
          SQRT_PREC, REDUCE_THRESHOLD, scalar_func, dqagse, &
          specialize_curve_generic, specialize_curve_quadratic, &
  -       subdivide_nodes_generic, split_candidate, projection_error, can_reduce
  +       subdivide_nodes_generic, split_candidate, allocate_candidates, &
  +       update_candidates, projection_error, can_reduce
     public &
          CurveData, LOCATE_MISS, LOCATE_INVALID, evaluate_curve_barycentric, &
          evaluate_multi, specialize_curve, evaluate_hodograph, subdivide_nodes, &
  
positive.code:     real(c_double), intent(in) :: point(1, dimension_)
      real(c_double), intent(out) :: s_approx
      ! Variables outside of signature.
      type(LocateCandidate), allocatable :: candidates(:), next_candidates(:)
      integer(c_int) :: sub_index, cand_index
      integer(c_int) :: num_candidates, num_next_candidates
      type(LocateCandidate) :: candidate
      real(c_double), allocatable :: s_params(:)
      real(c_double) :: std_dev
      logical(c_bool) :: predicate
  
      ! Start out with the full curve.
      allocate(candidates(1))
      candidates(1) = LocateCandidate(0.0_dp, 1.0_dp, nodes)
      ! NOTE: `num_candidates` will be tracked separately
      !       from `size(candidates)`.
      num_candidates = 1
      s_approx = LOCATE_MISS
  
      do sub_index = 1, MAX_LOCATE_SUBDIVISIONS + 1
         num_next_candidates = 0
         ! Allocate maximum amount of space needed.
         allocate(next_candidates(2 * num_candidates))
         do cand_index = 1, num_candidates
            candidate = candidates(cand_index)
            call contains_nd( &
                 num_nodes, dimension_, candidate%nodes, point(1, :), predicate)
            if (predicate) then
               num_next_candidates = num_next_candidates + 2
               call split_candidate( &
                    num_nodes, dimension_, candidate, &
                    next_candidates(num_next_candidates - 1:num_next_candidates))
            end if
         end do
  
         ! If there are no more candidates, we are done.
         if (num_next_candidates == 0) then
            return
         end if
  
         ! NOTE: This may copy empty slots, but this is OK since we track
         !       `num_candidates` separately.
         call move_alloc(next_candidates, candidates)
         num_candidates = num_next_candidates
  
      end do
  
negative.code:     ! Compute the s-parameter as the mean of the **start** and
      ! **end** parameters.
      allocate(s_params(2 * num_candidates))
      if (is_even) then
         ! NOTE: We "exclude" this block from ``lcov`` because it can never
         !       be invoked while ``MAX_LOCATE_SUBDIVISIONS`` is even.
         s_params(:num_candidates) = ( &
              candidates_odd(:num_candidates)%start)  ! LCOV_EXCL_LINE
         s_params(num_candidates + 1:) = ( &
              candidates_odd(:num_candidates)%end_)  ! LCOV_EXCL_LINE
      else
         s_params(:num_candidates) = candidates_even(:num_candidates)%start
         s_params(num_candidates + 1:) = candidates_even(:num_candidates)%end_
      end if
      s_approx = sum(s_params) / (2 * num_candidates)
  
      std_dev = sqrt(sum((s_params - s_approx)**2) / (2 * num_candidates))
  