9#include <casadi/core/function.hpp>
10#include <casadi/mem.h>
16template <Config Conf,
size_t N_in,
size_t N_out>
20 static_assert(std::is_same_v<real_t, casadi_real>);
28 using namespace std::literals::string_literals;
30 throw std::invalid_argument(
31 "Invalid number of input arguments: got "s +
32 std::to_string(
fun.n_in()) +
", should be " +
33 std::to_string(
N_in) +
".");
35 throw std::invalid_argument(
36 "Invalid number of output arguments: got "s +
37 std::to_string(
fun.n_out()) +
", should be " +
38 std::to_string(
N_out) +
".");
43 const std::array<casadi_dim, N_in> &
dim_in,
44 const std::array<casadi_dim, N_out> &
dim_out)
52 const std::array<casadi_dim, N_out> &
dim_out = {}) {
53 using namespace std::literals::string_literals;
54 static constexpr std::array count{
"first",
"second",
"third",
55 "fourth",
"fifth",
"sixth",
57 static_assert(
N_in <= count.size());
58 static_assert(
N_out <= count.size());
60 return "(" + std::to_string(d.first) +
", " +
61 std::to_string(d.second) +
")";
63 for (
size_t n = 0; n <
N_in; ++n) {
66 throw std::invalid_argument(
67 "Invalid dimension of "s + count[n] +
71 for (
size_t n = 0; n <
N_out; ++n) {
74 throw std::invalid_argument(
75 "Invalid dimension of "s + count[n] +
98 mutable std::vector<casadi_int>
iwork;
99 mutable std::vector<double>
dwork;
Class for evaluating CasADi functions, allocating the necessary workspace storage in advance for allo...
CasADiFunctionEvaluator(casadi::Function &&f, const std::array< casadi_dim, N_in > &dim_in, const std::array< casadi_dim, N_out > &dim_out)
CasADiFunctionEvaluator(casadi::Function &&f)
void validate_dimensions(const std::array< casadi_dim, N_in > &dim_in={}, const std::array< casadi_dim, N_out > &dim_out={})
void operator()(const double *const *in, double *const *out) const
std::vector< double * > res_work
void operator()(const double *const (&in)[N_in], double *const (&out)[N_out]) const
std::pair< casadi_int, casadi_int > casadi_dim
std::vector< double > dwork
std::vector< const double * > arg_work
std::vector< casadi_int > iwork
#define USING_ALPAQA_CONFIG(Conf)