Updating who/whos

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating who/whos

Oyvind Kristiansen-2
I've written a patch for updating who/whos.

What's new:
-ability to print information on memory used by variables
-ability to print descriptor of dimensions, instead of just rows and cols
(as it is today)

Two internal variables now rule the output from who/whos:
-who_traditional=true|false (defaults to false), tells Octave what
ordering is to be used per line of information, and what kind of
information is to be displayed. who_traditional=true will
cause an output similar to the output from who/whos in Matlab.
who_traditional=true, will cause an output much like the existing output.
-who_print_dims controls how many dimensions will be displayed. In Matlab,
when an array is 2x3x2x4, Matlab will tell it's a 4-D array. Octave will
check who_print_dims to find out how to print this information.

Cheers,
Oeyvind

test_who.m (419 bytes) Download Attachment
patch (89K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Updating who/whos

John W. Eaton-6
On  4-Feb-2004, Oyvind Kristiansen <[hidden email]> wrote:

| I've written a patch for updating who/whos.
|
| What's new:
| -ability to print information on memory used by variables
| -ability to print descriptor of dimensions, instead of just rows and cols
| (as it is today)
|
| Two internal variables now rule the output from who/whos:
| -who_traditional=true|false (defaults to false), tells Octave what
| ordering is to be used per line of information, and what kind of
| information is to be displayed. who_traditional=true will
| cause an output similar to the output from who/whos in Matlab.
| who_traditional=true, will cause an output much like the existing output.
| -who_print_dims controls how many dimensions will be displayed. In Matlab,
| when an array is 2x3x2x4, Matlab will tell it's a 4-D array. Octave will
| check who_print_dims to find out how to print this information.

I agree that whos needs to be updated for N-d arrays objects, but I'm
not sure that we need to have output that exactly mimics the output
from Matlab.  But maybe there is a reason that is needed.  If so, what
is it?

So, I think I would prefer to see the format updated so that it always
displays the full list of dimensions (at least up to some more
reasonable limit -- perhaps 8 would be enough for most uses.)

Displaying the number of bytes used is also reasonable.

Currently, Octave displays information about whether a variable is
read-only but even I can't remember what the code means, and I don't
think it is particularly useful, so maybe that could go away.

Or, if you really think that there should be multiple output formats
allowed, then I think a much better solution would be to provide a way
to control the output using some kind of format string.

Comments?

jwe


Reply | Threaded
Open this post in threaded view
|

Re: Updating who/whos

Oyvind Kristiansen-2


On Fri, 6 Feb 2004, John W. Eaton wrote:

> On  4-Feb-2004, Oyvind Kristiansen <[hidden email]> wrote:
>
> | I've written a patch for updating who/whos.
> |
> | What's new:
> | -ability to print information on memory used by variables
> | -ability to print descriptor of dimensions, instead of just rows and cols
> | (as it is today)
> |
> | Two internal variables now rule the output from who/whos:
> | -who_traditional=true|false (defaults to false), tells Octave what
> | ordering is to be used per line of information, and what kind of
> | information is to be displayed. who_traditional=true will
> | cause an output similar to the output from who/whos in Matlab.
> | who_traditional=true, will cause an output much like the existing output.
> | -who_print_dims controls how many dimensions will be displayed. In Matlab,
> | when an array is 2x3x2x4, Matlab will tell it's a 4-D array. Octave will
> | check who_print_dims to find out how to print this information.
>
> I agree that whos needs to be updated for N-d arrays objects, but I'm
> not sure that we need to have output that exactly mimics the output
> from Matlab.  But maybe there is a reason that is needed.  If so, what
> is it?

I can agree. But I think that the name of the variable is the most
important aspect of the variable, and that it should be printed first.

Also, I think the Matlab summary is necessary: "Grand total is xxx
element(s) using yyy byte(s)".

And, lastly, I think the matlab'ish way of printing headers meets the eye.
I think a header like:
  Name    Size      Bytes    Class

is much nicer (and "cleaner") than:
prot    type    rows  cols   name
====    ====    ====  ====   ====

>
> So, I think I would prefer to see the format updated so that it always
> displays the full list of dimensions (at least up to some more
> reasonable limit -- perhaps 8 would be enough for most uses.)
>
> Displaying the number of bytes used is also reasonable.
>
> Currently, Octave displays information about whether a variable is
> read-only but even I can't remember what the code means, and I don't
> think it is particularly useful, so maybe that could go away.
>
> Or, if you really think that there should be multiple output formats
> allowed, then I think a much better solution would be to provide a way
> to control the output using some kind of format string.
>

A format string is generally a good idea:
* it is possible to choose what information to print
* it is possible to choose how to organize the information is printed

There are however some drawbacks/points to consider:
* it will require more computation in advance to make the format
  more general (the original whos printout requires little computation in
  advance).
* in the current patch, computational effort in advance can easily be
  determined
* not all ways of printing variables will be favorable (for instance,
  name of variable is the most important aspect. Also, I think the way
  Matlab aligns bytes comunt together with class column is nice and
  "space-conserving"
* how sophisticated should a format string be to be useful? Should it
  contain information on alignment, and minimum space required by each
  column?

I think point 3 and 4 are the most important.

-Oeyvind

However, I favor the format string myself.

> Comments?
>
> jwe
>


Reply | Threaded
Open this post in threaded view
|

Re: Updating who/whos

Oyvind Kristiansen-2
In reply to this post by Oyvind Kristiansen-2
I've rewritten the patch for updating who/whos.

What's new (compared with the existing output):
-ability to print information on memory used by variables
-ability to print descriptor of dimensions, instead of just rows and cols
 (as it is today)

Two internal variables now describe the output from who/whos:
-whos_line_format, tells Octave what ordering is to be used per line of
 information and what information is to be included. It is a format
 string.
-whos_print_dims controls how many dimensions will be displayed. In Matlab,
 when an array is 2x3x2x4, Matlab will tell it's a 4-D array. Octave will
 check whos_print_dims to find out how to print this information.

Any comments?

Cheers,
Oeyvind

patch (56K) Download Attachment
ChangeLog (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Updating who/whos

John W. Eaton-6
On  3-Mar-2004, Oyvind Kristiansen <[hidden email]> wrote:

| I've rewritten the patch for updating who/whos.
|
| What's new (compared with the existing output):
| -ability to print information on memory used by variables
| -ability to print descriptor of dimensions, instead of just rows and cols
|  (as it is today)
|
| Two internal variables now describe the output from who/whos:
| -whos_line_format, tells Octave what ordering is to be used per line of
|  information and what information is to be included. It is a format
|  string.
| -whos_print_dims controls how many dimensions will be displayed. In Matlab,
|  when an array is 2x3x2x4, Matlab will tell it's a 4-D array. Octave will
|  check whos_print_dims to find out how to print this information.
|
| Any comments?

OK, I think a format string is a good idea.  But with the format
string, why do we need whos_print_dims?  How about a separate format
specifier for that option?

|   template <class T>
| + void
| + Array<T>::compute_size (long& elements, long& bytes) const
| + {
| +   elements = nelem ();
| +   bytes = sizeof (T) * elements;
| + }

If possible, I generally prefer to avoid methods that return multiple
values via reference arguments.  Also, this is somewhat redundant now
because the octave_value class now has

  int numel (void) const;

for the number of elements, and

  virtual size_t byte_size (void) const;

for the size of the object in bytes.  Can you please rewrite your
patch to use these methods instead of compute_size?







| + template <class T>
|   int
|   Array<T>::compute_index (const Array<int>& ra_idx) const
|   {
| Index: octave/liboctave/Array.h
| ===================================================================
| RCS file: /cvs/octave/liboctave/Array.h,v
| retrieving revision 1.86
| diff -p -c -r1.86 Array.h
| *** octave/liboctave/Array.h 2004/03/02 05:12:32 1.86
| --- octave/liboctave/Array.h 2004/03/02 23:37:03
| *************** public:
| *** 256,261 ****
| --- 256,263 ----
|     static int get_size (int r, int c, int p);
|     static int get_size (const dim_vector& dv);
|  
| +   void compute_size (long& elements, long& bytes) const;
| +
|     int compute_index (const Array<int>& ra_idx) const;
|  
|     T range_error (const char *fcn, int n) const;
| Index: octave/src/Cell.cc
| ===================================================================
| RCS file: /cvs/octave/src/Cell.cc,v
| retrieving revision 1.11
| diff -p -c -r1.11 Cell.cc
| *** octave/src/Cell.cc 2004/03/02 05:12:32 1.11
| --- octave/src/Cell.cc 2004/03/02 23:37:03
| *************** Software Foundation, 59 Temple Place - S
| *** 29,36 ****
| --- 29,38 ----
|   #endif
|  
|   #include "idx-vector.h"
| + #include "Array-util.h"
|  
|   #include "Cell.h"
| + #include "dim-vector.h"
|  
|   Cell::Cell (const string_vector& sv)
|     : ArrayN<octave_value> ()
| *************** Cell::index (const octave_value_list& id
| *** 85,90 ****
| --- 87,113 ----
|       }
|  
|     return retval;
| + }
| +
| + void
| + Cell::compute_size (long &elements, long &bytes) const
| + {
| +   long elements1, bytes1;
| +   int nr_elems = nelem ();
| +
| +   elements = 0;
| +   bytes = 0;
| +
| +   for (int i = 0; i < nr_elems; i++)
| +     {
| +       // Compute size of every element in the array
| +
| +       octave_value val;
| +       val = elem (i);
| +       val.compute_size (elements1, bytes1);
| +       elements += elements1;
| +       bytes += bytes1;
| +     }
|   }
|  
|   Cell&
| Index: octave/src/Cell.h
| ===================================================================
| RCS file: /cvs/octave/src/Cell.h,v
| retrieving revision 1.18
| diff -p -c -r1.18 Cell.h
| *** octave/src/Cell.h 2004/03/02 05:12:32 1.18
| --- octave/src/Cell.h 2004/03/02 23:37:04
| *************** public:
| *** 96,101 ****
| --- 96,103 ----
|     // XXX FIXME XXX
|     boolMatrix any (int dim = 0) const { return boolMatrix (); }
|  
| +   void compute_size (long &elements, long &bytes) const;
| +
|     int cat (const Cell& ra_arg, int dim, int iidx, int move);
|  
|     // XXX FIXME XXX
| Index: octave/src/ov-base-mat.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-base-mat.cc,v
| retrieving revision 1.26
| diff -p -c -r1.26 ov-base-mat.cc
| *** octave/src/ov-base-mat.cc 2004/02/06 00:59:45 1.26
| --- octave/src/ov-base-mat.cc 2004/03/02 23:37:04
| *************** octave_base_matrix<MT>::is_true (void) c
| *** 201,206 ****
| --- 201,213 ----
|   }
|  
|   template <class MT>
| + void
| + octave_base_matrix<MT>::compute_size (long &elements, long &bytes) const
| + {
| +   matrix.compute_size (elements, bytes);
| + }
| +
| + template <class MT>
|   bool
|   octave_base_matrix<MT>::print_as_scalar (void) const
|   {
| Index: octave/src/ov-base-mat.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-base-mat.h,v
| retrieving revision 1.29
| diff -p -c -r1.29 ov-base-mat.h
| *** octave/src/ov-base-mat.h 2003/12/16 16:47:52 1.29
| --- octave/src/ov-base-mat.h 2004/03/02 23:37:04
| *************** public:
| *** 120,125 ****
| --- 120,127 ----
|  
|     void print_info (std::ostream& os, const std::string& prefix) const;
|  
| +   void compute_size (long &elements, long &bytes) const;
| +
|   protected:
|  
|     MT matrix;
| Index: octave/src/ov-base-nd-array.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-base-nd-array.h,v
| retrieving revision 1.5
| diff -p -c -r1.5 ov-base-nd-array.h
| *** octave/src/ov-base-nd-array.h 2002/11/20 16:56:48 1.5
| --- octave/src/ov-base-nd-array.h 2004/03/02 23:37:04
| *************** public:
| *** 80,85 ****
| --- 80,87 ----
|  
|     virtual bool print_as_scalar (void) const;
|  
| +   void compute_size (long &elements, long& bytes) const { elements = 1; bytes = 0; }
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-base-scalar.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-base-scalar.cc,v
| retrieving revision 1.10
| diff -p -c -r1.10 ov-base-scalar.cc
| *** octave/src/ov-base-scalar.cc 2002/12/30 23:05:27 1.10
| --- octave/src/ov-base-scalar.cc 2004/03/02 23:37:04
| *************** octave_base_scalar<ST>::subsasgn (const
| *** 112,117 ****
| --- 112,125 ----
|  
|   template <class ST>
|   void
| + octave_base_scalar<ST>::compute_size (long& elements, long& bytes) const
| + {
| +   elements = 1;
| +   bytes = sizeof (ST);
| + }
| +
| + template <class ST>
| + void
|   octave_base_scalar<ST>::print (std::ostream& os, bool pr_as_read_syntax) const
|   {
|     print_raw (os, pr_as_read_syntax);
| *************** octave_base_scalar<ST>::print_name_tag (
| *** 134,140 ****
|   {
|     indent (os);
|     os << name << " = ";
| !   return false;    
|   }
|  
|   /*
| --- 142,148 ----
|   {
|     indent (os);
|     os << name << " = ";
| !   return false;
|   }
|  
|   /*
| Index: octave/src/ov-base-scalar.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-base-scalar.h,v
| retrieving revision 1.18
| diff -p -c -r1.18 ov-base-scalar.h
| *** octave/src/ov-base-scalar.h 2004/02/20 18:02:59 1.18
| --- octave/src/ov-base-scalar.h 2004/03/02 23:37:04
| *************** public:
| *** 93,98 ****
| --- 93,100 ----
|  
|     bool is_true (void) const { return (scalar != 0.0); }
|  
| +   void compute_size (long& elements, long& bytes) const;
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-base.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-base.h,v
| retrieving revision 1.68
| diff -p -c -r1.68 ov-base.h
| *** octave/src/ov-base.h 2004/02/20 18:02:59 1.68
| --- octave/src/ov-base.h 2004/03/02 23:37:04
| *************** public:
| *** 256,261 ****
| --- 256,263 ----
|  
|     void print_info (std::ostream& os, const std::string& prefix) const;
|  
| +     void compute_size (long& elements, long& bytes) const { elements = 1; bytes = 0; }
| +
|     bool save_ascii (std::ostream& os, bool& infnan_warned,
|     bool strip_nan_and_inf);
|  
| Index: octave/src/ov-cell.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-cell.cc,v
| retrieving revision 1.38
| diff -p -c -r1.38 ov-cell.cc
| *** octave/src/ov-cell.cc 2004/02/20 18:02:59 1.38
| --- octave/src/ov-cell.cc 2004/03/02 23:37:04
| *************** Software Foundation, 59 Temple Place - S
| *** 52,57 ****
| --- 52,59 ----
|   #include "ls-hdf5.h"
|   #include "ls-utils.h"
|  
| + #include "Array-util.h"
| +
|   template class octave_base_matrix<Cell>;
|  
|   DEFINE_OCTAVE_ALLOCATOR (octave_cell);
| *************** octave_cell::print_raw (std::ostream& os
| *** 406,411 ****
| --- 408,419 ----
|         os << "{" << dv.str () << " Cell Array}";
|         newline (os);
|       }
| + }
| +
| + void
| + octave_cell::compute_size (long& elements, long& bytes) const
| + {
| +   matrix.compute_size (elements, bytes);
|   }
|  
|   #define CELL_ELT_TAG "<cell-element>"
| Index: octave/src/ov-cell.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-cell.h,v
| retrieving revision 1.24
| diff -p -c -r1.24 ov-cell.h
| *** octave/src/ov-cell.h 2004/02/20 18:02:59 1.24
| --- octave/src/ov-cell.h 2004/03/02 23:37:04
| *************** public:
| *** 112,117 ****
| --- 112,118 ----
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
| +   void compute_size (long &elements, long &bytes) const;
|  
|     bool save_ascii (std::ostream& os, bool& infnan_warned,
|   bool strip_nan_and_inf);
| Index: octave/src/ov-colon.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-colon.h,v
| retrieving revision 1.10
| diff -p -c -r1.10 ov-colon.h
| *** octave/src/ov-colon.h 2002/05/15 03:21:00 1.10
| --- octave/src/ov-colon.h 2004/03/02 23:37:04
| *************** public:
| *** 70,75 ****
| --- 70,77 ----
|  
|     bool valid_as_zero_index (void) const { return false; }
|  
| +   void compute_size (long& elements, long& bytes) const { elements = 1; bytes = 0; }
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-cs-list.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-cs-list.cc,v
| retrieving revision 1.13
| diff -p -c -r1.13 ov-cs-list.cc
| *** octave/src/ov-cs-list.cc 2003/11/25 06:22:02 1.13
| --- octave/src/ov-cs-list.cc 2004/03/02 23:37:04
| *************** octave_cs_list::print (std::ostream& os,
| *** 60,65 ****
| --- 60,81 ----
|   }
|  
|   void
| + octave_cs_list::compute_size (long &elements, long &bytes) const
| + {
| +   int n = lst.length ();
| +   long elements1, bytes1;
| +
| +   for (int i = 0; i < n; i++)
| +     {
| +       octave_value val = lst (i);
| +
| +       val.compute_size(elements1, bytes1);
| +       elements += elements1;
| +       bytes += bytes1;
| +     }
| + }
| +
| + void
|   octave_cs_list::print_raw (std::ostream& os, bool) const
|   {
|     unwind_protect::begin_frame ("octave_cs_list_print");
| Index: octave/src/ov-cs-list.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-cs-list.h,v
| retrieving revision 1.13
| diff -p -c -r1.13 ov-cs-list.h
| *** octave/src/ov-cs-list.h 2003/11/25 06:22:02 1.13
| --- octave/src/ov-cs-list.h 2004/03/02 23:37:05
| *************** public:
| *** 77,82 ****
| --- 77,84 ----
|  
|     octave_value_list list_value (void) const { return lst; }
|  
| +   void compute_size (long &elements, long &bytes) const;
| +
|     void print (std::ostream& os, bool) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-fcn.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-fcn.h,v
| retrieving revision 1.19
| diff -p -c -r1.19 ov-fcn.h
| *** octave/src/ov-fcn.h 2004/02/20 18:44:43 1.19
| --- octave/src/ov-fcn.h 2004/03/02 23:37:05
| *************** public:
| *** 98,103 ****
| --- 98,105 ----
|  
|     virtual void accept (tree_walker&) { }
|  
| +   void compute_size (long& elements, long& bytes) const { elements = 1; bytes = 0; }
| +
|   protected:
|  
|     octave_function (const std::string& nm, const std::string& ds)
| Index: octave/src/ov-file.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-file.cc,v
| retrieving revision 1.14
| diff -p -c -r1.14 ov-file.cc
| *** octave/src/ov-file.cc 2003/11/22 12:25:44 1.14
| --- octave/src/ov-file.cc 2004/03/02 23:37:05
| *************** octave_file::print (std::ostream& os, bo
| *** 63,68 ****
| --- 63,75 ----
|   }
|  
|   void
| + octave_file::compute_size (long& elements, long& bytes) const
| + {
| +   elements = 1;
| +   bytes = sizeof (int); // Size of number -- this could be more accurate
| + }
| +
| + void
|   octave_file::print_raw (std::ostream& os, bool) const
|   {
|     indent (os); os << "{"; newline (os);
| Index: octave/src/ov-file.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-file.h,v
| retrieving revision 1.14
| diff -p -c -r1.14 ov-file.h
| *** octave/src/ov-file.h 2003/11/14 19:49:56 1.14
| --- octave/src/ov-file.h 2004/03/02 23:37:05
| *************** public:
| *** 93,98 ****
| --- 93,100 ----
|  
|     octave_value any (int = 0) const { return (number != 0.0); }
|  
| +   void compute_size (long& elements, long& bytes) const;
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-range.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-range.h,v
| retrieving revision 1.40
| diff -p -c -r1.40 ov-range.h
| *** octave/src/ov-range.h 2004/02/20 18:44:43 1.40
| --- octave/src/ov-range.h 2004/03/02 23:37:05
| *************** public:
| *** 167,172 ****
| --- 167,177 ----
|  
|     octave_value convert_to_str_internal (bool pad, bool force) const;
|  
| +   int size_of_element (void) const { return sizeof (Range); }
| +
| +   void compute_size (long &elements, long &bytes) const
| +     { bytes = size_of_element (); elements = 1; }
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-struct.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov-struct.cc,v
| retrieving revision 1.46
| diff -p -c -r1.46 ov-struct.cc
| *** octave/src/ov-struct.cc 2004/02/20 18:44:43 1.46
| --- octave/src/ov-struct.cc 2004/03/02 23:37:05
| *************** octave_struct::subsasgn (const std::stri
| *** 353,358 ****
| --- 353,381 ----
|     return retval;
|   }
|  
| + void
| + octave_struct::compute_size (long &elements, long &bytes) const
| + {
| +   // Compute total size in bytes and elements of all the map
| +
| +   long bytes1, elements1;
| +   elements = 0;
| +   bytes = 0;
| +
| +   int n = map.numel ();
| +
| +   for (Octave_map::const_iterator p = map.begin (); p != map.end (); p++)
| +     {
| +       Cell val = map.contents (p);
| +       // Follow syntax is strange ...
| +       octave_value tmp = (n == 1) ? octave_value (val, false) : octave_value (val, true);
| +
| +       tmp.compute_size (elements1, bytes1);
| +       elements += elements1;
| +       bytes += bytes1;
| +     }
| + }
| +
|   size_t
|   octave_struct::byte_size (void) const
|   {
| Index: octave/src/ov-struct.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-struct.h,v
| retrieving revision 1.28
| diff -p -c -r1.28 ov-struct.h
| *** octave/src/ov-struct.h 2004/02/20 18:02:59 1.28
| --- octave/src/ov-struct.h 2004/03/02 23:37:05
| *************** public:
| *** 103,108 ****
| --- 103,110 ----
|  
|     string_vector map_keys (void) const { return map.keys (); }
|  
| +   void compute_size (long &elements, long &bytes) const;
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov-va-args.h
| ===================================================================
| RCS file: /cvs/octave/src/ov-va-args.h,v
| retrieving revision 1.9
| diff -p -c -r1.9 ov-va-args.h
| *** octave/src/ov-va-args.h 2002/05/15 03:21:01 1.9
| --- octave/src/ov-va-args.h 2004/03/02 23:37:05
| *************** public:
| *** 62,67 ****
| --- 62,69 ----
|  
|     bool is_all_va_args (void) const { return true; }
|  
| +   void compute_size (long& elements, long& bytes) const { elements = 1; bytes = 0; }
| +
|     void print (std::ostream& os, bool pr_as_read_syntax = false) const;
|  
|     void print_raw (std::ostream& os, bool pr_as_read_syntax = false) const;
| Index: octave/src/ov.cc
| ===================================================================
| RCS file: /cvs/octave/src/ov.cc,v
| retrieving revision 1.104
| diff -p -c -r1.104 ov.cc
| *** octave/src/ov.cc 2004/02/20 18:02:59 1.104
| --- octave/src/ov.cc 2004/03/02 23:37:06
| *************** octave_value::empty_conv (const std::str
| *** 1888,1893 ****
| --- 1888,1907 ----
|     return retval;
|   }
|  
| + void
| + octave_value::compute_size (long &elements, long &bytes) const
| + {
| +   if (rep && count > 1)
| +   {
| +     rep->compute_size (elements, bytes);
| +   }
| +   else
| +     {
| +       elements = 1;
| +       bytes = sizeof (octave_value);
| +     }
| + }
| +
|   void
|   install_types (void)
|   {
| Index: octave/src/ov.h
| ===================================================================
| RCS file: /cvs/octave/src/ov.h,v
| retrieving revision 1.99
| diff -p -c -r1.99 ov.h
| *** octave/src/ov.h 2004/02/20 18:02:59 1.99
| --- octave/src/ov.h 2004/03/02 23:37:07
| *************** public:
| *** 336,341 ****
| --- 336,343 ----
|  
|     int ndims (void) const;
|  
| +   virtual void compute_size (long &elements, long &bytes) const;
| +
|     int numel (void) const;
|  
|     virtual size_t byte_size (void) const
| Index: octave/src/symtab.cc
| ===================================================================
| RCS file: /cvs/octave/src/symtab.cc,v
| retrieving revision 1.99
| diff -p -c -r1.99 symtab.cc
| *** octave/src/symtab.cc 2003/12/18 15:35:09 1.99
| --- octave/src/symtab.cc 2004/03/02 23:37:08
| *************** Software Foundation, 59 Temple Place - S
| *** 47,52 ****
| --- 47,55 ----
|   #include "utils.h"
|   #include "variables.h"
|  
| + #include "gripes.h"
| + #include "lo-mappers.h"
| +
|   unsigned long int symbol_table::symtab_count = 0;
|  
|   // Should variables be allowed to hide functions of the same name?  A
| *************** static int Vvariables_can_hide_functions
| *** 57,62 ****
| --- 60,71 ----
|   // Nonzero means we print debugging info about symbol table lookups.
|   static int Vdebug_symtab_lookups;
|  
| + // Sets the number of dimensions that are to be printed by who or whos
| + int Vwhos_print_dims;
| +
| + // Defines layout for the whos/who -long command
| + std::string Vwhos_line_format;
| +
|   octave_allocator
|   symbol_record::symbol_def::allocator (sizeof (symbol_record::symbol_def));
|  
| *************** symbol_record::pop_context (void)
| *** 410,442 ****
|       }
|   }
|  
|   void
| ! symbol_record::print_symbol_info_line (std::ostream& os) const
|   {
| !   os << (is_read_only () ? " r-" : " rw")
| !      << (is_static () || is_eternal () ? "-" : "d")
| !      << "  "
| !      << std::setiosflags (std::ios::left) << std::setw (24)
| !      << type_name () . c_str ();
|  
| !   os << std::resetiosflags (std::ios::left);
|  
| !   int nr = rows ();
| !   int nc = columns ();
|  
| !   if (nr < 0)
| !     os << "      -";
| !   else
| !     os << std::setiosflags (std::ios::right) << std::setw (7) << nr;
|  
| !   if (nc < 0)
| !     os << "      -";
| !   else
| !     os << std::setiosflags (std::ios::right) << std::setw (7) << nc;
|  
| !   os << std::resetiosflags (std::ios::right);
|  
| !   os << "  " << name () << "\n";
|   }
|  
|   void
| --- 419,652 ----
|       }
|   }
|  
| + std::string
| + symbol_record::make_dimensions_string (int& first_param_space,
| +       int& total_space) const
| + {
| +   // This method makes the dimensions-string, which is a string that
| +   // how large a object is, dimensionally.
| +   // Example: mat is a 2x3 matrix
| +
| +   long dim = 0;
| +
| +   // Calculating dimensions
| +   std::string dim_str = "";
| +   std::stringstream ss;
| +   dim_vector dimensions;
| +
| +   if (is_variable ())
| +     {
| +       if (is_matrix_type ())
| +         {
| +  dimensions = dims ();
| +  dim = dimensions.length ();
| + }
| +     }
| +
| +   first_param_space = (first_param_space >= 1 ? first_param_space : 1);
| +   total_space = (total_space >= 1 ? total_space : 1);
| +
| +   // Preparing dimension string
| +   if (dim <= Vwhos_print_dims || Vwhos_print_dims < 0)
| +     {
| +       // Only printing the dimension string as: axbxc...
| +       if (dim == 0)
| + ss << setiosflags (std::ios::right) << std::setw (first_param_space)
| +   << "1" << resetiosflags (std::ios::right) << "x1";
| +       else
| +         {
| +  for (int i = 0; i < dim; i++)
| +    {
| +      if (i == 0)
| + {
| +  if (dim == 1)
| +    // Looks like this is not going to happen in Octave, but ...
| +    ss << setiosflags (std::ios::right) << std::setw (first_param_space)
| +       << "1" << resetiosflags (std::ios::right) << "x" << dimensions (i);
| +  else
| +    {
| +      ss << setiosflags (std::ios::right) << std::setw (first_param_space)
| + << dimensions (i) << resetiosflags (std::ios::right);
| +
| +      dim_str = ss.str ();
| +      first_param_space = (static_cast<int> (dim_str.length ()) >
| +   first_param_space ?
| +   dim_str.length () : first_param_space);
| +    }
| + }
| +      else if (i < dim && dim != 1)
| + ss << "x" << dimensions (i);
| +    }
| + }
| +     }
| +   else
| +     {
| +       // Printing dimension string as: a-D
| +       ss << setiosflags (std::ios::right) << std::setw (first_param_space)
| + << dim << resetiosflags (std::ios::right);
| +
| +       dim_str = ss.str ();
| +       first_param_space = (static_cast<int> (dim_str.length ())> first_param_space ?
| +   dim_str.length () : first_param_space);
| +
| +       ss << "-D";
| +     }
| +
| +   dim_str = ss.str ();
| +   total_space = (static_cast<int> (dim_str.length ()) > total_space ?
| +   dim_str.length () : total_space);
| +
| +   return dim_str;
| + }
| +
|   void
| ! symbol_record::print_symbol_info_line (std::ostream& os,
| !       Array<int>& param_length,
| !       int& size_first_param_length,
| !       long &elements, long &bytes) const
|   {
| !   // This method prints a line of information on a given symbol
|  
| !   unsigned int format_len = Vwhos_line_format.length (), i = 0;
| !   int par_len;
| !   int items;
| !   std::string param_string = "benpst";
| !  
| !   char command, modifier;
|  
| !   compute_size (elements, bytes);
|  
| !   while (i < format_len)
| !     {
| !       if (Vwhos_line_format[i] == '%')
| !         {
| !  // XXX FIXME XXX A lot of this code is duplicated from maybe_list
| !  // Parse one argument...
| !  int a, b;
| !  int size_first_par, pos;
| !  std::string cmd;
| !  char garbage;
| !  command = 0;
| !  modifier = 'r';
| !  par_len = 0;
|  
| !  cmd = Vwhos_line_format.substr (i, Vwhos_line_format.length ());
| !  pos = cmd.find (';');
| !
| !  if (pos != NPOS)
| !    cmd = cmd.substr (0, pos + 1);
| !  else
| !    error ("print_symbol_info_line: parameter without ; in whos_line_format");
| !
| !  i += cmd.length ();
| !
| !  if (cmd.find_first_of ("lrc") != 1)
| !    items = sscanf (cmd.c_str (), "%c%c:%d:%d;", &garbage, &command, &a, &b);
| !  else
| !    items = sscanf (cmd.c_str (), "%c%c%c:%d:%d;", &garbage, &modifier, &command, &a, &b) - 1;
| !
| !  size_first_par = size_first_param_length;
| !
| !  pos = param_string.find (command);
| !  if (pos != NPOS)
| !    par_len = param_length(pos);
| !
| !  switch (items)
| !    {
| !    case 4:
| !      if ((modifier == 'c') && (command == 's'))
| ! size_first_par = (b <= 0 ? 0 :
| !  (b > size_first_param_length ?
| !   b : size_first_param_length));
| !
| !    case 3:
| !      if (pos != NPOS)
| ! par_len = (a <= 0 ? 0 : (a > par_len ? a : par_len));
| !
| !      if ((modifier == 'c') && (command == 's') && (size_first_param_length < b))
| ! par_len += b - size_first_param_length;
| !    }
| !
| !  // Do the actual printing
| !  switch (modifier)
| !    {
| !    case 'l':
| !      os << std::setiosflags (std::ios::left) << std::setw (par_len);
| !      break;
| !
| !    case 'r':
| !      os << std::setiosflags (std::ios::right) << std::setw (par_len);
| !      break;
| !
| !    case 'c':
| !      if (command == 's')
| ! os << std::setiosflags (std::ios::left)
| !   << std::setw (par_len)
| !   << make_dimensions_string (size_first_par, par_len)
| !   << std::resetiosflags (std::ios::left);
| !      else
| !        {
| !  error ("print_symbol_info_line: center modifier unaccessible with this parameter");
| !  os << std::setiosflags (std::ios::left) << std::setw (par_len);
| ! }
| !      break;
|  
| !    default:
| !      error ("print_symbol_info_line: modifier `%c' not available", modifier);
|  
| !      os << std::setiosflags (std::ios::right) << std::setw (par_len);
| !    }
| !
| !  switch (command)
| !    {
| !    case 'b':
| !      os << bytes;
| !      break;
| !
| !    case 'e':
| !      os << elements;
| !      break;
| !
| !    case 'n':
| !      os << name ();
| !      break;
| !
| !    case 'p':
| !      {
| ! std::stringstream ss;
| ! std::string str;
| !
| ! ss << (is_read_only () ? "r-" : "rw")
| !   << (is_static () || is_eternal () ? "-" : "d");
| ! str = ss.str ();
| !
| ! os << str;
| !      }
| !      break;
| !
| !    case 's':
| !      if (modifier != 'c')
| !        {
| !  int x = 0, y = 0;
| !
| !  os << make_dimensions_string (x, y);
| ! }
| !      break;
| !
| !    case 't':
| !      os << type_name ();
| !      break;
| !    }
| !
| !  os << std::resetiosflags (std::ios::left)
| !     << std::resetiosflags (std::ios::right);
| ! }
| !       else
| ! {
| !  os << Vwhos_line_format[i];
| !  i++;
| ! }
| !     }
|   }
|  
|   void
| *************** maybe_list_cmp_fcn (const void *a_arg, c
| *** 908,918 ****
| --- 1118,1247 ----
|     return a_nm.compare (b_nm);
|   }
|  
| + void
| + symbol_table::print_descriptor (std::ostream& os,
| + std::string& param_string,
| + Array<std::string>& param_names,
| + Array<int>& param_length,
| + int size_first_param_length) const
| + {
| +   int i = 0;
| +   unsigned int format_len = Vwhos_line_format.length ();
| +   char command, modifier, garbage;
| +   int pos_s = param_string.find ('s');
| +
| +   while (i < format_len)
| +     {
| +       if (Vwhos_line_format[i] == '%')
| +         {  
| +  // XXX FIXME XXX A lot of this code is duplicated from print_symbol_info_line
| +  // Parse one argument...
| +  int a, b;
| +  unsigned int size_first_par, par_len, items, pos;
| +  std::string cmd;
| +  command = 0;
| +  modifier = 'r';
| +  par_len = 0;
| +
| +  cmd = Vwhos_line_format.substr (i, Vwhos_line_format.length ());
| +  pos = cmd.find (';');
| +  if (pos != NPOS)
| +    cmd = cmd.substr (0, pos+1);
| +  else
| +    error ("maybe_list: parameter without ; in whos_line_format");
| +
| +  i += cmd.length ();
| +  
| +  if (cmd.find_first_of ("crl") != 1)
| +    items = sscanf (cmd.c_str (), "%c%c:%d:%d;",
| +    &garbage, &command, &a, &b);
| +  else
| +    items = sscanf (cmd.c_str (), "%c%c%c:%d:%d;",
| +    &garbage, &modifier, &command, &a, &b) - 1;
| +
| +  size_first_par = size_first_param_length;
| +  
| +  pos = param_string.find (command);
| +  if (pos != NPOS)
| +    par_len = param_length(pos);
| +  else
| +    par_len = 0;
| +
| +  switch (items)
| +    {
| +    case 4:
| +      if ((modifier == 'c') && (command == 's'))
| +  size_first_par = (b <= 0 ? 0 :
| +    (b > size_first_param_length ? b :
| +     size_first_param_length));
| +
| +    case 3:
| +      if (pos != NPOS)
| + par_len = (a <= 0 ? 0 : a > par_len ?
| +   a : par_len);
| +
| +      if ((modifier == 'c') && (command == 's') && (size_first_param_length < b))
| + par_len += b - size_first_param_length;
| +    }
| +
| +  // Do the actual printing
| +  switch (modifier)
| +    {
| +    case 'l':
| +      os << std::setiosflags (std::ios::left) << std::setw (par_len);
| +      break;
| +      
| +    case 'r':
| +      os << std::setiosflags (std::ios::right) << std::setw (par_len);
| +      break;
| +
| +    case 'c':
| +      if (command == 's')
| + os << std::setiosflags (std::ios::right)
| +   << std::setw (3 + size_first_par)
| +   << param_names(pos_s) << std::resetiosflags (std::ios::right)
| +   << std::setiosflags (std::ios::left)
| +   << std::setw (par_len - size_first_par - 3)
| +   << "" << std::resetiosflags (std::ios::left);
| +      else
| +        {
| +  error ("maybe_list: center modifier unaccessible with this parameter");
| +  os << std::setiosflags (std::ios::left) << std::setw (par_len);
| + }
| +      break;
| +
| +    default:
| +      error ("maybe_list: modifier `%c' not available", modifier);
| +
| +      os << std::setiosflags (std::ios::right) << std::setw (par_len);
| +    }
| +
| +  if (((command != 's') || (modifier != 'c')) && (param_string.find (command) != NPOS))
| +    os << param_names(param_string.find (command));
| +  
| +  os << std::resetiosflags (std::ios::left)
| +     << std::resetiosflags (std::ios::right);
| +
| + }
| +       else
| +         {
| +  os << Vwhos_line_format[i];
| +  i++;
| + }
| +     }
| + }
| +
|   int
|   symbol_table::maybe_list (const char *header, const string_vector& argv,
|    std::ostream& os, bool show_verbose,
|    unsigned type, unsigned scope)
|   {
| +   // This method prints information for sets of symbols, but only one set
| +   // at a time (like, for instance: all variables, og all
| +   // built-in-functions)
| +
| +   // This method invokes print_symbol_info_line to print info on every symbol
| +
|     int status = 0;
|  
|     if (show_verbose)
| *************** symbol_table::maybe_list (const char *he
| *** 923,936 ****
|  
|         if (len > 0)
|   {
| !  os << "\n" << header << "\n\n"
| !     << "prot  type                       rows   cols  name\n"
| !     << "====  ====                       ====   ====  ====\n";
|  
|    symbols.qsort (maybe_list_cmp_fcn);
|  
| !  for (int i = 0; i < len; i++)
| !    symbols(i)->print_symbol_info_line (os);
|  
|    status = 1;
|   }
| --- 1252,1344 ----
|  
|         if (len > 0)
|   {
| !  os << "\n" << header << "\n\n";
| !
| !  int size_first_param_length = 1, i;
| !  long elements = 0, bytes = 0, elements1, bytes1;
| !
| !  std::string param_string = "benpst";
| !  Array<int> param_length(param_string.length ());
| !  Array<std::string> param_names(param_string.length ());
| !  unsigned int pos_b, pos_t, pos_e, pos_n, pos_p, pos_s;
| !
| !  pos_b = param_string.find ('b');
| !  pos_t = param_string.find ('t');
| !  pos_e = param_string.find ('e');
| !  pos_n = param_string.find ('n');
| !  pos_p = param_string.find ('p');
| !  pos_s = param_string.find ('s');
| !
| !  param_names(pos_b) = "Bytes";
| !  param_names(pos_t) = "Class";
| !  param_names(pos_e) = "Elements";
| !  param_names(pos_n) = "Name";
| !  param_names(pos_p) = "Protected";
| !  param_names(pos_s) = "Size";
|  
| +  for (i=0; i < param_string.length (); i++)
| +    param_length(i) = param_names(i).length ();
| +
| +  std::string str;
| +
|    symbols.qsort (maybe_list_cmp_fcn);
| +
| +  // Calculating necessary spacing for name column, size column,
| +  // bytes column, elements column and class column
| +  for (i = 0; i < static_cast<unsigned int> (len); i++)
| +    {
| +      std::stringstream ss1, ss2;
| +
| +      str = symbols(i)->name ();
| +      param_length(pos_n) = ((static_cast<int> (str.length ()) >
| +      param_length(pos_n)) ?
| +     str.length () : param_length(pos_n));
| +
| +      str = symbols(i)->type_name ();
| +      param_length(pos_t) = ((static_cast<int> (str.length ()) >
| +      param_length(pos_t)) ?
| +     str.length () : param_length(pos_t));
| +
| +      symbols(i)->compute_size (elements1, bytes1);
| +      elements += elements1;
| +      bytes += bytes1;
| +
| +      ss1 << elements1;
| +      str = ss1.str ();
| +      param_length(pos_e) = ((static_cast<int> (str.length ()) >
| +      param_length(pos_e)) ?
| +     str.length () : param_length(pos_e));
| +
| +      ss2 << bytes1;
| +      str = ss2.str ();
| +      param_length(pos_b) = ((static_cast<int> (str.length ()) >
| +      param_length(pos_b)) ?
| +     str.length () : param_length (pos_b));
| +
| +      symbols(i)->make_dimensions_string (size_first_param_length,
| +  param_length(pos_s));
| +    }
| +
| +  // Continue calculating necessary spacing for columns
| +  for (i = 0; i < len; i++)
| +    symbols(i)->make_dimensions_string (size_first_param_length,
| + param_length(pos_s));
| +
| +  print_descriptor (os, param_string, param_names, param_length,
| +    size_first_param_length);
| +      
| +  os << "\n";
| +
| +  for (i = 0; i < static_cast<unsigned int> (len); i++)
| +    {
| +      symbols(i)->print_symbol_info_line (os, param_length,
| +  size_first_param_length,
| +  elements1, bytes1);
| +    }
|  
| !  os << "\nGrand total is " << elements
| !     << " element" << ((elements > 1) ? "s" : "") << " using " << bytes << " byte"
| !     << ((bytes > 1) ? "s" : "") << "\n";
|  
|    status = 1;
|   }
| *************** symbol_table::maybe_list (const char *he
| *** 940,950 ****
|         string_vector symbols = name_list (argv, 1, type, scope);
|  
|         if (! symbols.empty ())
| ! {
| !  os << "\n" << header << "\n\n";
|  
|    symbols.list_in_columns (os);
|  
|    status = 1;
|   }
|       }
| --- 1348,1360 ----
|         string_vector symbols = name_list (argv, 1, type, scope);
|  
|         if (! symbols.empty ())
| !         {    
| !  os << "\nYour variables are:\n\n";
|  
|    symbols.list_in_columns (os);
|  
| +  os << "\n";
| +
|    status = 1;
|   }
|       }
| *************** debug_symtab_lookups (void)
| *** 1107,1112 ****
| --- 1517,1548 ----
|     return 0;
|   }
|  
| + static int
| + whos_print_dims (void)
| + {
| +   double val;
| +   if (builtin_real_scalar_variable ("whos_print_dims", val)
| +       && ! xisnan (val))
| +     {
| +       int ival = NINT (val);
| +       if (ival == val)
| + {
| +  Vwhos_print_dims = ival;
| +  return 0;
| + }
| +     }
| +   gripe_invalid_value_specified ("whos_print_dims");
| +   return -1;
| + }
| +
| + static int
| + whos_line_format (void)
| + {
| +   Vwhos_line_format = builtin_string_variable ("whos_line_format");
| +
| +   return 0;
| + }
| +
|   void
|   symbols_of_symtab (void)
|   {
| *************** will cause Octave to print a warning, bu
| *** 1122,1128 ****
|       "-*- texinfo -*-\n\
|   @defvr debug_symtab_lookups\n\
|   If the value of htis variable is nonzero, print debugging info when\n\
| ! searching for symbols in the symbol tables");
|   }
|  
|  
| --- 1558,1636 ----
|       "-*- texinfo -*-\n\
|   @defvr debug_symtab_lookups\n\
|   If the value of htis variable is nonzero, print debugging info when\n\
| ! searching for symbols in the symbol tables\n\
| ! @end defvr");
| !
| !   DEFVAR (whos_print_dims, 8, whos_print_dims,
| !     "-*- texinfo -*-\n\
| ! @defvr {Built-in Variable} whos_print_dims\n\
| ! The value of @code{whos_print_dims} decides how many dimensions that are \n\
| ! to be printed when issuing the @code{who} og @code{whos} commands. If\n\
| ! dimensions of the object to be printed are less than or\n\
| ! equal to @code{whos_print_dims}, dimensions of the object are printed as\n\
| ! X-D.\n\
| ! Negative numbers means there is no limit.\n\
| ! \n\
| ! Default is 8.\n\
| ! @end defvr\n\
| ! @seealso {whos_line_format}");
| !
| !   DEFVAR (whos_line_format, "  %ln:6; %cs:16:6;  %rb:12;  %lt:-1;\n", whos_line_format,
| !     "-*- texinfo -*-\n\
| ! @defvr {Built-in Variable} whos_line_format\n\
| ! This string decides in what order attributtes of variables are to be printed.\n\
| ! The following commands are used:\n\
| ! @table @code\n\
| ! @item %b\n\
| ! Prints number of bytes occupied by variables.\n\
| ! @item %e\n\
| ! Prints elements held by variables.\n\
| ! @item %n\n\
| ! Prints variable names.\n\
| ! @item %p\n\
| ! Prints protection attributtes of variables.\n\
| ! @item %s\n\
| ! Prints dimensions of variables.\n\
| ! @item %t\n\
| ! Prints type names of variables.\n\
| ! @end table\n\
| ! \n\
| ! Every command may also have a modifier:\n\
| ! @table @code\n\
| ! @item l\n\
| ! Left alignment.\n\
| ! @item r\n\
| ! Right alignment (this is the default).\n\
| ! @item c\n\
| ! Centered (may only be used by for command %s).\n\
| ! @end table\n\
| ! \n\
| ! A command is composed like this:\n\
| ! %[modifier]<command>[:size_of_parameter:[center-specific]];\n\
| ! \n\
| ! Command and modifier is already explained. Size_of_parameter\n\
| ! tells how many columns the parameter will need for printing.\n\
| ! \n\
| ! Default format is \"  %ln:6; %cs:16:6;  %rb:12;  %lt:-1;\\n\".\n\
| ! @end defvr\n\
| ! @seealso {whos_print_dims}");
| !
| ! /*
| ! @table\n\
| ! @item %b\n\
| ! Prints number of bytes occupied by variables.\n\
| ! @item %e\n\
| ! Prints elements held by variables.\n\
| ! @item %n\n\
| ! Prints variable names.\n\
| ! @item %p\n\
| ! Prints protection attributtes of variables.\n\
| ! @item %s\n\
| ! Prints dimensions of variables.\n\
| ! @item %t\n\
| ! Prints type names of variables.\n\
| ! @end table\n\
| ! */
|   }
|  
|  
| Index: octave/src/symtab.h
| ===================================================================
| RCS file: /cvs/octave/src/symtab.h,v
| retrieving revision 1.66
| diff -p -c -r1.66 symtab.h
| *** octave/src/symtab.h 2003/02/13 21:03:04 1.66
| --- octave/src/symtab.h 2004/03/02 23:37:08
| *************** private:
| *** 146,151 ****
| --- 146,160 ----
|       bool is_eternal (void) const
|         { return eternal; }
|  
| +     bool is_matrix_type (void) const
| +       { return definition.is_matrix_type (); }
| +
| +     void compute_size (long &elements, long &bytes) const
| +       { definition.compute_size (elements, bytes); }
| +
| +     dim_vector dims (void) const
| +       { return definition.dims (); }
| +
|       int rows (void) const { return definition.rows (); }
|       int columns (void) const { return definition.columns (); }
|  
| *************** public:
| *** 325,330 ****
| --- 334,350 ----
|     bool is_static (void) const { return tagged_static; }
|     void unmark_static (void) { tagged_static = false; }
|  
| +   bool is_matrix_type (void) const
| +     { return definition->is_matrix_type (); }
| +
| +   void compute_size (long &elements, long &bytes) const
| +     { definition->compute_size (elements, bytes); }
| +
| +   dim_vector dims (void) const { return definition->dims (); }
| +
| +   std::string make_dimensions_string (int& first_param_space,
| +      int& total_spacing) const;
| +
|     int rows (void) const { return definition->rows (); }
|     int columns (void) const { return definition->columns (); }
|  
| *************** public:
| *** 351,357 ****
|  
|     void pop_context (void);
|  
| !   void print_symbol_info_line (std::ostream& os) const;
|  
|     void print_info (std::ostream& os,
|     const std::string& prefix = std::string ()) const;
| --- 371,380 ----
|  
|     void pop_context (void);
|  
| !   void print_symbol_info_line (std::ostream& os,
| !       Array<int>& param_length,
| !       int& size_first_param_space,
| !       long &elements, long &bytes) const;
|  
|     void print_info (std::ostream& os,
|     const std::string& prefix = std::string ()) const;
| *************** private:
| *** 511,516 ****
| --- 534,546 ----
|  
|     static unsigned long int symtab_count;
|  
| +   void
| +   print_descriptor (std::ostream& os,
| +    std::string& param_string,
| +    Array<std::string>& param_names,
| +    Array<int>& param_length,
| +    int size_first_param_length) const;
| +
|     unsigned int hash (const std::string& s);
|  
|     // No copying!
| *************** private:
| *** 519,524 ****
| --- 549,560 ----
|  
|     symbol_table& operator = (const symbol_table&);
|   };
| +
| + // Sets the number of dimensions that are to be printed by who or whos
| + extern int Vwhos_print_dims;
| +
| + // Defines layout for the whos/who -long command.
| + extern std::string Vwhos_line_format;
|  
|   #endif
|  
| Index: octave/src/variables.cc
| ===================================================================
| RCS file: /cvs/octave/src/variables.cc,v
| retrieving revision 1.256
| diff -p -c -r1.256 variables.cc
| *** octave/src/variables.cc 2004/02/07 06:27:28 1.256
| --- octave/src/variables.cc 2004/03/02 23:37:09
| *************** Set the documentation string for @var{sy
| *** 1109,1114 ****
| --- 1109,1117 ----
|   static octave_value
|   do_who (int argc, const string_vector& argv, int return_list)
|   {
| +   // XXX FIXME XXX -- unable to retrieve useful information
| +   //                  from global variables
| +
|     octave_value retval;
|  
|     bool show_builtins = false;
| *************** do_who (int argc, const string_vector& a
| *** 1122,1128 ****
|     for (i = 1; i < argc; i++)
|       {
|         if (argv[i] == "-all" || argv[i] == "-a")
| ! {
|    show_builtins = true;
|    show_functions = true;
|    show_variables = true;
| --- 1125,1131 ----
|     for (i = 1; i < argc; i++)
|       {
|         if (argv[i] == "-all" || argv[i] == "-a")
| !         {
|    show_builtins = true;
|    show_functions = true;
|    show_variables = true;
| *************** do_who (int argc, const string_vector& a
| *** 1256,1271 ****
|   {
|    pad_after += curr_sym_tab->maybe_list
|      ("*** local user variables:", pats, octave_stdout,
| !     show_verbose, symbol_record::USER_VARIABLE, SYMTAB_LOCAL_SCOPE);
|  
|    pad_after += curr_sym_tab->maybe_list
|      ("*** globally visible user variables:", pats,
| !     octave_stdout, show_verbose, symbol_record::USER_VARIABLE,
| !     SYMTAB_GLOBAL_SCOPE);
|   }
| -
| -       if (pad_after)
| - octave_stdout << "\n";
|       }
|  
|     return retval;
| --- 1259,1272 ----
|   {
|    pad_after += curr_sym_tab->maybe_list
|      ("*** local user variables:", pats, octave_stdout,
| !     show_verbose, symbol_record::USER_VARIABLE,
| !     SYMTAB_LOCAL_SCOPE);
|  
|    pad_after += curr_sym_tab->maybe_list
|      ("*** globally visible user variables:", pats,
| !     octave_stdout, show_verbose,
| !     symbol_record::USER_VARIABLE, SYMTAB_GLOBAL_SCOPE);
|   }
|       }
|  
|     return retval;
| *************** cleared.\n\
| *** 1299,1304 ****
| --- 1300,1308 ----
|   \n\
|   @item -variables\n\
|   List user-defined variables.\n\
| + \n\
| + @item -global\n\
| + List global user-defined variables only.\n\
|   @end table\n\
|   \n\
|   Valid patterns are the same as described for the @code{clear} command\n\
| *************** are listed.  By default, only user defin
| *** 1307,1313 ****
|   visible in the local scope are displayed.\n\
|   \n\
|   The command @kbd{whos} is equivalent to @kbd{who -long}.\n\
| ! @end deffn")
|   {
|     octave_value retval;
|  
| --- 1311,1318 ----
|   visible in the local scope are displayed.\n\
|   \n\
|   The command @kbd{whos} is equivalent to @kbd{who -long}.\n\
| ! @end deffn\n\
| ! @seealso {whos_line_format, whos_print_dims}")
|   {
|     octave_value retval;
|  
| octave/liboctave
| * Array.h, Array.cc
| (Array<T>::compute_size): New method. Calculates size of Array in
| bytes occupied and elements in array. Invoked by who/whos.
|
| octave/src
| * symtab.cc
| (symbol_record::make_dimensions_string): New method
| used by print_symbol_info_line and maybe_list for printing
| dimensions of variables.
| (symbol_record::print_symbol_info_line): Changes related to
| built-in variables whos_line_format and whos_print_dims.
| Affects output from who and whos. Dimensions of matrices are
| written in any number of dimensions (controlled by
| whos_print_dims). whos_line_format controls the output format for
| whos (who -long)
| (symbol_record::maybe_list): Headers to whos listing
| updated. A footer is added.
| (symbol_record::print_descriptor): Method printing the header of
| whos listings.
| (whos_line_format, Vwhos_line_format): New built-in variables which
| sets layout from whos listings. It is a format string.
| (whos_print_dims, Vwhos_print_dims): New built-in variable which
| sets layout for dimension string in whos.
| (symbols_of_symtab): Added definition of whos_line_format and
| whos_print_dims. Also added "@end defvar" in texinfo to symbol
| definition to debug_symtab_lookups.
|
| * symtab.h
| (is_matrix_type, compute_size): New methods in symbol_record and
| symbol_record::symbol_def
| (whos_line_format, Vwhos_line_format, who_print_dims,
| Vwho_print_dims): See symtab.cc
|
| * Cell.cc, Cell.h
| (Cell::compute_size): New method. Calculates size of cell in bytes
| and elements.
|
| * ov-base.h
| (octave_base_value::compute_size): New method. Calculates size of
| variable in bytes and elements.
|
| * ov-base-mat.cc, ov-base-mat.h
| (octave_base_matrix<MT>::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-base-nd-array.h
| (octave_base_nd_array<AT>::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-base-scalar.cc, ov-base_scalar.h
| (octave_base_scalar<ST>::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-cell.cc, ov-cell.h
| (octave_cell::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-colon.h
| (octave_magic_colon::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-cs-list.cc, ov-cs-list.h
| (octave_cs_list::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-fcn.h
| (octave_function::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-file.cc, ov-file.h
| (octave_file::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-range.h
| (octave_range::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-struct.cc, ov-struct.h
| (octave_struct::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov-va-args.h
| (octave_all_va_args::compute_size): New method. Calculates
| size of variable in bytes and elements.
|
| * ov.cc, ov.h
| (octave_value::compute_size): New method. Calculates
| size of variable in bytes and elements.