Skip to content

Add SVG writer for matrices

Santiago Ospina De Los Ríos requested to merge feature/write-matrix-to-svg into master

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

matrix-3.svg

matrix-0.svg

matrix-13.svg

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

output

Edited by Santiago Ospina De Los Ríos

Merge request reports

Loading