docs: fix endianness, exp_pauli, observe, spin example (#3341)#4376
Open
mitchdz wants to merge 2 commits intoNVIDIA:mainfrom
Open
docs: fix endianness, exp_pauli, observe, spin example (#3341)#4376mitchdz wants to merge 2 commits intoNVIDIA:mainfrom
mitchdz wants to merge 2 commits intoNVIDIA:mainfrom
Conversation
Closes NVIDIA#3341. - Fill in the missing spin-operator construction example in `operators.{py,cpp}` (the `[Begin Spin]` block was empty). - Fix the `get_state` endianness description: text said "Big-endian" while the table showed LSB-on-left. Rewrite with an explicit qubit-to-bit mapping and a note covering `SampleResult`, `get_pauli_word()`, and the binary form of the statevector index. - `exp_pauli` docs called the result a sum of exponentials; it's a product. Also swap the demo words from `XYZ`/`IXX` (commute, hides the point) to `ZYX`/`ZXX`. - Default `shots_count` for `observe` is `-1`, not `1`. - Rewrite `SpinOperator.degrees` docstring for consistency; fix `max_degree` docstring (said "smallest"). Signed-off-by: mdzurick <mitch_dz@hotmail.com>
sacpis
approved these changes
May 1, 2026
| #include <cudaq.h> | ||
| #include <iostream> | ||
|
|
||
| void build_operator() { |
Collaborator
There was a problem hiding this comment.
Seems like we are missing to call build_operator?
Comment on lines
+221
to
+222
| The statevector returned by `get_state` indexes basis states by interpreting each | ||
| qubit's amplitude bit with qubit 0 as the least significant bit, qubit 1 as the |
Collaborator
There was a problem hiding this comment.
nit: Can we please show an example as where the LSB and MSB is?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3341.
operators.{py,cpp}(the[Begin Spin]block was empty).get_stateendianness description: text said "Big-endian" while the table showed LSB-on-left. Rewrite with an explicit qubit-to-bit mapping and a note coveringSampleResult,get_pauli_word(), and thebinary form of the statevector index.
exp_paulidocs called the result a sum of exponentials; it's a product. Also swap the demo words fromXYZ/IXX(commute, hides the point) toZYX/ZXX.shots_countforobserveis-1, not1.SpinOperator.degreesdocstring for consistency; fixmax_degreedocstring (said "smallest").