List of all members | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes
casadi::BinarySX Class Reference

Represents a basic binary operation on two SXElem nodes. More...

#include <binary_sx.hpp>

Detailed Description

Author
Joel Andersson
Date
2010

Extra doc: https://github.com/casadi/casadi/wiki/L_115

Definition at line 41 of file binary_sx.hpp.

Inheritance diagram for casadi::BinarySX:
Inheritance graph
[legend]
Collaboration diagram for casadi::BinarySX:
Collaboration graph
[legend]

Public Member Functions

 ~BinarySX () override
 Destructor. More...
 
std::string class_name () const override
 Get type name. More...
 
bool is_smooth () const override
 Check if smooth. More...
 
bool is_op (casadi_int op) const override
 check properties of a node More...
 
bool is_equal (const SXNode *node, casadi_int depth) const override
 Check if two nodes are equivalent up to a given depth. More...
 
casadi_int n_dep () const override
 Number of dependencies. More...
 
const SXElemdep (casadi_int i) const override
 get the reference of a dependency More...
 
SXElemdep (casadi_int i) override
 get the reference of a child More...
 
casadi_int op () const override
 Get the operation. More...
 
std::string print (const std::string &arg1, const std::string &arg2) const override
 Print expression. More...
 
void serialize_node (SerializingStream &s) const override
 
virtual const std::string & name () const
 
virtual Function which_function () const
 Get called function. More...
 
virtual casadi_int which_output () const
 Get function output. More...
 
virtual SXElem get_output (casadi_int oind) const
 Get an output. More...
 
virtual void disp (std::ostream &stream, bool more) const
 print More...
 
void can_inline (std::map< const SXNode *, casadi_int > &nodeind) const
 Find out which nodes can be inlined. More...
 
std::string print_compact (std::map< const SXNode *, casadi_int > &nodeind, std::vector< std::string > &intermed) const
 Print compact. More...
 
bool marked () const
 
void mark () const
 
SXElem shared_from_this ()
 Get a shared object from the current internal object. More...
 
const SXElem shared_from_this () const
 Get a shared object from the current internal object. More...
 
void serialize (SerializingStream &s) const
 Serialize an object. More...
 
virtual bool is_constant () const
 check properties of a node More...
 
virtual bool is_integer () const
 check properties of a node More...
 
virtual bool is_symbolic () const
 check properties of a node More...
 
virtual bool is_zero () const
 check properties of a node More...
 
virtual bool is_almost_zero (double tol) const
 check properties of a node More...
 
virtual bool is_one () const
 check properties of a node More...
 
virtual bool is_minus_one () const
 check properties of a node More...
 
virtual bool is_nan () const
 check properties of a node More...
 
virtual bool is_inf () const
 check properties of a node More...
 
virtual bool is_minus_inf () const
 check properties of a node More...
 
virtual bool is_call () const
 check properties of a node More...
 
virtual bool is_output () const
 check properties of a node More...
 
virtual bool has_output () const
 check properties of a node More...
 
virtual double to_double () const
 Get value of a constant node. More...
 
virtual casadi_int to_int () const
 Get value of a constant node. More...
 

Static Public Member Functions

static SXElem create (unsigned char op, const SXElem &dep0, const SXElem &dep1)
 Create a binary expression. More...
 
static SXNodedeserialize (DeserializingStream &s, casadi_int op)
 Deserialize without type information. More...
 
static void safe_delete (SXNode *n)
 Non-recursive delete. More...
 
static SXNodedeserialize (DeserializingStream &s)
 

Public Attributes

unsigned char op_
 The binary operation as an 1 byte integer (allows 256 values) More...
 
SXElem dep0_
 The dependencies of the node. More...
 
SXElem dep1_
 
int temp
 
unsigned int count
 

Static Public Attributes

static casadi_int eq_depth_ = 1
 
static std::map< casadi_int, SXNode *(*)(DeserializingStream &)> deserialize_map
 

Constructor & Destructor Documentation

◆ ~BinarySX()

casadi::BinarySX::~BinarySX ( )
inlineoverride

