Sleipnir C++ API
Loading...
Searching...
No Matches
sleipnir::Spy Class Reference

#include <sleipnir/util/Spy.hpp>

Public Member Functions

 Spy (std::string_view filename, std::string_view title, std::string_view rowLabel, std::string_view colLabel, int rows, int cols)
 
void Add (const Eigen::SparseMatrix< double > &mat)
 

Detailed Description

Writes the sparsity pattern of a sparse matrix to a file.

Each file represents the sparsity pattern of one matrix over time. spy.py can display it as an animation.

The file starts with the following header:

  1. Plot title (length as a little-endian int32, then characters)
  2. Row label (length as a little-endian int32, then characters)
  3. Column label (length as a little-endian int32, then characters)

Then, each sparsity pattern starts with:

  1. Number of coordinates as a little-endian int32

followed by that many coordinates in the following format:

  1. Row index as a little-endian int32
  2. Column index as a little-endian int32
  3. Sign as a character ('+' for positive, '-' for negative, or '0' for zero)
Parameters
[out]fileA file stream.
[in]matThe sparse matrix.

Constructor & Destructor Documentation

◆ Spy()

sleipnir::Spy::Spy ( std::string_view  filename,
std::string_view  title,
std::string_view  rowLabel,
std::string_view  colLabel,
int  rows,
int  cols 
)
inline

Constructs a Spy instance.

Parameters
filenameThe filename.
titlePlot title.
rowLabelRow label.
colLabelColumn label.
rowsThe sparse matrix's number of rows.
colsThe sparse matrix's number of columns.

Member Function Documentation

◆ Add()

void sleipnir::Spy::Add ( const Eigen::SparseMatrix< double > &  mat)
inline

Adds a matrix to the file.

Parameters
matThe matrix.

The documentation for this class was generated from the following file: