John H Palmieri wrote:
> On Aug 26, 6:21 am, "Nicolas M. Thiery" <[email protected]>
> wrote:
>> Dear and Javier, dear John,
>
> [snip]
>
>> So in the long run, we definitely need both the direct sum and the
>> direct product functorial constructions, with appropriate
>> "inheritance" to share whatever is valid for both direct products and
>> direct sums. For the moment, I'll just leave a note about this in the
>> code (for the moment, this feature is essentially used nowhere).
>>
>> A little question: if V and W are two vector spaces which turn out to
>> be also in stronger categories, some with direct sums, and some
>> without, what should the following do:
>>
>> sage: direct_sum(V, W)
>
> Could there be an optional argument:
>
> sage: direct_sum(V, W, cat)
>
> If cat is not present, find the "strongest" category which contains
> both V and W, and compute the direct sum there, raising an error if it
> doesn't exist. (Or just raise an error? Or raise an error, saying
> what this strongest category is, and suggesting computing the direct
> sum there? Maybe I like this last approach the best.) If cat is
> present, check that cat contains both V and W, and then compute the
> direct sum there.
Isn't this sort of what the coercion system is all about? If you can't
do a direct sum of V and W, try coercing them into a category that can
do a direct sum? If you want to specifically compute the direct sum in
a particular category, then do an explicit cast yourself, like
direct_sum(cat(V), cat(W)), or maybe cat.direct_sum(V,W) or something.
Maybe there is some function that gives back the categories V belongs to
and the categories W belongs to with some sort of hierarchy, so that you
can ask what the strongest category is. Maybe there is some way to
filter a set of categories by existence of operations. So you could do
something like:
category_graph=V.categories().subgraph(W.categories())
category_graph.subgraph(lambda cat: cat.exists('direct_sum'))
strongest_category=category_graph.root()
Forgive me if I don't make any sense :).
Jason
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send an email to [email protected]
To unsubscribe from this group, send an email to
[email protected]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---