WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
slp::Spy< Scalar > Class Template Reference

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

#include </home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/util/spy.hpp>

Public Member Functions

 Spy (std::string_view filename, std::string_view title, std::string_view row_label, std::string_view col_label, int rows, int cols)
 Constructs a Spy instance.
void add (const Eigen::SparseMatrix< Scalar > &mat)
 Adds a matrix to the file.

Detailed Description

template<typename Scalar>
class slp::Spy< Scalar >

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)
Template Parameters
ScalarScalar type.

Constructor & Destructor Documentation

◆ Spy()

template<typename Scalar>
slp::Spy< Scalar >::Spy ( std::string_view filename,
std::string_view title,
std::string_view row_label,
std::string_view col_label,
int rows,
int cols )
inline

Constructs a Spy instance.

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

Member Function Documentation

◆ add()

template<typename Scalar>
void slp::Spy< Scalar >::add ( const Eigen::SparseMatrix< Scalar > & mat)
inline

Adds a matrix to the file.

Parameters
matThe matrix.

The documentation for this class was generated from the following file:
  • /home/runner/work/allwpilib/allwpilib/wpimath/src/main/native/thirdparty/sleipnir/include/sleipnir/util/spy.hpp