  We show that quantum circuits where the initial state and all the following
quantum operations can be represented by positive Wigner functions can be
classically efficiently simulated. This is true both for continuous-variable as
well as discrete variable systems in odd prime dimensions, two cases which will
be treated on entirely the same footing. Noting the fact that Clifford and
Gaussian operations preserve the positivity of the Wigner function, our result
generalizes the Gottesman-Knill theorem. Our algorithm provides a way of
sampling from the output distribution of a computation or a simulation,
including the efficient sampling from an approximate output distribution in
case of sampling imperfections for initial states, gates, or measurements. In
this sense, this work highlights the role of the positive Wigner function as
separating classically efficiently simulatable systems from those that are
potentially universal for quantum computing and simulation, and it emphasizes
the role of negativity of the Wigner function as a computational resource.