This is a rather complex destructor which is necessary since the default destructor can cause stack overflow due to recursive calling.

Extra doc: https://github.com/casadi/casadi/wiki/L_118 

Definition at line 75 of file binary_sx.hpp.

75  {
78  }
SXElem dep0_
The dependencies of the node.
Definition: binary_sx.hpp:133
SXNode * assignNoDelete(const SXElem &scalar)
Assign the node to something, without invoking the deletion of the node,.
Definition: sx_elem.cpp:118
static void safe_delete(SXNode *n)
Non-recursive delete.
Definition: sx_node.cpp:184
static const SXElem nan
Definition: sx_elem.hpp:323

References casadi::SXElem::assignNoDelete(), dep0_, dep1_, and casadi::SXNode::safe_delete().

Member Function Documentation

◆ can_inline()

void casadi::SXNode::can_inline ( std::map< const SXNode *, casadi_int > &  nodeind) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_a6

Definition at line 113 of file sx_node.cpp.

113  {
114  // Add or mark node in map
115  std::map<const SXNode*, casadi_int>::iterator it=nodeind.find(this);
116  if (it==nodeind.end()) {
117  // First time encountered, mark inlined
118  nodeind.insert(it, std::make_pair(this, 0));
119 
120  // Handle dependencies with recursion
121  for (casadi_int i=0; i<n_dep(); ++i) {
122  dep(i)->can_inline(nodeind);
123  }
124  } else if (it->second==0 && op()!=OP_PARAMETER) {
125  // Node encountered before, do not inline (except if symbolic primitive)
126  it->second = -1;
127  }
128  }
virtual const SXElem & dep(casadi_int i) const
get the reference of a child
Definition: sx_node.cpp:80
virtual casadi_int n_dep() const
Number of dependencies.
Definition: sx_node.hpp:124
virtual casadi_int op() const =0
get the operation
void can_inline(std::map< const SXNode *, casadi_int > &nodeind) const
Find out which nodes can be inlined.
Definition: sx_node.cpp:113
@ OP_PARAMETER
Definition: calculus.hpp:85

References casadi::SXNode::can_inline(), casadi::SXNode::dep(), casadi::SXNode::n_dep(), casadi::SXNode::op(), and casadi::OP_PARAMETER.

Referenced by casadi::SXNode::can_inline(), and casadi::SXNode::disp().

◆ class_name()

std::string casadi::BinarySX::class_name ( ) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_9y

Implements casadi::SXNode.

Definition at line 81 of file binary_sx.hpp.

81 {return "BinarySX";}

◆ create()

static SXElem casadi::BinarySX::create ( unsigned char  op,
const SXElem dep0,
const SXElem dep1 
)
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_117

Definition at line 55 of file binary_sx.hpp.

55  {
56  if (dep0.is_constant() && dep1.is_constant()) {
57  // Evaluate constant
58  double dep0_val(dep0);
59  double dep1_val(dep1);
60  double ret_val;
61  casadi_math<double>::fun(op, dep0_val, dep1_val, ret_val);
62  return ret_val;
63  } else {
64  // Expression containing free variables
65  return SXElem::create(new BinarySX(op, dep0, dep1));
66  }
67  }
casadi_int op() const override
Get the operation.
Definition: binary_sx.hpp:116
static SXElem create(SXNode *node)
Definition: sx_elem.cpp:62
static void fun(unsigned char op, const T &x, const T &y, T &f)
Evaluate a built in function (scalar-scalar)
Definition: calculus.hpp:1289

References casadi::SXElem::create(), casadi::casadi_math< T >::fun(), casadi::SXElem::is_constant(), and op().

Referenced by casadi::SXElem::binary().

◆ dep() [1/2]

const SXElem& casadi::BinarySX::dep ( casadi_int  i) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_11b

Reimplemented from casadi::SXNode.

Definition at line 110 of file binary_sx.hpp.

110 { return i==0 ? dep0_ : dep1_;}

References dep0_, and dep1_.

◆ dep() [2/2]

SXElem& casadi::BinarySX::dep ( casadi_int  i)
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_a3

Reimplemented from casadi::SXNode.

