# HG changeset patch
# User Oscar CastilloFelisola <o.castillo.felisola@gmail.com>
# Date 1350389473 10800
# Node ID 16b64a78fc636209ec3081d58f85aa7bc52b0222
# Parent fc92d1920d1c299a1a94700ff3d5dc6e3757d965
trac 13606: Adding anticommutator operation of matrices
diff git a/sage/matrix/matrix0.pyx b/sage/matrix/matrix0.pyx
a

b

cdef class Matrix(sage.structure.element 
2136  2136  """ 
2137  2137  return self*other  other*self 
2138  2138  
 2139  def anticommutator(self, other): 
 2140  r""" 
 2141  Return the anticommutator ``self`` and ``other``. 
 2142  
 2143  The *anticommutator* of two `n \times n` matrices `A` and `B` 
 2144  is defined as `\{A, B\} := AB + BA` (sometimes this is written as 
 2145  `[A, B]_+`). 
 2146  
 2147  EXAMPLES:: 
 2148  
 2149  sage: A = Matrix(ZZ, 2, 2, range(4)) 
 2150  sage: B = Matrix(ZZ, 2, 2, [0, 1, 0, 0]) 
 2151  sage: A.anticommutator(B) 
 2152  [2 3] 
 2153  [0 2] 
 2154  sage: A.anticommutator(B) == B.anticommutator(A) 
 2155  True 
 2156  sage: A.commutator(B) + B.anticommutator(A) == 2*A*B 
 2157  True 
 2158  """ 
 2159  return self*other + other*self 
 2160  
2139  2161  ################################################### 
2140  2162  # Row and column operations 
2141  2163  # The _c versions do no bounds checking. 