Skip to content

Commit 34603eb

Browse files
committed
Add variable_union_type
1 parent fe0d7ca commit 34603eb

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

docs/src/types.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ AbstractVariable
1111
variable
1212
name
1313
name_base_indices
14+
variable_union_type
1415
similarvariable
1516
@similarvariable
1617
```

src/variable.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@ export name, name_base_indices, similarvariable, @similarvariable
22

33
Base.copy(x::AbstractVariable) = x
44

5+
"""
6+
variable_union_type(p::AbstractPolynomialLike)
7+
8+
Return the supertype for variables of `p`. If `p` is a variable, it should not
9+
be the type of `p` but the supertype of all variables that could be created.
10+
11+
### Examples
12+
13+
For `TypedPolynomials`, a variable of name `x` has type `Variable{:x}` so
14+
`variable_union_type` should return `Variable`.
15+
For `DynamicPolynomials`, all variables have the same type `PolyVar{C}` where
16+
`C` is `true` for commutative variables and `false` for non-commutative ones so
17+
`variable_union_type` should return `PolyVar{C}`.
18+
"""
19+
function variable_union_type end
20+
521
"""
622
variable(p::AbstractPolynomialLike)
723

0 commit comments

Comments
 (0)