60 Spy(std::string_view filename, std::string_view title,
61 std::string_view rowLabel, std::string_view colLabel,
int rows,
int cols)
62 : m_file{std::string{filename}, std::ios::binary} {
64 Write32le(title.size());
65 m_file.write(title.data(), title.size());
68 Write32le(rowLabel.size());
69 m_file.write(rowLabel.data(), rowLabel.size());
72 Write32le(colLabel.size());
73 m_file.write(colLabel.data(), colLabel.size());
85 void Add(
const Eigen::SparseMatrix<double>& mat) {
87 Write32le(mat.nonZeros());
90 for (
int k = 0; k < mat.outerSize(); ++k) {
91 for (Eigen::SparseMatrix<double>::InnerIterator it{mat, k}; it; ++it) {
94 if (it.value() > 0.0) {
96 }
else if (it.value() < 0.0) {