Ralf Hemmecke <[EMAIL PROTECTED]> writes:

> > Well, I think that only "morally" equal functions should share names.  
> > Although
> > this is very vague indeed.  I'd expect that two functions of the same name, 
> > one
> > taking a list of variables and a list of exponents which together specify a
> > monomial (and which I personally consider bad practice already, but anyway),
> > and the other taking a monomial in the form of IndexedExponents should yield
> > the *same* result.
> 
> Oh, I am sorry. I would also ban
> 
>    coefficient: (%, List Var, List NNI) -> %                 (*1)

Me too.

> and instead change
> 
>    coefficient: (%, IndexedExponents Var) -> Coef             (*2)
> 
> to return %.

This is exported by AbelianMonoidRing, and I think it's OK to have it.  At
least, it's consistent with Polynomial Integer:

(35) -> coefficient(x^2+y+y*z, monomial(1,z)$IndexedExponents(Symbol))

   (35)  0
                                                     Type: NonNegativeInteger

> But I am not totally convinced. Having two lists in the argument is bad.  I'd
> rather prefer something like
> 
>    coefficient: (%, List Cross(Var, NNI)) -> %
>
> Here the return type % is fine.

I'd rather prefer

     coefficient: (%, Monomial) -> ???

which is what I did in (35) above.

Only, the return type is not totally clear.  Maybe the signature in
AbelianMonoidRing should export both

     coefficient: (%, Monomial) -> %

and

     coefficient: (%, Monomial) -> Coeff

> Also (*2) is not totally optimal. Suppose you power series contains x 
> and y and you give IndexedExponents that only involve x. The return type 
> should then be % instead of Coef.

Well, currently it seems that there are two kinds of coefficient functions:

1) eg in POLYCAT:

    coefficient: (%,List VarSet,List NonNegativeInteger) -> %
      ++ 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)}.

2) in AbelianMonoidRing, where the exponents of variables that are not given
   are implicitely assumed as zero.

so:

(39) -> coefficient(x^2+y+y*z, monomial(1,z)$IS)

   (39)  0
                                                     Type: NonNegativeInteger
(40) -> coefficient(x^2+y+y*z, z, 1)

   (40)  y
                                                    Type: Polynomial(Integer)

I think we should consider to remove or rename one of them.  I'm not completely
sure which one, though.

Now that I see the pattern, I think I'll provide both for TS, for the moment.
Proper design takes too long.


Martin


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to