8#include "akreon/linalg/operator/operator_traits.hpp"
14template <
typename Space>
18template <linalg::SquareMatrix Mat>
19 requires(!linalg::is_symmetric_matrix_space_v<Mat>)
22 using T = linalg::space_type_t<Mat>;
23 static constexpr std::size_t N = linalg::mat_rows_v<Mat>;
24 static constexpr std::size_t Dim = linalg::space_dim_v<Mat>;
25 using Vec = linalg::Vector<T, Dim>;
28 static constexpr auto make() {
30 for (std::size_t
i = 0;
i < N; ++
i) weights(
i * N +
i) =
T(1);
36template <linalg::SquareMatrix Mat>
39 using Space = linalg::SymmetricMatrix<Mat>;
40 using T = linalg::space_type_t<Space>;
41 static constexpr std::size_t N = linalg::mat_rows_v<Mat>;
42 static constexpr std::size_t Dim = linalg::space_dim_v<Space>;
43 using Vec = linalg::Vector<T, Dim>;
46 static constexpr auto make() {
48 for (std::size_t
i = 0;
i < N; ++
i) weights(
i * (
i + 1) / 2 +
i) =
T(1);
59template <linalg::RnSpace Space>
62 using T = linalg::space_type_t<Space>;
63 static constexpr std::size_t
N = linalg::space_dim_v<Space>;
64 using Vec = linalg::Vector<T, N>;
75 template <AtomLike Var>
79 std::same_as<dom_space_t<meta_codom_t<atom_meta_t<Var>>>, Space>,
80 "Trace variable codomain must match trace space");
93template <AtomLike Var>
109template <std::
size_t Offset, linalg::RnSpace TraceSpace, AtomLike Var>
113 using T = linalg::space_type_t<VarSpace>;
114 static constexpr std::size_t
VarDim = linalg::space_dim_v<VarSpace>;
115 static constexpr std::size_t
TraceDim = linalg::space_dim_v<TraceSpace>;
117 "Trace block exceeds variable dimension");
118 static_assert(std::same_as<T, linalg::space_type_t<TraceSpace>>,
119 "Trace block scalar type must match variable scalar type");
121 linalg::Vector<T, VarDim> weights{};
typename dom_traits< linalg::remove_cvref_t< Dom > >::Space dom_space_t
constexpr std::size_t dom_size_v
constexpr auto make_trace_block(const Var &X)
make trace objective over a matrix block inside a merged variable.
constexpr auto make_trace(const Var &X)
make trace objective with domain deduced from variable atom.
static constexpr auto make()
make helper to form weights for trace objective
linalg::Vector< T, Dim > Vec
linalg::space_type_t< Mat > T
alias and type extractions
linalg::Vector< T, Dim > Vec
static constexpr auto make()
make helper to form weights for trace objective
linalg::SymmetricMatrix< Mat > Space
alias and type extractions
linalg::space_type_t< Space > T
Forward decl of trace weights.
linalg::space_type_t< Space > T
alias and type extractions
static constexpr std::size_t N
linalg::Vector< T, N > Vec
static constexpr auto weights()
constexpr auto operator()(const Var &X) const
operator overload