Global Namespace

Overview

// namespaces

namespace Base64;
namespace GATEGPU;
namespace QGATE_SPACE;
namespace QPanda;
    namespace QPanda::Variational;
namespace gpu;
namespace std;

// typedefs

typedef std::map<std::string, std::map<std::string, uint32_t>> config_map;
typedef float qstate_type;
typedef std::complex<qstate_type> qcomplex_t;
typedef std::vector<qcomplex_t> QStat;
typedef std::vector<size_t> Qnum;
typedef std::vector<double> prob_vec;
typedef std::unordered_map<std::string, double> prob_map;
typedef std::unordered_map<std::string, qcomplex_t> stat_map;
typedef std::map<std::string, double> prob_dict;
typedef std::vector<std::pair<size_t, double>> prob_tuple;
typedef wide_integer::generic_template::uint128_t uint128_t;
typedef wide_integer::generic_template::uint256_t uint256_t;
typedef wide_integer::generic_template::uint512_t uint512_t;
typedef size_t gpu_qsize_t;
typedef float gpu_qstate_t;
typedef std::complex<gpu_qstate_t> gpu_qcomplex_t;
typedef std::pair<size_t, double> gpu_pair;
typedef std::vector<gpu_pair> touple_prob;
typedef std::vector<double> vec_prob;
typedef std::vector<gpu_qsize_t> Qnum;

typedef bool (*noise_mode_function)(
    rapidjson::Value &,
    NoiseOp &
    );

typedef std::vector<QGateParam> vQParam;
typedef struct QubitVertice qubit_vertice_t;
typedef float qdata_t;
typedef size_t qsize_t;
typedef complex<qdata_t> qcomplex_data_t;
typedef vector<qcomplex_data_t> qstate_t;
typedef vector<pair<qsize_t, qsize_t>> qubit_vector_t;
typedef map<size_t, Edge> EdgeMap;
typedef struct Mask mask_t;
typedef map<qsize_t, Vertice> vertice_map_t;
typedef vector<vertice_map_t> vertice_matrix_t;

// enums

enum GateType;
enum MetadataGateType;
enum NOISE_MODEL;
enum NodeType;
enum OperatorType;
enum Operatortype;
enum QError;

// structs

struct Complex;
struct Mask;
struct QGateParam;
struct QubitVertice;

// classes

class AbstractDistributedFullAmplitudeEngine;
class AbstractQuantumGates;
class CPUImplQPU;
class CPUImplQPUSingleThread;
class CPUImplQPUSingleThreadWithOracle;
class CPUImplQPUWithOracle;
class ComplexTensor;
class DefaultRandomEngine;
class DeleteUnitQnode;
class DistributedFullAmplitudeEngine;
class DoubleGateNoiseModeMap;
class Edge;
class Instructions;
class NoisyCPUImplQPU;
class QPUImpl;
class QuantumProgMap;
class RandomEngine;
class ReadLock;
class SharedMutex;
class SingleGateNoiseModeMap;
class TensorEngine;
class Vertice;
class VerticeMatrix;
class WriteLock;
class XC_RandomEngine16807;
class originirBaseVisitor;
class originirLexer;
class originirListener;
class originirParser;
class originirVisitor;
class qasmBaseVisitor;
class qasmLexer;
class qasmListener;
class qasmParser;
class qasmVisitor;

// global variables

const qstate_type PI;
constexpr qstate_type SQRT2;
const gpu_qsize_t kThreadDim;

// global functions

