akreon-convex
Typed convex modeling, conic canonicalization, and primal-dual optimization in C++26.
Loading...
Searching...
No Matches
cone_block.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2025-2026 Akreon LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
8#include "cone_traits.hpp"
9
10namespace conic {
11
17template <affine::AffineMapLike Map, typename... Cs>
18struct ConeBlock {
20 using MatT = affine::affine_mat_t<Map>;
21 using T = linalg::matrix_scalar_t<MatT>;
22
24 static constexpr std::size_t M = linalg::mat_rows_v<MatT>;
25 static constexpr std::size_t N = linalg::mat_cols_v<MatT>;
26
33 constexpr explicit ConeBlock(const Map& map_in, Cs... cs)
34 : map(map_in), cones(std::forward<Cs>(cs)...) {}
35
42 constexpr explicit ConeBlock(const Map& map_in, std::tuple<Cs...> cs)
43 : map(map_in), cones(std::move(cs)) {}
44
50 constexpr bool validate() const {
51 // (dakre) lambda functor to perform the soft check
52 std::size_t n_dims = 0;
53 auto perform_check = [&](const auto& arg) {
54 using ArgT = cone_scalar_t<decltype(arg)>;
55 static_assert(
56 std::same_as<ArgT, T>,
57 "Cone scalar type is mismatched with cone block scalar type");
58 n_dims += cone_dim_t<decltype(arg)>;
59 };
60 // (dakre) apply fold expression over comma operator on stored cones
61 std::apply([&](const auto&... args) { (perform_check(args), ...); }, cones);
62 return n_dims == M;
63 }
64
66 Map map;
67 std::tuple<Cs...> cones;
68};
69
70} // namespace conic
constexpr std::size_t cone_dim_t
helper to get N from cone
typename cone_traits< linalg::remove_cvref_t< Cone > >::T cone_scalar_t
alias for scalar type in cone
Cone block.
static constexpr std::size_t N
linalg::matrix_scalar_t< MatT > T
affine::affine_mat_t< Map > MatT
alias to extract scalar type from space
constexpr ConeBlock(const Map &map_in, Cs... cs)
CTOR for cone block.
constexpr bool validate() const
validate cone block
static constexpr std::size_t M
alias to extract codom & dom of affine map
Map map
member vars for cone block
constexpr ConeBlock(const Map &map_in, std::tuple< Cs... > cs)
CTOR for cone block.
std::tuple< Cs... > cones
tuple of cones aligned with map