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>);
37 const std::array<casadi_dim, N_in> &
dim_in,
38 const std::array<casadi_dim, N_out> &
dim_out)
45 using namespace std::literals::string_literals;
48 "Invalid number of input arguments: got "s +
49 std::to_string(
fun.n_in()) +
", should be " +
50 std::to_string(
N_in) +
".");
53 "Invalid number of output arguments: got "s +
54 std::to_string(
fun.n_out()) +
", should be " +
55 std::to_string(
N_out) +
".");
61 const std::array<casadi_dim, N_in> &
dim_in = {},
62 const std::array<casadi_dim, N_out> &
dim_out = {}) {
63 using namespace std::literals::string_literals;
64 static constexpr std::array count{
"first",
"second",
"third",
65 "fourth",
"fifth",
"sixth",
67 static_assert(
N_in <= count.size());
68 static_assert(
N_out <= count.size());
70 return "(" + std::to_string(d.first) +
", " +
71 std::to_string(d.second) +
")";
73 for (
size_t n = 0; n <
N_in; ++n) {
76 throw invalid_argument_dimensions(
77 "Invalid dimension of "s + count[n] +
81 for (
size_t n = 0; n <
N_out; ++n) {
84 throw invalid_argument_dimensions(
85 "Invalid dimension of "s + count[n] +
94 const std::array<casadi_dim, N_out> &
dim_out = {}) {
99 void operator()(
const double *
const *
in,
double *
const *out)
const {
107 double *
const (&out)[
N_out])
const {
115 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)
static void validate_num_args(const casadi::Function &fun)
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
static void validate_dimensions(const casadi::Function &fun, const std::array< casadi_dim, N_in > &dim_in={}, const std::array< casadi_dim, N_out > &dim_out={})
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)