9#define ALPAQA_DL_ABI_VERSION 0xA1A000000002
13#define ALPAQA_BEGIN_STRUCT(name) struct name
14#define ALPAQA_END_STRUCT(name)
15#define ALPAQA_DEFAULT(...) \
18#define ALPAQA_BEGIN_STRUCT(name) typedef struct
19#define ALPAQA_END_STRUCT(name) name
20#define ALPAQA_DEFAULT(...)
50 alpaqa_sparse_csc_unsorted = 0,
51 alpaqa_sparse_csc_sorted_rows = 1,
64 alpaqa_sparse_csc_l_unsorted = 0,
65 alpaqa_sparse_csc_l_sorted_rows = 1,
78 alpaqa_sparse_csc_ll_unsorted = 0,
79 alpaqa_sparse_csc_ll_sorted_rows = 1,
92 alpaqa_sparse_coo_unsorted = 0,
93 alpaqa_sparse_coo_sorted_by_cols_and_rows = 1,
94 alpaqa_sparse_coo_sorted_by_cols_only = 2,
95 alpaqa_sparse_coo_sorted_by_rows_and_cols = 3,
96 alpaqa_sparse_coo_sorted_by_rows_only = 4,
110 alpaqa_sparse_coo_l_unsorted = 0,
111 alpaqa_sparse_coo_l_sorted_by_cols_and_rows = 1,
112 alpaqa_sparse_coo_l_sorted_by_cols_only = 2,
113 alpaqa_sparse_coo_l_sorted_by_rows_and_cols = 3,
114 alpaqa_sparse_coo_l_sorted_by_rows_only = 4,
128 alpaqa_sparse_coo_ll_unsorted = 0,
129 alpaqa_sparse_coo_ll_sorted_by_cols_and_rows = 1,
130 alpaqa_sparse_coo_ll_sorted_by_cols_only = 2,
131 alpaqa_sparse_coo_ll_sorted_by_rows_and_cols = 3,
132 alpaqa_sparse_coo_ll_sorted_by_rows_only = 4,
190 void (*eval_grad_g_prod)(
207 void (*eval_grad_gi)(
214 void (*eval_hess_L_prod)(
235 void (*eval_hess_ψ_prod)(
274 void (*eval_grad_f_grad_g_prod)(
336 void (*initialize_box_C)(
342 void (*initialize_box_D)(
352 void (*initialize_l1_reg)(
421 void (*eval_grad_f_prod)(
462 void (*eval_add_Q_N)(
467 void (*eval_add_R_masked)(
475 void (*eval_add_S_masked)(
483 void (*eval_add_R_prod_masked)(
493 void (*eval_add_S_prod_masked)(
511 void (*eval_constr_N)(
515 void (*eval_grad_constr_prod)(
521 void (*eval_grad_constr_prod_N)(
526 void (*eval_add_gn_hess_constr)(
532 void (*eval_add_gn_hess_constr_N)(
566#if !defined(__cplusplus) || defined(DOXYGEN)
585#define ALPAQA_PROBLEM_REGISTER_INIT(self) \
586 _Generic((self), alpaqa_problem_register_t * \
587 : alpaqa_problem_register_init, \
588 alpaqa_control_problem_register_t * \
589 : alpaqa_control_problem_register_init)(self)
592#if defined(__cplusplus) && \
593 (__cplusplus > 201703L || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L))
602 std::map<std::string, std::any>
dict{};
623 if (extra_functions ==
nullptr)
625 extra_functions->
dict.insert_or_assign(
626 std::move(name), std::function{std::forward<Func>(func)});
633 std::forward<Func>(func));
640 std::forward<Func>(func));
643template <
class Result,
class T,
class Ret,
class...
Args>
648 auto *self = reinterpret_cast<T *>(self_);
649 return (self->*member)(std::forward<Args>(args)...);
653template <
class Result,
class T,
class Ret,
class...
Args>
658 const auto *self = reinterpret_cast<const T *>(self_);
659 return (self->*member)(std::forward<Args>(args)...);
666template <
auto Member,
class Class,
class Ret,
class...
Args>
669 auto *self =
reinterpret_cast<Class *
>(
self_);
670 return (self->*Member)(std::forward<Args>(
args)...);
675template <
auto Member,
class Class,
class Ret,
class...
Args>
678 requires std::is_void_v<Self>
680 const auto *self =
reinterpret_cast<const Class *
>(
self_);
681 return (self->*Member)(std::forward<Args>(
args)...);
686template <auto Member,
class Class,
class Ret>
689 requires std::is_void_v<Self>
691 using CClass = std::conditional_t<std::is_const_v<Self>,
692 std::add_const_t<Class>,
Class>;
694 return self->*Member;
713template <auto Member>
715 return detail::member_caller<Member>(Member);
726 delete extra_functions;
727 extra_functions =
nullptr;
static void alpaqa_control_problem_register_init(alpaqa_control_problem_register_t *self)
#define ALPAQA_DL_ABI_VERSION
struct alpaqa_function_dict_s alpaqa_function_dict_t
Opaque type for a C++-only map of extra functions.
ptrdiff_t alpaqa_length_t
#define ALPAQA_END_STRUCT(name)
#define ALPAQA_DEFAULT(...)
alpaqa_length_t alpaqa_index_t
#define ALPAQA_BEGIN_STRUCT(name)
std::map< std::string, std::any > dict
static void alpaqa_problem_register_init(alpaqa_problem_register_t *self)
void unregister_functions(function_dict_t *&extra_functions)
Cleans up the extra functions registered by register_function.
void register_function(function_dict_t *&extra_functions, std::string name, Func &&func)
Make the given function available to alpaqa.
void register_member_function(Result &result, std::string name, Ret(T::*member)(Args...))
static auto member_caller()
Wrap the given member function or variable into a (possibly generic) lambda function that accepts the...
alpaqa_function_dict_t * extra_functions
Pointer to a map of extra functions (C++ only).
uint64_t abi_version
To check whether the loaded problem is compatible with the version of the solver.
C API providing function pointers to problem functions.
alpaqa_function_dict_t * extra_functions
Pointer to a map of extra functions (C++ only).
uint64_t abi_version
To check whether the loaded problem is compatible with the version of the solver.
const long long * row_indices
const long long * col_indices
const long long * inner_idx
const long long * outer_ptr
@ alpaqa_sparsity_sparse_csc
@ alpaqa_sparsity_sparse_coo_l
@ alpaqa_sparsity_sparse_coo_ll
@ alpaqa_sparsity_sparse_csc_ll
@ alpaqa_sparsity_sparse_csc_l
@ alpaqa_sparsity_sparse_coo