#NEWLINE# def _trace_symbanded( a , b , lower = 0 ) : #NEWLINE# #INDENT# '\n    Compute the trace(ab) for two upper or banded real symmetric matrices\n    stored either in either upper or lower form.\n\n    INPUTS:\n       a, b    -- two banded real symmetric matrices (either lower or upper)\n       lower   -- if True, a and b are assumed to be the lower half\n\n\n    OUTPUTS: trace\n       trace   -- trace(ab)\n\n    ' #NEWLINE# if lower : #NEWLINE# #INDENT# t = _zero_triband ( ( b * b ) , lower = 1 ) #NEWLINE# return ( t [ 0 ] . sum ( ) + ( 2 * t [ 1 : ] . sum ( ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# t = _zero_triband ( ( a * b ) , lower = 0 ) #NEWLINE# return ( t [ ( - 1 ) ] . sum ( ) + ( 2 * t [ : ( - 1 ) ] . sum ( ) ) )