subassign.cpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #include "subassign.hpp"
27 
28 namespace casadi {
29 
30  SubAssign::SubAssign(const MX& x, const MX& y, const Slice& i, const Slice& j) : i_(i), j_(j) {
31  set_dep(x, y);
32  casadi_error("not ready");
33  }
34 
35  int SubAssign::eval(const double** arg, double** res, casadi_int* iw, double* w) const {
36  return eval_gen<double>(arg, res, iw, w);
37  }
38 
39  int SubAssign::eval_sx(const SXElem** arg, SXElem** res, casadi_int* iw, SXElem* w) const {
40  return eval_gen<SXElem>(arg, res, iw, w);
41  }
42 
43  template<typename T>
44  int SubAssign::eval_gen(const T* const* arg, T* const* res, casadi_int* iw, T* w) const {
45  casadi_error("not ready");
46  return 1;
47  }
48 
49  int SubAssign::sp_forward(const bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w) const {
50  casadi_error("not ready");
51  return 1;
52  }
53 
54  int SubAssign::sp_reverse(bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w) const {
55  casadi_error("not ready");
56  return 1;
57  }
58 
59  std::string SubAssign::disp(const std::vector<std::string>& arg) const {
60  std::stringstream ss;
61  ss << "(" << arg.at(0) << "[" << i_ << ", " << j_ << "]=" << arg.at(1) << ")";
62  return ss.str();
63  }
64 
65  void SubAssign::eval_mx(const std::vector<MX>& arg, std::vector<MX>& res) const {
66  casadi_error("not ready");
67  }
68 
69  void SubAssign::ad_forward(const std::vector<std::vector<MX> >& fseed,
70  std::vector<std::vector<MX> >& fsens) const {
71  casadi_error("not ready");
72  }
73 
74  void SubAssign::ad_reverse(const std::vector<std::vector<MX> >& aseed,
75  std::vector<std::vector<MX> >& asens) const {
76  casadi_error("not ready");
77  }
78 
80  const std::vector<casadi_int>& arg,
81  const std::vector<casadi_int>& res,
82  const std::vector<bool>& arg_is_ref,
83  std::vector<bool>& res_is_ref) const {
84  casadi_error("not ready");
85  }
86 
88  return {{"i", i_.info()}, {"j", j_.info()}};
89  }
90 
91 } // namespace casadi
Helper class for C code generation.
void set_dep(const MX &dep)
Set unary dependency.
Definition: mx_node.cpp:226
MX - Matrix expression.
Definition: mx.hpp:92
The basic scalar symbolic class of CasADi.
Definition: sx_elem.hpp:75
Class representing a Slice.
Definition: slice.hpp:48
Dict info() const
Definition: slice.hpp:120
int eval(const double **arg, double **res, casadi_int *iw, double *w) const override
Evaluate the function numerically.
Definition: subassign.cpp:35
void generate(CodeGenerator &g, const std::vector< casadi_int > &arg, const std::vector< casadi_int > &res, const std::vector< bool > &arg_is_ref, std::vector< bool > &res_is_ref) const override
Generate code for the operation.
Definition: subassign.cpp:79
int eval_sx(const SXElem **arg, SXElem **res, casadi_int *iw, SXElem *w) const override
Evaluate the function symbolically (SX)
Definition: subassign.cpp:39
void ad_reverse(const std::vector< std::vector< MX > > &aseed, std::vector< std::vector< MX > > &asens) const override
Calculate reverse mode directional derivatives.
Definition: subassign.cpp:74
int sp_forward(const bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w) const override
Propagate sparsity forward.
Definition: subassign.cpp:49
Dict info() const override
Definition: subassign.cpp:87
int eval_gen(const T *const *arg, T *const *res, casadi_int *iw, T *w) const
Evaluate the function (template)
Definition: subassign.cpp:44
std::string disp(const std::vector< std::string > &arg) const override
Print expression.
Definition: subassign.cpp:59
void eval_mx(const std::vector< MX > &arg, std::vector< MX > &res) const override
Evaluate symbolically (MX)
Definition: subassign.cpp:65
void ad_forward(const std::vector< std::vector< MX > > &fseed, std::vector< std::vector< MX > > &fsens) const override
Calculate forward mode directional derivatives.
Definition: subassign.cpp:69
int sp_reverse(bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w) const override
Propagate sparsity backwards.
Definition: subassign.cpp:54
Slice i_
Data members.
Definition: subassign.hpp:110
SubAssign(const MX &x, const MX &y, const Slice &i, const Slice &j)
Constructor.
Definition: subassign.cpp:30
The casadi namespace.
Definition: archiver.cpp:28
unsigned long long bvec_t
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.