Mercurial > hg > octave-lojdl
changeset 9423:f284e2a26ff9
graphics.cc (convert_cdata): return NaN for NaN values in cdata
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 08 Jul 2009 18:31:29 -0400 |
parents | d8d410b08228 |
children | 69d05d1a63b9 |
files | src/ChangeLog src/graphics.cc |
diffstat | 2 files changed, 20 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,6 +1,6 @@ 2009-07-08 John W. Eaton <jwe@octave.org> - * graphics.cc (convert_cdata): Handle NaN values in cdata. + * graphics.cc (convert_cdata): Return NaN for NaN values in cdata. * pt-assign.cc (maybe_warn_former_built_in_variable): Improve message.
--- a/src/graphics.cc +++ b/src/graphics.cc @@ -437,16 +437,25 @@ else x = xround (x - 1); - if (xisnan (x) || x < 0) - x = 0; - else if (x >= nc) - x = (nc - 1); - - octave_idx_type idx = static_cast<octave_idx_type> (x); - - av[i] = cmapv[idx]; - av[i+lda] = cmapv[idx+nc]; - av[i+2*lda] = cmapv[idx+2*nc]; + if (xisnan (x)) + { + av[i] = x; + av[i+lda] = x; + av[i+2*lda] = x; + } + else + { + if (x < 0) + x = 0; + else if (x >= nc) + x = (nc - 1); + + octave_idx_type idx = static_cast<octave_idx_type> (x); + + av[i] = cmapv[idx]; + av[i+lda] = cmapv[idx+nc]; + av[i+2*lda] = cmapv[idx+2*nc]; + } } return octave_value (a);