class QPanda::BasicGridDevice¶
Overview¶
A BasicGirdDevice is a device model that qubits put on nodes of a rectangular grid It is a virtual class because we haven’t dicided how qubits connecting with each other For the simpliest situation, see SimpleGridDevice. More…
#include <GridDevice.h> class BasicGridDevice { public: // structs struct PhysicalQubit; // construction BasicGridDevice(int m, int n); // methods void clear(); int getM(); int getN(); auto& getQubit(int i, int j); bool canApplyGate(int i1, int j1, int i2, int j2, int); bool canApplyGate(int i, int j, int); bool canSwap( int i1, int j1, int i2, int j2 ); void applySingleGate(int i, int j); void applyGate(int i1, int j1, int i2, int j2, int time); void applyDoubleGate( int i1, int j1, int i2, int j2 ); void applySwap( int i1, int j1, int i2, int j2 ); virtual bool isNearBy(int i1, int j1, int i2, int j2) = 0; virtual int getDistance(int i1, int j1, int i2, int j2) = 0; void map(int dest, int i, int j); void resetTime(); void nextCycle(); int maxTime(); int getTime(); bool isQubitFree(int i, int j); bool isAllQubitFree(); bool isSimpleGridDevice(); bool isSupportSwapGate(); }; // direct descendants class ExGridDevice; class SimpleGridDevice;
Detailed Documentation¶
A BasicGirdDevice is a device model that qubits put on nodes of a rectangular grid It is a virtual class because we haven’t dicided how qubits connecting with each other For the simpliest situation, see SimpleGridDevice.
Methods¶
void clear()
clear all properties except gird side length, re-initialize
auto& getQubit(int i, int j)
get the qubit on (i, j)
bool canApplyGate(int i1, int j1, int i2, int j2, int)
Determine whether a double-qubit gate can be applied.
bool canApplyGate(int i, int j, int)
Determine whether a single-qubit gate can be applied.
void applySingleGate(int i, int j)
apply gate and comsume time
void applyGate(int i1, int j1, int i2, int j2, int time)
apply a double-qubit gate
virtual bool isNearBy(int i1, int j1, int i2, int j2) = 0
Check if two qubits are adjacent, location of qubits are (i1, j1) and (i2, j2)
virtual int getDistance(int i1, int j1, int i2, int j2) = 0
get distance+1 of two qubits
void map(int dest, int i, int j)
map one qubit
Parameters:
int |
dest: index of the logical qubit |
int |
i: location of the physical qubit |
int |
j: location of the physical qubit |
void resetTime()
reset the time
void nextCycle()
go on next instruction cycle
int maxTime()
time when all qubits end up being busy
bool isQubitFree(int i, int j)
check if physical qubit on (i, j) free
bool isAllQubitFree()
check if all physical qubits free