Mercurial > hg > octave-avbm
changeset 1041:7dbf5bb19bde
[project @ 1995-01-18 15:06:19 by jwe]
author | jwe |
---|---|
date | Wed, 18 Jan 1995 15:07:02 +0000 |
parents | ba91ca569177 |
children | 1173ee1952be |
files | src/Array-tc.cc src/SLStack-sym.cc src/pt-const.h src/tc-inlines.h src/tc-rep-ass.cc src/tc-rep-idx.cc src/tc-rep.cc src/tc-rep.h |
diffstat | 8 files changed, 74 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/src/Array-tc.cc +++ b/src/Array-tc.cc @@ -28,6 +28,21 @@ #include "tree-const.h" +extern template class ArrayRep<int>; +extern template class Array<int>; +extern template class Array2<int>; +extern template class DiagArray<int>; + +extern template class ArrayRep<double>; +extern template class Array<double>; +extern template class Array2<double>; +extern template class DiagArray<double>; + +extern template class ArrayRep<Complex>; +extern template class Array<Complex>; +extern template class Array2<Complex>; +extern template class DiagArray<Complex>; + template class ArrayRep<tree_constant>; template class Array<tree_constant>;
--- a/src/SLStack-sym.cc +++ b/src/SLStack-sym.cc @@ -28,6 +28,11 @@ #include "symtab.h" +extern template class SLNode<unsigned>; +extern template class SLList<unsigned>; +extern template class Stack<unsigned>; +extern template class SLStack<unsigned>; + template class SLNode<symbol_def *>; template class SLList<symbol_def *>; template class Stack<symbol_def *>;
--- a/src/pt-const.h +++ b/src/pt-const.h @@ -241,6 +241,11 @@ int valid_as_scalar_index (void) const { return rep->valid_as_scalar_index (); } +// Is this constant valid as a zero scalar index? + + int valid_as_zero_index (void) const + { return rep->valid_as_zero_index (); } + // Does this constant correspond to a truth value? int is_true (void) const { return rep->is_true (); }
--- a/src/tc-inlines.h +++ b/src/tc-inlines.h @@ -293,6 +293,18 @@ && args(0).valid_as_scalar_index ())); } +static inline int +valid_zero_index (const Octave_object& args) +{ + int nargin = args.length (); + + return ((nargin == 2 + && args(1).valid_as_zero_index () + && args(0).valid_as_zero_index ()) + || (nargin == 1 + && args(0).valid_as_zero_index ())); +} + /* ;;; Local Variables: *** ;;; mode: C++ ***
--- a/src/tc-rep-ass.cc +++ b/src/tc-rep-ass.cc @@ -104,10 +104,9 @@ int nargin = args.length (); - if ((rhs.is_scalar_type () || rhs.is_zero_by_zero ()) - && valid_scalar_indices (args)) + if (rhs.is_zero_by_zero ()) { - if (rhs.is_zero_by_zero ()) + if (valid_scalar_indices (args)) { if (type_tag == complex_scalar_constant) delete complex_scalar; @@ -115,7 +114,15 @@ matrix = new Matrix (0, 0); type_tag = matrix_constant; } - else if (type_tag == unknown_constant || type_tag == scalar_constant) + else if (! valid_zero_index (args)) + { + ::error ("invalid assigment of empty matrix to scalar"); + return; + } + } + else if (rhs.is_scalar_type () && valid_scalar_indices (args)) + { + if (type_tag == unknown_constant || type_tag == scalar_constant) { if (rhs.const_type () == scalar_constant) {
--- a/src/tc-rep-idx.cc +++ b/src/tc-rep-idx.cc @@ -135,8 +135,8 @@ } else { - int rows = 0; - int cols = 0; + int rows = -1; + int cols = -1; int nargin = args.length (); @@ -212,16 +212,23 @@ else break; -// If only one index, cols will not be set. +// If only one index, cols will not be set, so we set it. +// If single index is [], rows will be zero, and we should set cols to +// zero too. - if (cols == 0) + if (cols < 0) { - if (user_pref.prefer_column_vectors) - cols = 1; + if (rows == 0) + cols = 0; else { - cols = rows; - rows = 1; + if (user_pref.prefer_column_vectors) + cols = 1; + else + { + cols = rows; + rows = 1; + } } }
--- a/src/tc-rep.cc +++ b/src/tc-rep.cc @@ -652,6 +652,16 @@ } int +TC_REP::valid_as_zero_index (void) const +{ + return ((type_tag == scalar_constant && NINT (scalar) == 0) + || (type_tag == matrix_constant + && matrix->rows () == 0 && matrix->columns () == 0) + || (type_tag == range_constant + && range->nelem () == 1 && NINT (range->base ()) == 0)); +} + +int TC_REP::is_true (void) const { int retval = 0;