uint32_t LOAD(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t STORE(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t BEQ(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t imm
    );

uint32_t BNE(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t imm
    );

uint32_t BLT(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t imm
    );

uint32_t BGT(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t imm
    );

uint32_t ADDI(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t ANDI(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t XORI(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t ORI(
    uint32_t rs1,
    uint32_t rd,
    uint32_t imm
    );

uint32_t ADD(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t rd
    );

uint32_t AND(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t rd
    );

uint32_t XOR(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t rd
    );

uint32_t OR(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t rd
    );

uint32_t QWAITI(uint32_t imm);

uint32_t FMR(
    uint32_t rs1,
    uint32_t rd
    );

uint32_t SMIS(
    uint32_t rd,
    uint32_t imm
    );

uint32_t QI(
    uint32_t rs1,
    uint32_t rs2,
    uint32_t PI,
    uint32_t opcode1,
    uint32_t opcode2
    );

uint32_t MEASURE(
    uint32_t rs1,
    uint32_t PI
    );

template <typename UnsignedIntegralType>
std::string integerToBinary(
    const UnsignedIntegralType& number,
    int ret_len
    );

template <typename UnsignedIntegralType>
std::string integerToString(const UnsignedIntegralType& number);

template <typename UnsignedIntegralType>
UnsignedIntegralType getDecIndex(
    const UnsignedIntegralType& num1,
    const UnsignedIntegralType& num2,
    std::vector<size_t> qvec,
    size_t len
    );

QStat matrix_multiply(
    const QStat& matrix_left,
    const QStat& matrix_right
    );

QStat matrix_tensor(
    const QStat& matrix_left,
    const QStat& matrix_right
    );

bool damping_kraus_operator (
    rapidjson::Value&,
    NoiseOp& noise
    );

bool dephasing_kraus_operator (
    rapidjson::Value&,
    NoiseOp& noise
    );

bool decoherence_kraus_operator (
    rapidjson::Value&,
    NoiseOp& noise
    );

bool double_damping_kraus_operator (
    rapidjson::Value&,
    NoiseOp& noise
    );

bool double_decoherence_kraus_operator (
    rapidjson::Value&,
    NoiseOp& noise
    );

bool pauli_kraus_map(
    rapidjson::Value&,
    NoiseOp& noise
    );

bool decoherence_kraus_operator_p1_p2 (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool bitflip_kraus_operator (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool depolarizing_kraus_operator (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool bit_phase_flip_operator (rapidjson::Value& value, NoiseOp& noise);
bool phase_damping_oprator(rapidjson::Value& value, NoiseOp& noise);

bool double_decoherence_kraus_operator_p1_p2 (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool double_bitflip_kraus_operator (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool double_depolarizing_kraus_operator (
    rapidjson::Value& value,
    NoiseOp& noise
    );

bool double_bit_phase_flip_operator (rapidjson::Value& value, NoiseOp& noise);
bool double_phase_damping_oprator(rapidjson::Value& value, NoiseOp& noise);
double _default_random_generator();

void H_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void T_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void S_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void X_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void Y_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void Z_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void X1_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void Y1_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void Z1_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    bool isDagger
    );

void RX_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    double angle,
    bool isDagger
    );

void RY_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    double angle,
    bool isDagger
    );

void RZ_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    double angle,
    bool isDagger
    );

void U1_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit,
    double angle,
    bool isDagger
    );

void CZ_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit1,
    qsize_t qubit2,
    bool isDagger
    );

void CNOT_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit1,
    qsize_t qubit2,
    bool isDagger
    );

void ISWAP_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit1,
    qsize_t qubit2,
    bool isDagger
    );

void SQISWAP_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit1,
    qsize_t qubit2,
    bool isDagger
    );

void CR_Gate(
    QuantumProgMap& prog_map,
    qsize_t qubit1,
    qsize_t qubit2,
    double angle,
    bool isDagger
    );

void split(
    QuantumProgMap* prog_map,
    qubit_vertice_t* qubit_vertice,
    qcomplex_data_t* result
    );

DLLEXPORT ChemiQ* initialize(char* dir);
DLLEXPORT void finalize(ChemiQ* chemiq);
DLLEXPORT void setMolecule(ChemiQ* chemiq, char* molecule);
DLLEXPORT void setMolecules(ChemiQ* chemiq, char* molecules);
DLLEXPORT void setMultiplicity(ChemiQ* chemiq, int multiplicity);
DLLEXPORT void setCharge(ChemiQ* chemiq, int charge);
DLLEXPORT void setBasis(ChemiQ* chemiq, char* basis);
DLLEXPORT void setTransformType(ChemiQ* chemiq, int type);
DLLEXPORT void setUccType(ChemiQ* chemiq, int type);
DLLEXPORT void setOptimizerType(ChemiQ* chemiq, int type);
DLLEXPORT void setOptimizerIterNum(ChemiQ* chemiq, int value);
DLLEXPORT void setOptimizerFuncCallNum(ChemiQ* chemiq, int value);
DLLEXPORT void setOptimizerXatol(ChemiQ* chemiq, double value);
DLLEXPORT void setOptimizerFatol(ChemiQ* chemiq, double value);
DLLEXPORT void setLearningRate(ChemiQ* chemiq, double value);
DLLEXPORT void setEvolutionTime(ChemiQ* chemiq, double value);
DLLEXPORT void setHamiltonianSimulationSlices(ChemiQ* chemiq, int value);
DLLEXPORT void setSaveDataDir(ChemiQ* chemiq, char* dir);
DLLEXPORT bool exec(ChemiQ* chemiq);

// macros

#define CONFIG_PATH
#define CONST_GATE(NAME)
#define CONTROL_CONST_GATE(NAME)
#define CONTROL_SINGLE_ANGLE_GATE(NAME)
#define DECL_ANGLE_GATE_MATRIX(NAME)
#define DECL_GATE_MATRIX(NAME)
#define DEF_EVALUATIONS
#define DEF_ITERATIONS
#define DEF_KEY
#define DEF_MESSAGE
#define DEF_OPTI_STATUS_CALCULATING
#define DEF_OPTI_STATUS_MAX_FEV
#define DEF_OPTI_STATUS_MAX_ITER
#define DEF_OPTI_STATUS_PARA_ERROR
#define DEF_OPTI_STATUS_SUCCESS
#define DEF_UNINIT_FLOAT
#define DEF_UNINIT_INT
#define DEF_VALUE
#define DEF_WARING
#define DoubleGateMatrixSize
#define IBMQ_BACKENDS_CONFIG
#define IBMQ_BACKENDS_CONFIG_FILE
#define MACRO_GET_GATETYPE(name)
#define NoiseOp
#define NoiseOp
#define PI
#define PI
#define PI
#define QCERR(x)

#define QCERR_AND_THROW_ERRSTR( \
    std_exception, \
    x \
    )