Definition at line 111 of file binary_sx.hpp.

111 { return i==0 ? dep0_ : dep1_;}

References dep0_, and dep1_.

◆ deserialize() [1/2]

SXNode * casadi::SXNode::deserialize ( DeserializingStream s)
staticinherited

Definition at line 243 of file sx_node.cpp.

243  {
244  casadi_int op;
245  s.unpack("SXNode::op", op);
246 
248  return BinarySX::deserialize(s, op);
249  } else if (casadi_math<MX>::is_unary(op)) {
250  return UnarySX::deserialize(s, op);
251  }
252 
253  auto it = SXNode::deserialize_map.find(op);
254  if (it==SXNode::deserialize_map.end()) {
255  casadi_error("Not implemented op " + str(casadi_int(op)));
256  } else {
257  return it->second(s);
258  }
259  }
static SXNode * deserialize(DeserializingStream &s, casadi_int op)
Deserialize without type information.
Definition: binary_sx.hpp:143
static std::map< casadi_int, SXNode *(*)(DeserializingStream &)> deserialize_map
Definition: sx_node.hpp:209
static SXNode * deserialize(DeserializingStream &s, casadi_int op)
Definition: unary_sx.hpp:127
std::string str(const T &v)
String representation, any type.
static bool is_binary(unsigned char op)
Is binary operation?
Definition: calculus.hpp:1602
static bool is_unary(unsigned char op)
Is unary operation?
Definition: calculus.hpp:1613

References deserialize(), casadi::UnarySX::deserialize(), casadi::SXNode::deserialize_map, casadi::SXNode::op(), casadi::str(), and casadi::DeserializingStream::unpack().

Referenced by casadi::SXElem::deserialize().

◆ deserialize() [2/2]

static SXNode* casadi::BinarySX::deserialize ( DeserializingStream s,
casadi_int  op 
)
inlinestatic

Extra doc: https://github.com/casadi/casadi/wiki/L_11g

Definition at line 143 of file binary_sx.hpp.

143  {
144  SXElem dep0, dep1;
145  s.unpack("UnarySX::dep0", dep0);
146  s.unpack("UnarySX::dep1", dep1);
147  return new BinarySX(op, dep0, dep1);
148  }
friend class SXElem
Definition: sx_node.hpp:50

References op(), and casadi::DeserializingStream::unpack().

Referenced by casadi::SXNode::deserialize().

◆ disp()

void casadi::SXNode::disp ( std::ostream &  stream,
bool  more 
) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_a5

Definition at line 88 of file sx_node.cpp.

88  {
89  // Find out which noded can be inlined
90  std::map<const SXNode*, casadi_int> nodeind;
91  can_inline(nodeind);
92 
93  // Print expression
94  std::vector<std::string> intermed;
95  std::string s = print_compact(nodeind, intermed);
96 
97  // Print intermediate expressions
98  for (casadi_int i=0; i<intermed.size(); ++i)
99  stream << "@" << (i+1) << "=" << intermed[i] << ", ";
100 
101  // Print this
102  stream << s;
103  }
std::string print_compact(std::map< const SXNode *, casadi_int > &nodeind, std::vector< std::string > &intermed) const
Print compact.
Definition: sx_node.cpp:130

References casadi::SXNode::can_inline(), and casadi::SXNode::print_compact().

Referenced by casadi::SXElem::disp().

◆ get_output()

SXElem casadi::SXNode::get_output ( casadi_int  oind) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_293

Reimplemented in casadi::CallSX.

Definition at line 227 of file sx_node.cpp.

227  {
228  casadi_assert(oind==0, "Output index out of bounds");
229  return shared_from_this();
230  }
SXElem shared_from_this()
Get a shared object from the current internal object.
Definition: sx_node.cpp:261

References casadi::SXNode::shared_from_this().

Referenced by casadi::SXElem::get_output().

◆ has_output()

virtual bool casadi::SXNode::has_output ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::CallSX.

Definition at line 82 of file sx_node.hpp.

82 { return false; }

Referenced by casadi::SXElem::has_output().

◆ is_almost_zero()

