9#include <Eigen/SparseCore>
31 const Eigen::SparseMatrix<double>& mat) {
32 const int cells_width = mat.cols() + 1;
33 const int cells_height = mat.rows();
38 cells.
reserve(cells_width * cells_height);
41 for (
int row = 0; row < mat.rows(); ++row) {
42 for (
int col = 0; col < mat.cols(); ++col) {
49 for (
int k = 0; k < mat.outerSize(); ++k) {
50 for (Eigen::SparseMatrix<double>::InnerIterator it{mat, k}; it; ++it) {
51 if (it.value() < 0.0) {
52 cells[it.row() * cells_width + it.col()] =
'-';
53 }
else if (it.value() > 0.0) {
54 cells[it.row() * cells_width + it.col()] =
'+';
60 for (
const auto& c : cells) {
80 const Eigen::SparseMatrix<double>& mat) {
81 std::ofstream file{std::string{filename}};
82 if (!file.is_open()) {
This file defines the SmallVector class.
#define SLEIPNIR_DLLEXPORT
Definition SymbolExports.hpp:34
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition SmallVector.h:1212
reference emplace_back(ArgTypes &&... Args)
Definition SmallVector.h:953
void reserve(size_type N)
Definition SmallVector.h:679
Definition Hessian.hpp:18
SLEIPNIR_DLLEXPORT void Spy(std::ostream &file, const Eigen::SparseMatrix< double > &mat)
Write the sparsity pattern of a sparse matrix to a file.
Definition Spy.hpp:30