changeset 10755:6ba7937a6fa4

more array-like methods in octave_map
author Jaroslav Hajek <highegg@gmail.com>
date Fri, 25 Jun 2010 10:47:14 +0200
parents 92eb5fb58ebc
children d808eb829d48
files src/oct-map.cc src/oct-map.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/oct-map.cc	Fri Jun 25 10:19:26 2010 +0200
+++ b/src/oct-map.cc	Fri Jun 25 10:47:14 2010 +0200
@@ -811,6 +811,22 @@
   return retval;
 }
 
+// Perhaps one day these will be optimized. Right now, they just call index.
+octave_map 
+octave_map::column (octave_idx_type k) const
+{
+  return index (idx_vector::colon, k);
+}
+
+octave_map 
+octave_map::page (octave_idx_type k) const
+{
+  static Array<idx_vector> ia (3, 1, idx_vector::colon);
+
+  ia(2) = k;
+  return index (ia);
+}
+
 void
 octave_map::assign (const idx_vector& i, const octave_map& rhs)
 {
--- a/src/oct-map.h	Fri Jun 25 10:19:26 2010 +0200
+++ b/src/oct-map.h	Fri Jun 25 10:47:14 2010 +0200
@@ -363,6 +363,15 @@
   octave_scalar_map
   checkelem (const Array<octave_idx_type>& ra_idx) const;
 
+  octave_scalar_map operator () (octave_idx_type n) const
+    { return checkelem (n); }
+  octave_scalar_map operator () (octave_idx_type i, octave_idx_type j) const
+    { return checkelem (i, j); }
+
+  octave_scalar_map
+  operator () (const Array<octave_idx_type>& ra_idx) const
+    { return checkelem (ra_idx); }
+
   octave_map squeeze (void) const; 
 
   octave_map permute (const Array<int>& vec, bool inv = false) const; 
@@ -393,6 +402,9 @@
 
   octave_map index (const octave_value_list&, bool resize_ok = false) const;
   
+  octave_map column (octave_idx_type k) const;
+  octave_map page (octave_idx_type k) const;
+
   void assign (const idx_vector& i, const octave_map& rhs);
 
   void assign (const idx_vector& i, const idx_vector& j, const octave_map& rhs);