virtual bool casadi::SXNode::is_almost_zero ( double  tol) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::ZeroSX, and casadi::RealtypeSX.

Definition at line 74 of file sx_node.hpp.

74 { return false; }

Referenced by casadi::SXElem::is_almost_zero().

◆ is_call()

virtual bool casadi::SXNode::is_call ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::CallSX.

Definition at line 80 of file sx_node.hpp.

80 { return false; }

Referenced by casadi::SXElem::is_call().

◆ is_constant()

virtual bool casadi::SXNode::is_constant ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::ConstantSX.

Definition at line 69 of file sx_node.hpp.

69 { return false; }

Referenced by casadi::SXElem::binary(), casadi::SXFunction::init(), and casadi::SXElem::is_constant().

◆ is_equal()

bool casadi::BinarySX::is_equal ( const SXNode node,
casadi_int  depth 
) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_119

Reimplemented from casadi::SXNode.

Definition at line 90 of file binary_sx.hpp.

90  {
91  const BinarySX* n = dynamic_cast<const BinarySX*>(node);
92  if (n==nullptr) return false;
93  if (n->op_ != op_) return false;
94  if (SXElem::is_equal(n->dep0_, dep0_, depth-1)
95  && SXElem::is_equal(n->dep1_, dep1_, depth-1)) return true;
96  if (operation_checker<CommChecker>(op_)
97  && SXElem::is_equal(n->dep1_, dep0_, depth-1)
98  && SXElem::is_equal(n->dep0_, dep1_, depth-1)) return true;
99  return false;
100  }
unsigned char op_
The binary operation as an 1 byte integer (allows 256 values)
Definition: binary_sx.hpp:128
static bool is_equal(const SXElem &x, const SXElem &y, casadi_int depth=0)
Check equality up to a given depth.
Definition: sx_elem.cpp:529

References dep0_, dep1_, casadi::SXElem::is_equal(), and op_.

◆ is_inf()

virtual bool casadi::SXNode::is_inf ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::InfSX.

Definition at line 78 of file sx_node.hpp.

78 { return false; }

Referenced by casadi::SXElem::is_inf().

◆ is_integer()

virtual bool casadi::SXNode::is_integer ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::MinusOneSX, casadi::OneSX, casadi::ZeroSX, and casadi::IntegerSX.

Definition at line 70 of file sx_node.hpp.

70 { return false; }

Referenced by casadi::SXElem::binary(), and casadi::SXElem::is_integer().

◆ is_minus_inf()

virtual bool casadi::SXNode::is_minus_inf ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::MinusInfSX.

Definition at line 79 of file sx_node.hpp.

79 { return false; }

Referenced by casadi::SXElem::is_minus_inf().

◆ is_minus_one()

virtual bool casadi::SXNode::is_minus_one ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::MinusOneSX.

Definition at line 76 of file sx_node.hpp.

76 { return false; }

Referenced by casadi::SXElem::binary(), and casadi::SXElem::is_minus_one().

◆ is_nan()

virtual bool casadi::SXNode::is_nan ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::NanSX.

Definition at line 77 of file sx_node.hpp.

77 { return false; }

Referenced by casadi::SXElem::is_nan().

◆ is_one()

virtual bool casadi::SXNode::is_one ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::OneSX.

Definition at line 75 of file sx_node.hpp.

75 { return false; }

Referenced by casadi::SXElem::binary(), and casadi::SXElem::is_one().

◆ is_op()

bool casadi::BinarySX::is_op ( casadi_int  op) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented from casadi::SXNode.

Definition at line 85 of file binary_sx.hpp.

85 { return op_==op; }

References op(), and op_.

◆ is_output()

virtual bool casadi::SXNode::is_output ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::OutputSX.

Definition at line 81 of file sx_node.hpp.

81 { return false; }

Referenced by casadi::SXElem::is_output().

◆ is_smooth()

bool casadi::BinarySX::is_smooth ( ) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_a4

Reimplemented from casadi::SXNode.

Definition at line 83 of file binary_sx.hpp.

83 { return operation_checker<SmoothChecker>(op_);}

References op_.

