Mercurial > hg > octave-nkf
changeset 2436:a628e881be66
[project @ 1996-10-29 22:08:28 by jwe]
author | jwe |
---|---|
date | Tue, 29 Oct 1996 22:10:39 +0000 |
parents | 3be97fe02051 |
children | 61306ea5f870 |
files | src/ChangeLog src/load-save.cc src/ov-range.cc src/ov-range.h src/ov.cc src/strftime.c |
diffstat | 6 files changed, 63 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,16 @@ +Tue Oct 29 15:54:27 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + + * ov-range.cc (octave_range::index): New Function. + (octave_range::all, octave_range::any, octave_range::is_true): + Make these functions work. + + * ov.cc (octave_value::try_assignment_with_conversion): Remove + left over debugging print statements. + +Mon Oct 28 10:49:03 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + + * strftime.c: Add missing #endif for previous change. + Sun Oct 27 14:06:44 1996 John W. Eaton <jwe@bevo.che.wisc.edu> * oct-hist.cc (do_history): Rewite option parsing to avoid
--- a/src/load-save.cc +++ b/src/load-save.cc @@ -1149,11 +1149,13 @@ } // LEN includes the terminating character, and the file is also - // supposed to include it. + // supposed to include it, but apparently not all files do. Either + // way, I think this should work. - name = new char [len]; + name = new char [len+1]; if (! is.read (name, len)) goto data_read_error; + name[len] = '\0'; dlen = nr * nc; if (dlen < 0)
--- a/src/ov-range.cc +++ b/src/ov-range.cc @@ -78,6 +78,24 @@ return retval; } +octave_value +octave_range::index (const octave_value_list& idx) const +{ + // XXX FIXME XXX -- this doesn't solve the problem of + // + // a = 1:5; a(1, 1, 1) + // + // and similar constructions. Hmm... + + // XXX FIXME XXX -- using this constructor avoids possibly narrowing + // the range to a scalar value. Need a better solution to this + // problem. + + octave_value tmp (new octave_matrix (range.matrix_value ())); + + return tmp.index (idx); +} + double octave_range::double_value (bool) const { @@ -96,24 +114,42 @@ octave_value octave_range::all (void) const { - octave_value retval; - error ("octave_range::all(): not implemented"); - return retval; + // XXX FIXME XXX -- this is a potential waste of memory. + + Matrix m = range.matrix_value (); + + return m.all (); } octave_value octave_range::any (void) const { - octave_value retval; - error ("octave_range::any(): not implemented"); - return retval; + return (double) (range.base () != 0.0 || range.nelem () > 1); } bool octave_range::is_true (void) const { bool retval = false; - error ("octave_range::is_true(): not implemented"); + + if (range.nelem () == 0) + { + int flag = Vpropagate_empty_matrices; + + if (flag < 0) + warning ("empty range used in conditional expression"); + else if (flag == 0) + error ("empty range used in conditional expression"); + } + else + { + // XXX FIXME XXX -- this is a potential waste of memory. + + Matrix m ((range.matrix_value () . all ()) . all ()); + + retval = (m.rows () == 1 && m.columns () == 1 && m (0, 0) != 0.0); + } + return retval; }
--- a/src/ov-range.h +++ b/src/ov-range.h @@ -89,6 +89,8 @@ octave_value *try_narrowing_conversion (void); + octave_value index (const octave_value_list& idx) const; + idx_vector index_vector (void) const { return idx_vector (range); } int rows (void) const { return (columns () > 0); }