licence added + log_sum_exp trick added