26 #ifndef CASADI_SETNONZEROS_HPP
27 #define CASADI_SETNONZEROS_HPP
29 #include "mx_node.hpp"
52 static MX create(
const MX& y,
const MX& x,
const std::vector<casadi_int>& nz);
53 static MX create(
const MX& y,
const MX& x,
const Slice& s);
54 static MX create(
const MX& y,
const MX& x,
const Slice& inner,
const Slice& outer);
64 virtual std::vector<casadi_int>
all()
const = 0;
69 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
75 std::vector<std::array<MX, 3> >& res)
const override {
76 eval_linear_rearrange(arg, res);
82 void ad_forward(
const std::vector<std::vector<MX> >& fseed,
83 std::vector<std::vector<MX> >& fsens)
const override;
88 void ad_reverse(
const std::vector<std::vector<MX> >& aseed,
89 std::vector<std::vector<MX> >& asens)
const override;
132 std::vector<casadi_int>
all()
const override {
return nz_;}
137 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
141 int eval_gen(
const T** arg, T** res, casadi_int* iw, T* w)
const;
144 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
147 int eval_sx(
const SXElem** arg,
SXElem** res, casadi_int* iw,
SXElem* w)
const override;
152 int sp_forward(
const bvec_t** arg,
bvec_t** res, casadi_int* iw,
bvec_t* w)
const override;
162 std::string disp(
const std::vector<std::string>& arg)
const override;
168 const std::vector<casadi_int>& arg,
169 const std::vector<casadi_int>& res,
170 const std::vector<bool>& arg_is_ref,
171 std::vector<bool>& res_is_ref)
const override;
176 bool is_equal(
const MXNode* node, casadi_int depth)
const override;
179 Dict info()
const override {
return {{
"nz", nz_}, {
"add", Add}}; }
182 std::vector<casadi_int>
nz_;
211 std::vector<casadi_int>
all()
const override {
return s_.all(s_.stop);}
216 int sp_forward(
const bvec_t** arg,
bvec_t** res, casadi_int* iw,
bvec_t* w)
const override;
226 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
230 int eval_gen(
const T** arg, T** res, casadi_int* iw, T* w)
const;
233 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
236 int eval_sx(
const SXElem** arg,
SXElem** res, casadi_int* iw,
SXElem* w)
const override;
241 std::string disp(
const std::vector<std::string>& arg)
const override;
247 const std::vector<casadi_int>& arg,
248 const std::vector<casadi_int>& res,
249 const std::vector<bool>& arg_is_ref,
250 std::vector<bool>& res_is_ref)
const override;
255 bool is_equal(
const MXNode* node, casadi_int depth)
const override;
258 Dict info()
const override {
return {{
"slice", s_.info()}, {
"add", Add}}; }
285 SetNonzeros<Add>(y, x), inner_(inner), outer_(outer) {}
291 std::vector<casadi_int>
all()
const override {
return inner_.all(outer_, outer_.stop);}
296 int sp_forward(
const bvec_t** arg,
bvec_t** res, casadi_int* iw,
bvec_t* w)
const override;
306 void eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const override;
310 int eval_gen(
const T** arg, T** res, casadi_int* iw, T* w)
const;
313 int eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const override;
316 int eval_sx(
const SXElem** arg,
SXElem** res, casadi_int* iw,
SXElem* w)
const override;
321 std::string disp(
const std::vector<std::string>& arg)
const override;
327 const std::vector<casadi_int>& arg,
328 const std::vector<casadi_int>& res,
329 const std::vector<bool>& arg_is_ref,
330 std::vector<bool>& res_is_ref)
const override;
335 bool is_equal(
const MXNode* node, casadi_int depth)
const override;
338 Dict info()
const override {
return {{
"inner", inner_.info()}, {
"outer", outer_.info()},
Helper class for C code generation.
Helper class for Serialization.
Node class for MX objects.
The basic scalar symbolic class of CasADi.
Helper class for Serialization.
std::vector< casadi_int > all() const override
Get all the nonzeros.
SetNonzerosSlice2(const MX &y, const MX &x, const Slice &inner, const Slice &outer)
Constructor.
Dict info() const override
~SetNonzerosSlice2() override
Destructor.
~SetNonzerosSlice() override
Destructor.
Dict info() const override
std::vector< casadi_int > all() const override
Get all the nonzeros.
SetNonzerosSlice(const MX &y, const MX &x, const Slice &s)
Constructor.
Add the nonzeros of a matrix to another matrix.
Dict info() const override
std::vector< casadi_int > nz_
Operation sequence.
std::vector< casadi_int > all() const override
Get all the nonzeros.
~SetNonzerosVector() override
Destructor.
Assign or add entries to a matrix.
void eval_linear(const std::vector< std::array< MX, 3 > > &arg, std::vector< std::array< MX, 3 > > &res) const override
Evaluate the MX node on a const/linear/nonlinear partition.
SetNonzeros(DeserializingStream &s)
Deserializing constructor.
casadi_int op() const override
Get the operation.
casadi_int n_inplace() const override
Can the operation be performed inplace (i.e. overwrite the result)
virtual std::vector< casadi_int > all() const =0
Get all the nonzeros.
Class representing a Slice.
bool is_equal(double x, double y, casadi_int depth=0)
unsigned long long bvec_t
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.