def _trace_symbanded(a, b, lower=0):
 if lower:
  t = _zero_triband((a * b), lower=1)
  return (t[0].sum() + (2 * t[1:].sum()))
 else:
  t = _zero_triband((a * b), lower=0)
  return (t[(-1)].sum() + (2 * t[:(-1)].sum()))

def _trace_symbanded ( a , b , lower = 0 ) : if lower : t = _zero_triband ( ( a * b ) , lower = 1 ) return ( t [ 0 ] . sum ( ) + ( 2 * t [ 1 : ] . sum ( ) ) ) else : t = _zero_triband ( ( a * b ) , lower = 0 ) return ( t [ ( - 1 ) ] . sum ( ) + ( 2 * t [ : ( - 1 ) ] . sum ( ) ) )
compute the trace for two upper or banded real symmetric matrices stored either in either upper or lower form .