Mercurial > hg > octave-lyh
changeset 4407:16e8acbd19d5
[project @ 2003-05-05 19:00:56 by jwe]
author | jwe |
---|---|
date | Mon, 05 May 2003 19:00:56 +0000 |
parents | 28f1efef88f7 |
children | e50ef03af9ba |
files | liboctave/ChangeLog liboctave/kpse.cc scripts/ChangeLog scripts/plot/hist.m |
diffstat | 4 files changed, 31 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2003-05-04 John W. Eaton <jwe@bevo.che.wisc.edu> + + * kpse.cc (dir_list_add): Ensure that directory ends with a + directory separator. + 2003-04-30 John W. Eaton <jwe@bevo.che.wisc.edu> * pathsearch.cc: Include kpse.cc here.
--- a/liboctave/kpse.cc +++ b/liboctave/kpse.cc @@ -2588,8 +2588,10 @@ dir_list_add (str_llist_type *l, const std::string& dir) { char last_char = dir[dir.length () - 1]; + std::string saved_dir = dir; - if (IS_DIR_SEP (last_char) || IS_DEVICE_SEP (last_char)) + + if (! (IS_DIR_SEP (last_char) || IS_DEVICE_SEP (last_char))) saved_dir += DIR_SEP_STRING; str_llist_add (l, saved_dir);
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2003-05-05 Andy Adler <adler@site.uottawa.ca> + + * plot/hist.m: Improve performance by using different algorithms + depending on number of bins. + 2003-05-01 John W. Eaton <jwe@bevo.che.wisc.edu> * control/system/sysadd.m: If systems are not "tf", convert before
--- a/scripts/plot/hist.m +++ b/scripts/plot/hist.m @@ -77,26 +77,32 @@ warning ("hist: bin values not sorted on input"); x = tmp; endif - n = length (x); - cutoff = zeros (1, n-1); - for i = 1:n-1 - cutoff (i) = (x (i) + x (i+1)) / 2; - endfor + cutoff = (x(1:end-1) + x(2:end)) / 2; else error ("hist: second argument must be a scalar or a vector"); endif endif - freq = zeros (1, n); - freq (1) = sum (y < cutoff (1)); - for i = 2:n-1 - freq (i) = sum (y >= cutoff (i-1) & y < cutoff (i)); - endfor - freq (n) = sum (y >= cutoff (n-1)); + if (n < 30) + ## The following algorithm works fastest for n less than about 30. + chist = [zeros(n,1); length(y)]; + for i = 1:n-1 + chist(i+1) = sum (y < cutoff(i)); + endfor + else + ## The following algorithm works fastest for n greater than about 30. + ## Put cutoff elements between boundaries, integrate over all + ## elements, keep totals at boundaries. + [s, idx] = sort ([cutoff(:); y(:)]); + chist = cumsum(idx>n); + chist = [0; chist(idx<n); chist(end)]; + endif + + freq= diff(chist)'; if (nargin == 3) ## Normalise the histogram. - freq = freq / length(y) * norm; + freq = freq / length (y) * norm; endif if (nargout > 0)