SX/n_nodes.py

This example looks at the n_nodes method

View output (PDF) | source (python)

See also
casadi::n_nodes(const SX& A);
casadi::n_nodesFull(const SX& A);
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 from casadi import *
28 from casadi.tools import *
29 
30 
31 
32 x = SX.sym("x")
33 y = SX.sym("y")
34 z = x*y+2*y
35 print(n_nodes(z), " nodes in ", z)
36 dotdraw(z)
37 
38 z += 4*z
39 print(n_nodes(z), " nodes in ", z)
40 dotdraw(z)
41 
42 z *= z+1
43 print(n_nodes(z), " nodes in ", z)
44 dotdraw(z)
45 
46