Core Components and Quantum Gates¶
Basic Components (SparQ/include/basic_components.h)¶
Basic component definitions.
Defines the core data structures and base classes of the sparse state simulator, including state storage, system management, and the operator base class
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Typedefs
Functions
-
const std::string &get_name(const StateInfoType &m)¶
Get the name from the state info (const version)
- Parameters:
m – State info tuple
- Returns:
Const reference to the register name
-
std::string &get_name(StateInfoType &m)¶
Get the name from the state info (non-const version)
- Parameters:
m – State info tuple
- Returns:
Reference to the register name
-
const StateStorageType &get_type(const StateInfoType &m)¶
Get the type from the state info (const version)
- Parameters:
m – State info tuple
- Returns:
Const reference to the state storage type
-
StateStorageType &get_type(StateInfoType &m)¶
Get the type from the state info (non-const version)
- Parameters:
m – State info tuple
- Returns:
Reference to the state storage type
-
size_t get_size(const StateInfoType &m)¶
Get the size from the state info.
- Parameters:
m – State info tuple
- Returns:
Register size
-
size_t &get_size(StateInfoType &m)¶
Get a reference to the size in the state info.
- Parameters:
m – State info tuple
- Returns:
Reference to the register size
-
bool get_status(const StateInfoType &m)¶
Get the active status from the state info.
- Parameters:
m – State info tuple
- Returns:
Register active status
-
bool &get_status(StateInfoType &m)¶
Get a reference to the active status in the state info.
- Parameters:
m – State info tuple
- Returns:
Reference to the register active status
-
struct BaseOperator¶
- #include <basic_components.h>
Operator base class.
Abstract base class of all quantum operators, defining the basic operator interface
Subclassed by qram_simulator::Add_AnyInt_AnyInt_InPlace, qram_simulator::Add_ConstUInt_InPlace, qram_simulator::Add_Mult_UInt_ConstUInt_InPlace, qram_simulator::Add_UInt_UInt_InPlace, qram_simulator::CKS::CondRot_General_Bool_QW, qram_simulator::CKS::QuantumWalk, qram_simulator::CKS::SparseMatrixOracle2, qram_simulator::CKS::SparseMatrixOracle2_ComputeCol, qram_simulator::CKS::SparseMatrixOracle2_ComputeSparsity, qram_simulator::CKS::T, qram_simulator::CondRot_General_Bool_Fast< Callable >, qram_simulator::CondRot_Rational_Bool, qram_simulator::GlobalPhase, qram_simulator::InverseQFT, qram_simulator::Mod_Mult_UInt_ConstUInt_InPlace, qram_simulator::ModuleInheritance_Test, qram_simulator::Phase_Bool, qram_simulator::Pop, qram_simulator::Push, qram_simulator::QFT, qram_simulator::QFT_Full, qram_simulator::RZ_Bool, qram_simulator::Rot_Bool, qram_simulator::Rot_GeneralStatePrep, qram_simulator::Rot_GeneralUnitary, qram_simulator::SelfAdjointOperator, qram_simulator::ShiftLeft_InPlace, qram_simulator::ShiftRight_InPlace, qram_simulator::block_encoding::block_encoding_tridiagonal::Block_Encoding_Tridiagonal, qram_simulator::block_encoding::block_encoding_tridiagonal::PlusOneAndOverflow, qram_simulator::block_encoding::block_encoding_via_QRAM::Block_Encoding_via_QRAM, qram_simulator::block_encoding::block_encoding_via_QRAM::U_L, qram_simulator::block_encoding::block_encoding_via_QRAM::U_R, qram_simulator::state_prep::State_Prep_via_QRAM
Public Functions
-
virtual void operator()(std::vector<System> &state) const = 0¶
Apply the operator (pure virtual function)
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const¶
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline void operator()(SparseState &state) const¶
Apply the operator to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
virtual void operator()(std::vector<System> &state) const = 0¶
-
class SelfAdjointOperator : public qram_simulator::BaseOperator¶
- #include <basic_components.h>
Self-adjoint operator class.
Inherits from BaseOperator; the dagger of a self-adjoint operator equals itself
Subclassed by qram_simulator::Abs_SInt, qram_simulator::Add_UInt_ConstUInt, qram_simulator::Add_UInt_UInt, qram_simulator::And_UInt_UInt, qram_simulator::Assign, qram_simulator::CKS::GetDataAddr, qram_simulator::CKS::GetQWRotateAngle_Int_Int_Int, qram_simulator::CKS::GetRowAddr, qram_simulator::CKS::QuantumBinarySearch, qram_simulator::CKS::QuantumBinarySearch_Fast, qram_simulator::CKS::SparseMatrixOracle1, qram_simulator::Carry_UInt_UInt, qram_simulator::CheckDuplicateKey, qram_simulator::CheckNan, qram_simulator::CheckNormalization, qram_simulator::CheckNormalization_Renormalize, qram_simulator::ClearZero, qram_simulator::Compare_UInt_UInt, qram_simulator::CustomArithmetic, qram_simulator::Div_Sqrt_Arccos_UInt_UInt, qram_simulator::Div_UInt_UInt, qram_simulator::FlipBools, qram_simulator::GetMid_UInt_UInt, qram_simulator::GetRotateAngle_Int_Int, qram_simulator::Hadamard_Bool, qram_simulator::Hadamard_Int, qram_simulator::Hadamard_Int_Full, qram_simulator::Hadamard_Partial, qram_simulator::Init_Unsafe, qram_simulator::IsZero_UInt, qram_simulator::Less_SInt_SInt, qram_simulator::Less_UInt_UInt, qram_simulator::ModuleInheritance_Test_SelfAdjoint, qram_simulator::MulOverflow_UInt_UInt, qram_simulator::Mul_UInt_UInt, qram_simulator::Mult_UInt_ConstUInt, qram_simulator::Neg_UInt, qram_simulator::Negative_SInt, qram_simulator::Normalize, qram_simulator::Or_UInt_UInt, qram_simulator::Overflow_SInt_SInt, qram_simulator::QRAMLoad, qram_simulator::QRAMLoadFast, qram_simulator::RangeConditionalPhaseFlip, qram_simulator::Reflection_Bool, qram_simulator::Select_Bool_UInt_UInt, qram_simulator::SortByAmplitude, qram_simulator::SortByKey, qram_simulator::SortByKey2, qram_simulator::SortExceptBit, qram_simulator::SortExceptKey, qram_simulator::SortExceptKeyHadamard, qram_simulator::SortUnconditional, qram_simulator::Sqrt_Div_Arccos_Int_UInt, qram_simulator::Sqrt_UInt, qram_simulator::StatePrint, qram_simulator::Sub_UInt_UInt, qram_simulator::Swap_Bool_Bool, qram_simulator::Swap_General_General, qram_simulator::TestRemovable, qram_simulator::ViewNormalization, qram_simulator::X_Bool, qram_simulator::Xor_UInt_UInt, qram_simulator::Y_Bool, qram_simulator::ZeroConditionalPhaseFlip, qram_simulator::shor::ExpMod
Public Functions
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const override¶
-
struct SparseState¶
- #include <basic_components.h>
Sparse state class.
A sparse quantum state represented as a vector of basis states
Public Functions
-
inline SparseState()¶
Default constructor.
-
inline SparseState(size_t size)¶
Constructor with a given size.
- Parameters:
size – Size
-
inline SparseState(const std::vector<System> &basis_states_)¶
Copy constructor.
- Parameters:
basis_states_ – Basis state vector
-
inline SparseState(std::vector<System> &&basis_states_)¶
Move constructor.
- Parameters:
basis_states_ – Basis state vector
-
inline SparseState(const SparseState &other)¶
Copy constructor.
- Parameters:
other – Another sparse state
-
inline SparseState(SparseState &&other)¶
Move constructor.
- Parameters:
other – Another sparse state
-
inline SparseState &operator=(const SparseState &other)¶
Copy assignment operator.
- Parameters:
other – Another sparse state
- Returns:
Reference to itself
-
inline SparseState &operator=(SparseState &&other)¶
Move assignment operator.
- Parameters:
other – Another sparse state
- Returns:
Reference to itself
-
inline System &back()¶
Get the last element (non-const version)
- Returns:
Reference to the last system
-
inline const System &back() const¶
Get the last element (const version)
- Returns:
Const reference to the last system
-
inline vector_type::iterator begin()¶
Get the starting iterator.
- Returns:
Starting iterator
-
inline vector_type::const_iterator begin() const¶
-
inline vector_type::iterator end()¶
-
inline vector_type::const_iterator end() const¶
-
inline vector_type::reverse_iterator rbegin()¶
-
inline vector_type::const_reverse_iterator rbegin() const¶
-
inline vector_type::reverse_iterator rend()¶
-
inline vector_type::const_reverse_iterator rend() const¶
-
inline System &operator[](size_t i)¶
Subscript operator.
- Parameters:
i – Index
- Returns:
Reference to the system
-
inline size_t size() const¶
Get the size.
- Returns:
Number of basis states
-
inline bool empty() const¶
Check whether empty.
- Returns:
Whether empty
-
inline SparseState()¶
-
struct StateStorage¶
- #include <basic_components.h>
State storage structure.
The actual storage unit of a quantum register state, using uint64_t to hold the underlying value
Public Functions
-
template<typename Ty>
inline Ty as(size_t size) const¶ Interpret the value as the specified type.
- Template Parameters:
Ty – Target type (signed/unsigned integers, floating point, and bool are supported)
- Parameters:
size – Number of bits
- Throws:
Throws – an exception when the type is not supported
- Returns:
The converted value
-
inline HOST_DEVICE StateStorage()¶
Constructor.
- HOST_DEVICE uint64_t & val (size_t size)
Safely access the value (non-const version)
- Parameters:
size – Number of bits
- Returns:
Reference to the value
- HOST_DEVICE uint64_t val (size_t size) const
Safely access the value (const version)
- Parameters:
size – Number of bits
- Returns:
The value
- HOST_DEVICE bool operator== (const StateStorage &rhs) const
Equality comparison operator.
- Parameters:
rhs – Right-hand operand
- Returns:
Whether equal
- HOST_DEVICE bool operator!= (const StateStorage &rhs) const
Inequality comparison operator.
- Parameters:
rhs – Right-hand operand
- Returns:
Whether not equal
- HOST_DEVICE bool operator< (const StateStorage &rhs) const
Less-than comparison operator.
- Parameters:
rhs – Right-hand operand
- Returns:
Whether less than
- HOST_DEVICE bool operator> (const StateStorage &rhs) const
Greater-than comparison operator.
- Parameters:
rhs – Right-hand operand
- Returns:
Whether greater than
-
std::string to_string(const StateInfoType &info) const¶
Convert to string.
- Parameters:
info – State info
- Returns:
String representation
-
std::string to_io_string(const StateInfoType &info) const¶
Convert to an IO string.
- Parameters:
info – State info
- Returns:
String in IO format
-
std::string to_binary_string(const StateInfoType &info) const¶
Convert to a binary string.
- Parameters:
info – State info
- Returns:
String in binary format
- HOST_DEVICE void flip (size_t digit)
Flip the specified bit.
- Parameters:
digit – Bit index
Public Members
-
uint64_t value = 0¶
The actually stored value.
-
template<typename Ty>
-
struct System¶
- #include <basic_components.h>
System class.
Core class managing quantum registers and system state, containing static register information and dynamic state data
Public Functions
-
inline StateStorage &get(size_t id)¶
Get the state component at the given position (non-const version)
- Parameters:
id – Register ID
- Returns:
Reference to the state storage
-
inline const StateStorage &get(size_t id) const¶
Get the state component at the given position (const version)
- Parameters:
id – Register ID
- Returns:
Const reference to the state storage
-
inline void ensure_register_count(size_t count) const¶
Ensure the CPU basis state has at least count register slots.
get() synchronizes to the full current register table at once, so that earlier references are not invalidated by later vector growth when the same operation acquires multiple register references in sequence.
- Parameters:
count – Number of register slots needed
-
StateStorage &last_register()¶
Access the last activated register (non-const version)
- Returns:
Reference to the state storage
-
const StateStorage &last_register() const¶
Access the last activated register (const version)
- Returns:
Const reference to the state storage
-
inline System()¶
Constructor.
- HOST_DEVICE bool operator< (const System &rhs) const
Less-than comparison operator.
- Parameters:
rhs – Right-hand system
- Returns:
Whether less than
- HOST_DEVICE bool operator== (const System &rhs) const
Equality comparison operator.
- Parameters:
rhs – Right-hand system
- Returns:
Whether equal
- HOST_DEVICE bool operator!= (const System &rhs) const
Inequality comparison operator.
- Parameters:
rhs – Right-hand system
- Returns:
Whether not equal
Public Members
-
complex_t amplitude = 1.0¶
State amplitude.
-
mutable std::vector<StateStorage> registers¶
The CUDA device path requires a fixed, trivially copyable register layout.
CPU register storage; preallocated, then grows on demand
Public Static Functions
-
static inline void register_name(std::string name, size_t idx)¶
Register a name into the hash index.
-
static inline void invalidate_name_index()¶
Invalidate the hash index (called after operations such as MoveRegister)
-
static inline void rebuild_name_index()¶
Rebuild the hash index (lazily triggered)
-
static void clear()¶
Clear register allocation information.
-
static size_t get_qubit_count()¶
Get the total number of qubits.
- Returns:
Number of qubits
-
static size_t get_activated_register_size()¶
Get the number of activated registers.
- Returns:
Number of activated registers
-
static size_t get_last_activated_register()¶
Get the ID of the last activated register.
- Returns:
Register ID
-
static void update_max_size(size_t new_size)¶
Update the maximum system size.
- Parameters:
new_size – New size
-
static size_t get(std::string_view name)¶
Get register ID by name.
- Parameters:
name – Register name
- Returns:
Register ID
-
static StateInfoType get_register_info(std::string_view name)¶
Get register info by name.
- Parameters:
name – Register name
- Returns:
State info
-
static const std::string &name_of(size_t id)¶
Get register name by ID.
- Parameters:
id – Register ID
- Returns:
Const reference to the register name
-
static size_t size_of(std::string_view name)¶
Get register size by name.
- Parameters:
name – Register name
- Returns:
Register size
-
static size_t size_of(size_t id)¶
Get register size by ID.
- Parameters:
id – Register ID
- Returns:
Register size
-
static StateStorageType type_of(std::string_view name)¶
Get register type by name.
- Parameters:
name – Register name
- Returns:
State storage type
-
static StateStorageType type_of(size_t id)¶
Get register type by ID.
- Parameters:
id – Register ID
- Returns:
State storage type
-
static bool status_of(std::string_view name)¶
Get register active status by name.
- Parameters:
name – Register name
- Returns:
Active status (true = active)
-
static bool status_of(size_t id)¶
Get register active status by ID.
- Parameters:
id – Register ID
- Returns:
Active status (true = active)
-
static void add_register_status_bitmap(size_t pos)¶
Add a register status bitmap flag.
- Parameters:
pos – Position
-
static void remove_register_status_bitmap(size_t pos)¶
Remove a register status bitmap flag.
- Parameters:
pos – Position
-
static size_t add_register(std::string_view name, StateStorageType type, size_t size)¶
Add a new register.
- Parameters:
name – Register name
type – State storage type
size – Register size
- Returns:
Register ID
-
static size_t add_register_synchronous(std::string_view name, StateStorageType type, size_t size, std::vector<System> &system_states)¶
Add a register synchronously (initial state is 0)
- Parameters:
name – Register name
type – State storage type
size – Register size
system_states – System state vector
- Returns:
Register ID
-
static size_t add_register_synchronous(std::string_view name, StateStorageType type, size_t size, SparseState &system_states)¶
Add a register synchronously (initial state is 0, SparseState version)
- Parameters:
name – Register name
type – State storage type
size – Register size
system_states – Sparse state
- Returns:
Register ID
-
static void remove_register(size_t id)¶
Remove a register by ID.
- Parameters:
id – Register ID
-
static void remove_register(std::string_view name)¶
Remove a register by name.
- Parameters:
name – Register name
-
static void remove_register_synchronous(size_t id, std::vector<System> &state)¶
Remove a register synchronously (by ID)
- Parameters:
id – Register ID
state – System state vector
-
static void remove_register_synchronous(std::string_view name, std::vector<System> &state)¶
Remove a register synchronously (by name)
- Parameters:
name – Register name
state – System state vector
-
static void remove_register_synchronous(size_t id, SparseState &state)¶
Remove a register synchronously (SparseState version, by ID)
- Parameters:
id – Register ID
state – Sparse state
-
static void remove_register_synchronous(std::string_view name, SparseState &state)¶
Remove a register synchronously (SparseState version, by name)
- Parameters:
name – Register name
state – Sparse state
Public Static Attributes
-
static constexpr size_t InitialRegisterCapacity = 64¶
Default initial preallocated capacity.
-
static constexpr size_t CachedRegisterSize = InitialRegisterCapacity¶
Kept for old-code compatibility; on CPU this value is no longer the register count limit.
-
static std::vector<StateInfoType> name_register_map¶
Register info map.
-
static std::unordered_map<std::string, size_t> name_to_index¶
Hash index from name to index (O(1) lookup)
-
static bool name_index_valid = true¶
Whether the hash index is valid (invalidated by operations such as MoveRegister)
-
static uint64_t reg_status_bitmap = 0¶
Register status bitmap (CUDA fast path; on CPU, StateInfoType is authoritative)
-
static size_t max_qubit_count = 0¶
Maximum qubit count statistic.
-
static size_t max_register_count = 0¶
Maximum register count statistic.
-
static size_t max_system_size = 0¶
Maximum system size statistic.
-
inline StateStorage &get(size_t id)¶
-
const std::string &get_name(const StateInfoType &m)¶
Basic Quantum Gates (SparQ/include/basic_gates.h)¶
Quantum gate operation definitions.
Contains implementations of basic quantum operations such as single-qubit gates, multi-qubit gates, and controlled gates, supporting standard gates such as Phase, Rotation, Pauli (X/Y/Z), S, T, RX/RY/RZ, SX, U2, and U3
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Typedefs
-
struct GateBase¶
- #include <basic_gates.h>
Quantum gate base class.
Base class of all quantum gates, managing the register ID and qubit index
Subclassed by qram_simulator::Phase_Bool, qram_simulator::RZ_Bool, qram_simulator::Rot_Bool, qram_simulator::X_Bool, qram_simulator::Y_Bool
Public Functions
-
inline GateBase(std::string_view reg_, size_t digit_)¶
Constructor (name + bit index)
- Parameters:
reg_ – Register name
digit_ – Qubit index
- Throws:
Throws – an exception when the bit index is out of range
-
inline GateBase(size_t id_, size_t digit_)¶
Constructor (ID + bit index)
- Parameters:
id_ – Register ID
digit_ – Qubit index
-
inline GateBase(std::string_view reg_)¶
Constructor (name only, default bit index 0)
- Parameters:
reg_ – Register name
-
inline GateBase(size_t id_)¶
Constructor (ID only, default bit index 0)
- Parameters:
id_ – Register ID
-
inline GateBase(std::string_view reg_, size_t digit_)¶
-
struct Phase_Bool : public qram_simulator::BaseOperator, public qram_simulator::GateBase¶
- #include <basic_gates.h>
Phase gate.
Applies the phase rotation e^{iλ} on the specified qubit
Subclassed by qram_simulator::S_Bool, qram_simulator::T_Bool, qram_simulator::Z_Bool
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Phase_Bool(std::string_view reg_, size_t digit_, double lambda_)¶
Constructor (name + bit index + phase angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, size_t digit_, double lambda_)¶
Constructor (ID + bit index + phase angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(std::string_view reg_, double lambda_)¶
Constructor (name + phase angle, default bit index 0)
- Parameters:
reg_ – Register name
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, double lambda_)¶
Constructor (ID + phase angle, default bit index 0)
- Parameters:
id_ – Register ID
lambda_ – Phase angle (radians)
-
virtual void operator()(std::vector<System> &state) const¶
Apply the phase gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct Rot_Bool : public qram_simulator::BaseOperator, public qram_simulator::GateBase¶
- #include <basic_gates.h>
Rotation gate base class.
Implements a generic 2x2 unitary matrix rotation operation
Subclassed by qram_simulator::RX_Bool, qram_simulator::RY_Bool, qram_simulator::SX_Bool, qram_simulator::U2_Bool, qram_simulator::U3_Bool
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Rot_Bool(std::string_view reg_, size_t digit_, u22_t mat)¶
Constructor (name + bit index + matrix)
- Parameters:
reg_ – Register name
digit_ – Qubit index
mat – 2x2 unitary matrix
-
inline Rot_Bool(size_t id_, size_t digit_, u22_t mat)¶
Constructor (ID + bit index + matrix)
- Parameters:
id_ – Register ID
digit_ – Qubit index
mat – 2x2 unitary matrix
-
inline Rot_Bool(std::string_view reg_, u22_t mat)¶
Constructor (name + matrix, single-bit register)
- Parameters:
reg_ – Register name
mat – 2x2 unitary matrix
- Throws:
Throws – an exception when the register size is not 1
-
inline Rot_Bool(size_t id_, u22_t mat)¶
Constructor (ID + matrix, single-bit register)
- Parameters:
id_ – Register ID
mat – 2x2 unitary matrix
- Throws:
Throws – an exception when the register size is not 1
-
void operate(size_t l, size_t r, std::vector<System> &state) const¶
Perform the rotation over the given range.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
-
void _operate_diagonal(size_t l, size_t r, std::vector<System> &state, const u22_t &mat) const¶
Diagonal matrix operation implementation.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
mat – 2x2 diagonal matrix
-
void _operate_off_diagonal(size_t l, size_t r, std::vector<System> &state, const u22_t &mat) const¶
Anti-diagonal matrix operation implementation.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
mat – 2x2 anti-diagonal matrix
-
void _operate_general(size_t l, size_t r, std::vector<System> &state, const u22_t &mat) const¶
General matrix operation implementation.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
mat – 2x2 general unitary matrix
-
void operate_pair(size_t zero, size_t one, std::vector<System> &state) const¶
Paired operation (branches where both |0> and |1> exist)
- Parameters:
zero – |0> branch index
one – |1> branch index
state – System state vector
-
void operate_alone_zero(size_t zero, std::vector<System> &state) const¶
Operate on the |0> branch alone.
- Parameters:
zero – |0> branch index
state – System state vector
-
void operate_alone_one(size_t one, std::vector<System> &state) const¶
Operate on the |1> branch alone.
- Parameters:
one – |1> branch index
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the rotation gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
Public Static Functions
-
static bool _is_diagonal(const u22_t &data)¶
Check whether the matrix is diagonal.
- Parameters:
data – 2x2 matrix
- Returns:
Whether the matrix is diagonal
-
static bool _is_off_diagonal(const u22_t &data)¶
Check whether the matrix is anti-diagonal.
- Parameters:
data – 2x2 matrix
- Returns:
Whether the matrix is anti-diagonal
-
inline void clear_control_nonzeros()¶
-
struct RX_Bool : public qram_simulator::Rot_Bool¶
- #include <basic_gates.h>
RX gate (rotation around the X axis)
Rotates by the given angle around the X axis on the Bloch sphere
Public Functions
-
RX_Bool(std::string_view reg_, size_t digit_, double angle_)¶
Constructor (name + bit index + angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
angle_ – Rotation angle
-
RX_Bool(size_t id_, size_t digit_, double angle_)¶
Constructor (ID + bit index + angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
angle_ – Rotation angle
-
inline RX_Bool(std::string_view reg_, double angle_)¶
Constructor (name + angle, default bit index 0)
- Parameters:
reg_ – Register name
angle_ – Rotation angle
-
inline RX_Bool(size_t id_, double angle_)¶
Constructor (ID + angle, default bit index 0)
- Parameters:
id_ – Register ID
angle_ – Rotation angle
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the RX gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
Public Members
-
u22_t mat¶
Rotation matrix.
-
RX_Bool(std::string_view reg_, size_t digit_, double angle_)¶
-
struct RY_Bool : public qram_simulator::Rot_Bool¶
- #include <basic_gates.h>
RY gate (rotation around the Y axis)
Rotates by the given angle around the Y axis on the Bloch sphere
Public Functions
-
RY_Bool(std::string_view reg, size_t digit_, double angle_)¶
Constructor (name + bit index + angle)
- Parameters:
reg – Register name
digit_ – Qubit index
angle_ – Rotation angle
-
RY_Bool(size_t id_, size_t digit_, double angle_)¶
Constructor (ID + bit index + angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
angle_ – Rotation angle
-
inline RY_Bool(std::string_view reg_, double angle_)¶
Constructor (name + angle, default bit index 0)
- Parameters:
reg_ – Register name
angle_ – Rotation angle
-
inline RY_Bool(size_t id_, double angle_)¶
Constructor (ID + angle, default bit index 0)
- Parameters:
id_ – Register ID
angle_ – Rotation angle
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the RY gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
Public Members
-
u22_t mat¶
Rotation matrix.
-
RY_Bool(std::string_view reg, size_t digit_, double angle_)¶
-
struct RZ_Bool : public qram_simulator::BaseOperator, public qram_simulator::GateBase¶
- #include <basic_gates.h>
RZ gate (rotation around the Z axis)
Rotates by the given angle around the Z axis on the Bloch sphere
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
RZ_Bool(std::string_view reg_, size_t digit_, double angle_)¶
Constructor (name + bit index + angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
angle_ – Rotation angle
-
RZ_Bool(size_t id_, size_t digit_, double angle_)¶
Constructor (ID + bit index + angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
angle_ – Rotation angle
-
inline RZ_Bool(std::string_view reg_, double angle_)¶
Constructor (name + angle, default bit index 0)
- Parameters:
reg_ – Register name
angle_ – Rotation angle
-
inline RZ_Bool(size_t id_, double angle_)¶
Constructor (ID + angle, default bit index 0)
- Parameters:
id_ – Register ID
angle_ – Rotation angle
-
virtual void operator()(std::vector<System> &state) const¶
Apply the RZ gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct S_Bool : public qram_simulator::Phase_Bool¶
- #include <basic_gates.h>
S gate.
Phase gate, applying a phase of π/2
Public Functions
-
inline S_Bool(size_t id_)¶
Constructor (ID, default bit index 0)
- Parameters:
id_ – Register ID
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline Phase_Bool(std::string_view reg_, size_t digit_, double lambda_)¶
Constructor (name + bit index + phase angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, size_t digit_, double lambda_)¶
Constructor (ID + bit index + phase angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(std::string_view reg_, double lambda_)¶
Constructor (name + phase angle, default bit index 0)
- Parameters:
reg_ – Register name
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, double lambda_)¶
Constructor (ID + phase angle, default bit index 0)
- Parameters:
id_ – Register ID
lambda_ – Phase angle (radians)
-
inline S_Bool(size_t id_)¶
-
struct SX_Bool : public qram_simulator::Rot_Bool¶
- #include <basic_gates.h>
SX gate (square root of the X gate)
The sqrt(X) gate, half the rotation of the X gate
Public Functions
-
SX_Bool(std::string_view reg_, size_t digit_)¶
Constructor (name + bit index)
- Parameters:
reg_ – Register name
digit_ – Qubit index
-
SX_Bool(size_t id_, size_t digit_)¶
Constructor (ID + bit index)
- Parameters:
id_ – Register ID
digit_ – Qubit index
-
inline SX_Bool(std::string_view reg_)¶
Constructor (name, default bit index 0)
- Parameters:
reg_ – Register name
-
inline SX_Bool(size_t id_)¶
Constructor (ID, default bit index 0)
- Parameters:
id_ – Register ID
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the SX gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
Public Members
-
u22_t mat¶
Rotation matrix.
-
SX_Bool(std::string_view reg_, size_t digit_)¶
-
struct T_Bool : public qram_simulator::Phase_Bool¶
- #include <basic_gates.h>
T gate.
Phase gate, applying a phase of π/4
Public Functions
-
inline T_Bool(size_t id_)¶
Constructor (ID, default bit index 0)
- Parameters:
id_ – Register ID
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline Phase_Bool(std::string_view reg_, size_t digit_, double lambda_)¶
Constructor (name + bit index + phase angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, size_t digit_, double lambda_)¶
Constructor (ID + bit index + phase angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(std::string_view reg_, double lambda_)¶
Constructor (name + phase angle, default bit index 0)
- Parameters:
reg_ – Register name
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, double lambda_)¶
Constructor (ID + phase angle, default bit index 0)
- Parameters:
id_ – Register ID
lambda_ – Phase angle (radians)
-
inline T_Bool(size_t id_)¶
-
struct U2_Bool : public qram_simulator::Rot_Bool¶
- #include <basic_gates.h>
U2 gate (general single-qubit gate, 2 parameters)
A general single-qubit gate using the two parameters phi and lambda
Public Functions
-
U2_Bool(std::string_view reg_, size_t digit_, double phi, double lambda)¶
Constructor (name + bit index + phi + lambda)
- Parameters:
reg_ – Register name
digit_ – Qubit index
phi – phi parameter
lambda – lambda parameter
-
U2_Bool(size_t id_, size_t digit_, double phi, double lambda)¶
Constructor (ID + bit index + phi + lambda)
- Parameters:
id_ – Register ID
digit_ – Qubit index
phi – phi parameter
lambda – lambda parameter
-
inline U2_Bool(std::string_view reg_, double phi, double lambda)¶
Constructor (name + phi + lambda, default bit index 0)
- Parameters:
reg_ – Register name
phi – phi parameter
lambda – lambda parameter
-
inline U2_Bool(size_t id_, double phi, double lambda)¶
Constructor (ID + phi + lambda, default bit index 0)
- Parameters:
id_ – Register ID
phi – phi parameter
lambda – lambda parameter
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the U2 gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
U2_Bool(std::string_view reg_, size_t digit_, double phi, double lambda)¶
-
struct U3_Bool : public qram_simulator::Rot_Bool¶
- #include <basic_gates.h>
U3 gate (general single-qubit gate, 3 parameters)
The most general single-qubit gate, using the three parameters theta, phi, and lambda
Public Functions
-
U3_Bool(std::string_view reg, size_t digit_, double theta, double phi, double lambda)¶
Constructor (name + bit index + theta + phi + lambda)
- Parameters:
reg – Register name
digit_ – Qubit index
theta – theta parameter
phi – phi parameter
lambda – lambda parameter
-
U3_Bool(size_t id_, size_t digit_, double theta, double phi, double lambda)¶
Constructor (ID + bit index + theta + phi + lambda)
- Parameters:
id_ – Register ID
digit_ – Qubit index
theta – theta parameter
phi – phi parameter
lambda – lambda parameter
-
inline U3_Bool(std::string_view reg_, double theta, double phi, double lambda)¶
Constructor (name + theta + phi + lambda, default bit index 0)
- Parameters:
reg_ – Register name
theta – theta parameter
phi – phi parameter
lambda – lambda parameter
-
inline U3_Bool(size_t id_, double theta, double phi, double lambda)¶
Constructor (ID + theta + phi + lambda, default bit index 0)
- Parameters:
id_ – Register ID
theta – theta parameter
phi – phi parameter
lambda – lambda parameter
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the U3 gate operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
U3_Bool(std::string_view reg, size_t digit_, double theta, double phi, double lambda)¶
-
struct X_Bool : public qram_simulator::SelfAdjointOperator, public qram_simulator::GateBase¶
- #include <basic_gates.h>
X gate (Pauli-X / NOT gate)
Flips the qubit state |0> <-> |1>
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline X_Bool(std::string_view reg_, size_t digit_)¶
Constructor (name + bit index)
- Parameters:
reg_ – Register name
digit_ – Qubit index
-
inline X_Bool(size_t id_, size_t digit_)¶
Constructor (ID + bit index)
- Parameters:
id_ – Register ID
digit_ – Qubit index
-
inline X_Bool(std::string_view reg_)¶
Constructor (name, default bit index 0)
- Parameters:
reg_ – Register name
-
inline X_Bool(size_t id_)¶
Constructor (ID, default bit index 0)
- Parameters:
id_ – Register ID
-
virtual void operator()(std::vector<System> &state) const¶
Apply the X gate operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct Y_Bool : public qram_simulator::SelfAdjointOperator, public qram_simulator::GateBase¶
- #include <basic_gates.h>
Y gate (Pauli-Y gate)
Rotates by an angle of π around the Y axis on the Bloch sphere
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
virtual void operator()(std::vector<System> &state) const¶
Apply the operator (pure virtual function)
- Parameters:
state – System state vector
-
DenseMatrix<complex_t> extract_matrix()¶
Extract the matrix representation of the Y gate.
- Returns:
Dense matrix of the Y gate
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline GateBase(std::string_view reg_, size_t digit_)¶
Constructor (name + bit index)
- Parameters:
reg_ – Register name
digit_ – Qubit index
- Throws:
Throws – an exception when the bit index is out of range
-
inline GateBase(size_t id_, size_t digit_)¶
Constructor (ID + bit index)
- Parameters:
id_ – Register ID
digit_ – Qubit index
-
inline GateBase(std::string_view reg_)¶
Constructor (name only, default bit index 0)
- Parameters:
reg_ – Register name
-
inline GateBase(size_t id_)¶
Constructor (ID only, default bit index 0)
- Parameters:
id_ – Register ID
-
inline void clear_control_nonzeros()¶
-
struct Z_Bool : public qram_simulator::Phase_Bool¶
- #include <basic_gates.h>
Z gate (Pauli-Z gate)
Phase-flip gate, applying a phase of π
Public Functions
-
inline Z_Bool(size_t id_)¶
Constructor (ID, default bit index 0)
- Parameters:
id_ – Register ID
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline Phase_Bool(std::string_view reg_, size_t digit_, double lambda_)¶
Constructor (name + bit index + phase angle)
- Parameters:
reg_ – Register name
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, size_t digit_, double lambda_)¶
Constructor (ID + bit index + phase angle)
- Parameters:
id_ – Register ID
digit_ – Qubit index
lambda_ – Phase angle (radians)
-
inline Phase_Bool(std::string_view reg_, double lambda_)¶
Constructor (name + phase angle, default bit index 0)
- Parameters:
reg_ – Register name
lambda_ – Phase angle (radians)
-
inline Phase_Bool(size_t id_, double lambda_)¶
Constructor (ID + phase angle, default bit index 0)
- Parameters:
id_ – Register ID
lambda_ – Phase angle (radians)
-
inline Z_Bool(size_t id_)¶
-
struct GateBase¶
Integer-Register Hadamard (SparQ/include/hadamard.h)¶
Hadamard gate operation definitions.
Implements several variants of the Hadamard gate, including integer-register Hadamard, full Hadamard, single-bit Hadamard, and partial-qubit Hadamard
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Typedefs
-
using Hadamard_PartialQubit = Hadamard_Partial¶
-
struct Hadamard_Bool : public qram_simulator::SelfAdjointOperator¶
- #include <hadamard.h>
Single-bit Hadamard gate.
A Hadamard gate applicable only to single-bit registers
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Hadamard_Bool(std::string_view reg_in)¶
Constructor (name version)
- Parameters:
reg_in – Register name
- Throws:
Throws – an exception when the register size is not 1
-
inline Hadamard_Bool(size_t reg_in)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
- Throws:
Throws – an exception when the register size is not 1
-
void operate_pair(size_t zero, size_t one, std::vector<System> &state) const¶
Paired operation (V2 version)
- Parameters:
zero – |0> branch index
one – |1> branch index
state – System state vector
-
void operate_alone_zero(size_t zero, std::vector<System> &state) const¶
Operate on the |0> branch alone.
- Parameters:
zero – |0> branch index
state – System state vector
-
void operate_alone_one(size_t one, std::vector<System> &state) const¶
Operate on the |1> branch alone.
- Parameters:
one – |1> branch index
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the Hadamard gate operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct Hadamard_Int : public qram_simulator::SelfAdjointOperator¶
- #include <hadamard.h>
Integer Hadamard gate.
Applies the Hadamard transform to an entire integer register, turning computational basis states into superpositions
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Hadamard_Int(std::string_view reg_in, size_t n_digits_)¶
Constructor (name version)
- Parameters:
reg_in – Register name
n_digits_ – Number of qubits
-
inline Hadamard_Int(size_t reg_in, size_t n_digits_)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
n_digits_ – Number of qubits
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the given position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
void operate(size_t l, size_t r, std::vector<System> &state) const¶
Perform the operation over the given range.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the Hadamard gate operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct Hadamard_Int_Full : public qram_simulator::SelfAdjointOperator¶
- #include <hadamard.h>
Full Hadamard gate.
Applies the full Hadamard transform to an entire register, containing all possible output states
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Hadamard_Int_Full(std::string_view reg_in)¶
Constructor (name version)
- Parameters:
reg_in – Register name
-
inline Hadamard_Int_Full(size_t reg_in)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the given position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
virtual void operator()(std::vector<System> &state) const¶
Apply the Hadamard gate operation.
- Parameters:
state – System state vector
-
void operate_bucket_sparse(const std::vector<size_t> &positions, std::vector<System> &state) const¶
Sparse bucket operation.
- Parameters:
positions – List of positions
state – System state vector
-
void operate_bucket_inplace(const std::vector<size_t> &positions, std::vector<System> &state) const¶
In-place bucket operation.
- Parameters:
positions – List of positions
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct Hadamard_Partial : public qram_simulator::SelfAdjointOperator¶
- #include <hadamard.h>
Partial-qubit Hadamard gate.
Applies the Hadamard transform only to a subset of the qubits in a register
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Hadamard_Partial(std::string_view reg_in, std::set<size_t> &qubit_positions_)¶
Constructor (name version)
- Parameters:
reg_in – Register name
qubit_positions_ – Set of qubit positions
-
inline Hadamard_Partial(size_t reg_in, std::set<size_t> &qubit_positions_)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
qubit_positions_ – Set of qubit positions
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the given position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
void operate_pair(size_t zero, size_t one, std::vector<System> &state) const¶
Paired operation.
- Parameters:
zero – |0> branch index
one – |1> branch index
state – System state vector
-
void operate_alone_zero(size_t zero, std::vector<System> &state) const¶
Operate on the |0> branch alone.
- Parameters:
zero – |0> branch index
state – System state vector
-
void operate_alone_one(size_t one, std::vector<System> &state) const¶
Operate on the |1> branch alone.
- Parameters:
one – |1> branch index
state – System state vector
-
void operate(size_t l, size_t r, std::vector<System> &state) const¶
Perform the operation over the given range.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the partial Hadamard gate operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const override¶
Apply the dagger operation (the dagger of a self-adjoint operator equals itself)
- Parameters:
state – System state vector
-
inline virtual void dag(SparseState &state) const override¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
using Hadamard_PartialQubit = Hadamard_Partial¶
Quantum Fourier Transform (SparQ/include/qft.h)¶
Quantum Fourier transform (QFT) definitions.
Implements the quantum Fourier transform and its inverse, supporting the standard and full versions
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Typedefs
-
using inverseQFT = InverseQFT¶
-
struct InverseQFT : public qram_simulator::BaseOperator¶
- #include <qft.h>
Inverse quantum Fourier transform (inverse QFT)
Performs the inverse quantum Fourier transform on an integer register
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
InverseQFT(std::string_view reg_ins)¶
Constructor (name version)
- Parameters:
reg_ins – Register name
-
InverseQFT(size_t reg_in)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the specified position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
void operate(size_t l, size_t r, std::vector<System> &state) const¶
Perform the operation on the specified range.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the inverse QFT operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const¶
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct QFT : public qram_simulator::BaseOperator¶
- #include <qft.h>
Quantum Fourier transform (QFT)
Performs the quantum Fourier transform on an integer register
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
QFT(size_t reg_in)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the specified position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
void operate(size_t l, size_t r, std::vector<System> &state) const¶
Perform the operation on the specified range.
- Parameters:
l – Left boundary
r – Right boundary
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the QFT operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger (inverse QFT) operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
struct QFT_Full : public qram_simulator::BaseOperator¶
- #include <qft.h>
Full quantum Fourier transform.
Full QFT implementation optimized with the FFT algorithm, including bit-reversal preprocessing
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline void precompute_bitrev()¶
Precompute the bit-reversal table.
-
inline QFT_Full(size_t reg_in)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
-
inline QFT_Full(std::string_view reg_in)¶
Constructor (name version)
- Parameters:
reg_in – Register name
-
inline size_t &val(size_t i, std::vector<System> &state) const¶
Get the value at the specified position (helper function)
- Parameters:
i – Index
state – System state vector
- Returns:
Reference to the value
-
void operate_bucket_sparse(const std::vector<size_t> &positions, std::vector<System> &state) const¶
Sparse bucket operation.
- Parameters:
positions – Position list
state – System state vector
-
void fft(const std::vector<size_t> &positions, std::vector<System> &state, bool inverse) const¶
FFT implementation.
- Parameters:
positions – Position list
state – System state vector
inverse – Whether this is the inverse transform
-
void operate_bucket_inplace(const std::vector<size_t> &positions, std::vector<System> &state) const¶
In-place bucket operation.
- Parameters:
positions – Position list
state – System state vector
-
void operate_bucket_inplace_inv(const std::vector<size_t> &positions, std::vector<System> &state) const¶
In-place inverse bucket operation.
- Parameters:
positions – Position list
state – System state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the full QFT operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger (inverse QFT) operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline void clear_control_nonzeros()¶
-
using inverseQFT = InverseQFT¶
General Rotations and State Preparation (SparQ/include/rot.h)¶
Rotation gate and state preparation operation definitions.
Implements general unitary rotation gates and quantum state preparation operations, supporting unitary matrix rotations of arbitrary dimension and Schmidt-decomposition state preparation
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Functions
-
struct Rot_GeneralStatePrep : public qram_simulator::BaseOperator¶
- #include <rot.h>
General state preparation operation.
Uses a unitary matrix to prepare |0…0> into the target quantum state
Public Types
-
using unitary_t = DenseMatrix<complex_t>¶
Unitary matrix type.
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
Rot_GeneralStatePrep(std::string_view reg_in, const std::vector<complex_t> &vec)¶
Constructor (name version)
- Parameters:
reg_in – Register name
vec – Target state vector
-
Rot_GeneralStatePrep(size_t reg_in, const std::vector<complex_t> &vec)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
vec – Target state vector
-
virtual void operator()(std::vector<System> &state) const¶
Apply the state preparation operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
Public Members
-
size_t id¶
Register ID.
-
size_t n_digits¶
Number of qubits.
-
size_t full_size¶
Full state size.
-
Rot_GeneralUnitary rot_general¶
General rotation gate.
-
using unitary_t = DenseMatrix<complex_t>¶
-
struct Rot_GeneralUnitary : public qram_simulator::BaseOperator¶
- #include <rot.h>
General unitary rotation gate.
Applies a unitary matrix of arbitrary dimension to an integer register
Public Types
-
using unitary_t = DenseMatrix<complex_t>¶
Unitary matrix type.
Public Functions
-
inline void clear_control_nonzeros()¶
-
inline auto &conditioned_by_nonzeros(size_t cond)¶
-
inline void clear_control_all_ones()¶
-
inline auto &conditioned_by_all_ones(size_t cond)¶
-
inline void clear_control_by_bit()¶
-
inline auto &conditioned_by_bit(size_t cond, size_t pos)¶
-
inline void clear_control_by_value()¶
-
inline auto &conditioned_by_value(size_t cond, size_t pos)¶
-
inline Rot_GeneralUnitary(std::string_view reg_in, const unitary_t &mat_)¶
Constructor (name version)
- Parameters:
reg_in – Register name
mat_ – Unitary matrix
- Throws:
Throws – an exception when the matrix size does not match the register size
-
inline Rot_GeneralUnitary(size_t reg_in, const unitary_t &mat_)¶
Constructor (ID version)
- Parameters:
reg_in – Register ID
mat_ – Unitary matrix
- Throws:
Throws – an exception when the matrix size does not match the register size
-
void operate_bucket_inplace(const std::vector<size_t> &positions, std::vector<System> &state, bool dagger) const¶
In-place bucket operation.
- Parameters:
positions – Position list
state – System state vector
dagger – Whether this is the dagger operation
-
void operate(std::vector<System> &state, bool dagger) const¶
Perform the rotation operation.
- Parameters:
state – System state vector
dagger – Whether this is the dagger operation
-
virtual void operator()(std::vector<System> &state) const¶
Apply the rotation operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
using unitary_t = DenseMatrix<complex_t>¶
-
struct Rot_GeneralStatePrep : public qram_simulator::BaseOperator¶
Conditional Rotations (SparQ/include/condrot.h)¶
Controlled rotation gate operation definitions.
Implements condition-based rotation operations, including rational-number conditional rotation and general-function conditional rotation
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
Typedefs
-
template<typename Callable = std::function<u22_t(uint64_t)>>
using CondRot_General_Bool = CondRot_General_Bool_Fast<Callable>¶
-
template<typename Callable = std::function<u22_t(uint64_t)>>
using CondRot_General_Bool_fast = CondRot_General_Bool_Fast<Callable>¶
Functions
- inline HOST_DEVICE u22_t make_func (uint64_t value, size_t n_digit)
Create a rotation function (based on a value and the number of digits)
- Parameters:
value – Input value
n_digit – Number of digits
- Returns:
2x2 rotation matrix
- inline HOST_DEVICE u22_t make_func_inv (uint64_t value, size_t n_digit)
Create an inverse rotation function (based on a value and the number of digits)
- Parameters:
value – Input value
n_digit – Number of digits
- Returns:
2x2 inverse rotation matrix
-
struct CondRot_Fixed_Bool : public qram_simulator::CondRot_Rational_Bool¶
Public Functions
-
void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline CondRot_Rational_Bool(std::string_view reg_in, std::string_view reg_out)¶
Constructor (name version)
- Parameters:
reg_in – Input register name
reg_out – Output register name
- Throws:
Throws – an exception when the types do not match
-
inline CondRot_Rational_Bool(size_t reg_in, size_t reg_out)¶
Constructor (ID version)
- Parameters:
reg_in – Input register ID
reg_out – Output register ID
-
void dag(std::vector<System> &state) const¶
-
template<typename Callable = std::function<u22_t(uint64_t)>>
struct CondRot_General_Bool_Fast : public qram_simulator::BaseOperator¶ - #include <condrot.h>
General controlled rotation gate (single qubit)
Performs a controlled rotation on the Boolean output register based on a general function
- Template Parameters:
Callable – Type of the angle computation function
Public Functions
-
inline CondRot_General_Bool_Fast(std::string_view reg_in, std::string_view reg_out, Callable angle_function)¶
Constructor (name version)
- Parameters:
reg_in – Input register name
reg_out – Output register name
angle_function – Angle computation function
- Throws:
Throws – an exception when the types do not match or the output register size is not 1
-
inline CondRot_General_Bool_Fast(size_t reg_in, size_t reg_out, Callable angle_function)¶
Constructor (ID version)
- Parameters:
reg_in – Input register ID
reg_out – Output register ID
angle_function – Angle computation function
-
inline void operate_pair(size_t zero, size_t one, std::vector<System> &state) const¶
Operate on a pair.
- Parameters:
zero – |0> branch index
one – |1> branch index
state – System state vector
-
inline void operate_alone_zero(size_t zero, std::vector<System> &state) const¶
Operate on the |0> branch alone.
- Parameters:
zero – |0> branch index
state – System state vector
-
inline void operate_alone_one(size_t one, std::vector<System> &state) const¶
Operate on the |1> branch alone.
- Parameters:
one – |1> branch index
state – System state vector
-
inline virtual void operator()(std::vector<System> &state) const¶
Apply the general controlled rotation operation (V2 implementation)
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const¶
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
struct CondRot_Rational_Bool : public qram_simulator::BaseOperator¶
- #include <condrot.h>
Rational-number controlled rotation gate (single qubit)
Performs a controlled rotation on the Boolean output register based on the value of the rational input register
Subclassed by qram_simulator::CondRot_Fixed_Bool
Public Functions
-
inline CondRot_Rational_Bool(std::string_view reg_in, std::string_view reg_out)¶
Constructor (name version)
- Parameters:
reg_in – Input register name
reg_out – Output register name
- Throws:
Throws – an exception when the types do not match
-
inline CondRot_Rational_Bool(size_t reg_in, size_t reg_out)¶
Constructor (ID version)
- Parameters:
reg_in – Input register ID
reg_out – Output register ID
-
virtual void operator()(std::vector<System> &state) const¶
Apply the controlled rotation operation.
- Parameters:
state – System state vector
-
virtual void dag(std::vector<System> &state) const¶
Apply the dagger operation.
- Parameters:
state – System state vector
-
inline virtual void dag(std::vector<System> &state) const
Apply the conjugate transpose (dagger) operation.
- Parameters:
state – System state vector
- Throws:
Throws – a not-implemented exception by default
-
inline virtual void dag(SparseState &state) const¶
Apply dagger to a SparseState.
- Parameters:
state – Sparse state
-
inline CondRot_Rational_Bool(std::string_view reg_in, std::string_view reg_out)¶
-
template<typename Callable = std::function<u22_t(uint64_t)>>
Interference Basic Components (SparQ/include/quantum_interfere_basic.h)¶
Quantum interference basic utility definitions.
Provides basic utility classes such as state hashing, equality comparison and less-than comparison, used for state management and lookup in quantum interference operations
-
namespace qram_simulator
QRAM sparse state simulator namespace.
Contains all classes, functions, and data structures related to quantum computing simulation
-
struct StateEqualExceptKey¶
- #include <quantum_interfere_basic.h>
State equality comparison excluding a specified key.
Excludes the specified register when comparing two states for equality
Public Functions
-
inline StateEqualExceptKey(size_t id_)¶
Constructor.
- Parameters:
id_ – ID of the excluded register
Public Members
-
size_t id¶
Excluded key (register ID)
-
inline StateEqualExceptKey(size_t id_)¶
-
struct StateEqualExceptQubits¶
- #include <quantum_interfere_basic.h>
State equality comparison excluding specified qubits.
Excludes the specified qubits of a register when comparing two states for equality
-
struct StateHashExceptKey¶
- #include <quantum_interfere_basic.h>
State hash excluding a specified key.
Excludes the specified register when computing the state hash value
Public Functions
-
inline StateHashExceptKey(size_t id_)¶
Constructor.
- Parameters:
id_ – ID of the excluded register
Public Members
-
size_t id¶
Excluded key (register ID)
-
inline StateHashExceptKey(size_t id_)¶
-
struct StateHashExceptQubits¶
- #include <quantum_interfere_basic.h>
State hash excluding specified qubits.
Excludes the specified qubits of a register when computing the state hash value
-
struct StateLessExceptKey¶
- #include <quantum_interfere_basic.h>
State less-than comparison excluding a specified key.
Excludes the specified register when comparing the order of two states
Public Functions
-
inline StateLessExceptKey(size_t id_)¶
Constructor.
- Parameters:
id_ – ID of the excluded register
Public Members
-
size_t id¶
Excluded key (register ID)
-
inline StateLessExceptKey(size_t id_)¶
-
struct StateLessExceptQubits¶
- #include <quantum_interfere_basic.h>
State less-than comparison excluding specified qubits.
Excludes the specified qubits of a register when comparing the order of two states
Public Functions
-
inline StateLessExceptQubits(size_t id_, std::set<size_t> qubit_ids_)¶
Constructor.
- Parameters:
id_ – Register ID
qubit_ids_ – Set of qubit IDs
-
inline size_t remove_digits(size_t val) const¶
Remove the specified bit.
- Parameters:
val – Original value
- Returns:
Value with the bit removed
-
inline StateLessExceptQubits(size_t id_, std::set<size_t> qubit_ids_)¶
-
struct StateEqualExceptKey¶