26 #ifndef CASADI_SETNONZEROS_PARAM_HPP
27 #define CASADI_SETNONZEROS_PARAM_HPP
29 #include "mx_node.hpp"
44 class CASADI_EXPORT SetNonzerosParam :
public MXNode {
53 static MX create(
const MX& y,
const MX& x,
const MX& nz);
54 static MX create(
const MX& y,
const MX& x,
const MX& inner,
const Slice& outer);
55 static MX create(
const MX& y,
const MX& x,
const Slice& inner,
const MX& outer);
56 static MX create(
const MX& y,
const MX& x,
const MX& inner,
const MX& outer);
60 SetNonzerosParam(
const MX& y,
const MX& x,
const MX& nz);
61 SetNonzerosParam(
const MX& y,
const MX& x,
const MX& nz,
const MX& nz2);
64 ~SetNonzerosParam()
override = 0;
69 int sp_forward(
const bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w)
const override;
74 int sp_reverse(bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w)
const override;
79 casadi_int op()
const override {
return Add ? OP_ADDNONZEROS_PARAM : OP_SETNONZEROS_PARAM;}
82 casadi_int n_inplace()
const override {
return 1;}
87 void generate(CodeGenerator& g,
88 const std::vector<casadi_int>& arg,
89 const std::vector<casadi_int>& res)
const override;
94 static MXNode* deserialize(DeserializingStream& s);
100 explicit SetNonzerosParam(DeserializingStream& s) : MXNode(s) {}
111 class CASADI_EXPORT SetNonzerosParamVector :
public SetNonzerosParam<Add>{
115 SetNonzerosParamVector(
const MX& y,
const MX& x,
const MX& nz);
118 ~SetNonzerosParamVector()
override {}
123 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
126 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
131 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
132 std::vector<std::vector<MX> >& fsens)
const override;
137 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
138 std::vector<std::vector<MX> >& asens)
const override;
143 std::string disp(
const std::vector<std::string>& arg)
const override;
148 void generate(CodeGenerator& g,
149 const std::vector<casadi_int>& arg,
150 const std::vector<casadi_int>& res)
const override;
155 void serialize_body(SerializingStream& s)
const override;
159 void serialize_type(SerializingStream& s)
const override;
164 explicit SetNonzerosParamVector(DeserializingStream& s);
169 class CASADI_EXPORT SetNonzerosParamSlice :
public SetNonzerosParam<Add>{
175 size_t sz_iw()
const override;
178 SetNonzerosParamSlice(
const MX& y,
const MX& x,
const MX& inner,
const Slice& outer) :
179 SetNonzerosParam<Add>(y, x, inner), outer_(outer) {}
182 ~SetNonzerosParamSlice()
override {}
187 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
192 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
193 std::vector<std::vector<MX> >& fsens)
const override;
198 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
199 std::vector<std::vector<MX> >& asens)
const override;
202 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
207 std::string disp(
const std::vector<std::string>& arg)
const override;
212 void generate(CodeGenerator& g,
213 const std::vector<casadi_int>& arg,
214 const std::vector<casadi_int>& res)
const override;
222 void serialize_body(SerializingStream& s)
const override;
226 void serialize_type(SerializingStream& s)
const override;
231 explicit SetNonzerosParamSlice(DeserializingStream& s);
237 class CASADI_EXPORT SetNonzerosSliceParam :
public SetNonzerosParam<Add>{
241 SetNonzerosSliceParam(
const MX& y,
const MX& x,
const Slice& inner,
const MX& outer) :
242 SetNonzerosParam<Add>(y, x, outer), inner_(inner) {}
245 ~SetNonzerosSliceParam()
override {}
250 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
253 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
258 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
259 std::vector<std::vector<MX> >& fsens)
const override;
264 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
265 std::vector<std::vector<MX> >& asens)
const override;
270 std::string disp(
const std::vector<std::string>& arg)
const override;
275 void generate(CodeGenerator& g,
276 const std::vector<casadi_int>& arg,
277 const std::vector<casadi_int>& res)
const override;
285 void serialize_body(SerializingStream& s)
const override;
289 void serialize_type(SerializingStream& s)
const override;
294 explicit SetNonzerosSliceParam(DeserializingStream& s);
299 class CASADI_EXPORT SetNonzerosParamParam :
public SetNonzerosParam<Add>{
305 size_t sz_iw()
const override;
308 SetNonzerosParamParam(
const MX& y,
const MX& x,
const MX& inner,
const MX& outer) :
309 SetNonzerosParam<Add>(y, x, inner, outer) {}
312 ~SetNonzerosParamParam()
override {}
317 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
320 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
325 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
326 std::vector<std::vector<MX> >& fsens)
const override;
331 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
332 std::vector<std::vector<MX> >& asens)
const override;
337 std::string disp(
const std::vector<std::string>& arg)
const override;
342 void generate(CodeGenerator& g,
343 const std::vector<casadi_int>& arg,
344 const std::vector<casadi_int>& res)
const override;
349 void serialize_type(SerializingStream& s)
const override;
354 explicit SetNonzerosParamParam(DeserializingStream& s);