◆ is_symbolic()

virtual bool casadi::SXNode::is_symbolic ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::SymbolicSX.

Definition at line 71 of file sx_node.hpp.

71 { return false; }

Referenced by casadi::SXFunction::init(), and casadi::SXElem::is_symbolic().

◆ is_zero()

virtual bool casadi::SXNode::is_zero ( ) const
inlinevirtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9w

Reimplemented in casadi::ZeroSX.

Definition at line 72 of file sx_node.hpp.

72 { return false; }

Referenced by casadi::SXElem::binary(), and casadi::SXElem::is_zero().

◆ mark()

void casadi::SXNode::mark ( ) const
inherited

Definition at line 109 of file sx_node.cpp.

109  {
110  temp = -temp-1;
111  }

References casadi::SXNode::temp.

◆ marked()

bool casadi::SXNode::marked ( ) const
inherited

Definition at line 105 of file sx_node.cpp.

105  {
106  return temp<0;
107  }

References casadi::SXNode::temp.

◆ n_dep()

casadi_int casadi::BinarySX::n_dep ( ) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_11a

Reimplemented from casadi::SXNode.

Definition at line 105 of file binary_sx.hpp.

105 { return 2;}

◆ name()

const std::string & casadi::SXNode::name ( ) const
virtualinherited

Reimplemented in casadi::SymbolicSX.

Definition at line 76 of file sx_node.cpp.

76  {
77  casadi_error("'name' not defined for " + class_name());
78  }
virtual std::string class_name() const =0
Get type name.

References casadi::SXNode::class_name().

Referenced by casadi::SXElem::name().

◆ op()

casadi_int casadi::BinarySX::op ( ) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_11c

Implements casadi::SXNode.

Definition at line 116 of file binary_sx.hpp.

116 { return op_;}

References op_.

Referenced by create(), deserialize(), and is_op().

◆ print()

std::string casadi::BinarySX::print ( const std::string &  arg1,
const std::string &  arg2 
) const
inlineoverridevirtual

Extra doc: https://github.com/casadi/casadi/wiki/L_11d

Implements casadi::SXNode.

Definition at line 121 of file binary_sx.hpp.

121  {
122  return casadi_math<double>::print(op_, arg1, arg2);
123  }
static std::string print(unsigned char op, const std::string &x, const std::string &y)
Print.
Definition: calculus.hpp:1641

References op_, and casadi::casadi_math< T >::print().

◆ print_compact()

std::string casadi::SXNode::print_compact ( std::map< const SXNode *, casadi_int > &  nodeind,
std::vector< std::string > &  intermed 
) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_a7

Definition at line 130 of file sx_node.cpp.

131  {
132  // Get reference to node index
133  casadi_int& ind = nodeind[this];
134 
135  // If positive, already in intermediate expressions
136  if (ind>0) {
137  std::stringstream ss;
138  ss << "@" << ind;
139  return ss.str();
140  }
141 
142  std::string s;
143  if (op()==OP_CALL) {
144  const Function& f = which_function();
145  // Get expressions for dependencies
146  s = which_function().name() + "(";
147 
148  casadi_int k = 0;
149  for (casadi_int i=0; i<f.n_in(); ++i) {
150  if (f.nnz_in(i)>1) s += "[";
151  for (casadi_int j=0; j<f.nnz_in(i); ++j) {
152  s += dep(k++)->print_compact(nodeind, intermed);
153  if (j<f.nnz_in(i)-1) s+=",";
154  }
155  if (f.nnz_in(i)>1) s += "]";
156  if (i<f.n_in()-1) s+=",";
157  }
158  s += ")";
159  } else {
160  // Get expressions for dependencies
161  std::string arg[2];
162  for (casadi_int i=0; i<n_dep(); ++i) {
163  arg[i] = dep(i)->print_compact(nodeind, intermed);
164  }
165 
166  // Get expression for this
167  s = print(arg[0], arg[1]);
168  }
169 
170  // Decide what to do with the expression
171  if (ind==0) {
172  // Inline expression
173  return s;
174  } else {
175  // Add to list of intermediate expressions and return reference
176  intermed.push_back(s);
177  ind = intermed.size(); // For subsequent references
178  std::stringstream ss;
179  ss << "@" << ind;
180  return ss.str();
181  }
182  }
const std::string & name() const
Name of the function.
Definition: function.cpp:1307
virtual Function which_function() const
Get called function.
Definition: sx_node.cpp:64
virtual std::string print(const std::string &arg1, const std::string &arg2) const =0
Print expression.
@ OP_CALL
Definition: calculus.hpp:88