#define QIF_REGISTER(className)
#define QPANDA_BEGIN
#define QPANDA_END
#define QWHILE_REGISTER(className)
#define Q_CONTROL_GATE_TIME_SEQUENCE
#define Q_GATE_TIME_SEQUENCE_CONFIG
#define Q_MEASURE_TIME_SEQUENCE
#define Q_PI
#define Q_PI_2
#define Q_RESET_TIME_SEQUENCE
#define Q_SINGLE_GATE_TIME_SEQUENCE
#define Q_SWAP_TIME_SEQUENCE

#define REGISTER_ANGLE_GATE_MATRIX( \
    NAME, \
    Nx, \
    Ny, \
    Nz \
    )

#define REGISTER_CBIT_NAME_(classname)
#define REGISTER_CEXPR(classname)
#define REGISTER_CLASSICAL_PROGRAM(className)
#define REGISTER_CMEM_SIZE_(classname)

#define REGISTER_GATE_MATRIX( \
    NAME, \
    U00, \
    U01, \
    U10, \
    U11 \
    )

#define REGISTER_MEASURE(className)
#define REGISTER_PHYSICAL_QUBIT(classname)
#define REGISTER_QCIRCUIT(className)
#define REGISTER_QPROGRAM(className)
#define REGISTER_QRES_NAME(classname)
#define REGISTER_QUANTUM_MACHINE(classname)
#define REGISTER_QUBIT(classname)
#define REGISTER_QUBIT_POOL_SIZE_(classname)
#define REGISTER_RESET(className)
#define SINGLETON_DECLARE(Type)
#define SINGLETON_IMPLEMENT_EAGER(Type)
#define SINGLETON_IMPLEMENT_LAZY(Type)
#define SINGLE_ANGLE_GATE(NAME)
#define SQ2
#define SQ2
#define SQ2
#define SingleGateMatrixSize
#define USING_QPANDA
#define ZeroJudgement
#define _DOUBLE_ANGLE_GATE(NAME)
#define _DOUBLE_GATE(NAME)
#define _SINGLE_ANGLE_GATE(NAME)
#define _SINGLE_GATE(NAME)
#define _TRIPLE_GATE(NAME)

#define const_single_qubit_gate( \
    GATE_NAME, \
    qn, \
    isConjugate, \
    error_rate \
    )

#define control_const_single_qubit_gate( \
    GATE_NAME, \
    qn, \
    vControlBit, \
    isConjugate, \
    error_rate \
    )

#define control_single_qubit_angle_gate( \
    GATE_NAME, \
    qn, \
    theta, \
    vControlBit, \
    isConjugate, \
    error_rate \
    )

#define iunit

#define single_qubit_angle_gate( \
    GATE_NAME, \
    qn, \
    theta, \
    isConjugate, \
    error_rate \
    )

Detailed Documentation

Global Variables

const qstate_type PI

Square root of two

Global Functions

DLLEXPORT ChemiQ* initialize(char* dir)

Initialize the quantum chemistry calculation.

