calc_with_mem
