|
Janus 2.0.0
High-performance C++20 dual-mode numerical framework
|
#include <Sparsity.hpp>
Public Member Functions | |
| SparsityPattern () | |
| Default-construct an empty 0x0 pattern. | |
| SparsityPattern (const casadi::Sparsity &sp) | |
| Construct from CasADi Sparsity object. | |
| SparsityPattern (const SymbolicScalar &mx) | |
| Construct from CasADi MX (extracts its sparsity). | |
| int | n_rows () const |
| Number of rows in the pattern. | |
| int | n_cols () const |
| Number of columns in the pattern. | |
| int | nnz () const |
| Number of structural non-zeros. | |
| double | density () const |
| Sparsity density (nnz / total elements). | |
| bool | has_nz (int row, int col) const |
| Check if a specific element is structurally non-zero. | |
| std::vector< std::pair< int, int > > | nonzeros () const |
| Get all non-zero positions as (row, col) pairs. | |
| std::tuple< std::vector< int >, std::vector< int > > | get_triplet () const |
| Get triplet format (row indices, column indices). | |
| std::tuple< std::vector< int >, std::vector< int > > | get_crs () const |
| Get Compressed Row Storage (CRS) format. | |
| std::tuple< std::vector< int >, std::vector< int > > | get_ccs () const |
| Get Compressed Column Storage (CCS) format. | |
| std::string | to_string (int max_rows=40, int max_cols=80) const |
| Generate ASCII spy plot of sparsity pattern. | |
| void | export_spy_dot (const std::string &filename, const std::string &name="sparsity") const |
| Export sparsity pattern to DOT format as a matrix grid (spy plot). | |
| bool | visualize_spy (const std::string &output_base) const |
| Export/Render sparsity pattern to PDF via Graphviz. | |
| void | export_spy_html (const std::string &filename, const std::string &name="sparsity") const |
| Export sparsity pattern to an interactive HTML file. | |
| const casadi::Sparsity & | casadi_sparsity () const |
| Access underlying CasADi Sparsity object. | |
| bool | operator== (const SparsityPattern &other) const |
| bool | operator!= (const SparsityPattern &other) const |
|
inline |
Default-construct an empty 0x0 pattern.
|
inlineexplicit |
Construct from CasADi Sparsity object.
| sp | CasADi sparsity to wrap |
|
inlineexplicit |
Construct from CasADi MX (extracts its sparsity).
| mx | Symbolic expression whose sparsity is extracted |
|
inline |
Access underlying CasADi Sparsity object.
|
inline |
Sparsity density (nnz / total elements).
|
inline |
Export sparsity pattern to DOT format as a matrix grid (spy plot).
Creates a DOT file that renders as a grid where non-zeros are colored squares. This mimics standard spy() plots found in MATLAB/Python.
| filename | Output filename (without .dot extension) |
| name | Graph name |
|
inline |
Export sparsity pattern to an interactive HTML file.
Creates a self-contained HTML file with an SVG spy plot. Supports pan, zoom, and hover info showing (row, col) coordinates.
| filename | Output filename (without extension, .html will be added) |
| name | Optional title for the visualization |
|
inline |
Get Compressed Column Storage (CCS) format.
|
inline |
Get Compressed Row Storage (CRS) format.
|
inline |
Get triplet format (row indices, column indices).
|
inline |
Check if a specific element is structurally non-zero.
| row | Row index |
| col | Column index |
|
inline |
Number of columns in the pattern.
|
inline |
Number of rows in the pattern.
|
inline |
Number of structural non-zeros.
|
inline |
Get all non-zero positions as (row, col) pairs.
|
inline |
|
inline |
|
inline |
Generate ASCII spy plot of sparsity pattern.
Returns a string representation where '*' = non-zero, '.' = zero
| max_rows | Maximum rows to display (default 40) |
| max_cols | Maximum cols to display (default 80) |
|
inline |
Export/Render sparsity pattern to PDF via Graphviz.
Creates a DOT file and renders it to PDF using the dot command. Use this for high-quality visualization of sparsity patterns.
| output_base | Base filename (creates output_base.dot and output_base.pdf) |