Parameters:

std::string The dir of the psi4 chemistry calculation package

Returns:

ChemiQ* a ChemiQ object ptr

DLLEXPORT void finalize(ChemiQ* chemiq)

Finalize the quantum chemistry calculation.

Parameters:

ChemiQ* the ChemiQ object ptr will be finalized
DLLEXPORT void setMolecule(ChemiQ* chemiq, char* molecule)

Set the molecular model to calculate.

Parameters:

ChemiQ* the target ChemiQ object ptr
std::string molecule model
DLLEXPORT void setMolecules(ChemiQ* chemiq, char* molecules)

Set the molecular model to calculate.

Parameters:

ChemiQ* the target ChemiQ object ptr
char* the molecules ptr
DLLEXPORT void setMultiplicity(ChemiQ* chemiq, int multiplicity)

Set the multiplicity of the molecular model.

Parameters:

ChemiQ* the target ChemiQ object ptr
int multiplicity
DLLEXPORT void setCharge(ChemiQ* chemiq, int charge)

Set the charge of the molecular model.

Parameters:

ChemiQ* the target ChemiQ object ptr
int charge
DLLEXPORT void setBasis(ChemiQ* chemiq, char* basis)

Set the calculation basis.

Parameters:

ChemiQ* the target ChemiQ object ptr
std::string basis
DLLEXPORT void setTransformType(ChemiQ* chemiq, int type)

Set the transform type from Fermion operator to Pauli operator.

Parameters:

ChemiQ* the target ChemiQ object ptr
int transform type

See also:

QPanda::TransFormType

DLLEXPORT void setUccType(ChemiQ* chemiq, int type)

Set the ucc type to contruct the Fermion operator.

Parameters:

ChemiQ* the target ChemiQ object ptr
int ucc type

See also:

QPanda::UccType

DLLEXPORT void setOptimizerType(ChemiQ* chemiq, int type)

Set the optimizer type.

Parameters:

ChemiQ* the target ChemiQ object ptr
int optimizer type

See also:

QPanda::OptimizerType

DLLEXPORT void setOptimizerIterNum(ChemiQ* chemiq, int value)

Set the optimizer iteration number.

Parameters:

ChemiQ* the target ChemiQ object ptr
size_t iteration number
DLLEXPORT void setOptimizerFuncCallNum(ChemiQ* chemiq, int value)

Set the optimizer function callback number.

Parameters:

ChemiQ* the target ChemiQ object ptr
size_t function callback number
DLLEXPORT void setOptimizerXatol(ChemiQ* chemiq, double value)

Set the optimizer iteration number.

Parameters:

ChemiQ* the target ChemiQ object ptr
size_t iteration number
DLLEXPORT void setOptimizerFatol(ChemiQ* chemiq, double value)

Set the optimizer fatol.It is the Absolute error in func(xopt) between iterations that is acceptable for convergence.

Parameters:

ChemiQ* the target ChemiQ object ptr
double absolute error between func(xopt)
DLLEXPORT void setLearningRate(ChemiQ* chemiq, double value)

Set the learing rate when using Gradient optimizer.

Parameters:

ChemiQ* the target ChemiQ object ptr
double learing rate
DLLEXPORT void setEvolutionTime(ChemiQ* chemiq, double value)

Set the evolution time when doing hamiltonian simulation.

Parameters:

ChemiQ* the target ChemiQ object ptr
double evolution time
DLLEXPORT void setHamiltonianSimulationSlices(ChemiQ* chemiq, int value)

Set the hamiltonian simulation slices (e^iAt/n*e^iBt/n)^n, n is the slices.

Parameters:

ChemiQ* the target ChemiQ object ptr
double hamiltonian simulation slices
DLLEXPORT void setSaveDataDir(ChemiQ* chemiq, char* dir)

Set the directory to save the calculated data. If it's a not exist dir data will not be saved.

Parameters:

ChemiQ* the target ChemiQ object ptr
std::string dir
DLLEXPORT bool exec(ChemiQ* chemiq)

exec molecule calculate.

Parameters:

ChemiQ* the target ChemiQ object ptr

Returns:

bool true:success; false:failed

Macros

#define QCERR(x)

QPanda2 cout error message.

#define QCERR_AND_THROW_ERRSTR(std_exception, x)

output the error string to standard error and throw a standard exception. A standard exception can be of the following types: runtime_error, invalid_argument, range_error, etc

#define Q_PI

pi

#define Q_PI_2

pi/2