26 #ifndef CASADI_COMMON_HPP
27 #define CASADI_COMMON_HPP
44 #define SWIG_IF_ELSE(is_swig, not_swig) is_swig
45 #define SWIG_OUTPUT(arg) OUTPUT
46 #define SWIG_INOUT(arg) INOUT
47 #define SWIG_CONSTREF(arg) const arg
49 #define SWIG_IND1 true
51 #define SWIG_IND1 false
54 #define SWIG_IF_ELSE(is_swig, not_swig) not_swig
55 #define SWIG_OUTPUT(arg) arg
56 #define SWIG_INOUT(arg) arg
57 #define SWIG_CONSTREF(arg) const arg &
58 #define SWIG_IND1 false
61 #include "casadi_types.hpp"
68 template<
class T>
class Matrix;
82 #ifdef __GNUC_PATCHLEVEL__
83 #define GCC_VERSION (__GNUC__ * 10000 +__GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
92 #pragma warning(disable:4018)
95 #pragma warning(disable:4244)
98 #pragma warning(disable:4251)
102 #pragma warning(disable:4275)
105 #pragma warning(disable:4715)
108 #pragma warning(disable:4800)
111 #pragma warning(disable:4910)
115 #pragma warning(disable:4996)
125 typedef unsigned long long bvec_t;
129 const int bvec_size = CHAR_BIT*
sizeof(bvec_t);
138 typedef int (*config_t)(int,
const char**);
139 typedef void (*signal_t)(void);
140 typedef casadi_int (*getint_t)(void);
141 typedef double (*default_t)(casadi_int i);
142 typedef const char* (*name_t)(casadi_int i);
143 typedef const casadi_int* (*sparsity_t)(casadi_int i);
144 typedef int (*diff_t)(casadi_int i);
145 typedef int (*casadi_checkout_t)(void);
146 typedef void (*casadi_release_t)(int);
147 typedef int (*work_t)(casadi_int* sz_arg, casadi_int* sz_res,
148 casadi_int* sz_iw, casadi_int* sz_w);
149 typedef int (*eval_t)(
const double** arg,
double** res,
150 casadi_int* iw,
double* w, int);
154 constexpr casadi_int LOOKUP_LINEAR = 0;
155 constexpr casadi_int LOOKUP_EXACT = 1;
156 constexpr casadi_int LOOKUP_BINARY = 2;
160 std::string str(
const T& v);
164 std::string str(
const T& v,
bool more);
168 std::string str(
const std::vector<T>& v,
bool more=
false);
172 std::string str(
const std::set<T>& v,
bool more=
false);
175 template<
typename T1,
typename T2>
176 std::string str(
const std::pair<T1, T2>& p,
bool more=
false);
179 template<
typename T1,
typename T2>
180 std::string str(
const std::map<T1, T2> &p,
bool more=
false);
183 template<
typename T2>
184 std::string str(
const std::map<std::string, T2> &p,
bool more=
false);
188 inline std::vector<std::string> strvec() {
193 template<
typename T1>
194 inline std::vector<std::string> strvec(
const T1& t1) {
199 template<
typename T1,
typename T2>
200 inline std::vector<std::string> strvec(
const T1& t1,
const T2& t2) {
201 return {str(t1), str(t2)};
205 template<
typename T1,
typename T2,
typename T3>
206 inline std::vector<std::string> strvec(
const T1& t1,
const T2& t2,
const T3& t3) {
207 return {str(t1), str(t2), str(t3)};
211 template<
typename T1,
typename T2,
typename T3,
typename T4>
212 inline std::vector<std::string> strvec(
const T1& t1,
const T2& t2,
const T3& t3,
214 return {str(t1), str(t2), str(t3), str(t4)};
218 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5>
219 inline std::vector<std::string> strvec(
const T1& t1,
const T2& t2,
const T3& t3,
220 const T4& t4,
const T5& t5) {
221 return {str(t1), str(t2), str(t3), str(t4), str(t5)};
225 template<
typename T1,
typename T2,
typename T3,
typename T4,
typename T5,
typename T6>
226 inline std::vector<std::string> strvec(
const T1& t1,
const T2& t2,
const T3& t3,
227 const T4& t4,
const T5& t5,
const T6& t6) {
228 return {str(t1), str(t2), str(t3), str(t4), str(t5), str(t6)};
232 inline std::string fmtstr(
const std::string& fmt,
const std::vector<std::string>& args) {
234 for (
auto&& e : args) {
235 std::string::size_type n = s.find(
"%s");
236 if (n==std::string::npos)
return "** Ill-formatted string ** " + fmt;
244 std::string str(
const T& v) {
245 std::stringstream ss;
251 std::string str(
const T& v,
bool more) {
252 return v.get_str(more);
256 std::string str(
const std::vector<T>& v,
bool more) {
257 std::stringstream ss;
259 for (casadi_int i=0; i<v.size(); ++i) {
260 if (i!=0) ss <<
", ";
268 std::string str(
const std::set<T>& v,
bool more) {
269 std::stringstream ss;
272 for (
const auto& e : v) {
273 if (cnt++!=0) ss <<
", ";
280 template<
typename T1,
typename T2>
281 std::string str(
const std::pair<T1, T2>& p,
bool more) {
282 std::stringstream ss;
283 ss <<
"[" << p.first <<
"," << p.second <<
"]";
287 template<
typename T1,
typename T2>
288 std::string str(
const std::map<T1, T2>& p,
bool more) {
289 std::stringstream ss;
291 casadi_int count = 0;
293 ss << e.first <<
": " << e.second;
294 if (++count < p.size()) ss <<
", ";
300 template<
typename T2>
301 std::string str(
const std::map<std::string, T2>& p,
bool more) {
302 std::stringstream ss;
304 casadi_int count = 0;
306 ss <<
"\"" << e.first <<
"\": " << e.second;
307 if (++count < p.size()) ss <<
", ";
316 #include "casadi_logger.hpp"