Basic functions

Functions for terms

LinearCombinations.degMethod
deg(x)

Return the degree of x. The default value of deg(x) is 0. (More precisely, it is LinearCombinations.Zero(), which behaves like 0.)

See also deg(::AbstractTensor), LinearCombinations.Zero.

Examples

The degree of a GradedString (created with the gr"" string macro) is its length.

julia> using LinearCombinations.TestHelpers: GradedString, @gr_str

julia> deg(*)
LinearCombinations.Zero()

julia> gr"xy" |> deg
2

julia> gr"xy" * gr"z" |> deg
3

julia> Base.Fix1(*, gr"xy") |> deg
2

julia> Base.Fix1(*, gr"xy") ∘ Base.Fix1(*, gr"z") |> deg
3

julia> deg(LinearCombinations.diff)
-1
source

Traits and functions for rings

LinearCombinations.has_char2Function
has_char2(::Type{R}) where R -> Bool
has_char2(x::R) where R -> Bool

Return true if the ring R is known to have characteristic 2 and false otherwise.

By default, has_char2 returns false for all arguments. Changing it to true for a ring R avoids (possibly expensive) sign computations.

See also is_domain.

source
LinearCombinations.is_domainFunction
is_domain(::Type{R}) where R -> Bool

Return true if the ring R is known to be integral domain and false otherwise. An integral domain is a commutative ring without zero divisors.

By default, is_domain returns true only for subtypes of Real and Complex. If is_domain(R) == true, then sometimes more efficient algorithms can be chosen.

See also has_char2.

source
LinearCombinations.withsignFunction
LinearCombinations.withsign(k, x)

Return a value representing (-1)^k*x. The default definition is

withsign(k, x) = has_char2(x) || iseven(k) ? x : -x

Additional methods may be needed to support more exotic coefficient types.

source