26 #ifndef CASADI_LINEAR_INTERPOLANT_HPP
27 #define CASADI_LINEAR_INTERPOLANT_HPP
29 #include "casadi/core/interpolant_impl.hpp"
30 #include <casadi/solvers/casadi_interpolant_linear_export.h>
51 class LinearInterpolant :
public Interpolant {
54 LinearInterpolant(
const std::string& name,
55 const std::vector<double>& grid,
56 const std::vector<casadi_int>& offset,
57 const std::vector<double>& values,
61 ~LinearInterpolant()
override;
64 const char* plugin_name()
const override {
return "linear";}
67 std::string class_name()
const override {
return "LinearInterpolant";}
70 static Interpolant* creator(
const std::string& name,
71 const std::vector<double>& grid,
72 const std::vector<casadi_int>& offset,
73 const std::vector<double>& values,
75 return new LinearInterpolant(name, grid, offset, values, m);
78 static Function do_inline(
const std::string& name,
79 const std::vector<double>& grid,
80 const std::vector<casadi_int>& offset,
81 const std::vector<double>& values,
86 void init(
const Dict& opts)
override;
89 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w,
void* mem)
const override;
93 bool has_jacobian()
const override {
return true;}
94 Function get_jacobian(
const std::string& name,
95 const std::vector<std::string>& inames,
96 const std::vector<std::string>& onames,
97 const Dict& opts)
const override;
101 bool has_codegen()
const override {
return true;}
104 void codegen_body(CodeGenerator& g)
const override;
107 static const std::string meta_doc;
111 static const Options options_;
112 const Options& get_options()
const override {
return options_;}
116 void serialize_body(SerializingStream &s)
const override;
118 void serialize_type(SerializingStream &s)
const override;
121 static ProtoFunction* deserialize(DeserializingStream& s);
123 std::vector<casadi_int> lookup_mode_;
127 explicit LinearInterpolant(DeserializingStream& s);
131 class LinearInterpolantJac :
public FunctionInternal {
134 LinearInterpolantJac(
const std::string& name) : FunctionInternal(name) {}
137 ~LinearInterpolantJac()
override;
140 std::string class_name()
const override {
return "LinearInterpolantJac";}
143 bool has_codegen()
const override {
return true;}
146 void codegen_body(CodeGenerator& g)
const override;
149 void init(
const Dict& opts)
override;
152 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w,
void* mem)
const override;
156 bool has_jacobian()
const override {
return true;}
157 Function get_jacobian(
const std::string& name,
158 const std::vector<std::string>& inames,
159 const std::vector<std::string>& onames,
160 const Dict& opts)
const override;
164 void serialize_type(SerializingStream &s)
const override;
167 bool has_parametric_values()
const;
168 bool has_parametric_grid()
const;
171 std::string serialize_base_function()
const override {
return "Interpolant"; }
174 explicit LinearInterpolantJac(DeserializingStream& s) : FunctionInternal(s) {}
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.