#19473: FiniteDimensionalAlgebra.is_unitary is not sufficient
-------------------------------------+-------------------------------------
       Reporter:  darij              |        Owner:
           Type:  defect             |       Status:  needs_review
       Priority:  major              |    Milestone:  sage-6.10
      Component:  algebra            |   Resolution:
       Keywords:  finite-            |    Merged in:
  dimensional algebra, linear        |    Reviewers:  Travis Scrimshaw
  algebra                            |  Work issues:  clear up
        Authors:  Darij Grinberg,    |  associativity requirement; if
  Travis Scrimshaw                   |  necessary, change superclass and
Report Upstream:  N/A                |  is_unitary method
         Branch:                     |       Commit:
  public/algebra/finite_dim_algebra_fixes-19473|  
0cfe0366fc527d2f692c835be3d40f60aa61c471
   Dependencies:                     |     Stopgaps:
-------------------------------------+-------------------------------------

Comment (by pbruin):

 Here is Johan Bosman's implementation of `is_unitary()` from #12141 before
 my wrong rewrite (and after some editing and simplification):
 {{{
 #!python
 @cached_method
 def is_unitary(self):
     """
     Return True if ``self`` is unitary.

     EXAMPLES::

         sage: B = FiniteDimensionalAlgebra(QQ, [Matrix([[1,0],[0,1]]),
 Matrix([[0,1],[-1,0]])])
         sage: B.is_unitary()
         True
         sage: C = FiniteDimensionalAlgebra(QQ, [Matrix([[0,0],[0,0]]),
 Matrix([[0,0],[0,0]])])
         sage: C.is_unitary()
         False
     """
     n = self._degree
     k = self.base_ring()
     if n == 0:
         self._one = vector(k, [])
         return True
     B1 = reduce(lambda x, y: x.augment(y),
                 self._table, Matrix(k, n, 0))
     B2 = reduce(lambda x, y: x.augment(y),
                 self.left_table(), Matrix(k, n, 0))
     # This is the vector obtained by concatenating the rows of the
     # n times n identity matrix:
     v = vector(k, (n - 1) * ([1] + n * [0]) + [1])
     try:
         sol1 = B1.solve_left(v)
         sol2 = B2.solve_left(v)
     except ValueError:
         return False
     if sol1 == sol2:
         self._one = sol1
         return = True
     else:
         return False
 }}}
 If this is correct, we can just re-use it.

--
Ticket URL: <http://trac.sagemath.org/ticket/19473#comment:14>
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