|
3 | 3 | ModelingToolkit IR mirrors the Julia AST but allows for easy mathematical
|
4 | 4 | manipulation by itself following mathematical semantics. The base of the IR is
|
5 | 5 | the `Sym` type, which defines a symbolic variable. Registered (mathematical)
|
6 |
| -functions on `Sym`s (or `Term`s) return `Term`s. For example, `op1 = x+y` is |
7 |
| -one `Term` and `op2 = 2z` is another, and so `op1*op2` is another `Term`. Then, |
8 |
| -at the top, an `Equation`, normally written as `op1 ~ op2`, defines the |
9 |
| -symbolic equality between two operations. |
| 6 | +functions on `Sym`s (or `istree` objects) return an expression that `istree`. |
| 7 | +For example, `op1 = x+y` is one symbolic object and `op2 = 2z` is another, and |
| 8 | +so `op1*op2` is another tree object. Then, at the top, an `Equation`, normally |
| 9 | +written as `op1 ~ op2`, defines the symbolic equality between two operations. |
10 | 10 |
|
11 | 11 | ### Types
|
12 | 12 | `Sym`, `Term`, and `FnType` are from [SymbolicUtils.jl](https://juliasymbolics.github.io/SymbolicUtils.jl/api/). Note that in
|
13 | 13 | ModelingToolkit, we always use `Sym{Real}`, `Term{Real}`, and
|
14 |
| -`FnType{Tuple{Any}, Real}`. To get the arguments of a `Term` use |
15 |
| -`arguments(t::Term)`, and to get the operation of a `Term` use |
16 |
| -`operation(t::Term)`. |
| 14 | +`FnType{Tuple{Any}, Real}`. To get the arguments of a `istree` object use |
| 15 | +`arguments(t::Term)`, and to get the operation, use `operation(t::Term)`. |
| 16 | +However, note that one should never dispatch on `Term` or test `isa Term`. |
| 17 | +Instead, one needs to use `SymbolicUtils.istree` to check if `arguments` and |
| 18 | +`operation` is defined. |
17 | 19 |
|
18 | 20 | ```@docs
|
19 | 21 | Equation
|
|
0 commit comments