def logDiffExp(A, B, out=None):
 if (out is None):
  out = numpy.zeros(A.shape)
 indicator1 = (A >= B)
 assert indicator1.all(), 'Values in the first array should be greater than the values in the second'
 out[indicator1] = (A[indicator1] + numpy.log((1 - numpy.exp((B[indicator1] - A[indicator1])))))
 return out

def logDiffExp ( A , B , out = None ) : if ( out is None ) : out = numpy . zeros ( A . shape ) indicator1 = ( A >= B ) assert indicator1 . all ( ) , 'Values in the first array should be greater than the values in the second' out [ indicator1 ] = ( A [ indicator1 ] + numpy . log ( ( 1 - numpy . exp ( ( B [ indicator1 ] - A [ indicator1 ] ) ) ) ) ) return out
returns log(exp(a) - exp(b)) .