9#include <casadi/core/function.hpp>
10#include <casadi/mem.h>
15 using std::invalid_argument::invalid_argument;
20template <Config Conf,
size_t N_in,
size_t N_out>
24 static_assert(std::is_same_v<real_t, casadi_real>);
32 using namespace std::literals::string_literals;
35 "Invalid number of input arguments: got "s +
36 std::to_string(
fun.n_in()) +
", should be " +
37 std::to_string(
N_in) +
".");
40 "Invalid number of output arguments: got "s +
41 std::to_string(
fun.n_out()) +
", should be " +
42 std::to_string(
N_out) +
".");
47 const std::array<casadi_dim, N_in> &
dim_in,
48 const std::array<casadi_dim, N_out> &
dim_out)
56 const std::array<casadi_dim, N_out> &
dim_out = {}) {
57 using namespace std::literals::string_literals;
58 static constexpr std::array count{
"first",
"second",
"third",
59 "fourth",
"fifth",
"sixth",
61 static_assert(
N_in <= count.size());
62 static_assert(
N_out <= count.size());
64 return "(" + std::to_string(d.first) +
", " +
65 std::to_string(d.second) +
")";
67 for (
size_t n = 0; n <
N_in; ++n) {
70 throw invalid_argument_dimensions(
71 "Invalid dimension of "s + count[n] +
75 for (
size_t n = 0; n <
N_out; ++n) {
78 throw invalid_argument_dimensions(
79 "Invalid dimension of "s + count[n] +
102 mutable std::vector<casadi_int>
iwork;
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)