26 #ifndef CASADI_GETNONZEROS_PARAM_HPP
27 #define CASADI_GETNONZEROS_PARAM_HPP
29 #include "mx_node.hpp"
42 class CASADI_EXPORT GetNonzerosParam :
public MXNode {
47 static MX create(
const MX& x,
const MX& nz);
48 static MX create(
const MX& x,
const MX& inner,
const Slice& outer);
49 static MX create(
const MX& x,
const Slice& inner,
const MX& outer);
50 static MX create(
const MX& x,
const MX& inner,
const MX& outer);
54 GetNonzerosParam(
const Sparsity& sp,
const MX& y,
const MX& nz);
55 GetNonzerosParam(
const Sparsity& sp,
const MX& y,
const MX& nz,
const MX& nz_extra);
58 ~GetNonzerosParam()
override {}
63 int sp_forward(
const bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w)
const override;
68 int sp_reverse(bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w)
const override;
73 casadi_int op()
const override {
return OP_GETNONZEROS_PARAM;}
78 static MXNode* deserialize(DeserializingStream& s);
84 explicit GetNonzerosParam(DeserializingStream& s) : MXNode(s) {}
88 class CASADI_EXPORT GetNonzerosParamVector :
public GetNonzerosParam {
91 GetNonzerosParamVector(
const MX& x,
92 const MX& nz) : GetNonzerosParam(nz.sparsity(), x, nz) {}
95 ~GetNonzerosParamVector()
override {}
100 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
101 std::vector<std::vector<MX> >& fsens)
const override;
106 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
107 std::vector<std::vector<MX> >& asens)
const override;
110 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
115 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
120 std::string disp(
const std::vector<std::string>& arg)
const override;
125 void generate(CodeGenerator& g,
126 const std::vector<casadi_int>& arg,
127 const std::vector<casadi_int>& res)
const override;
132 void serialize_body(SerializingStream& s)
const override;
136 void serialize_type(SerializingStream& s)
const override;
141 explicit GetNonzerosParamVector(DeserializingStream& s);
145 class CASADI_EXPORT GetNonzerosSliceParam :
public GetNonzerosParam {
149 GetNonzerosSliceParam(
const Sparsity& sp,
const MX& x,
const Slice& inner,
151 GetNonzerosParam(sp, x, outer), inner_(inner) {}
154 ~GetNonzerosSliceParam()
override {}
157 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
162 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
167 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
168 std::vector<std::vector<MX> >& fsens)
const override;
173 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
174 std::vector<std::vector<MX> >& asens)
const override;
179 std::string disp(
const std::vector<std::string>& arg)
const override;
184 void generate(CodeGenerator& g,
185 const std::vector<casadi_int>& arg,
186 const std::vector<casadi_int>& res)
const override;
189 Dict info()
const override {
return {{
"inner", inner_.info()}}; }
197 void serialize_body(SerializingStream& s)
const override;
201 void serialize_type(SerializingStream& s)
const override;
206 explicit GetNonzerosSliceParam(DeserializingStream& s);
210 class CASADI_EXPORT GetNonzerosParamSlice :
public GetNonzerosParam {
214 GetNonzerosParamSlice(
const Sparsity& sp,
const MX& x,
const MX& inner,
215 const Slice& outer) :
216 GetNonzerosParam(sp, x, inner), outer_(outer) {}
219 ~GetNonzerosParamSlice()
override {}
224 size_t sz_iw()
const override;
227 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
232 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
237 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
238 std::vector<std::vector<MX> >& fsens)
const override;
243 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
244 std::vector<std::vector<MX> >& asens)
const override;
249 std::string disp(
const std::vector<std::string>& arg)
const override;
254 void generate(CodeGenerator& g,
255 const std::vector<casadi_int>& arg,
256 const std::vector<casadi_int>& res)
const override;
259 Dict info()
const override {
return {{
"outer", outer_.info()}}; }
267 void serialize_body(SerializingStream& s)
const override;
271 void serialize_type(SerializingStream& s)
const override;
276 explicit GetNonzerosParamSlice(DeserializingStream& s);
281 class CASADI_EXPORT GetNonzerosParamParam :
public GetNonzerosParam {
285 GetNonzerosParamParam(
const Sparsity& sp,
const MX& x,
const MX& inner,
287 GetNonzerosParam(sp, x, inner, outer) {}
290 ~GetNonzerosParamParam()
override {}
295 size_t sz_iw()
const override;
298 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
303 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
308 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
309 std::vector<std::vector<MX> >& fsens)
const override;
314 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
315 std::vector<std::vector<MX> >& asens)
const override;
320 std::string disp(
const std::vector<std::string>& arg)
const override;
325 void generate(CodeGenerator& g,
326 const std::vector<casadi_int>& arg,
327 const std::vector<casadi_int>& res)
const override;
330 Dict info()
const override {
return {}; }
336 void serialize_type(SerializingStream& s)
const override;
341 explicit GetNonzerosParamParam(DeserializingStream& s);
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.