12#include <dolfinx/common/types.h>
21enum class Norm : std::int8_t
31template <
class U,
class T>
33 = std::invocable<U, std::span<const std::int32_t>,
34 std::span<const std::int32_t>, std::span<const T>>;
50template <dolfinx::scalar T>
54 std::span<const T, 1> diag_span(&diagonal, 1);
55 for (std::size_t i = 0; i < std::ranges::size(rows); ++i)
57 std::span<const std::int32_t, 1> row(std::ranges::data(rows) + i, 1);
58 set_fn(row, row, diag_span);
72template <dolfinx::scalar T>
75 std::span<const T> diagonals)
77 if (diagonals.size() != std::ranges::size(rows))
79 throw std::invalid_argument(
80 std::format(
"Number of diagonal values ({}) does not match number "
82 diagonals.size(), std::ranges::size(rows)));
85 for (std::size_t i = 0; i < diagonals.size(); ++i)
89 std::span<const std::int32_t, 1>(std::ranges::data(rows) + i, 1),
Concept for a contiguous list of process-local indices, e.g. the row or column indices passed to a ma...
Definition types.h:75
Matrix accumulate/set concept for functions that can be used in assemblers to accumulate or set value...
Definition utils.h:33
Linear algebra interface.
Definition dolfinx_la.h:7
void set_diagonal(MatSet< T > auto &&set_fn, const common::LocalIndexRange auto &rows, T diagonal=T(1))
Set a value on the diagonal of a matrix for specified rows.
Definition utils.h:51
Norm
Norm types.
Definition utils.h:22