def cross_entropy(mat, p, target=None, tiny=1e-10):
 if (not target):
  target = mat
 if isinstance(p, EigenMatrix):
  err_code = _eigenmat.compute_cross_entropy(mat.p_mat, p.p_mat, target.p_mat, ct.c_float(tiny))
 else:
  raise ValueError, 'Value must be of type EigenMatrix.'
 if err_code:
  raise generate_exception(err_code)
 return target

def cross_entropy ( mat , p , target = None , tiny = 1e-10 ) : if ( not target ) : target = mat if isinstance ( p , EigenMatrix ) : err_code = _eigenmat . compute_cross_entropy ( mat . p_mat , p . p_mat , target . p_mat , ct . c_float ( tiny ) ) else : raise ValueError , 'Value must be of type EigenMatrix.' if err_code : raise generate_exception ( err_code ) return target
compute -mat*log(p) .