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"
65 class CASADI_EXPORT
SXElem :
public GenericExpression<SXElem>,
66 public Printable<SXElem> {
68 friend class BinarySXNode;
97 static SXElem sym(
const std::string& name);
101 SXElem(SXNode* node,
bool dummy);
114 static SXElem create(SXNode* node);
119 SXElem& operator=(
double scalar);
126 static std::string type_name() {
return "SXElem";}
129 void disp(std::ostream& stream,
bool more=
false)
const;
141 const SXNode* operator->()
const;
142 SXNode* operator->();
148 static SXElem binary(casadi_int op,
const SXElem& x,
const SXElem& y);
149 static SXElem unary(casadi_int op,
const SXElem& x);
156 bool __nonzero__()
const;
163 bool is_leaf()
const;
164 bool is_constant()
const;
165 bool is_integer()
const;
166 bool is_symbolic()
const;
170 bool is_commutative()
const;
172 bool is_almost_zero(
double tol)
const;
174 bool is_minus_one()
const;
177 bool is_minus_inf()
const;
178 const std::string& name()
const;
179 casadi_int op()
const;
180 bool is_op(casadi_int op)
const;
188 bool is_nonnegative()
const;
189 SXElem dep(casadi_int ch=0)
const;
192 explicit operator double()
const;
195 explicit operator casadi_int()
const;
200 bool is_doubled()
const;
205 casadi_int n_dep()
const;
212 casadi_int __hash__()
const;
217 SXElem operator-()
const;
227 static bool is_equal(
const SXElem& x,
const SXElem& y, casadi_int depth=0);
231 int get_temp()
const;
234 void set_temp(
int t)
const;
247 void assignIfDuplicate(
const SXElem& scalar, casadi_int depth=1);
254 SXNode* assignNoDelete(
const SXElem& scalar);
260 inline bool is_null() {
return false;}
265 friend inline SXElem if_else(
const SXElem& x,
const SXElem& y,
const SXElem& z) {
266 return if_else_zero(x, y) + if_else_zero(!x, z);
272 void serialize(SerializingStream& s)
const;
274 static SXElem deserialize(DeserializingStream& s);
281 class CASADI_EXPORT casadi_limits<SXElem>{
283 static bool is_zero(
const SXElem& val);
284 static bool is_equal(
const SXElem& x,
const SXElem& y, casadi_int depth);
285 static bool is_almost_zero(
const SXElem& val,
double tol);
286 static bool is_one(
const SXElem& val);
287 static bool is_minus_one(
const SXElem& val);
288 static bool is_constant(
const SXElem& val);
289 static bool is_integer(
const SXElem& val);
290 static bool is_inf(
const SXElem& val);
291 static bool is_minus_inf(
const SXElem& val);
292 static bool is_nan(
const SXElem& val);
294 static const SXElem zero;
295 static const SXElem one;
296 static const SXElem two;
297 static const SXElem minus_one;
298 static const SXElem nan;
299 static const SXElem inf;
300 static const SXElem minus_inf;
312 class CASADI_EXPORT numeric_limits<
casadi::SXElem>{
314 static const bool is_specialized =
true;
316 static
casadi::SXElem max() throw();
317 static const
int digits = 0;
318 static const
int digits10 = 0;
319 static const
bool is_signed = false;
320 static const
bool is_integer = false;
321 static const
bool is_exact = false;
322 static const
int radix = 0;
323 static
casadi::SXElem epsilon() throw();
324 static
casadi::SXElem round_error() throw();
325 static const
int min_exponent = 0;
326 static const
int min_exponent10 = 0;
327 static const
int max_exponent = 0;
328 static const
int max_exponent10 = 0;
330 static const
bool has_infinity = true;
331 static const
bool has_quiet_NaN = true;
332 static const
bool has_signaling_NaN = false;
334 static const
bool has_denorm_loss = false;
335 static
casadi::SXElem infinity() throw();
336 static
casadi::SXElem quiet_NaN() throw();
339 static const
bool is_iec559 = false;
340 static const
bool is_bounded = false;
341 static const
bool is_modulo = false;
343 static const
bool traps = false;
344 static const
bool tinyness_before = false;
345 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.