Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mono.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function MP.monomial(vars::Vector{Variable{V,M}}, z::Vector{Int}) where {V,M}
return Monomial{V,M}(vars, z)
end

iscomm(::Type{<:Monomial{V}}) where {V} = iscomm(V)
MP.is_commutative(::Type{<:Monomial{V}}) where {V} = iscomm(V)
Monomial{V,M}() where {V,M} = Monomial{V,M}(Variable{V,M}[], Int[])
function Monomial(vars::TupOrVec{Variable{V,M}}, z::Vector{Int}) where {V,M}
return Monomial{V,M}(vars, z)
Expand Down
2 changes: 1 addition & 1 deletion src/poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function Polynomial{V,M,T}(terms::AbstractVector{<:_Term{V,M}}) where {V,M,T}
return Polynomial{V,M,T}(a, x)
end

iscomm(::Type{Polynomial{V,M,T}}) where {V,M,T} = V, M
MP.is_commutative(::Type{Polynomial{V,M,T}}) where {V,M,T} = iscomm(V)

function _zero_with_variables(
::Type{Polynomial{V,M,T}},
Expand Down
13 changes: 7 additions & 6 deletions src/var.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,17 @@ end

MP.monomial(v::Variable) = Monomial(v)
MP.variables(v::Variable) = [v]
MP.exponents(v::Variable) = [1]
MP.exponents(::Variable) = [1]
MP.ordering(v::Variable) = MP.ordering(typeof(v))
MP.ordering(::Type{Variable{V,M}}) where {V,M} = M

iscomm(::Type{Variable{C}}) where {C} = C
MP.is_commutative(::Type{Variable{V}}) where {V} = iscomm(V)
MP.is_commutative(::Type{<:Vector{<:Variable{V}}}) where {V} = iscomm(V)

Base.isreal(x::Variable{C}) where {C} = x.kind != COMPLEX && x.kind != CONJ
MP.isrealpart(x::Variable{C}) where {C} = x.kind == REAL_PART
MP.isimagpart(x::Variable{C}) where {C} = x.kind == IMAG_PART
MP.isconj(x::Variable{C}) where {C} = x.kind == CONJ
Base.isreal(x::Variable) = x.kind != COMPLEX && x.kind != CONJ
MP.isrealpart(x::Variable) = x.kind == REAL_PART
MP.isimagpart(x::Variable) = x.kind == IMAG_PART
MP.isconj(x::Variable) = x.kind == CONJ
function MP.ordinary_variable(x::Variable)
return x.kind == REAL || x.kind == COMPLEX ? x : Variable(x, COMPLEX)
end
Expand Down
Loading