Revision: 2655
http://sourceforge.net/p/fricas/code/2655
Author: whebisch
Date: 2020-03-18 15:49:16 +0000 (Wed, 18 Mar 2020)
Log Message:
-----------
Add FreeModuleCategory to polynomial rings
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/algebra/Makefile.in
trunk/src/algebra/indexedp.spad
trunk/src/algebra/multpoly.spad
trunk/src/algebra/poly.spad
trunk/src/algebra/polycat.spad
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/ChangeLog 2020-03-18 15:49:16 UTC (rev 2655)
@@ -1,5 +1,12 @@
2020-03-18 Waldek Hebisch <
heb...@math.uni.wroc.pl>
+ * src/algebra/Makefile.in, src/algebra/indexedp.spad,
+ src/algebra/multpoly.spad, src/algebra/poly.spad,
+ src/algebra/polycat.spad: Add FreeModuleCategory
+ to polynomial rings
+
+2020-03-18 Waldek Hebisch <
heb...@math.uni.wroc.pl>
+
* src/algebra/expr.spad, src/algebra/opalg.spad,
src/algebra/pgcd.spad, src/algebra/xlpoly.spad,
src/algebra/xpoly.spad: Cleanup related to free
Modified: trunk/src/algebra/Makefile.in
===================================================================
--- trunk/src/algebra/Makefile.in 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/src/algebra/Makefile.in 2020-03-18 15:49:16 UTC (rev 2655)
@@ -182,7 +182,7 @@
INTEF INTFACT INTG0 INTHEORY INTHERAL \
INTHERTR INTLOCP INTPAF INTPAR1 INTPAR2 INTPM INTRAT INTRET \
INTRF INTRVL INTSLPE INT INTTOOLS INTTR \
- INVLAPLA IPADIC IPF IPRNTPK IR2F IR2 \
+ INVLAPLA IPADIC IPC IPF IPRNTPK IR2F IR2 \
IROOT IRREDFFX IRRF2F IRSN IR IRURPK \
ISMITH ISTRING ISUMP ISUPS ITAYLOR ITFUN2 ITFUN3 \
ITRIGMNP ITUPLE IVECTOR IXAGG JBBFC JBC \
@@ -323,7 +323,7 @@
FDIVCAT FFCAT FILECAT FINGEN FINGRP MAGMA MORECAT NARNG \
NAALG FINAALG LIECAT FLALG \
FORTCAT FMC FMCAT FMFUN FMTC FNCAT FORTFN REAL RNS FPS FRNAALG \
- SETAGG FSAGG FVC FVFUN GPOLCAT GRMOD GRALG APRODC IDPC OINTDOM \
+ SETAGG FSAGG FVC FVFUN GPOLCAT GRMOD GRALG APRODC IPC IDPC OINTDOM \
INS INTCAT LALG LORER \
LFCAT OREPCAT LODOCAT LZSTAGG MATCAT MDAGG MAGMAWU MRCAT MSETAGG \
PSCAT MTSCAT NARING NASRNG NASRING PSETCAT TSETCAT RSETCAT NTSCAT OC \
Modified: trunk/src/algebra/indexedp.spad
===================================================================
--- trunk/src/algebra/indexedp.spad 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/src/algebra/indexedp.spad 2020-03-18 15:49:16 UTC (rev 2655)
@@ -9,8 +9,8 @@
if A has AbelianGroup then AbelianGroup
-)abbrev category IDPC IndexedDirectProductCategory
-++ Author: James Davenport
+)abbrev category IPC IndexedProductCategory
+++ Author: James Davenport, Waldek Hebisch
++ Basic Functions:
++ Related Constructors:
++ Also See:
@@ -18,22 +18,20 @@
++ Keywords:
++ References:
++ Description:
-++ This category represents the direct product of some set with
-++ respect to an ordered indexing set.
-++ The ordered set \spad{S} is considered as the ``basis elements'' and
+++ This category represents the product of some set with
+++ respect to an indexing set.
+++ The set \spad{S} is considered as the ``basis elements'' and
++ the elements from \spad{A} as ``coefficients''.
+++ Elements may have infinite support. For
+++ \spad{Comparable} (ordered) \spad{S} we assume that support
+++ of each element is well-orderd.
-IndexedDirectProductCategory(A : SetCategory, S : SetCategory
+IndexedProductCategory(A : SetCategory, S : SetCategory
) : Category == Export where
Term ==> Record(k : S, c : A)
Export == AbelianProductCategory(A) with
- if A has Comparable and S has Comparable then Comparable
- if S has OrderedSet then
- if A has OrderedAbelianMonoid then OrderedAbelianMonoid
- if A has OrderedAbelianMonoidSup then OrderedAbelianMonoidSup
-
map : (A -> A, %) -> %
++ map(f, z) returns the new element created by applying the
++ function f to each component of the direct product element z.
@@ -48,14 +46,6 @@
++ \spad{construct(l)} takes a list of terms and creates
++ the object with these components. First components
++ of elements of \spad{l} should be different.
- listOfTerms : % -> List Term
- ++ \spad{listOfTerms(x)} returns a list \spad{lt} of terms with type
- ++ \spad{Record(k: S, c: R)} such that \spad{x} equals
- ++ \spad{construct(lt)}. If \spad{S has Comparable} than
- ++ \spad{x} equals \spad{constructOrdered(lt)}.
- numberOfMonomials : % -> NonNegativeInteger
- ++ \spad{numberOfMonomials(x)} returns the number
- ++ of monomials of \spad{x}.
if S has Comparable then
leadingMonomial : % -> %
++ \spad{leadingMonomial(x)} returns the monomial supported by
@@ -87,6 +77,38 @@
++ (with respect to the ordering on the indexing set) term of z.
++ Error: if z has no support.
+
+)abbrev category IDPC IndexedDirectProductCategory
+++ Author: James Davenport
+++ Basic Functions:
+++ Related Constructors:
+++ Also See:
+++ AMS Classifications:
+++ Keywords:
+++ References:
+++ Description:
+++ This category represents the direct product of some set with
+++ respect to an ordered indexing set.
+++ The ordered set \spad{S} is considered as the ``basis elements'' and
+++ the elements from \spad{A} as ``coefficients''.
+
+IndexedDirectProductCategory(A : SetCategory, S : SetCategory
+ ) : Category == Export where
+ Term ==> Record(k : S, c : A)
+
+ Export == IndexedProductCategory(A, S) with
+
+ if A has Comparable and S has Comparable then Comparable
+
+ listOfTerms : % -> List Term
+ ++ \spad{listOfTerms(x)} returns a list \spad{lt} of terms with type
+ ++ \spad{Record(k: S, c: R)} such that \spad{x} equals
+ ++ \spad{construct(lt)}. If \spad{S has Comparable} than
+ ++ \spad{x} equals \spad{constructOrdered(lt)}.
+ numberOfMonomials : % -> NonNegativeInteger
+ ++ \spad{numberOfMonomials(x)} returns the number
+ ++ of monomials of \spad{x}.
+
)abbrev domain IDPO IndexedDirectProductObject
++ Description:
++ Indexed direct products of objects over a set \spad{A}
@@ -105,7 +127,10 @@
-- an object is the pair \spad{[s, a]} with \spad{s} maximal and thus
-- the first entry in the list representing the object.
IndexedDirectProductObject(A : SetCategory, S : SetCategory
- ) : IndexedDirectProductCategory(A, S)
+ ) : IndexedDirectProductCategory(A, S) with
+ if S has OrderedSet then
+ if A has OrderedAbelianMonoid then OrderedAbelianMonoid
+ if A has OrderedAbelianMonoidSup then OrderedAbelianMonoidSup
== add
--representation
Modified: trunk/src/algebra/multpoly.spad
===================================================================
--- trunk/src/algebra/multpoly.spad 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/src/algebra/multpoly.spad 2020-03-18 15:49:16 UTC (rev 2655)
@@ -225,6 +225,40 @@
return unlikeUnivReconstruct(u, mvar)
[mvar, u]$VPoly
+ construct(lt) ==
+ res : % := 0
+ ltr := reverse(lt)
+ for t in lt repeat
+ res := res + monomial(t.c, t.k)
+ res
+
+ constructOrdered(lt) == construct(lt)
+
+ leadingSupport(p) == degree(p)
+
+ leadingTerm(p) == [degree(p), leadingCoefficient(p)]
+
+ linearExtend(f, p) ==
+ res : % := 0
+ while not(zero?(p)) repeat
+ res := leadingCoefficient(p)*f(degree(p)) + res
+ p := reductum(p)
+ res
+
+ listOfTerms(p) ==
+ res : List(Record(k : IndexedExponents(VarSet), c : R)) := []
+ while not(zero?(p)) repeat
+ res := cons(leadingTerm(p), res)
+ p := reductum(p)
+ reverse!(res)
+
+ support(p) ==
+ res : List(IndexedExponents(VarSet)) := []
+ while not(zero?(p)) repeat
+ res := cons(degree(p), res)
+ p := reductum(p)
+ reverse!(res)
+
ground?(p : %) : Boolean ==
p case R => true
false
Modified: trunk/src/algebra/poly.spad
===================================================================
--- trunk/src/algebra/poly.spad 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/src/algebra/poly.spad 2020-03-18 15:49:16 UTC (rev 2655)
@@ -36,9 +36,6 @@
++ Author: Michel Petitot (
pet...@lifl.fr)
++
++ Note (Franz Lehner, June 2009):
-++ Since \spad{leadingTerm} makes no sense for unordered base sets,
-++ and at the time of this writing this domain was never used for such,
-++ the base set is required to be \spad{Comparable}.
++ \spad{FreeModule} originally was not of FreeModuleCategory.
++ Some functions (like \spad{support}, \spad{coefficients},
++ \spad{monomials}, ...) from here could be moved to
@@ -49,12 +46,6 @@
S : SetCategory
Exports == Join(BiModule(R, R), IndexedDirectProductCategory(R, S)) with
- if R has SemiRing then RetractableTo S
- "*" : (R, S) -> %
- ++ \spad{r*b} returns the product of \spad{r} by \spad{b}.
- "*":(S,R) -> %
- ++ \spad{s*r} returns the product \spad{r*s}
- ++ used by \spadtype{XRecursivePolynomial}
coefficients : % -> List R
++ \spad{coefficients(x)} returns the list of coefficients of \spad{x}.
support : % -> List S
@@ -70,7 +61,6 @@
linearExtend : (S->R, %)->R
++ \spad{linearExtend: (f, x)} returns the linear extension
++ of a map defined on the basis applied to a linear combination
- if R has Comparable and S has Comparable then Comparable
add
if R has Comparable and S has Comparable then
smaller?(p : %, q : %) : Boolean ==
@@ -116,6 +106,16 @@
FreeModule(R : Join(SemiRng, AbelianMonoid), S : SetCategory) :
Join(BiModule(R, R), FreeModuleCategory(R, S)) with
if R has CommutativeRing then Module(R)
+ if R has SemiRing then RetractableTo S
+ if S has OrderedSet then
+ if R has OrderedAbelianMonoid then OrderedAbelianMonoid
+ if R has OrderedAbelianMonoidSup then OrderedAbelianMonoidSup
+ "*" : (R, S) -> %
+ ++ \spad{r*b} returns the product of \spad{r} by \spad{b}.
+ "*":(S,R) -> %
+ ++ \spad{s*r} returns the product \spad{r*s}
+ ++ used by \spadtype{XRecursivePolynomial}
+
== IndexedDirectProductObject(R, S) add
--representations
Term ==> Record(k : S, c : R)
Modified: trunk/src/algebra/polycat.spad
===================================================================
--- trunk/src/algebra/polycat.spad 2020-03-18 15:28:49 UTC (rev 2654)
+++ trunk/src/algebra/polycat.spad 2020-03-18 15:49:16 UTC (rev 2655)
@@ -19,27 +19,13 @@
++ Conceptually at least, only the non-zero terms are ever operated on.
AbelianMonoidRing(R : Join(SemiRng, AbelianMonoid), E : OrderedAbelianMonoid
- ) : Category == Join(SemiRng, BiModule(R, R)) with
- leadingCoefficient : % -> R
- ++ leadingCoefficient(p) returns the coefficient highest degree term of p.
- leadingMonomial : % -> %
- ++ leadingMonomial(p) returns the monomial of p with the highest degree.
+ ) : Category == Join(SemiRng, BiModule(R, R),
+ IndexedProductCategory(R, E)) with
degree : % -> E
++ degree(p) returns the maximum of the exponents of the terms of p.
- map : (R -> R, %) -> %
- ++ map(fn, u) maps function fn onto the coefficients
- ++ of the non-zero monomials of u.
- monomial? : % -> Boolean
- ++ monomial?(p) tests if p is a single monomial.
- monomial : (R, E) -> %
- ++ monomial(r, e) makes a term from a coefficient r and an exponent e.
- reductum : % -> %
- ++ reductum(u) returns u minus its leading monomial
- ++ returns zero if handed the zero element.
coefficient : (%, E) -> R
++ coefficient(p, e) extracts the coefficient of the monomial with
++ exponent e from polynomial p, or returns zero if exponent is not present.
- if R has CancellationAbelianMonoid then CancellationAbelianMonoid
if R has SemiRing then SemiRing
if R has Ring then Ring
if R has Field then "/": (%,R) -> %
@@ -80,7 +66,8 @@
FiniteAbelianMonoidRing(R : Join(SemiRng, AbelianMonoid),
E : OrderedAbelianMonoid) : Category ==
- Join(AbelianMonoidRing(R, E), FullyRetractableTo R) with
+ Join(AbelianMonoidRing(R, E), FreeModuleCategory(R, E),
+ FullyRetractableTo R) with
ground? : % -> Boolean
++ ground?(p) tests if polynomial p is a member of the coefficient ring.
-- can't be defined earlier, since a power series
@@ -87,10 +74,6 @@
-- might not know if there were other terms or not
ground : % -> R
++ ground(p) retracts polynomial p to the coefficient ring.
- coefficients : % -> List R
- ++ coefficients(p) gives the list of non-zero coefficients of polynomial p.
- numberOfMonomials : % -> NonNegativeInteger
- ++ numberOfMonomials(p) gives the number of non-zero monomials in polynomial p.
minimumDegree : % -> E
++ minimumDegree(p) gives the least exponent of a non-zero term of polynomial p.
++ Error: if applied to 0.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.