Ralf Hemmecke <[EMAIL PROTECTED]> writes:
> >> coefficient: (%, IndexedExponents Var) -> Coef (*2)
> >>
> >> to return %.
> >
> > I'd rather prefer
> >
> > coefficient: (%, Monomial) -> ???
> >
> > which is what I did in (35) above.
>
> Well... What is a power series? It's a mapping from N^n to the
> coefficient domain. Now whether you call N^n "Monomial" is probably a
> matter of taste. I also think that it is not bad, but IndexedExponents
> is not totally bad, either.
Sorry, I was unclear. IndexedExponents is OK for me. What I somewhat dislike
is that
-- 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)}.
but
-- coefficient(p, e) extracts the coefficient of the monomial with exponent e
-- from polynomial p, or returns zero if exponent is not present.
I.e., the second form takes a proper monomial, the first form doesn't.
> > Only, the return type is not totally clear. Maybe the signature in
> > AbelianMonoidRing should export both
> >
> > coefficient: (%, Monomial) -> %
> >
> > and
> >
> > coefficient: (%, Monomial) -> Coeff
>
> I don't think that is reasonable. The "->%" works in every case. For
> "->Coeff" one should expect an exception in general.
Huh? No, the two functions have quite different semantics. It's an unfortunate
coincidence that they carry the same name.
> So I would rather have "->%" and a function "ground?" which tests whether the
> power series is, in fact, constant, i.e. an element of Coeff.
>
> > Proper design takes too long.
>
> Yes, it does. ;-)
Anyway, here is a first patch that implements some of the missing functions for
TS. I guess that quite a few definitions should become defaults of the
category.
By the way, IndexedExponents is really awkward to use...
Martin
Index: mts.spad.pamphlet
===================================================================
--- mts.spad.pamphlet (revision 440)
+++ mts.spad.pamphlet (working copy)
@@ -86,6 +86,38 @@
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), s)
+
+-- 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)
+
+ monomial(c, m): % == monomial(c, m)$SMP::%
+
+ map(f: Coef -> Coef, x: %): % == map(map(f, #1), x)$Rep
+
--% creation of series
coerce(r:Coef) == monom(r::SMP,0)$STT
Index: pscat.spad.pamphlet
===================================================================
--- pscat.spad.pamphlet (revision 440)
+++ pscat.spad.pamphlet (working copy)
@@ -599,6 +599,11 @@
--++ We provide transcendental functions when we can divide
--++ coefficients by integers.
+ add
+
+ coefficient(s: %, v: Var, n: NNI): % == coefficient(s, [v], [n])
+
+
@
\section{License}
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---