Mercurial > octave-nkf
diff scripts/ode/private/fuzzy_compare.m @ 20584:eb9e2d187ed2
maint: Use Octave coding conventions in scripts/ode/private dir.
* AbsRel_Norm.m, fuzzy_compare.m, hermite_quartic_interpolation.m,
integrate_adaptive.m, integrate_const.m, integrate_n_steps.m, kahan.m,
ode_struct_value_check.m, odepkg_event_handle.m, odepkg_structure_check.m,
runge_kutta_45_dorpri.m, starting_stepsize.m:
Wrap long lines to < 80 chars.
Use double quotes rather than single quotes where possible.
Use ';' at end of keywords "return;" and "break;"
Use '##" for stand-alone comments and '#' for end-of-line comments.
Use two spaces after period before starting new sentence.
Use '!' instead of '~' for logical negation.
Use specific form of end (endif, endfor, etc.).
Don't use line continuation marker '...' unless necessary.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 04 Oct 2015 22:18:54 -0700 |
parents | 25623ef2ff4f |
children | b7ac1e94266e |
line wrap: on
line diff
--- a/scripts/ode/private/fuzzy_compare.m Sun Oct 04 16:24:32 2015 +0100 +++ b/scripts/ode/private/fuzzy_compare.m Sun Oct 04 22:18:54 2015 -0700 @@ -17,14 +17,15 @@ ## <http://www.gnu.org/licenses/>. ## -*- texinfo -*- -## @deftypefn {Function File} {[@var{res}] =} fuzzy_compare (@var{"string1"}, @var{string_set}, [@var{correctness}]) +## @deftypefn {Function File} {@var{res} =} fuzzy_compare (@var{"string1"}, @var{string_set}) +## @deftypefnx {Function File} {@var{res} =} fuzzy_compare (@var{"string1"}, @var{string_set}, @var{correctness}) ## ## Compare a string with a set of strings and returns the positions in the ## set of strings at which there are the fields that best fit the one we are ## comparing. ## -## The distance used to compare the words is the Levenshtein distance -## and for more details see +## The distance used to compare the words is the Levenshtein distance. +## For more details see ## @url{http://en.wikipedia.org/wiki/Levenshtein_distance}. ## ## This function must be called with one output argument @var{res} which @@ -95,9 +96,9 @@ res = []; m = length (string1); - fields_nb = size (string_set, 1); + fields_nb = rows (string_set); - values = inf .* ones (fields_nb, 1); + values = Inf (fields_nb, 1); string1 = deblank (string1); string2 = []; @@ -121,13 +122,13 @@ positions = find (values == minimus); if (minimus == 0) # exact match - if (size (positions, 1) != 1) + if (rows (positions) != 1) error ("OdePkg:InvalidArgument", - "there are %d strings perfectly matching ''%s''", - size (positions, 1), string1); + "there are %d strings perfectly matching '%s'", + rows (positions), string1); endif res = positions; - return + return; endif ## determine the tolerance with the formula described in the @@ -142,19 +143,18 @@ && isscalar (correctness) && correctness == 0) || (ischar (correctness) - && strcmp (lower (deblank (correctness)), 'exact'))) + && strcmp (lower (deblank (correctness)), "exact"))) error ("OdePkg:InvalidArgument", - "no exact matching for string ''%s''", string1); + "no exact matching for string '%s'", string1); endif - if (isnumeric (correctness) - && isscalar (correctness)) + if (isnumeric (correctness) && isscalar (correctness)) tolerance = correctness; endif endif ## returning the positions of the fields whose distance is lower ## than the tolerance - for i = 1:1:fields_nb + for i = 1:fields_nb if (values(i) <= tolerance) res = [res; i]; endif @@ -162,6 +162,3 @@ endfunction -## Local Variables: *** -## mode: octave *** -## End: ***