Waldek Hebisch <[EMAIL PROTECTED]> writes:
> coefficient lowers total degree by a constant, so it should be
> enough to shift Stream.
Thanks. Below a new patch. If you give OK for
+ coefficient(s: %, lv: List Var, ln: List NNI): % ==
+ map(coefficient(#1, lv, ln), rest(s, reduce(_+, ln)))
and the generic definition in pscat
coefficient(s: %, v: Var, n: NNI): % == coefficient(s, [v], [n])
I'll write some unittests, run them, and commit.
(and I'd really like to be able to commit the other pile of patches... sorry
for being annoying...)
Martin
Index: mts.spad.pamphlet
===================================================================
--- mts.spad.pamphlet (revision 440)
+++ mts.spad.pamphlet (working copy)
@@ -86,6 +86,36 @@
coefficient(s,n) == elt(s,n + 1)$Rep -- 1-based indexing for streams
+-- coefficient(p, lv, ln) views the polynomial p as a polynomial
+-- in the variables of lv and returns the coefficient of the term
+-- \spad{lv**ln}, i.e. \spad{prod(lv_i ** ln_i)}.
+
+ coefficient(s: %, lv: List Var, ln: List NNI): % ==
+ map(coefficient(#1, lv, ln), rest(s, reduce(_+, ln)))
+
+-- extracts the coefficient of the monomial with
+-- exponent e from polynomial p, or returns zero if exponent is not present.
+
+ coefficient(s: %, m: IndexedExponents Var): Coef ==
+-- compute degree of m
+ n := leadingCoefficient(mon := m)
+ while not zero?(mon := reductum mon) repeat
+ n := n + leadingCoefficient mon
+
+ coefficient(coefficient(s, n), m)
+
+ leadingCoefficient s ==
+ leadingCoefficient(coefficient(s, order(s pretend PS)$PS))
+
+ leadingMonomial s ==
+ leadingMonomial(coefficient(s, order(s pretend PS)$PS))::%
+
+ reductum s == s - leadingMonomial s
+
+ degree s == degree coefficient(s, order(s pretend PS)$PS)
+
+ map(f: Coef -> Coef, x: %): % == map(map(f, #1), x)$Rep
+
--% creation of series
coerce(r:Coef) == monom(r::SMP,0)$STT
@@ -108,6 +138,8 @@
monomial(r:%,v:Var,n:NNI) ==
r * monom(monomial(1,v,n)$SMP,n)$STT
+ monomial(c, m): % == monomial(c, m)$SMP::%
+
--% evaluation
substvar: (SMP,L Var,L %) -> %
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---