References casadi::SXNode::dep(), casadi::SXNode::n_dep(), casadi::Function::n_in(), casadi::Function::name(), casadi::Function::nnz_in(), casadi::SXNode::op(), casadi::OP_CALL, casadi::SXNode::print(), casadi::SXNode::print_compact(), and casadi::SXNode::which_function().

Referenced by casadi::SXNode::disp(), and casadi::SXNode::print_compact().

◆ safe_delete()

void casadi::SXNode::safe_delete ( SXNode n)
staticinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_a9

Definition at line 184 of file sx_node.cpp.

184  {
185  // Quick return if more owners
186  if (n->count>0) return;
187  // Delete straight away if it doesn't have any dependencies
188  if (!n->n_dep()) {
189  delete n;
190  return;
191  }
192  // Stack of expressions to be deleted
193  std::stack<SXNode*> deletion_stack;
194  // Add the node to the deletion stack
195  deletion_stack.push(n);
196  // Process stack
197  while (!deletion_stack.empty()) {
198  // Top element
199  SXNode *t = deletion_stack.top();
200  // Check if the top element has dependencies with dependencies
201  bool added_to_stack = false;
202  for (casadi_int c2=0; c2<t->n_dep(); ++c2) { // for all dependencies of the dependency
203  // Get the node of the dependency of the top element
204  // and remove it from the smart pointer
205  SXNode *n2 = t->dep(c2).assignNoDelete(casadi_limits<SXElem>::nan);
206  // Check if this is the only reference to the element
207  if (n2->count == 0) {
208  // Check if unary or binary
209  if (!n2->n_dep()) {
210  // Delete straight away if not binary
211  delete n2;
212  } else {
213  // Add to deletion stack
214  deletion_stack.push(n2);
215  added_to_stack = true;
216  }
217  }
218  }
219  // Delete and pop from stack if nothing added to the stack
220  if (!added_to_stack) {
221  delete deletion_stack.top();
222  deletion_stack.pop();
223  }
224  }
225  }
SXNode()
constructor
Definition: sx_node.cpp:40

References casadi::SXElem::assignNoDelete(), casadi::SXNode::count, casadi::SXNode::dep(), and casadi::SXNode::n_dep().

Referenced by ~BinarySX(), and casadi::UnarySX::~UnarySX().

◆ serialize()

void casadi::SXNode::serialize ( SerializingStream s) const
inherited

Extra doc: https://github.com/casadi/casadi/wiki/L_aa

Definition at line 238 of file sx_node.cpp.

238  {
239  s.pack("SXNode::op", op());
240  serialize_node(s);
241  }
virtual void serialize_node(SerializingStream &s) const
Definition: sx_node.cpp:234

References casadi::SXNode::op(), casadi::SerializingStream::pack(), and casadi::SXNode::serialize_node().

◆ serialize_node()

void casadi::BinarySX::serialize_node ( SerializingStream s) const
inlineoverridevirtual

Reimplemented from casadi::SXNode.

Definition at line 135 of file binary_sx.hpp.

135  {
136  s.pack("UnarySX::dep0", dep0_);
137  s.pack("UnarySX::dep1", dep1_);
138  }

References dep0_, dep1_, and casadi::SerializingStream::pack().

◆ shared_from_this() [1/2]

SXElem casadi::SXNode::shared_from_this ( )
inherited

Definition at line 261 of file sx_node.cpp.

261  {
262  return SXElem(this, false);
263  }

References casadi::SXNode::SXElem.

Referenced by casadi::SXNode::get_output(), and casadi::CallSX::get_output().

◆ shared_from_this() [2/2]

