9#define ALPAQA_DL_ABI_VERSION 0xA1A000000001
13#define ALPAQA_DEFAULT(...) \
16#define ALPAQA_DEFAULT(...)
58 void (*eval_grad_g_prod)(
84 void (*eval_hess_L_prod)(
107 void (*eval_hess_ψ_prod)(
148 void (*eval_grad_f_grad_g_prod)(
210 void (*initialize_box_C)(
216 void (*initialize_box_D)(
226 void (*initialize_l1_reg)(
289 void (*eval_grad_f_prod)(
330 void (*eval_add_Q_N)(
335 void (*eval_add_R_masked)(
343 void (*eval_add_S_masked)(
351 void (*eval_add_R_prod_masked)(
361 void (*eval_add_S_prod_masked)(
379 void (*eval_constr_N)(
383 void (*eval_grad_constr_prod)(
389 void (*eval_grad_constr_prod_N)(
394 void (*eval_add_gn_hess_constr)(
400 void (*eval_add_gn_hess_constr_N)(
428#if !defined(__cplusplus) || defined(DOXYGEN)
447#define ALPAQA_PROBLEM_REGISTER_INIT(self) \
449 alpaqa_problem_register_t *: alpaqa_problem_register_init, \
450 alpaqa_control_problem_register_t *: alpaqa_control_problem_register_init)( \
454#if defined(__cplusplus) && __cplusplus > 201703L
463 std::map<std::string, std::any>
dict{};
484 if (extra_functions ==
nullptr)
486 extra_functions->
dict.insert_or_assign(
487 std::move(name), std::function{std::forward<Func>(func)});
494 std::forward<Func>(func));
501 std::forward<Func>(func));
504template <
class Result,
class T,
class Ret,
class... Args>
506 Ret (T::*member)(Args...)) {
508 [member](
void *self_, Args... args) -> Ret {
509 auto *self = reinterpret_cast<T *>(self_);
510 return (self->*member)(std::forward<Args>(args)...);
514template <
class Result,
class T,
class Ret,
class... Args>
516 Ret (T::*member)(Args...)
const) {
518 [member](
const void *self_, Args... args) -> Ret {
519 const auto *self = reinterpret_cast<const T *>(self_);
520 return (self->*member)(std::forward<Args>(args)...);
527template <
auto Member,
class Class,
class Ret,
class... Args>
529 return [](
void *self_, Args... args) -> Ret {
530 auto *self =
reinterpret_cast<Class *
>(self_);
531 return (self->*Member)(std::forward<Args>(args)...);
536template <
auto Member,
class Class,
class Ret,
class... Args>
538 return []<
class Self>(Self * self_, Args... args) -> Ret
539 requires std::is_void_v<Self>
541 const auto *self =
reinterpret_cast<const Class *
>(self_);
542 return (self->*Member)(std::forward<Args>(args)...);
547template <auto Member,
class Class,
class Ret>
549 return []<
class Self>(Self * self_) ->
decltype(
auto)
550 requires std::is_void_v<Self>
552 using CClass = std::conditional_t<std::is_const_v<Self>,
553 std::add_const_t<Class>, Class>;
554 auto *self =
reinterpret_cast<CClass *
>(self_);
555 return self->*Member;
574template <auto Member>
576 return detail::member_caller<Member>(Member);
587 delete extra_functions;
588 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.