qsim
Summary
Enumerations |
|
---|---|
GateAnyKind
|
enum |
GateKind
|
enum |
Typedefs |
|
---|---|
Bitstring
|
using
uint64_t
|
For
|
using |
GateQSim
|
using
Gate
< fp_type, GateKind >
|
Matrix
|
using
std::vector< fp_type >
Gate
matrix type.
|
ParallelFor
|
using
ParallelForT
< 1024 >
|
Simulator
|
using
SimulatorBasic
<
For
>
|
schmidt_decomp_type
|
using
std::vector< std::vector< std::vector< fp_type >>>
|
Functions |
|
---|---|
ApplyFusedGate
(const
Simulator
& simulator, const
Gate
& gate, typename Simulator::State & state)
|
void
Applies the given fused gate to the simulator state.
|
ApplyFusedGate
(const typename
Simulator::StateSpace
& state_space, const
Simulator
& simulator, const
Gate
& gate, Rgen & rgen, typename Simulator::State & state, std::vector< typename Simulator::StateSpace::MeasurementResult > & mresults)
|
bool
Applies the given fused gate to the simulator state.
|
ApplyFusedGate
(const typename
Simulator::StateSpace
& state_space, const
Simulator
& simulator, const
Gate
& gate, Rgen & rgen, typename Simulator::State & state)
|
bool
Applies the given fused gate to the simulator state, discarding measurement results.
|
ApplyFusedGateDagger
(const
Simulator
& simulator, const
Gate
& gate, typename Simulator::State & state)
|
void
Applies the given fused gate dagger to the simulator state.
|
ApplyGate
(const
Simulator
& simulator, const
Gate
& gate, typename Simulator::State & state)
|
void
Applies the given gate to the simulator state.
|
ApplyGate
(const typename
Simulator::StateSpace
& state_space, const
Simulator
& simulator, const
Gate
& gate, Rgen & rgen, typename Simulator::State & state, std::vector< typename Simulator::StateSpace::MeasurementResult > & mresults)
|
bool
Applies the given gate to the simulator state.
|
ApplyGate
(const typename
Simulator::StateSpace
& state_space, const
Simulator
& simulator, const
Gate
& gate, Rgen & rgen, typename Simulator::State & state)
|
bool
Applies the given gate to the simulator state, discarding measurement results.
|
ApplyGateDagger
(const
Simulator
& simulator, const
Gate
& gate, typename Simulator::State & state)
|
void
Applies the given gate dagger to the simulator state.
|
BitstringsFromFile
(unsigned num_qubits, const std::string & file, std::vector< Bitstring > & bitstrings)
|
bool
Reads bitstrings (representing initialized or measured states of qubits) from the given file and stores them in a vector.
|
BitstringsFromStream
(unsigned num_qubits, const std::string & provider, Stream & fs, std::vector< Bitstring > & bitstrings)
|
bool
Reads bitstrings (representing initialized or measured states of qubits) from a provided stream object and stores them in a vector.
|
CalculateFusedMatrix
(const FusedGate & gate)
|
Matrix< fp_type >
Multiplies component gate matrices of a fused gate.
|
CreateGate
(unsigned time, Qubits && qubits, M && matrix, std::vector< typename Gate::fp_type > && params)
|
|
GenerateRandomValues
(uint64_t num_samples, unsigned seed, DistrRealType max_value)
|
std::vector< DistrRealType >
|
GetSchmidtDecomp
(GateKind kind, const std::vector< fp_type > & params)
|
schmidt_decomp_type< fp_type >
|
GetSchmidtDecomp
(Cirq::GateKind kind, const std::vector< fp_type > & params)
|
schmidt_decomp_type< fp_type >
|
GetSchmidtDecomp
(GateKind kind, const std::vector< fp_type > & params)
|
schmidt_decomp_type< fp_type >
|
GetTime
()
|
double
|
MakeControlledGate
(Qubits && controlled_by,
Gate
& gate)
|
Gate
&
|
MakeControlledGate
(Qubits && controlled_by, const std::vector< unsigned > & control_values,
Gate
& gate)
|
Gate
&
|
MatrixClear
(Matrix< fp_type > & m)
|
void
Sets all matrix elements to zero.
|
MatrixDagger
(unsigned n, Matrix< fp_type > & m)
|
void
Daggers a matrix.
|
MatrixIdentity
(unsigned n, Matrix< fp_type > & m)
|
void
Sets an identity matrix.
|
MatrixMultiply
(unsigned q, const Matrix< fp_type1 > & m1, Matrix< fp_type2 > & m2)
|
void
Multiplies two gate matrices of equal size: m2 = m1 m2.
|
MatrixMultiply
(unsigned mask1, unsigned q1, const Matrix< fp_type1 > & m1, unsigned q2, Matrix< fp_type2 > & m2)
|
void
Multiplies two gate matrices: m2 = m1 m2.
|
MatrixScalarMultiply
(fp_type1 c, Matrix< fp_type2 > & m)
|
void
Multiply a matrix by a scalar value.
|
MatrixShuffle
(const std::vector< unsigned > & perm, unsigned q, Matrix< fp_type > & m)
|
void
Shuffles the gate matrix elements to get the matrix that acts on qubits that are in "normal" order (in increasing orger).
|
NormalToGateOrderPermutation
(const std::vector< unsigned > & qubits)
|
std::vector< unsigned >
Gets a permutation to rearrange qubits from "normal" order to "gate" order.
|
RandomValue
(RGen & rgen, DistrRealType max_value)
|
DistrRealType
|
SplitString
(const std::string & str, char delim, Container & words)
|
void
|
SplitString
(const std::string & str, char delim, Op op, Container & words)
|
void
|
Classes |
|
---|---|
qsim::
|
Stateless object with methods for aggregating
|
qsim::
|
Parser for the (deprecated) qsim file input format . |
qsim::
|
A base class for fuser classes with some common functions. |
qsim::
|
Quantum circuit simulator with AVX vectorization. |
qsim::
|
Quantum circuit simulator without vectorization. |
qsim::
|
Quantum circuit simulator with SSE vectorization. |
qsim::
|
Abstract class containing context and routines for general state-vector manipulations. |
qsim::
|
Object containing context and routines for AVX state-vector manipulations. |
qsim::
|
Object containing context and routines for unoptimized state-vector manipulations. |
qsim::
|
Object containing context and routines for SSE state-vector manipulations. |
Structs |
|
---|---|
qsim::
|
A collection of gates. |
qsim::
|
A generic gate to make it easier to use qsim with external gate sets. |
qsim::
|
The controlled-X (CX or CNOT) gate. |
qsim::
|
The controlled phase gate. |
qsim::
|
The controlled-Z (CZ) gate. |
qsim::
|
The fermionic simulation (FSim) gate family. |
qsim::
|
A collection of "fused" gates which can be multiplied together before being applied to the state vector. |
qsim::
|
A pi / 2 rotation around the X + Y axis. |
qsim::
|
The Hadamard gate. |
qsim::
|
The ISWAP gate. |
qsim::
|
The one-qubit identity gate. |
qsim::
|
The two-qubit identity gate. |
qsim::
|
A gate that rotates around the X axis of the Bloch sphere. |
qsim::
|
A gate that rotates around an arbitrary axis in the XY-plane. |
qsim::
|
A gate that rotates around the Y axis of the Bloch sphere. |
qsim::
|
A gate that rotates around the Z axis of the Bloch sphere. |
qsim::
|
The S gate, equivalent to "square root of Z". |
qsim::
|
The SWAP gate. |
qsim::
|
The T gate, equivalent to
|
qsim::
|
The Pauli X (or "NOT") gate. |
qsim::
|
The "square root of X" gate. |
qsim::
|
The Pauli Y gate. |
qsim::
|
The "square root of Y" gate. |
qsim::
|
The Pauli Z gate. |
qsim::
|
Hybrid Feynman-Schrodinger simulator. |
qsim::
|
Controller for output logs. |
qsim::
|
Controller for output logs with methods for writing to file. |
qsim::
|
Helper struct for executing for-loops in parallel across multiple threads. |
qsim::
|
Helper struct for running qsimh. |
qsim::
|
Helper struct for running qsim. |
qsim::
|
Helper struct for executing for loops in series. |
Namespaces |
|
---|---|
qsim::
|
|
qsim::
|
|
qsim::
|
|
qsim::
|
Enumerations
GateAnyKind
GateAnyKind
GateKind
GateKind
Typedefs
Bitstring
uint64_t Bitstring
Matrix
std::vector< fp_type > Matrix
Gate matrix type.
Matrices are stored as vectors. The matrix elements are accessed as real(m[i][j]) <- vector[2 * (n * i + j)] and imag(m[i][j]) <- vector[2 * (n * i + j) + 1], where n is the number of rows or columns (n = 2^q, where q is the number of gate qubits).
schmidt_decomp_type
std::vector< std::vector< std::vector< fp_type >>> schmidt_decomp_type
Functions
ApplyFusedGate
void ApplyFusedGate( const Simulator & simulator, const Gate & gate, typename Simulator::State & state )
Applies the given fused gate to the simulator state.
Ignores measurement gates.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
ApplyFusedGate
bool ApplyFusedGate( const typename Simulator::StateSpace & state_space, const Simulator & simulator, const Gate & gate, Rgen & rgen, typename Simulator::State & state, std::vector< typename Simulator::StateSpace::MeasurementResult > & mresults )
Applies the given fused gate to the simulator state.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Returns |
True if the measurement performed successfully; false otherwise.
|
ApplyFusedGate
bool ApplyFusedGate( const typename Simulator::StateSpace & state_space, const Simulator & simulator, const Gate & gate, Rgen & rgen, typename Simulator::State & state )
Applies the given fused gate to the simulator state, discarding measurement results.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
True if the measurement performed successfully; false otherwise.
|
ApplyFusedGateDagger
void ApplyFusedGateDagger( const Simulator & simulator, const Gate & gate, typename Simulator::State & state )
Applies the given fused gate dagger to the simulator state.
If the gate matrix is unitary then this is equivalent to applying the inverse gate. Ignores measurement gates.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
ApplyGate
void ApplyGate( const Simulator & simulator, const Gate & gate, typename Simulator::State & state )
Applies the given gate to the simulator state.
Ignores measurement gates.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
ApplyGate
bool ApplyGate( const typename Simulator::StateSpace & state_space, const Simulator & simulator, const Gate & gate, Rgen & rgen, typename Simulator::State & state, std::vector< typename Simulator::StateSpace::MeasurementResult > & mresults )
Applies the given gate to the simulator state.
Details | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||||
Returns |
True if the measurement performed successfully; false otherwise.
|
ApplyGate
bool ApplyGate( const typename Simulator::StateSpace & state_space, const Simulator & simulator, const Gate & gate, Rgen & rgen, typename Simulator::State & state )
Applies the given gate to the simulator state, discarding measurement results.
Details | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||||
Returns |
True if the measurement performed successfully; false otherwise.
|
ApplyGateDagger
void ApplyGateDagger( const Simulator & simulator, const Gate & gate, typename Simulator::State & state )
Applies the given gate dagger to the simulator state.
If the gate matrix is unitary then this is equivalent to applying the inverse gate. Ignores measurement gates.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
BitstringsFromFile
bool BitstringsFromFile( unsigned num_qubits, const std::string & file, std::vector< Bitstring > & bitstrings )
Reads bitstrings (representing initialized or measured states of qubits) from the given file and stores them in a vector.
Details | |||||||
---|---|---|---|---|---|---|---|
Parameters |
|
||||||
Returns |
True if reading succeeded; false otherwise.
|
BitstringsFromStream
bool BitstringsFromStream( unsigned num_qubits, const std::string & provider, Stream & fs, std::vector< Bitstring > & bitstrings )
Reads bitstrings (representing initialized or measured states of qubits) from a provided stream object and stores them in a vector.
Details | |||||||||
---|---|---|---|---|---|---|---|---|---|
Parameters |
|
||||||||
Returns |
True if reading succeeded; false otherwise.
|
CalculateFusedMatrix
Matrix< fp_type > CalculateFusedMatrix( const FusedGate & gate )
Multiplies component gate matrices of a fused gate.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
Matrix product of component matrices.
|
CreateGate
Gate CreateGate( unsigned time, Qubits && qubits, M && matrix, std::vector< typename Gate::fp_type > && params )
GenerateRandomValues
std::vector< DistrRealType > GenerateRandomValues( uint64_t num_samples, unsigned seed, DistrRealType max_value )
GetSchmidtDecomp
schmidt_decomp_type< fp_type > GetSchmidtDecomp( GateKind kind, const std::vector< fp_type > & params )
GetSchmidtDecomp
schmidt_decomp_type< fp_type > GetSchmidtDecomp( Cirq::GateKind kind, const std::vector< fp_type > & params )
GetSchmidtDecomp
schmidt_decomp_type< fp_type > GetSchmidtDecomp( GateKind kind, const std::vector< fp_type > & params )
GetTime
double GetTime()
MakeControlledGate
Gate & MakeControlledGate( Qubits && controlled_by, const std::vector< unsigned > & control_values, Gate & gate )
MatrixClear
void MatrixClear( Matrix< fp_type > & m )
Sets all matrix elements to zero.
Matrix to be cleared.
MatrixDagger
void MatrixDagger( unsigned n, Matrix< fp_type > & m )
Daggers a matrix.
Number of matrix rows (columns). Input matrix. Output matrix.
MatrixIdentity
void MatrixIdentity( unsigned n, Matrix< fp_type > & m )
Sets an identity matrix.
Number of matrix rows (columns). Output identity matrix.
MatrixMultiply
void MatrixMultiply( unsigned q, const Matrix< fp_type1 > & m1, Matrix< fp_type2 > & m2 )
Multiplies two gate matrices of equal size: m2 = m1 m2.
Number of gate qubits. The number of matrix rows (columns) is 2^q. Matrix m1. Input matrix m2. Output product of matrices m2 = m1 m2.
MatrixMultiply
void MatrixMultiply( unsigned mask1, unsigned q1, const Matrix< fp_type1 > & m1, unsigned q2, Matrix< fp_type2 > & m2 )
Multiplies two gate matrices: m2 = m1 m2.
The size of m1 should not exceed the size of m2. Qubit mask that specifies the subset of qubits m1 acts on. Number of gate qubits. The number of matrix rows (columns) is 2^q1. Matrix m1. Number of gate qubits. The number of matrix rows (columns) is 2^q2. Input matrix m2. Output product of matrices m2 = m1 m2.
MatrixScalarMultiply
void MatrixScalarMultiply( fp_type1 c, Matrix< fp_type2 > & m )
Multiply a matrix by a scalar value.
Scalar
value. Input matrix to be multiplied. Output matrix.
MatrixShuffle
void MatrixShuffle( const std::vector< unsigned > & perm, unsigned q, Matrix< fp_type > & m )
Shuffles the gate matrix elements to get the matrix that acts on qubits that are in "normal" order (in increasing orger).
Permutation to rearrange qubits from "normal" order to "gate" order. Number of gate qubits. The number of matrix rows (columns) is 2^q. Input matrix. Output shuffled matrix.
NormalToGateOrderPermutation
std::vector< unsigned > NormalToGateOrderPermutation( const std::vector< unsigned > & qubits )
Gets a permutation to rearrange qubits from "normal" order to "gate" order.
Qubits are ordered in increasing order for "normal" order. Qubits are ordered arbitrarily for "gate" order. Returns an empty vector if the qubits are in "normal" order. Qubit indices in "gate" order.
Details | |
---|---|
Returns |
Permutation as a vector.
|
RandomValue
DistrRealType RandomValue( RGen & rgen, DistrRealType max_value )
SplitString
void SplitString( const std::string & str, char delim, Container & words )
SplitString
void SplitString( const std::string & str, char delim, Op op, Container & words )