25#include <Eigen/SparseCore>
52template <base::concepts::sparse_matrix Matrix>
69 [[nodiscard]]
auto mat() const noexcept -> const Matrix& {
return *
mat_; }
100template <base::concepts::sparse_matrix Matrix>
115template <num_collect::base::concepts::sparse_matrix Matrix>
116struct formatter<
num_collect::util::impl::sparse_matrix_format_view<Matrix>>
117 :
public formatter<typename Matrix::Scalar> {
128 format_context& context)
const ->
decltype(context.out()) {
129 const auto& mat = val.mat();
130 switch (val.type()) {
132 return format_one_line(mat, context);
134 return format_multi_line(mat, context);
149 ->
decltype(context.out()) {
150 const Eigen::Index rows = mat.rows();
151 const Eigen::Index cols = mat.cols();
152 auto out = context.out();
155 for (Eigen::Index row = 0; row < rows; ++row) {
157 out = write_comma(out);
161 for (Eigen::Index col = 0; col < cols; ++col) {
163 out = write_comma(out);
165 context.advance_to(out);
166 out = formatter<typename Matrix::Scalar>::format(
167 mat.coeff(row, col), context);
185 ->
decltype(context.out()) {
186 const Eigen::Index rows = mat.rows();
187 const Eigen::Index cols = mat.cols();
188 auto out = context.out();
193 for (Eigen::Index row = 0; row < rows; ++row) {
206 for (Eigen::Index col = 0; col < cols; ++col) {
208 out = write_comma(out);
210 context.advance_to(out);
211 out = formatter<typename Matrix::Scalar>::format(
212 mat.coeff(row, col), context);
231 -> format_context::iterator {
Class of exception on invalid arguments.
Definition of exceptions.
Definition of macros for logging.
#define NUM_COLLECT_LOG_AND_THROW(EXCEPTION_TYPE,...)
Write an error log and throw an exception for an error.
Namespace of fmt library.
@ multi_line
Multiple lines.
sparse_matrix_format_type
Enumeration of matrix format types.
@ multi_line
Multiple lines.
auto format_sparse_matrix(const Matrix &mat, sparse_matrix_format_type type=sparse_matrix_format_type::one_line)
Format a sparse matrix.
Namespace of num_collect source codes.
Definition of sparse_matrix concept.