#19416: Implement some generic category methods
-------------------------------------+-------------------------------------
       Reporter:  tscrim             |        Owner:  tscrim
           Type:  enhancement        |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.10
      Component:  categories         |   Resolution:
       Keywords:                     |    Merged in:
        Authors:  Travis Scrimshaw   |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  public/categories/generic_methods-19416|  
f9b5da0e38fc793122ac2615df86efa3a590f3ad
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by jhpalmieri):

 I would prefer if the docstring for `is_commutative` said "Return
 ''whether'' self is a commutative algebra" (or "Return whether this
 algebra is a commutative algebra").

 Is it worth saving any time by removing `self.one()` from the basis before
 doing the iteration? With the following change:
 {{{
 #!diff
 diff --git a/src/sage/categories/finite_dimensional_algebras_with_basis.py
 b/src/sage/categories/finite_dimensional_algebras_with_basis.py
 index da1a870..8934e6c 100644
 --- a/src/sage/categories/finite_dimensional_algebras_with_basis.py
 +++ b/src/sage/categories/finite_dimensional_algebras_with_basis.py
 @@ -951,7 +951,7 @@ class
 FiniteDimensionalAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
          @cached_method
          def is_commutative(self):
              """
 -            Return if ``self`` is a commutative algebra.
 +            Return whether ``self`` is a commutative algebra.

              EXAMPLES::

 @@ -963,6 +963,7 @@ class
 FiniteDimensionalAlgebrasWithBasis(CategoryWithAxiom_over_base_ring):
                  True
              """
              B = list(self.basis())
 +            B.remove(self.one())
              return all(b*bp == bp*b for i,b in enumerate(B) for bp in
 B[i+1:])

      class ElementMethods:
 }}}
 it appears to be faster to check commutativity for
 `SymmetricGroupAlgebra(5, QQ)`. (I removed the `@cached_method` line
 before testing.) It's even a little faster for commutative algebras: the
 time spent removing the

--
Ticket URL: <http://trac.sagemath.org/ticket/19416#comment:2>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to