Hi Nicolas,

On 26 Mrz., 11:59, "Nicolas M. Thiery" <nicolas.thi...@u-psud.fr>
wrote:
> ...
> Very short answer for the moment: I should have pointed you to the
> upcoming tutorial:
>
> http://combinat.sagemath.org/doc/reference/demos/tutorial-using-free-...

Thank you! That was what I was looking for.

Some comments: I would expect that monomial_coefficients() (or better
a different name that is backwards compatible, see below!) is a
required  abstract element method of the category of ModulesWithBasis,
on top of which there is a default implementation of support(),
monomials(), coefficients(). Is that planned?

And is it possible to change the names of these methods at this point?

For example, shouldn't we better use dict() rather than
monomial_coefficients()? Namely, this is how the corresponding method
is called for polynomials:
  sage: P.<a,b,c> = PolynomialRing(QQ)
  sage: p = (a+b)^2
  sage: p.dict()
  {(1, 1, 0): 2, (2, 0, 0): 1, (0, 2, 0): 1}

Moreover, in the case of a module, I wouldn't use the name "monomial"
for the basis elements. Is there a better name than "e.monomials()" if
e is an element of a ModuleWithBasis? Perhaps *this* should be called
"e.support()", whereas the indices of the support should be named
"e.support_indices()" or "e.indices_of_support()".

Is it planned to also have a parent method, say, _element_from_dict_,
with the property P._element_from_dict_(e.dict())==e for any e in P?
The default implementation for a ModuleWithBasis could be:
def _element_from_dict_(self, D):
    B = self.basis()
    return self.sum([c*B[m] for m,c in D.iteritems()])

Then, _element_from_dict_ could be used in convert maps: If e is an
element of a ModuleWithBasis P, and Q is a ModuleWithBasis with a
different basis but the same index set (or there is a conversion from
the index set for P into the index set for Q), then Q(e) should result
in Q._element_from_dict_(e.dict()).

So, _element_form_dict_ would be used in addition to
_element_constructor_ (probably it would be used if
_element_constructor_ fails with a TypeError).

And rather than always returning an actual dictionary or list by
e.dict() resp e.monomial_coefficients() or by e.coefficients(),
wouldn't it be a good idea to have an iterator e.iter_items(),
e.iter_coefficients() etc?

Just some random thoughts...

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to