# HG changeset patch # User jwe # Date 1092082919 0 # Node ID 703d97b8950757d6a846adb4f13c9deda8a2ec21 # Parent 4cf211c831585ee9dd964f1887655b65a87e1724 [project @ 2004-08-09 20:21:59 by jwe] diff -r 4cf211c83158 -r 703d97b89507 liboctave/ChangeLog --- a/liboctave/ChangeLog Fri Aug 06 16:21:20 2004 +0000 +++ b/liboctave/ChangeLog Mon Aug 09 20:21:59 2004 +0000 @@ -1,3 +1,14 @@ +2004-08-09 John W. Eaton + + * idx-vector.h (idx_vector::idx_vector_rep::tree_to_mat_idx + (const octave_int&)): New member function. + (idx_vector::idx_vector_rep::tree_to_mat_idx (double, bool&), + idx_vector::idx_vector_rep::tree_to_mat_idx (int)): + Now member functions instead of static in idx-vector.cc. + (idx_vector::idx_vector_rep::idx_vector_rep (const octave_int&), + idx_vector::idx_vector_rep::idx_vector_rep (const intNDArray&)): + New template constructors. + 2004-08-05 John W. Eaton * EIG.cc (EIG::init): Add volatile qualifier to nvr decl. diff -r 4cf211c83158 -r 703d97b89507 liboctave/idx-vector.cc --- a/liboctave/idx-vector.cc Fri Aug 06 16:21:20 2004 +0000 +++ b/liboctave/idx-vector.cc Mon Aug 09 20:21:59 2004 +0000 @@ -59,8 +59,8 @@ } } -static inline int -tree_to_mat_idx (double x, bool& conversion_error) +int +IDX_VEC_REP::tree_to_mat_idx (double x, bool& conversion_error) { int retval = -1; @@ -79,12 +79,6 @@ return retval; } -static inline int -tree_to_mat_idx (int i) -{ - return i - 1; -} - static inline bool idx_is_inf_or_nan (double x) { diff -r 4cf211c83158 -r 703d97b89507 liboctave/idx-vector.h --- a/liboctave/idx-vector.h Fri Aug 06 16:21:20 2004 +0000 +++ b/liboctave/idx-vector.h Mon Aug 09 20:21:59 2004 +0000 @@ -30,6 +30,8 @@ #include #include "dim-vector.h" +#include "oct-inttypes.h" +#include "intNDArray.h" class ColumnVector; class boolNDArray; @@ -56,6 +58,35 @@ idx_vector_rep (const NDArray& nda); + template + idx_vector_rep (const intNDArray& inda) + : data (0), len (inda.length ()), num_zeros (0), num_ones (0), + max_val (0), min_val (0), count (1), frozen_at_z_len (0), + frozen_len (0), colon (0), one_zero (0), initialized (0), + frozen (0), colon_equiv_checked (0), colon_equiv (0), + orig_dims (inda.dims ()) + { + if (len == 0) + { + initialized = 1; + return; + } + else + { + data = new int [len]; + + bool conversion_error = false; + + for (int i = 0; i < len; i++) + data[i] = tree_to_mat_idx (inda.elem (i), conversion_error); + + if (conversion_error) + return; + } + + init_state (); + } + idx_vector_rep (const Range& r); idx_vector_rep (double d); @@ -66,6 +97,21 @@ idx_vector_rep (bool b); + template + idx_vector_rep (const octave_int& i) + : data (0), len (1), num_zeros (0), num_ones (0), + max_val (0), min_val (0), count (1), frozen_at_z_len (0), + frozen_len (0), colon (0), one_zero (0), initialized (0), + frozen (0), colon_equiv_checked (0), colon_equiv (0), + orig_dims (1, 1) + { + data = new int [len]; + + data[0] = tree_to_mat_idx (i); + + init_state (); + } + idx_vector_rep (const boolNDArray& bnda); idx_vector_rep (const idx_vector_rep& a); @@ -134,6 +180,13 @@ void init_state (void); void maybe_convert_one_zero_to_idx (int z_len); + + int tree_to_mat_idx (double x, bool& conversion_error); + + int tree_to_mat_idx (int i) { return i - 1; } + + template int tree_to_mat_idx (const octave_int& i) + { return i.value () - 1; } }; public: @@ -156,6 +209,13 @@ rep->count = 1; } + template + idx_vector (const intNDArray& inda) + { + rep = new idx_vector_rep (inda); + rep->count = 1; + } + idx_vector (const Range& r) { rep = new idx_vector_rep (r); @@ -186,6 +246,13 @@ rep->count = 1; } + template + idx_vector (const octave_int& i) + { + rep = new idx_vector_rep (i); + rep->count = 1; + } + idx_vector (const boolNDArray& bnda) { rep = new idx_vector_rep (bnda); diff -r 4cf211c83158 -r 703d97b89507 src/ChangeLog --- a/src/ChangeLog Fri Aug 06 16:21:20 2004 +0000 +++ b/src/ChangeLog Mon Aug 09 20:21:59 2004 +0000 @@ -1,3 +1,8 @@ +2004-08-09 John W. Eaton + + * ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::index_vector, + OCTAVE_VALUE_INT_SCALAR_T::index_vector): New functions. + 2004-08-06 David Bateman * OPERATORS/op-struct.cc: New file. diff -r 4cf211c83158 -r 703d97b89507 src/ov-intx.h --- a/src/ov-intx.h Fri Aug 06 16:21:20 2004 +0000 +++ b/src/ov-intx.h Mon Aug 09 20:21:59 2004 +0000 @@ -71,6 +71,8 @@ return retval; } + idx_vector index_vector (void) const { return idx_vector (matrix); } + private: DECLARE_OCTAVE_ALLOCATOR @@ -119,6 +121,8 @@ return retval; } + idx_vector index_vector (void) const { return idx_vector (scalar); } + private: DECLARE_OCTAVE_ALLOCATOR