IndexedFreeAdditiveCombinationType
Usage
macro A == Integer; -- coefficient type
macro J == MachineInteger; -- index type
SparseOrderedAdditiveArray(A, J): with {
IndexedFreeAdditiveCombinationType(A, J);
TotallyOrderedType;
} == add { ... }
Description
A category of weak polynomials.
Informally a domain that realizes IndexedFreeAdditiveCombinationType can be seen as a polynomial domain A[J] that lacks multiplication and implements subtraction only if A does.
The type IndexedFreeAdditiveCombinationType is the type of structures whose elements are finite products of elements from A. It can be see as the monoid
(173) |
The semigroup structure of A lifts to X (see +). Also subtraction is lifted if it exists in A.
Parameters
An additive monoid that allows a zero test.
An ordered (finite or infinite) index set.
Remarks
We do not require AbelianMonoid as the type of A since we do not necessarily assume that the addition is commutative and since we want to be as minimal as possible.
Exports of IndexedFreeAdditiveCombinationType
0: % Zero element.
zero?: % -> Boolean Zero test.
bracket: (A, J) -> % Construction of a monomial element.
+: (%, %) -> % Lifted addition.
leadingMonomial: % -> Cross(A, J) Returns the monomial with biggest index.
leadingCoefficient: % -> A Returns the coefficient of the monomial with biggest index.
reductum: % -> % Removes the monomial with biggest index.
maxSupport: % -> J Returns the biggest index of the support of the element.
generator: % -> Generator Cross(A, J) Generates coefficient-index pairs starting with the biggest index.
#: % -> MachineInteger Returns the number of elements in the support.
map: (A -> A) -> % -> % Applies a function to all coefficients.
map: (Cross(A,J) -> Cross(A,J)) -> % -> % Applies a function to all monomials.
if A has with {-: (%, %) -> %; -: % -> %} then {
-: (%, %) -> % Lifted subtration.
-: % -> % Lifted negation.
}
if A has with {0: %} then {
apply: (%, J) -> A Returns the coefficient corresponding to the given index.
}
if A has PrimitiveType then PrimitiveType;
if A has TotallyOrderedType then TotallyOrderedType;
if A has OutputType and J has OutputType then OutputType;
Export of IndexedFreeAdditiveCombinationType
bracket: (A, J) -> %
Description
Construction of a monomial element.
The call [a,j] returns f so that for all i ∈ J:
(174) |
Export of IndexedFreeAdditiveCombinationType
+: (%, %) -> %
Description
Lifted addition.
The monoid structure of A lifts to X = A(J). Let a1 : J → A and a2 : J → A with supp(a1) = I1 and supp(a2) = I2. Then a = a1 + a2 is defined as the function a : J → A with
(175) |
Export of IndexedFreeAdditiveCombinationType
leadingMonomial: % -> Cross(A, J)
Description
Returns the monomial with biggest index.
Since each element f has finite support S, the function returns the pair (f(j),j) such that j = maxS where the maximum is taken with respect to the given compare function of the given index set J.
Remarks
The result of leadingMonomial(0) is undefined and may result in a runtime exception.
Export of IndexedFreeAdditiveCombinationType
leadingCoefficient: % -> A
Description
Returns the coefficient of the monomial with biggest index.
Since each element f has finite support S, the function returns f(j) for j = maxS where the maximum is taken with respect to the given compare function of the given index set J.
Remarks
The result of leadingCoefficient(0) is undefined and may result in a runtime exception.
Export of IndexedFreeAdditiveCombinationType
reductum: % -> %
Description
Removes the monomial with biggest index.
Since each element f has finite support S, the function returns the element g with supp(g) = S ∖ and f(j) = g(j) on the common support of f and g.
The maximum is taken with respect to the given compare function of the given index set J.
Remarks
The result of reductum(0) is undefined and may result in a runtime exception.
Export of IndexedFreeAdditiveCombinationType
maxSupport: % -> J
Description
Returns the biggest index of the support of the element.
Since each element f has finite support S, the function returns j = maxS where the maximum is taken with respect to the given compare function of the given index set J.
Remarks
The result of maxSupport(0) is undefined and may result in a runtime exception.
Export of IndexedFreeAdditiveCombinationType
generator: % -> Generator Cross(A, J)
Description
Generates coefficient-index pairs starting with the biggest index.
Remarks
The call generator(0) returns a generator that generates no element.
Export of IndexedFreeAdditiveCombinationType
#: % -> MachineInteger
Description
Returns the number of elements in the support.
Remarks
The call #(0) returns 0.
Export of IndexedFreeAdditiveCombinationType
map: (A -> A) -> % -> %
Description
Applies a function to all coefficients.
Export of IndexedFreeAdditiveCombinationType
map: (Cross(A,J) -> Cross(A,J)) -> % -> %
Description
Applies a function to all monomials.
Remarks
This function assumes that the given function that is applied to coefficient and index does not destroy the order, i. e., we assume that in map(f,x) the function f : A × J → A × J is monotone in its second argurment; if (a1′,j1′) = f(a1,j1) and (a2′,j2′) = f(a2,j2) and j1 < j2 then j1′ < j2′.
Some functionality can only be implemented (and we do it as category defaults) if the coefficient domain A provides enought functionality.
Export of IndexedFreeAdditiveCombinationType
-: (%, %) -> %
Description
Lifted subtration.
The monoid structure of A lifts to X = A(J). Let a1 : J → A and a2 : J → A with supp(a1) = I1 and supp(a2) = I2. Then a = a1 − a2 is defined as the function a : J → A with
(176) |
Export of IndexedFreeAdditiveCombinationType
apply: (%, J) -> A
Description
Returns the coefficient corresponding to the given index.
An element f is a function f : J → A. The call apply(f,j) or f.j returns f(j).
Remarks
If jsuppf then f(j) = 0.
Let x and y be elements of the current domain then x < y if and only if one of the following conditions holds.
where jx = maxsupp(x) and x′ = reductum(x), and jy and y′ are defined analogously.
Note that this order has a minimal element, namely 0. This order is not additive in general. Take A = J = ℤ and the functions a,b : ℤ → ℤ where a(0) = 1, b(0) = −1 and all other function value are zero. Then we clearly have 0 < a and 0 < b. However, 0 + a < a + b = 0 is false.
Nevertheless, the order is modelled after the lexicographic order starting the comparison with the biggest index. It is sometimes also known as the reverse lexicographical order (which should not be confused with the inverse lexicographical order which is simply < −1 for the lexicographical order <, i. e., if a < b then b < −1a).
Similarly, compare(x,y) is 0 if x = y, < 0 if x < y and > 0 if x > y.