Adding support for pretty printing of 2D arrays

Morten Olsen Lysgaard <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAOujwNE6a+fM9ge=2dyMQObuPc20YRGsMkSLgc45wyHddGo5Fw@mail.gmail.com>
Hi, lately I have been working with the C++ Eigen [1] linear algebra
template library.
Naturally Eigen has data structures for Matrices. Currently when
pretty printing these the  content is shown in the following way.

A matrix

M = [1 2
     3 4]

would be pretty printed in the following way

[0,0] = 1, [0,1] = 2, [1,0] = 3, [1,1] = 4

which is better than the "array" pretty pretty printing hint which gives just

1 2 3 4

I would like to know if it makes sense to add 2D, and possibly a
n-dimensional, array pretty printing hint and logic?

If so I would like to invest some time to implement this.

The rationale behind such a feature is to simplify debugging numerical
code using data structures of the kind

struct matrix {
  int rows;
  int cols;
  double *data;
};

which, at least in my field, are very normal.

[1] http://eigen.tuxfamily.org/

Have a nice day! - Morten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.