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.
Implementation in UnitaryMatrix Class
The updated UnitaryMatrix class constructor addresses this requirement by allowing the radixes parameter to be either a single integer or a sequence of integers. Here’s how the implementation handles this:
Single Integer Radix:
If radixes is provided as a single integer, the constructor automatically infers the number of qudits in the system based on the dimension of the input matrix.
The single integer radix is then broadcast to create a sequence where each element is the same radix. This sequence matches the inferred number of qudits.
Sequence of Radixes:
If radixes is provided as a sequence, the constructor directly uses this sequence, assuming it correctly specifies the radix for each qudit.
Default Behavior:
If radixes is not provided, the constructor attempts to infer it from the input matrix’s dimension. It checks if the dimension is a power of two or three and assigns corresponding radixes (e.g., [2, 2, ...] for a power of two).
Validation:
The constructor validates the provided or inferred radixes to ensure they are correct and match the dimension of the input matrix.