diff --git a/docs/sphinx/examples/cpp/basics/noise_modeling.cpp b/docs/sphinx/examples/cpp/basics/noise_modeling.cpp index 42ab1e6bea..435b425906 100644 --- a/docs/sphinx/examples/cpp/basics/noise_modeling.cpp +++ b/docs/sphinx/examples/cpp/basics/noise_modeling.cpp @@ -39,9 +39,9 @@ int main() { {-0.05773502691896258, 0.0}}); // Create the noise model - cudaq::noise_model noise; + auto noise = std::make_shared(); // Add the Kraus channel to the x operation on qubit 0. - noise.add_channel({0}, depol); + noise->add_channel({0}, depol); // Set the noise model cudaq::set_noise(noise); @@ -49,4 +49,8 @@ int main() { // Run the noisy simulation counts = cudaq::sample(xgate); counts.dump(); + + // Unset the noise model when done. This is not necessary in this case but is + // good practice in order to not interfere with future simulations. + cudaq::unset_noise(); } diff --git a/docs/sphinx/using/advanced/_noise.rst b/docs/sphinx/using/advanced/_noise.rst index 2ac9c7061c..ce4e68eb80 100644 --- a/docs/sphinx/using/advanced/_noise.rst +++ b/docs/sphinx/using/advanced/_noise.rst @@ -45,7 +45,7 @@ template type is the quantum operation the channel applies to (e.g. :code:`model apply to the simulated state via a :code:`noise_model::get_channel(...)` call. Noise models can be constructed via the :code:`cudaq::noise_model` and specified for -execution via a public :code:`cudaq::set_noise(cudaq::noise_model&)` function. This function +execution via a public :code:`cudaq::set_noise(std::shared_ptr)` function. This function should forward the :code:`noise_model` to the current :code:`quantum_platform` which can attach it to the current :code:`ExecutionContext` and retrieved by backend simulators.