Files
FESADev/include/fesa/Math/SparsePattern.hpp
T
2026-05-05 01:16:26 +09:00

31 lines
613 B
C++

#pragma once
#include "fesa/Core/Types.hpp"
#include <algorithm>
#include <vector>
namespace fesa {
struct SparsePatternEntry {
EquationId row = 0;
EquationId col = 0;
};
struct SparsePattern {
EquationId equation_count = 0;
std::vector<SparsePatternEntry> entries;
SparseIndex nonzeroCount() const {
return static_cast<SparseIndex>(entries.size());
}
bool contains(EquationId row, EquationId col) const {
return std::any_of(entries.begin(), entries.end(), [&](const SparsePatternEntry& entry) {
return entry.row == row && entry.col == col;
});
}
};
} // namespace fesa