Skip to content

Commit

Permalink
Update example and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bmhowe23 committed Sep 9, 2023
1 parent 1d9ad42 commit c1215ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions docs/sphinx/examples/cpp/basics/noise_modeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,18 @@ int main() {
{-0.05773502691896258, 0.0}});

// Create the noise model
cudaq::noise_model noise;
auto noise = std::make_shared<cudaq::noise_model>();
// Add the Kraus channel to the x operation on qubit 0.
noise.add_channel<cudaq::types::x>({0}, depol);
noise->add_channel<cudaq::types::x>({0}, depol);

// Set the noise model
cudaq::set_noise(noise);

// 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();
}
2 changes: 1 addition & 1 deletion docs/sphinx/using/advanced/_noise.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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<cudaq::noise_model>)` 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.

Expand Down

0 comments on commit c1215ee

Please sign in to comment.