#pragma once

#include <cstddef>
#include <cstdint>
#include <span>
#include <vector>

#include <fesa/assembly/symmetric_csr.hpp>
#include <fesa/model/ids.hpp>

namespace fesa {

struct MatrixContribution final {
    std::size_t row;
    std::size_t column;
    ElementId element;
    std::uint16_t local_order;
    double value;
};

[[nodiscard]] std::vector<MatrixContribution> canonicalize_contributions(
    std::span<const MatrixContribution> contributions);

[[nodiscard]] SymmetricCsr merge_contributions(
    std::size_t order,
    std::span<const MatrixContribution> canonical);

}  // namespace fesa
