Skip to content

Commit

Permalink
Clarify tri input is unused in dsearch, change griddata to dsearchn (…
Browse files Browse the repository at this point in the history
…bug #66760).

* dsearch.m, dsearchn.m: Add note to docstring that tri input is unused for
dsearch calculation.

* griddata: Change internal dsearch call to a dsearchn call.
  • Loading branch information
NRJank committed Feb 9, 2025
1 parent 6124148 commit c036a03
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion scripts/geometry/dsearch.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
## Return the index @var{idx} of the closest point in @code{@var{x}, @var{y}}
## to the elements @code{[@var{xi}(:), @var{yi}(:)]}.
##
## The variable @var{s} is accepted for compatibility but is ignored.
## The variables @var{s} and @var{tri} are accepted for compatibility, but they
## are not used in the calculation or checked for validity.
##
## @seealso{dsearchn, tsearch}
## @end deftypefn

Expand Down
7 changes: 7 additions & 0 deletions scripts/geometry/dsearchn.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
## The optional output @var{d} contains a column vector of distances between
## the query points @var{xi} and the nearest simplex points @var{x}.
##
## Compatibility note: The @code{dsearchn} algorithm only uses the input
## @var{tri} when @var{outdim} is specified to determine if any points lie
## outside of the triangulation region. For compatibility, @var{tri} is
## accepted as an input even when @var{outdim} is not specified, but it is not
## used or checked to be a valid triangulation, and providing it will not
## affect either the output @var{idx} or the calculation efficiency.
##
## @seealso{dsearch, tsearch}
## @end deftypefn

Expand Down
2 changes: 1 addition & 1 deletion scripts/geometry/griddata.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@

elseif (strcmp (method, "nearest"))
## Search index of nearest point.
idx = dsearch (x, y, tri, xi, yi);
idx = dsearchn ([x(:), y(:)], tri, [xi(:), yi(:)]);
valid = ! isnan (idx);
zi(valid) = z(idx(valid));

Expand Down

0 comments on commit c036a03

Please sign in to comment.