const SXElem casadi::SXNode::shared_from_this ( ) const
inherited

Definition at line 265 of file sx_node.cpp.

265  {
266  return SXElem(const_cast<SXNode*>(this), false);
267  }

References casadi::SXNode::SXElem.

◆ to_double()

double casadi::SXNode::to_double ( ) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9x

Reimplemented in casadi::ConstantSX, casadi::NanSX, casadi::MinusInfSX, casadi::InfSX, casadi::MinusOneSX, casadi::OneSX, casadi::ZeroSX, casadi::IntegerSX, and casadi::RealtypeSX.

Definition at line 56 of file sx_node.cpp.

56  {
57  return std::numeric_limits<double>::quiet_NaN();
58  }

Referenced by casadi::SXElem::binary(), and casadi::SXFunction::init().

◆ to_int()

casadi_int casadi::SXNode::to_int ( ) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_9x

Reimplemented in casadi::MinusOneSX, casadi::OneSX, casadi::ZeroSX, casadi::IntegerSX, and casadi::RealtypeSX.

Definition at line 60 of file sx_node.cpp.

60  {
61  casadi_error("to_int not defined for " + class_name());
62  }

References casadi::SXNode::class_name().

Referenced by casadi::SXElem::binary().

◆ which_function()

Function casadi::SXNode::which_function ( ) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_291

Reimplemented in casadi::CallSX.

Definition at line 64 of file sx_node.cpp.

64  {
65  casadi_error("'which_function' not defined for class " + class_name());
66  }

References casadi::SXNode::class_name().

Referenced by casadi::SXNode::print_compact(), and casadi::SXElem::which_function().

◆ which_output()

casadi_int casadi::SXNode::which_output ( ) const
virtualinherited

Extra doc: https://github.com/casadi/casadi/wiki/L_292

Reimplemented in casadi::OutputSX.

Definition at line 68 of file sx_node.cpp.

68  {
69  casadi_error("'which_output' not defined for class " + class_name());
70  }

References casadi::SXNode::class_name().

Referenced by casadi::SXElem::which_output().

Member Data Documentation

◆ count

unsigned int casadi::SXNode::count
inherited

◆ dep0_

SXElem casadi::BinarySX::dep0_

Extra doc: https://github.com/casadi/casadi/wiki/L_11f

Definition at line 133 of file binary_sx.hpp.

Referenced by dep(), is_equal(), serialize_node(), and ~BinarySX().

◆ dep1_

SXElem casadi::BinarySX::dep1_

Definition at line 133 of file binary_sx.hpp.

Referenced by dep(), is_equal(), serialize_node(), and ~BinarySX().

◆ deserialize_map

std::map< casadi_int, SXNode *(*)(DeserializingStream &)> casadi::SXNode::deserialize_map
staticinherited
Initial value:
= {
static SXNode * deserialize(DeserializingStream &s)
Definition: call_sx.hpp:161
static SXNode * deserialize(DeserializingStream &s)
Definition: output_sx.hpp:152
static SXNode * deserialize(DeserializingStream &s)
Definition: symbolic_sx.hpp:77
SXNode * ConstantSX_deserialize(DeserializingStream &s)
@ OP_CONST
Definition: calculus.hpp:79

Definition at line 209 of file sx_node.hpp.

Referenced by casadi::SXNode::deserialize().

◆ eq_depth_

casadi_int casadi::SXNode::eq_depth_ = 1
staticinherited

◆ op_

unsigned char casadi::BinarySX::op_

Extra doc: https://github.com/casadi/casadi/wiki/L_11e

Definition at line 128 of file binary_sx.hpp.

Referenced by is_equal(), is_op(), is_smooth(), op(), and print().

◆ temp

int casadi::SXNode::temp
mutableinherited

Temporary variables to be used in user algorithms like sorting, the user is responsible of making sure that use is thread-safe The variable is initialized to zero

Definition at line 191 of file sx_node.hpp.

Referenced by casadi::SXFunction::init(), casadi::SXNode::mark(), casadi::SXNode::marked(), and casadi::SXNode::SXNode().


The documentation for this class was generated from the following file: