35 std::string
Dot::disp(
const std::vector<std::string>& arg)
const {
36 return "dot(" + arg.at(0) +
", " + arg.at(1) +
")";
39 void Dot::eval_mx(
const std::vector<MX>& arg, std::vector<MX>& res)
const {
40 res[0] = arg[0]->get_dot(arg[1]);
44 std::vector<std::array<MX, 3> >& res)
const {
45 const std::array<MX, 3>& x = arg[0];
46 const std::array<MX, 3>& y = arg[1];
47 std::array<MX, 3>& f = res[0];
49 f[0] +=
dot(x[0], y[0]);
50 f[1] +=
dot(x[0], y[1]);
51 f[1] +=
dot(x[1], y[0]);
52 f[2] +=
dot(x[0], y[2]);
53 f[2] +=
dot(x[1]+x[2], y[1]+y[2]);
54 f[2] +=
dot(x[2], y[0]);
58 std::vector<std::vector<MX> >& fsens)
const {
59 for (casadi_int d=0; d<fsens.size(); ++d) {
66 std::vector<std::vector<MX> >& asens)
const {
67 for (casadi_int d=0; d<aseed.size(); ++d) {
68 asens[d][0] += aseed[d][0] *
dep(1);
69 asens[d][1] += aseed[d][0] *
dep(0);
73 int Dot::eval(
const double** arg,
double** res, casadi_int* iw,
double* w)
const {
74 return eval_gen<double>(arg, res, iw, w);
78 return eval_gen<SXElem>(arg, res, iw, w);
88 const bvec_t *a0=arg[0], *a1=arg[1];
90 const casadi_int n =
dep(0).
nnz();
92 for (casadi_int i=0; i<n; ++i) {
99 bvec_t *a0=arg[0], *a1=arg[1], *r=res[0];
100 const casadi_int n =
dep(0).
nnz();
101 for (casadi_int i=0; i<n; ++i) {
110 const std::vector<casadi_int>& arg,
111 const std::vector<casadi_int>& res,
112 const std::vector<bool>& arg_is_ref,
113 std::vector<bool>& res_is_ref)
const {
114 g << g.
workel(res[0]) <<
" = "
Helper class for C code generation.
std::string work(casadi_int n, casadi_int sz, bool is_ref) const
std::string workel(casadi_int n) const
std::string dot(casadi_int n, const std::string &x, const std::string &y)
Codegen inner product.
void eval_mx(const std::vector< MX > &arg, std::vector< MX > &res) const override
Evaluate symbolically (MX)
void ad_reverse(const std::vector< std::vector< MX > > &aseed, std::vector< std::vector< MX > > &asens) const override
Calculate reverse mode directional derivatives.
int sp_reverse(bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w) const override
Propagate sparsity backwards.
int sp_forward(const bvec_t **arg, bvec_t **res, casadi_int *iw, bvec_t *w) const override
Propagate sparsity forward.
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.
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.
int eval_gen(const T **arg, T **res, casadi_int *iw, T *w) const
Evaluate the function (template)
int eval_sx(const SXElem **arg, SXElem **res, casadi_int *iw, SXElem *w) const override
Evaluate the function symbolically (SX)
void ad_forward(const std::vector< std::vector< MX > > &fseed, std::vector< std::vector< MX > > &fsens) const override
Calculate forward mode directional derivatives.
int eval(const double **arg, double **res, casadi_int *iw, double *w) const override
Evaluate the function numerically.
Dot(const MX &x, const MX &y)
Constructor.
std::string disp(const std::vector< std::string > &arg) const override
Print expression.
casadi_int nnz() const
Get the number of (structural) non-zero elements.
virtual MX get_dot(const MX &y) const
Inner product.
casadi_int nnz(casadi_int i=0) const
const MX & dep(casadi_int ind=0) const
dependencies - functions that have to be evaluated before this one
void set_sparsity(const Sparsity &sparsity)
Set the sparsity.
void set_dep(const MX &dep)
Set unary dependency.
const Sparsity & sparsity() const
Get the sparsity pattern.
The basic scalar symbolic class of CasADi.
static Sparsity scalar(bool dense_scalar=true)
Create a scalar sparsity pattern *.
unsigned long long bvec_t
T1 casadi_dot(casadi_int n, const T1 *x, const T1 *y)
Inner product.
T dot(const std::vector< T > &a, const std::vector< T > &b)