allocate z_size_max=2*(x_size+y_size)