speedup wafom by precomputation