9#define ALPAQA_DL_ABI_VERSION 0xA1A000000001
13#define ALPAQA_DEFAULT(...) \
16#define ALPAQA_DEFAULT(...)
53 void (*eval_grad_g_prod)(
79 void (*eval_hess_L_prod)(
102 void (*eval_hess_ψ_prod)(
143 void (*eval_grad_f_grad_g_prod)(
205 void (*initialize_box_C)(
211 void (*initialize_box_D)(
221 void (*initialize_l1_reg)(
288 void (*eval_grad_f_prod)(
329 void (*eval_add_Q_N)(
334 void (*eval_add_R_masked)(
342 void (*eval_add_S_masked)(
350 void (*eval_add_R_prod_masked)(
360 void (*eval_add_S_prod_masked)(
378 void (*eval_constr_N)(
382 void (*eval_grad_constr_prod)(
388 void (*eval_grad_constr_prod_N)(
393 void (*eval_add_gn_hess_constr)(
399 void (*eval_add_gn_hess_constr_N)(
431#if !defined(__cplusplus) || defined(DOXYGEN)
450#define ALPAQA_PROBLEM_REGISTER_INIT(self) \
452 alpaqa_problem_register_t *: alpaqa_problem_register_init, \
453 alpaqa_control_problem_register_t *: alpaqa_control_problem_register_init)( \
457#if defined(__cplusplus) && __cplusplus > 201703L
466 std::map<std::string, std::any>
dict{};
487 if (extra_functions ==
nullptr)
489 extra_functions->
dict.insert_or_assign(
490 std::move(name), std::function{std::forward<Func>(func)});
497 std::forward<Func>(func));
504 std::forward<Func>(func));
507template <
class Result,
class T,
class Ret,
class... Args>
509 Ret (T::*member)(Args...)) {
511 [member](
void *self_, Args... args) -> Ret {
512 auto *self = reinterpret_cast<T *>(self_);
513 return (self->*member)(std::forward<Args>(args)...);
517template <
class Result,
class T,
class Ret,
class... Args>
519 Ret (T::*member)(Args...)
const) {
521 [member](
const void *self_, Args... args) -> Ret {
522 const auto *self = reinterpret_cast<const T *>(self_);
523 return (self->*member)(std::forward<Args>(args)...);
530template <
auto Member,
class Class,
class Ret,
class... Args>
532 return [](
void *self_, Args... args) -> Ret {
533 auto *self =
reinterpret_cast<Class *
>(self_);
534 return (self->*Member)(std::forward<Args>(args)...);
539template <
auto Member,
class Class,
class Ret,
class... Args>
541 return []<
class Self>(Self * self_, Args... args) -> Ret
542 requires std::is_void_v<Self>
544 const auto *self =
reinterpret_cast<const Class *
>(self_);
545 return (self->*Member)(std::forward<Args>(args)...);
550template <auto Member,
class Class,
class Ret>
552 return []<
class Self>(Self * self_) ->
decltype(
auto)
553 requires std::is_void_v<Self>
555 using CClass = std::conditional_t<std::is_const_v<Self>,
556 std::add_const_t<Class>, Class>;
557 auto *self =
reinterpret_cast<CClass *
>(self_);
558 return self->*Member;
577template <auto Member>
579 return detail::member_caller<Member>(Member);
590 delete extra_functions;
591 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_DEFAULT(...)
alpaqa_length_t alpaqa_index_t
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.