Add SVG writer for matrices
Summary
Grasping nested matrix structures is challenging. When the matrix has more than one block level, writing down the values and indices help very little to get an idea of how the matrix looks like. I am not aware of any tool for visualizing blocked matrices, so this MR resolves that question.
What does this MR do?
This MR adds a function to write matrices into the SVG format. In particular, the function calculates recursively the bounding box of every block in a possible nested matrix and writes an SVG object in it.
Features:
- The default options write a rectangle on every bounding box and a title with their multi-indices (in HTML, the title appears on mouse hover).
- The SVG can be customized to write any SVG object in their bounding box (e.g. colored blocks or any custom glyph).
- It works with many types of nested matrices:
FieldMatrix
,DiagonalMatrix
,ScaledIdentityMatrix
,BCRSMatrix
, etc.
Examples
How about medium matrices?
Redering SVG directly may not work if there are too many entries. In that case, it is very simple to convert SVG to PNG using inkscape
inkscape -z -w 20000 -h 20000 matrix.svg -e matrix.png
Example
Merge request reports
Activity
added discussion feature suggestion labels
Personally, I would write the matrix out in matlab format, fire up octave and use
spy(mat)
. But that does omit stored zeroes. (I faintly recalled that I might also have used gnuplot before).But this is definitely more fancy. Does it work with MultitypeBlockMatrix, too?
thanks a lot
Edited by Markus BlattI don’t think so. However there is only one loop definition over the matrix:
for_each_entry
. It could be specialised for that case to use hybrid loops or unpack indices. Is there a generic way to check for MultitypeBlockMatrix?Edited by Santiago Ospina De Los Ríos
mentioned in commit 0aa93fd7
mentioned in merge request !464 (merged)