Make sure A is contiguous