Mercurial > hg > octave-lyh
changeset 6717:b319df52ba87
[project @ 2007-06-13 20:25:53 by jwe]
author | jwe |
---|---|
date | Wed, 13 Jun 2007 20:25:53 +0000 |
parents | 3b4a5f838de7 |
children | 509469a21cde |
files | scripts/ChangeLog scripts/miscellaneous/mkoctfile.m src/ChangeLog src/ov-bool-mat.cc src/ov-cx-mat.cc src/ov-re-mat.cc src/ov-str-mat.cc |
diffstat | 7 files changed, 125 insertions(+), 52 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,12 +1,6 @@ -2007-06-12 David Bateman <dbateman@free.fr> - - * general/Makefile.in (SOURCES): Include __spline__.m, interp3.m - and interpn.m. - -2007-06-12 David Bateman <dbateman@free.fr> - - * pkg/pkg.m (pkg:load_package_dirs): Check for field "loaded" in - structure before using it. +2007-06-13 John W. Eaton <jwe@octave.org> + + * miscellaneous/mkoctfile.m: Quote args too. 2007-06-13 Michael Goffioul <michael.goffioul@swing.be> @@ -19,6 +13,14 @@ 2007-06-12 David Bateman <dbateman@free.fr> + * general/Makefile.in (SOURCES): Include __spline__.m, interp3.m + and interpn.m. + + * pkg/pkg.m (pkg:load_package_dirs): Check for field "loaded" in + structure before using it. + +2007-06-12 David Bateman <dbateman@free.fr> + * general/interp1.m: Change examples to use new graphics interface. * general/__splinen__.m: New support function for N-dimensional spline interpolation.
--- a/scripts/miscellaneous/mkoctfile.m +++ b/scripts/miscellaneous/mkoctfile.m @@ -128,7 +128,7 @@ cmd = strcat ("\"", shell_script, "\""); for i = 1:nargin - cmd = strcat (cmd, " ", varargin{i}); + cmd = strcat (cmd, " \"", varargin{i}, "\""); endfor status = system (cmd);
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2007-06-13 John W. Eaton <jwe@octave.org> + + * ov-re-mat.cc (octave_matrix::load_ascii): + Do a better job of handling read errors and empty matrices. + * ov-cx-mat.cc (octave_complex_matrix::load_ascii): Likewise. + * ov-bool-mat.cc (octave_bool_matrix::load_ascii): Likewise. + * ov-str-mat.cc (octave_char_matrix_str::load_ascii): Likewise. + 2007-06-13 David Bateman <dbateman@free.fr> * DLD-FUNCTIONS/minmax.cc (MINMAX_BODY): Don't treat as single
--- a/src/ov-bool-mat.cc +++ b/src/ov-bool-mat.cc @@ -204,24 +204,40 @@ for (int i = 0; i < mdims; i++) is >> dv(i); - NDArray tmp(dv); - is >> tmp; + if (is) + { + boolNDArray btmp (dv); + + if (btmp.is_empty ()) + matrix = btmp; + else + { + NDArray tmp(dv); + is >> tmp; - if (!is) + if (is) + { + for (octave_idx_type i = 0; i < btmp.nelem (); i++) + btmp.elem (i) = (tmp.elem (i) != 0.); + + matrix = btmp; + } + else + { + error ("load: failed to load matrix constant"); + success = false; + } + } + } + else { - error ("load: failed to load matrix constant"); + error ("load: failed to extract dimensions"); success = false; } - - boolNDArray btmp (dv); - for (octave_idx_type i = 0; i < btmp.nelem (); i++) - btmp.elem (i) = (tmp.elem (i) != 0.); - - matrix = btmp; } else { - error ("load: failed to extract number of rows and columns"); + error ("load: failed to extract number of dimensions"); success = false; } } @@ -236,18 +252,20 @@ { Matrix tmp (nr, nc); is >> tmp; - if (!is) + if (is) + { + boolMatrix btmp (nr, nc); + for (octave_idx_type j = 0; j < nc; j++) + for (octave_idx_type i = 0; i < nr; i++) + btmp.elem (i,j) = (tmp.elem (i, j) != 0.); + + matrix = btmp; + } + else { error ("load: failed to load matrix constant"); success = false; } - - boolMatrix btmp (nr, nc); - for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = 0; i < nr; i++) - btmp.elem (i,j) = (tmp.elem (i, j) != 0.); - - matrix = btmp; } else if (nr == 0 || nc == 0) matrix = boolMatrix (nr, nc);
--- a/src/ov-cx-mat.cc +++ b/src/ov-cx-mat.cc @@ -261,19 +261,34 @@ for (int i = 0; i < mdims; i++) is >> dv(i); - ComplexNDArray tmp(dv); - is >> tmp; + if (is) + { + ComplexNDArray tmp(dv); + + if (tmp.is_empty ()) + matrix = tmp; + else + { + is >> tmp; - if (!is) + if (is) + matrix = tmp; + else + { + error ("load: failed to load matrix constant"); + success = false; + } + } + } + else { - error ("load: failed to load matrix constant"); + error ("load: failed to read dimensions"); success = false; } - matrix = tmp; } else { - error ("load: failed to extract number of rows and columns"); + error ("load: failed to extract number of dimensions"); success = false; } } @@ -288,12 +303,13 @@ { ComplexMatrix tmp (nr, nc); is >> tmp; - if (!is) + if (is) + matrix = tmp; + else { error ("load: failed to load matrix constant"); success = false; } - matrix = tmp; } else if (nr == 0 || nc == 0) matrix = ComplexMatrix (nr, nc);
--- a/src/ov-re-mat.cc +++ b/src/ov-re-mat.cc @@ -316,19 +316,34 @@ for (int i = 0; i < mdims; i++) is >> dv(i); - NDArray tmp(dv); - is >> tmp; + if (is) + { + NDArray tmp(dv); + + if (tmp.is_empty ()) + matrix = tmp; + else + { + is >> tmp; - if (!is) + if (is) + matrix = tmp; + else + { + error ("load: failed to load matrix constant"); + success = false; + } + } + } + else { - error ("load: failed to load matrix constant"); + error ("load: failed to read dimensions"); success = false; } - matrix = tmp; } else { - error ("load: failed to extract number of rows and columns"); + error ("load: failed to extract number of dimensions"); success = false; } }
--- a/src/ov-str-mat.cc +++ b/src/ov-str-mat.cc @@ -333,20 +333,34 @@ for (int i = 0; i < mdims; i++) is >> dv(i); - charNDArray tmp(dv); - char *ftmp = tmp.fortran_vec (); + if (is) + { + charNDArray tmp(dv); + + if (tmp.is_empty ()) + matrix = tmp; + else + { + char *ftmp = tmp.fortran_vec (); - // Skip the return line - if (! is.read (ftmp, 1)) - return false; + // Skip the return line + if (! is.read (ftmp, 1)) + return false; - if (! is.read (ftmp, dv.numel ()) || !is) + if (! is.read (ftmp, dv.numel ()) || !is) + { + error ("load: failed to load string constant"); + success = false; + } + else + matrix = tmp; + } + } + else { - error ("load: failed to load string constant"); + error ("load: failed to read dimensions"); success = false; } - else - matrix = tmp; } else {