changeset 4938:703d97b89507

[project @ 2004-08-09 20:21:59 by jwe]
author jwe
date Mon, 09 Aug 2004 20:21:59 +0000
parents 4cf211c83158
children 22388c7625a0
files liboctave/ChangeLog liboctave/idx-vector.cc liboctave/idx-vector.h src/ChangeLog src/ov-intx.h
diffstat 5 files changed, 89 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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  <jwe@octave.org>
+
+	* idx-vector.h (idx_vector::idx_vector_rep::tree_to_mat_idx
+	(const octave_int<U>&)): 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<U>&),
+	idx_vector::idx_vector_rep::idx_vector_rep (const intNDArray<U>&)):
+	New template constructors.
+
 2004-08-05  John W. Eaton  <jwe@octave.org>
 
 	* EIG.cc (EIG::init): Add volatile qualifier to nvr decl.
--- 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)
 {
--- 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 <iostream>
 
 #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 <class U>
+    idx_vector_rep (const intNDArray<U>& 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 <class U>
+    idx_vector_rep (const octave_int<U>& 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 <class U> int tree_to_mat_idx (const octave_int<U>& i)
+      { return i.value () - 1; }
   };
 
 public:
@@ -156,6 +209,13 @@
       rep->count = 1;
     }
 
+  template <class U>
+  idx_vector (const intNDArray<U>& 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 <class U>
+  idx_vector (const octave_int<U>& i)
+    {
+      rep = new idx_vector_rep (i);
+      rep->count = 1;
+    }
+
   idx_vector (const boolNDArray& bnda)
     {
       rep = new idx_vector_rep (bnda);
--- 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  <jwe@octave.org>
+
+	* ov-intx.h (OCTAVE_VALUE_INT_MATRIX_T::index_vector,
+	OCTAVE_VALUE_INT_SCALAR_T::index_vector): New functions.
+
 2004-08-06  David Bateman  <dbateman@free.fr>
 
 	* OPERATORS/op-struct.cc: New file.
--- 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