forked from casadi/casadi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
symbolic_mx.cpp
102 lines (82 loc) · 3 KB
/
symbolic_mx.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* This file is part of CasADi.
*
* CasADi -- A symbolic framework for dynamic optimization.
* Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl,
* K.U. Leuven. All rights reserved.
* Copyright (C) 2011-2014 Greg Horn
*
* CasADi is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* CasADi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with CasADi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "symbolic_mx.hpp"
#include "casadi_misc.hpp"
#include "serializing_stream.hpp"
using namespace std;
namespace casadi {
SymbolicMX::SymbolicMX(const std::string& name, casadi_int nrow, casadi_int ncol) : name_(name) {
set_sparsity(Sparsity::dense(nrow, ncol));
}
SymbolicMX::SymbolicMX(const std::string& name, const Sparsity & sp) : name_(name) {
set_sparsity(sp);
}
std::string SymbolicMX::disp(const std::vector<std::string>& arg) const {
return name_;
}
int SymbolicMX::eval(const double** arg, double** res, casadi_int* iw, double* w) const {
return 0;
}
int SymbolicMX::eval_sx(const SXElem** arg, SXElem** res, casadi_int* iw, SXElem* w) const {
return 0;
}
void SymbolicMX::eval_mx(const std::vector<MX>& arg, std::vector<MX>& res) const {
}
void SymbolicMX::ad_forward(const std::vector<std::vector<MX> >& fseed,
std::vector<std::vector<MX> >& fsens) const {
}
void SymbolicMX::ad_reverse(const std::vector<std::vector<MX> >& aseed,
std::vector<std::vector<MX> >& asens) const {
}
const std::string& SymbolicMX::name() const {
return name_;
}
int SymbolicMX::sp_forward(const bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w) const {
fill_n(res[0], nnz(), 0);
return 0;
}
int SymbolicMX::sp_reverse(bvec_t** arg, bvec_t** res, casadi_int* iw, bvec_t* w) const {
fill_n(res[0], nnz(), 0);
return 0;
}
bool SymbolicMX::has_duplicates() const {
if (this->temp!=0) {
casadi_warning("Duplicate expression: " + name());
return true;
} else {
this->temp = 1;
return false;
}
}
void SymbolicMX::reset_input() const {
this->temp = 0;
}
void SymbolicMX::serialize_body(SerializingStream& s) const {
MXNode::serialize_body(s);
s.pack("SymbolicMX::name", name_);
}
SymbolicMX::SymbolicMX(DeserializingStream& s) : MXNode(s) {
s.unpack("SymbolicMX::name", name_);
}
} // namespace casadi