Adding support for pretty printing of 2D arrays

Morten Olsen Lysgaard morten@lysgaard.no
Thu Apr 17 12:33:00 GMT 2014


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



More information about the Gdb mailing list