-
-
Notifications
You must be signed in to change notification settings - Fork 454
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy species #38544
base: develop
Are you sure you want to change the base?
Lazy species #38544
Conversation
…groups Also added various miscellaneous functions
Co-authored-by: Martin Rubey <axiomize@yahoo.de>
Also some fixes to _element_constructor_ ConjugacyClassesOfSubgroups
Added _repr_ for ConjugacyClassesOfSubgroups I now output B[(gens or name if available)] as _repr_ for generators, for example B[1] + 2*B[(2,3,4)]
…y and doctest updates
…ial case in construct_element
src/sage/rings/lazy_species.py
Outdated
def add_structures(labels): | ||
yield from self.structures(labels) | ||
yield from other.structures(labels) | ||
|
||
result = super()._add_(other) | ||
result.structures = add_structures | ||
return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tscrim, I'm not sure whether this is the best way to do it. I tried to create a separate class SumSpeciesElement
inheriting from LazySpeciesElement
that only overrides the method structures
(and will override generating_series
, etc.), but got stuck.
I think I would like to turn the result of super()._add_(other)
into a SumSpeciesElement
instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other thing: I am not sure, but perhaps it would actually be nice to take some decisions of LazyModuleElement._add_
into account. For example, if one of the arguments is zero, I might not want to return a SumSpeciesElement, but rather the other summand.
However, this smells badly like duplicating a lot of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rethinking this: I guess it happens next to never that we are in one of the cases treated specially by LazyModuleElement._add_
(or _mul_
, etc.) So maybe my afterthought is thinking about the empty set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the following look correct to you? At least it works. I admit that the arguments super
requires are not super-clear to me.
class LazySpeciesElement(LazyCompletionGradedAlgebraElement):
...
def _add_(self, other):
return SumSpeciesElement(self, other)
...
class SumSpeciesElement(LazySpeciesElement):
def __init__(self, left, right):
self._left = left
self._right = right
coeff_stream = super(LazySpeciesElement, type(left))._add_(left, right)._coeff_stream
super().__init__(self.parent(), coeff_stream)
def structures(self, labels):
yield from self._left.structures(labels)
yield from self._right.structures(labels)
We provide an implementation of combinatorial species based on the lazy series framework and #38446.