#NEWLINE# def logsum( logv ) : #NEWLINE# #INDENT# '\n    Return log(v[0]+v[1]+...), avoiding arithmetic underflow/overflow.\n    ' #NEWLINE# res = logzero ( ) #NEWLINE# for val in logv : #NEWLINE# #INDENT# res = logsum_pair ( res , val ) #NEWLINE# #UNINDENT# return res