26 #ifndef CASADI_SX_ELEMENT_HPP
27 #define CASADI_SX_ELEMENT_HPP
30 #include "printable.hpp"
31 #include "exception.hpp"
32 #include "casadi_limits.hpp"
33 #include "matrix_fwd.hpp"
34 #include "generic_expression.hpp"
35 #include "serializing_stream.hpp"
47 #ifdef CASADI_WITH_THREAD
49 #ifdef CASADI_WITH_THREAD_MINGW
50 #include <mingw.mutex.h>
74 class CASADI_EXPORT
SXElem :
public GenericExpression<SXElem>,
75 public Printable<SXElem> {
77 friend class BinarySXNode;
106 static SXElem sym(
const std::string& name);
110 SXElem(SXNode* node,
bool dummy);
123 static SXElem create(SXNode* node);
128 SXElem& operator=(
double scalar);
135 static std::string type_name() {
return "SXElem";}
138 void disp(std::ostream& stream,
bool more=
false)
const;
150 const SXNode* operator->()
const;
151 SXNode* operator->();
157 static SXElem binary(casadi_int op,
const SXElem& x,
const SXElem& y);
158 static SXElem unary(casadi_int op,
const SXElem& x);
159 static std::vector<SXElem> call(
const Function& f,
const std::vector<SXElem>& deps);
166 bool __nonzero__()
const;
173 bool is_leaf()
const;
174 bool is_constant()
const;
175 bool is_integer()
const;
176 bool is_symbolic()
const;
180 bool is_commutative()
const;
182 bool is_almost_zero(
double tol)
const;
184 bool is_minus_one()
const;
187 bool is_minus_inf()
const;
188 const std::string& name()
const;
189 casadi_int op()
const;
190 bool is_op(casadi_int op)
const;
191 bool is_call()
const;
192 bool is_output()
const;
193 bool has_output()
const;
194 Function which_function()
const;
195 casadi_int which_output()
const;
203 bool is_nonnegative()
const;
204 SXElem dep(casadi_int ch=0)
const;
207 explicit operator double()
const;
210 explicit operator casadi_int()
const;
215 bool is_doubled()
const;
220 casadi_int n_dep()
const;
225 SXElem get_output(casadi_int oind)
const;
232 casadi_int __hash__()
const;
237 SXElem operator-()
const;
247 static bool is_equal(
const SXElem& x,
const SXElem& y, casadi_int depth=0);
251 int get_temp()
const;
254 void set_temp(
int t)
const;
267 void assignIfDuplicate(
const SXElem& scalar, casadi_int depth=1);
274 SXNode* assignNoDelete(
const SXElem& scalar);
280 inline bool is_null() {
return false;}
285 friend inline SXElem if_else(
const SXElem& x,
const SXElem& y,
const SXElem& z) {
286 return if_else_zero(x, y) + if_else_zero(!x, z);
292 void serialize(SerializingStream& s)
const;
294 static SXElem deserialize(DeserializingStream& s);
296 #ifdef CASADI_WITH_THREADSAFE_SYMBOLICS
297 static std::mutex mutex_temp;
306 class CASADI_EXPORT casadi_limits<SXElem>{
308 static bool is_zero(
const SXElem& val);
309 static bool is_equal(
const SXElem& x,
const SXElem& y, casadi_int depth);
310 static bool is_almost_zero(
const SXElem& val,
double tol);
311 static bool is_one(
const SXElem& val);
312 static bool is_minus_one(
const SXElem& val);
313 static bool is_constant(
const SXElem& val);
314 static bool is_integer(
const SXElem& val);
315 static bool is_inf(
const SXElem& val);
316 static bool is_minus_inf(
const SXElem& val);
317 static bool is_nan(
const SXElem& val);
319 static const SXElem zero;
320 static const SXElem one;
321 static const SXElem two;
322 static const SXElem minus_one;
323 static const SXElem nan;
324 static const SXElem inf;
325 static const SXElem minus_inf;
337 class CASADI_EXPORT numeric_limits<
casadi::SXElem>{
339 static const bool is_specialized =
true;
341 static
casadi::SXElem max() throw();
342 static const
int digits = 0;
343 static const
int digits10 = 0;
344 static const
bool is_signed = false;
345 static const
bool is_integer = false;
346 static const
bool is_exact = false;
347 static const
int radix = 0;
348 static
casadi::SXElem epsilon() throw();
349 static
casadi::SXElem round_error() throw();
350 static const
int min_exponent = 0;
351 static const
int min_exponent10 = 0;
352 static const
int max_exponent = 0;
353 static const
int max_exponent10 = 0;
355 static const
bool has_infinity = true;
356 static const
bool has_quiet_NaN = true;
357 static const
bool has_signaling_NaN = false;
359 static const
bool has_denorm_loss = false;
360 static
casadi::SXElem infinity() throw();
361 static
casadi::SXElem quiet_NaN() throw();
364 static const
bool is_iec559 = false;
365 static const
bool is_bounded = false;
366 static const
bool is_modulo = false;
368 static const
bool traps = false;
369 static const
bool tinyness_before = false;
370 static const float_round_style round_style = round_toward_zero;
Sparse matrix class. SX and DM are specializations.
bool is_regular(const std::vector< T > &v)
Checks if array does not contain NaN or Inf.