├── pyQPanda ├── draw_test.py ├── __init__.py ├── pyqpanda │ ├── Operator │ │ └── __init__.py │ ├── Algorithm │ │ ├── test │ │ │ ├── hamiltonian_simulation_test.py │ │ │ └── __init__.py │ │ ├── demo │ │ │ └── __init__.py │ │ ├── QuantumGradient │ │ │ ├── __init__.py │ │ │ └── quantum_gradient_qaoa_test.py │ │ ├── __init__.py │ │ ├── QuantumCircuitLearning │ │ │ └── __init__.py │ │ └── VariationalQuantumEigensolver │ │ │ └── __init__.py │ ├── Hamiltonian │ │ ├── test │ │ │ └── __init__.py │ │ ├── __init__.py │ │ └── PauliOperator │ │ │ └── __init__.py │ ├── msvcr120.dll │ ├── TorchLayer │ │ ├── __init__.py │ │ └── Torch_.py │ ├── backends │ │ └── IBM │ │ │ └── IBMQconfig.py │ ├── Variational │ │ └── VariationalCircuit.py │ ├── OriginService │ │ └── __init__.py │ ├── Visualization │ │ └── __init__.py │ └── __init__.py ├── postbuildtool │ ├── stubgen │ │ ├── requirements.txt │ │ └── regfilter.py │ └── README(CN).md ├── my_networkx_plot.png ├── requirements.txt ├── example │ ├── test_draw_probability.py │ ├── IBMQconfig.py │ ├── test_print_circuit_info.py │ └── test_main.py ├── Tensor.py ├── pydtrace.d ├── README.md ├── test_circuit_layer.py └── Stabilizer.py ├── Core ├── Utilities │ ├── Benchmark │ │ └── BenchmarkingGate.cpp │ ├── QProgInfo │ │ ├── KAK.cpp │ │ └── QGateCounter.cpp │ ├── Tools │ │ └── QCircuitOptimize.cpp │ ├── Compiler │ │ ├── PyquilToOriginIR.cpp │ │ ├── operations │ │ │ ├── NonUnitaryOperation.cpp │ │ │ ├── Expression.cpp │ │ │ └── ClassicControlledOperation.cpp │ │ ├── UmatrixToOriginIR.cpp │ │ ├── PyquilCompiler │ │ │ ├── pyquilVisitor.cpp │ │ │ ├── pyquilListener.cpp │ │ │ ├── pyquilBaseListener.cpp │ │ │ └── pyquilBaseVisitor.cpp │ │ ├── QASMCompiler │ │ │ └── parser │ │ │ │ └── Statement.cpp │ │ └── QASMToOriginIR.cpp │ └── QProgTransform │ │ └── QProgToDAG │ │ └── QProgToDAG.cpp ├── Module │ └── Module.cpp ├── Debugger │ ├── Debug.cpp │ └── QPUDebugger.cpp ├── QuantumNoise │ ├── OriginNoise.cpp │ └── QNoise.cpp ├── QuantumMachine │ ├── OriginQMachineStatus.cpp │ ├── OriginQubit.cpp │ ├── OriginPhysicalQubit.cpp │ └── QuantumMachineInterface.cpp ├── VirtualQuantumProcessor │ └── QPUImpl.cpp ├── QuantumCloud │ └── QCloudLog.cpp └── Variational │ └── utils.cpp ├── ThirdParty ├── Eigen │ ├── Eigen │ ├── src │ │ ├── Core │ │ │ ├── util │ │ │ │ ├── NonMPL2.h │ │ │ │ └── ReenableStupidWarnings.h │ │ │ ├── functors │ │ │ │ └── TernaryFunctors.h │ │ │ └── DiagonalProduct.h │ │ └── misc │ │ │ └── lapacke_mangling.h │ ├── Dense │ ├── StdList │ ├── StdDeque │ ├── StdVector │ ├── Householder │ ├── Sparse │ ├── Jacobi │ ├── QtAlignedMalloc │ └── MetisSupport ├── antlr4 │ └── runtime │ │ └── src │ │ ├── misc │ │ ├── Predicate.cpp │ │ ├── Predicate.h │ │ └── InterpreterDataReader.h │ │ ├── tree │ │ ├── xpath │ │ │ ├── XPathLexer.tokens │ │ │ ├── XPathLexerErrorListener.cpp │ │ │ ├── XPathWildcardElement.h │ │ │ ├── XPathWildcardAnywhereElement.h │ │ │ ├── XPathWildcardElement.cpp │ │ │ ├── XPathLexerErrorListener.h │ │ │ ├── XPathRuleElement.h │ │ │ ├── XPathRuleAnywhereElement.cpp │ │ │ ├── XPathTokenAnywhereElement.cpp │ │ │ ├── XPathTokenElement.h │ │ │ ├── XPathTokenAnywhereElement.h │ │ │ ├── XPathWildcardAnywhereElement.cpp │ │ │ ├── XPathRuleAnywhereElement.h │ │ │ ├── XPathElement.cpp │ │ │ └── XPathRuleElement.cpp │ │ ├── ErrorNode.cpp │ │ ├── pattern │ │ │ ├── Chunk.cpp │ │ │ ├── TextChunk.cpp │ │ │ ├── TagChunk.cpp │ │ │ └── TokenTagToken.cpp │ │ ├── TerminalNode.cpp │ │ ├── ParseTreeVisitor.cpp │ │ ├── ParseTreeListener.cpp │ │ ├── ParseTree.cpp │ │ ├── ErrorNode.h │ │ ├── ErrorNodeImpl.cpp │ │ ├── TerminalNode.h │ │ ├── TerminalNodeImpl.h │ │ └── ParseTreeWalker.h │ │ ├── Token.cpp │ │ ├── TokenSource.cpp │ │ ├── WritableToken.cpp │ │ ├── atn │ │ ├── LexerAction.cpp │ │ ├── BlockStartState.cpp │ │ ├── BasicState.cpp │ │ ├── LoopEndState.cpp │ │ ├── RuleStopState.cpp │ │ ├── TokensStartState.cpp │ │ ├── PlusLoopbackState.cpp │ │ ├── BasicBlockStartState.cpp │ │ ├── PlusBlockStartState.cpp │ │ ├── StarBlockStartState.cpp │ │ ├── OrderedATNConfigSet.cpp │ │ ├── BlockEndState.cpp │ │ ├── RuleStartState.cpp │ │ ├── StarLoopEntryState.cpp │ │ ├── AbstractPredicateTransition.cpp │ │ ├── ATNType.h │ │ ├── DecisionState.cpp │ │ ├── BasicState.h │ │ ├── OrderedATNConfigSet.h │ │ ├── ContextSensitivityInfo.cpp │ │ ├── ErrorInfo.cpp │ │ ├── StarLoopbackState.h │ │ ├── BasicBlockStartState.h │ │ ├── StarBlockStartState.h │ │ ├── BlockStartState.h │ │ ├── LoopEndState.h │ │ ├── StarLoopbackState.cpp │ │ ├── DecisionEventInfo.cpp │ │ ├── TokensStartState.h │ │ ├── AbstractPredicateTransition.h │ │ ├── LookaheadEventInfo.cpp │ │ ├── RuleStartState.h │ │ ├── BlockEndState.h │ │ ├── AmbiguityInfo.cpp │ │ ├── PlusLoopbackState.h │ │ ├── DecisionState.h │ │ ├── PredicateEvalInfo.cpp │ │ ├── WildcardTransition.h │ │ ├── RuleStopState.h │ │ ├── NotSetTransition.h │ │ ├── WildcardTransition.cpp │ │ ├── PlusBlockStartState.h │ │ ├── RangeTransition.h │ │ ├── EmptyPredictionContext.h │ │ ├── SetTransition.h │ │ ├── AtomTransition.h │ │ ├── DecisionInfo.cpp │ │ ├── AtomTransition.cpp │ │ ├── EmptyPredictionContext.cpp │ │ ├── NotSetTransition.cpp │ │ ├── PrecedencePredicateTransition.h │ │ ├── SetTransition.cpp │ │ ├── StarLoopEntryState.h │ │ ├── ActionTransition.h │ │ └── RangeTransition.cpp │ │ ├── CharStream.cpp │ │ ├── TokenStream.cpp │ │ ├── ANTLRErrorListener.cpp │ │ ├── ANTLRErrorStrategy.cpp │ │ ├── support │ │ └── Any.cpp │ │ ├── IntStream.cpp │ │ ├── InputMismatchException.cpp │ │ ├── dfa │ │ ├── LexerDFASerializer.cpp │ │ ├── LexerDFASerializer.h │ │ └── DFASerializer.h │ │ ├── ConsoleErrorListener.cpp │ │ ├── InterpreterRuleContext.cpp │ │ ├── WritableToken.h │ │ ├── RuleContextWithAltNum.cpp │ │ ├── InputMismatchException.h │ │ ├── ANTLRFileStream.cpp │ │ ├── ANTLRFileStream.h │ │ ├── LexerNoViableAltException.h │ │ └── RuleContextWithAltNum.h ├── pybind11 │ ├── tools │ │ ├── pyproject.toml │ │ ├── pybind11.pc.in │ │ ├── JoinPaths.cmake │ │ └── cmake_uninstall.cmake.in │ └── include │ │ └── pybind11 │ │ ├── common.h │ │ ├── eigen.h │ │ └── eigen │ │ └── common.h ├── EigenUnsupported │ └── Eigen │ │ ├── src │ │ └── EulerAngles │ │ │ └── CMakeLists.txt │ │ ├── CXX11 │ │ ├── CMakeLists.txt │ │ └── src │ │ │ └── ThreadPool │ │ │ ├── ThreadYield.h │ │ │ └── ThreadLocal.h │ │ ├── MoreVectorization │ │ ├── Splines │ │ ├── ArpackSupport │ │ ├── Skyline │ │ └── KroneckerProduct ├── gtest │ └── CMakeLists.txt ├── bplus-tree │ ├── include │ │ └── private │ │ │ ├── utils.h │ │ │ ├── errors.h │ │ │ └── tree.h │ └── CMakeLists.txt ├── googletest │ └── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ └── libgtest.la.in ├── nlopt │ ├── include │ │ ├── praxis.h │ │ └── slsqp.h │ └── CMakeLists.txt ├── mpfit │ └── CMakeLists.txt └── bz2 │ └── CMakeLists.txt ├── Documentation └── img │ └── 1.png ├── test ├── QAlg │ ├── HHL.test.cpp │ ├── TestMain.cpp │ ├── CMakeLists.txt │ └── Shor.test.cpp ├── Core │ ├── CutQC.test.cpp │ ├── DrawLatex.test.cpp │ ├── QASMToQProg.test.cpp │ ├── QASMToOriginIR.test.cpp │ ├── GetQubitTopology.test.cpp │ ├── OriginIrToQprog.test.cpp │ ├── CMakeLists.txt │ ├── TestMain.cpp │ ├── Oracle.test.cpp │ └── QVec.test.cpp ├── Components │ ├── TestMain.cpp │ └── CMakeLists.txt ├── CMakeLists.txt └── Overall_scan │ ├── QMachine │ ├── CMemFactory.test.cpp │ ├── CBitFactory.test.cpp │ ├── QubitFactory.test.cpp │ ├── QuantumMachineFactory.test.cpp │ └── FullAmplitudeQVM.test.cpp │ ├── CMakeLists.txt │ ├── TestMain.cpp │ ├── QCricut │ └── ProbMeasure.test.cpp │ └── Utilities │ └── QProgInfo │ └── QdrawAndlayerProg.test.cpp ├── QAlg ├── QARM │ └── QARMAlgorithm.cpp ├── QSVM │ └── QSVMAlgorithm.cpp └── CMakeLists.txt ├── Template ├── Linux │ ├── build.sh │ ├── test.cpp │ └── README.md ├── Python │ └── test.py ├── VS │ ├── test.cpp │ └── CMakeSettings.json ├── MacOS │ └── test.cpp └── MinGW │ └── test.cpp ├── include ├── Components │ ├── Utils │ │ └── RJson │ │ │ └── RJson.h │ └── MaxCutProblemGenerator │ │ └── MaxCutProblemGenerator.h ├── Core │ ├── Variational │ │ ├── Optimizer.h │ │ └── DataType.h │ ├── Utilities │ │ ├── Compiler │ │ │ ├── OriginIRToQProg.h │ │ │ ├── PyquilToOriginIR.h │ │ │ ├── operations │ │ │ │ └── StandardOperation.hpp │ │ │ ├── QASMCompiler │ │ │ │ └── parser │ │ │ │ │ ├── passes │ │ │ │ │ └── CompilerPass.hpp │ │ │ │ │ └── NestedEnvironment.hpp │ │ │ ├── QASMToOriginIR.hpp │ │ │ └── QASMToQProg.hpp │ │ ├── UnitaryDecomposer │ │ │ └── UniformlyControlledGates.h │ │ ├── QProgInfo │ │ │ └── ConfigMap.h │ │ └── QProgTransform │ │ │ └── QProgToDAG │ │ │ └── TopologSequence.h │ ├── QuantumCloud │ │ └── Signature.h │ ├── Debugger │ │ ├── Debug.h │ │ ├── AbstractQDebugNode.h │ │ ├── OriginDebug.h │ │ ├── QDebug.h │ │ └── QPUDebugger.h │ ├── QuantumNoise │ │ ├── AbstractNoiseNode.h │ │ ├── QNoise.h │ │ └── OriginNoise.h │ ├── Module │ │ └── Operators.h │ ├── VirtualQuantumProcessor │ │ └── MPSQVM │ │ │ └── NoiseDefinition.h │ └── QuantumCircuit │ │ └── QNodeManager.h └── QAlg │ ├── IQAE │ └── IterativeQuantumAmplitudeEstimation.h │ └── Base_QCircuit │ └── SzegedyWalk.h ├── Applications ├── QSpringRank │ ├── QSpringRank.cpp │ └── CMakeLists.txt ├── NodeSort │ └── CMakeLists.txt ├── QuantumWalk │ └── CMakeLists.txt ├── B_V_Algorithm │ └── CMakeLists.txt ├── DJ_Algorithm │ └── CMakeLists.txt ├── HHL_Algorithm │ └── CMakeLists.txt ├── QPEAlgorithm │ └── CMakeLists.txt ├── OptimizerTest │ └── CMakeLists.txt ├── PennyGame_Algorithm │ └── CMakeLists.txt ├── QAOAExample │ └── CMakeLists.txt ├── Grover_Algorithm │ └── CMakeLists.txt ├── SimonAlgorithm │ └── CMakeLists.txt └── CMakeLists.txt ├── configVersion.h.in ├── .github ├── PULL_REQUEST_TEMPLATE.md └── ISSUE_TEMPLATE │ ├── feature_request.md │ ├── documentation.md │ └── bug_report.md ├── config.h.in ├── azure-pipelines.yml ├── QPANDAConfigVersion.cmake.in ├── pyQPandaCpp └── CMakeLists.txt ├── Components └── Optimizer │ └── AbstractOptimizer.cpp ├── Extensions └── Extensions.h ├── .travis.yml ├── .gitignore ├── QPANDAConfig.cmake.in ├── cmake_uninstall.cmake.in └── CMakeSettings.json /pyQPanda/draw_test.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyQPanda/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Operator/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /Core/Utilities/Benchmark/BenchmarkingGate.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/test/hamiltonian_simulation_test.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/Eigen: -------------------------------------------------------------------------------- 1 | #include "Dense" 2 | #include "Sparse" 3 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Hamiltonian/test/__init__.py: -------------------------------------------------------------------------------- 1 | from . import hamiltonian_test -------------------------------------------------------------------------------- /pyQPanda/postbuildtool/stubgen/requirements.txt: -------------------------------------------------------------------------------- 1 | mypy<=0.971 2 | parso>=0.8.2 3 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/demo/__init__.py: -------------------------------------------------------------------------------- 1 | from . import Deustch_Jozsa, Grover -------------------------------------------------------------------------------- /Documentation/img/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Documentation/img/1.png -------------------------------------------------------------------------------- /test/QAlg/HHL.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/QAlg/HHL.test.cpp -------------------------------------------------------------------------------- /test/Core/CutQC.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/CutQC.test.cpp -------------------------------------------------------------------------------- /QAlg/QARM/QARMAlgorithm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/QAlg/QARM/QARMAlgorithm.cpp -------------------------------------------------------------------------------- /QAlg/QSVM/QSVMAlgorithm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/QAlg/QSVM/QSVMAlgorithm.cpp -------------------------------------------------------------------------------- /test/Core/DrawLatex.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/DrawLatex.test.cpp -------------------------------------------------------------------------------- /pyQPanda/my_networkx_plot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/pyQPanda/my_networkx_plot.png -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/msvcr120.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/pyQPanda/pyqpanda/msvcr120.dll -------------------------------------------------------------------------------- /test/Core/QASMToQProg.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/QASMToQProg.test.cpp -------------------------------------------------------------------------------- /Core/Utilities/QProgInfo/KAK.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Core/Utilities/QProgInfo/KAK.cpp -------------------------------------------------------------------------------- /test/Core/QASMToOriginIR.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/QASMToOriginIR.test.cpp -------------------------------------------------------------------------------- /test/Core/GetQubitTopology.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/GetQubitTopology.test.cpp -------------------------------------------------------------------------------- /test/Core/OriginIrToQprog.test.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/test/Core/OriginIrToQprog.test.cpp -------------------------------------------------------------------------------- /Core/Module/Module.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Module/Module.h" 2 | USING_QPANDA 3 | QuantumMachine* ModuleContext::qm = nullptr; 4 | -------------------------------------------------------------------------------- /Template/Linux/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | mkdir -p build 3 | cd build 4 | cmake .. 5 | make -j4 6 | cd bin 7 | ./testQPanda 8 | -------------------------------------------------------------------------------- /include/Components/Utils/RJson/RJson.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/Components/Utils/RJson/RJson.h -------------------------------------------------------------------------------- /include/Core/Variational/Optimizer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/Core/Variational/Optimizer.h -------------------------------------------------------------------------------- /Applications/QSpringRank/QSpringRank.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Applications/QSpringRank/QSpringRank.cpp -------------------------------------------------------------------------------- /Core/Utilities/Tools/QCircuitOptimize.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Core/Utilities/Tools/QCircuitOptimize.cpp -------------------------------------------------------------------------------- /ThirdParty/Eigen/src/Core/util/NonMPL2.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_MPL2_ONLY 2 | #error Including non-MPL2 code in EIGEN_MPL2_ONLY mode 3 | #endif 4 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/misc/Predicate.cpp: -------------------------------------------------------------------------------- 1 | #include "misc/Predicate.h" 2 | 3 | antlr4::misc::Predicate::~Predicate() { 4 | } 5 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/PyquilToOriginIR.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Core/Utilities/Compiler/PyquilToOriginIR.cpp -------------------------------------------------------------------------------- /ThirdParty/pybind11/tools/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42", "wheel"] 3 | build-backend = "setuptools.build_meta" 4 | -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/OriginIRToQProg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/Core/Utilities/Compiler/OriginIRToQProg.h -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/PyquilToOriginIR.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/Core/Utilities/Compiler/PyquilToOriginIR.h -------------------------------------------------------------------------------- /Core/Utilities/QProgTransform/QProgToDAG/QProgToDAG.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Core/Utilities/QProgTransform/QProgToDAG/QProgToDAG.cpp -------------------------------------------------------------------------------- /include/QAlg/IQAE/IterativeQuantumAmplitudeEstimation.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/QAlg/IQAE/IterativeQuantumAmplitudeEstimation.h -------------------------------------------------------------------------------- /Core/Utilities/Compiler/operations/NonUnitaryOperation.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/Core/Utilities/Compiler/operations/NonUnitaryOperation.cpp -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/QuantumGradient/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Test Module\n 3 | Copyright (C) Origin Quantum 2017-2024\n 4 | Licensed Under Apache Licence 2.0 5 | ''' -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Algorithm\n 3 | Copyright (C) Origin Quantum 2017-2018\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | 7 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/UmatrixToOriginIR.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Utilities/Compiler/UmatrixToOriginIR.h" 2 | 3 | namespace QPanda { 4 | namespace UTIR { 5 | 6 | }; 7 | }; -------------------------------------------------------------------------------- /ThirdParty/Eigen/Dense: -------------------------------------------------------------------------------- 1 | #include "Core" 2 | #include "LU" 3 | #include "Cholesky" 4 | #include "QR" 5 | #include "SVD" 6 | #include "Geometry" 7 | #include "Eigenvalues" 8 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /pyQPanda/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.17 2 | matplotlib>=3.7 3 | pydot 4 | scipy 5 | mypy<=0.971 6 | requests 7 | snowland-smx 8 | Cython 9 | gmssl 10 | networkx 11 | 12 | -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/operations/StandardOperation.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OriginQ/QPanda-2/HEAD/include/Core/Utilities/Compiler/operations/StandardOperation.hpp -------------------------------------------------------------------------------- /configVersion.h.in: -------------------------------------------------------------------------------- 1 | #define QPANDA_MAJOR_VERSION @QPANDA_MAJOR_VERSION@ 2 | #define QPANDA_MINOR_VERSION @QPANDA_MINOR_VERSION@ 3 | #define QPANDA_PATCH_VERSION @QPANDA_PATCH_VERSION@ 4 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/QuantumCircuitLearning/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Algorithm\n 3 | Copyright (C) Origin Quantum 2017-2024\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | 7 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/PyquilCompiler/pyquilVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from .\pyquil.g4 by ANTLR 4.8 3 | 4 | 5 | #include "Core/Utilities/Compiler/PyquilCompiler/pyquilVisitor.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/VariationalQuantumEigensolver/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Algorithm\n 3 | Copyright (C) Origin Quantum 2017-2024\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | 7 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/PyquilCompiler/pyquilListener.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from .\pyquil.g4 by ANTLR 4.8 3 | 4 | 5 | #include "Core/Utilities/Compiler/PyquilCompiler/pyquilListener.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/PyquilCompiler/pyquilBaseListener.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from .\pyquil.g4 by ANTLR 4.8 3 | 4 | 5 | #include "Core/Utilities/Compiler/PyquilCompiler/pyquilBaseListener.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/PyquilCompiler/pyquilBaseVisitor.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Generated from .\pyquil.g4 by ANTLR 4.8 3 | 4 | 5 | #include "Core/Utilities/Compiler/PyquilCompiler/pyquilBaseVisitor.h" 6 | 7 | 8 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Hamiltonian/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Hamiltonian Simulation\n 3 | Copyright (C) Origin Quantum 2017-2018\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | #from .chemistry_client import * 7 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/TorchLayer/__init__.py: -------------------------------------------------------------------------------- 1 | from .basic_eng import Generator_Weight_Circuit 2 | from .cir_angle import Generator_Angle_Circuit 3 | from .Torch_ import TorchModel 4 | from .torchlayer import TorchLayer -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathLexer.tokens: -------------------------------------------------------------------------------- 1 | TOKEN_REF=1 2 | RULE_REF=2 3 | ANYWHERE=3 4 | ROOT=4 5 | WILDCARD=5 6 | BANG=6 7 | ID=7 8 | STRING=8 9 | '//'=3 10 | '/'=4 11 | '*'=5 12 | '!'=6 13 | -------------------------------------------------------------------------------- /include/Core/QuantumCloud/Signature.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include "QPandaConfig.h" 7 | 8 | std::string qcloud_signature(const std::string& apikey); 9 | -------------------------------------------------------------------------------- /include/Core/Debugger/Debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OriginDebug.h" 4 | #include "QDebug.h" 5 | 6 | QPANDA_BEGIN 7 | 8 | extern std::shared_ptr g_origin_debug; 9 | 10 | QDebug Debug(); 11 | 12 | QPANDA_END -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 8 | 9 | # 综述 10 | 11 | # 细节与解释 -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/src/EulerAngles/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FILE(GLOB Eigen_EulerAngles_SRCS "*.h") 2 | 3 | INSTALL(FILES 4 | ${Eigen_EulerAngles_SRCS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/src/EulerAngles COMPONENT Devel 6 | ) 7 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/tools/pybind11.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix_for_pc_file@ 2 | includedir=@includedir_for_pc_file@ 3 | 4 | Name: @PROJECT_NAME@ 5 | Description: Seamless operability between C++11 and Python 6 | Version: @PROJECT_VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /Applications/NodeSort/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(NodeSort) 3 | file(GLOB_RECURSE NODE_SORT_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${NODE_SORT_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QALG}) -------------------------------------------------------------------------------- /Applications/QuantumWalk/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QuantumWalk) 3 | file(GLOB_RECURSE QW_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${QW_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /Core/Debugger/Debug.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Debugger/Debug.h" 2 | 3 | QPANDA_BEGIN 4 | 5 | std::shared_ptr g_origin_debug = std::make_shared(); 6 | 7 | QDebug Debug() 8 | { 9 | return QDebug(g_origin_debug); 10 | } 11 | 12 | QPANDA_END -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/backends/IBM/IBMQconfig.py: -------------------------------------------------------------------------------- 1 | APItoken = '49000a0a22dd2d69bf5c5f27353ee8538c6c4ebd666b7baadab86f154c2316b3777585677b43f00a7a5d9452aab309c31459c736a923535ce451bdd93cb1e3b1' 2 | 3 | config = { 4 | 'url': 'https://auth.quantum-computing.ibm.com/api' 5 | } -------------------------------------------------------------------------------- /Applications/B_V_Algorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(B_V_Algorithm) 3 | file(GLOB_RECURSE BV_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${BV_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /Applications/DJ_Algorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(DJ_Algorithm) 3 | file(GLOB_RECURSE DJ_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${DJ_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /Applications/HHL_Algorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(HHL_Algorithm) 3 | file(GLOB_RECURSE HHL_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${HHL_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /Applications/QPEAlgorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QPE_Algorithm) 3 | file(GLOB_RECURSE QPE_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${QPE_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /test/Components/TestMain.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "QPanda.h" 3 | 4 | using namespace std; 5 | USING_QPANDA 6 | 7 | int main(int argc, char **argv) { 8 | ::testing::InitGoogleTest(&argc, argv); 9 | 10 | return RUN_ALL_TESTS(); 11 | } 12 | 13 | -------------------------------------------------------------------------------- /Applications/OptimizerTest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(OptimizerTest) 3 | file(GLOB_RECURSE OP_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${OP_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_COMPONENTS}) 6 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Hamiltonian/PauliOperator/__init__.py: -------------------------------------------------------------------------------- 1 | # from pyQPandaPauliOperator import * 2 | 3 | # H1 = PauliOperator({'X0':1}) 4 | # H2 = PauliOperator({'Y0':-1}) 5 | 6 | # a = 2 + H1 7 | # b = 3 + H2 8 | 9 | # c = a * b 10 | # d = 4 * c 11 | 12 | # print(d) 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: " Feature request" 3 | about: "针对QPanda提出您的idea" 4 | title: '' 5 | labels: enhancement 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | # 新功能的预期行为是什么? -------------------------------------------------------------------------------- /Applications/PennyGame_Algorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(PennyGame_Algorithm) 3 | file(GLOB_RECURSE PG_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${PG_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /Applications/QAOAExample/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QAOAExample) 3 | file(GLOB_RECURSE QAOA_EXAMPLE_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${QAOA_EXAMPLE_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QALG}) -------------------------------------------------------------------------------- /Applications/Grover_Algorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Grover_Algorithm) 3 | file(GLOB_RECURSE GROVER_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${GROVER_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ) 6 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | add_subdirectory(Core) 4 | if(USE_EXTENSION) 5 | # add_subdirectory(Core) 6 | add_subdirectory(QAlg) 7 | endif(USE_EXTENSION) 8 | 9 | add_subdirectory(Components) 10 | add_subdirectory(Overall_scan) 11 | 12 | -------------------------------------------------------------------------------- /Applications/QSpringRank/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QSpringRank) 3 | file(GLOB_RECURSE Q_Spring_Rank_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${Q_Spring_Rank_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ) 6 | -------------------------------------------------------------------------------- /Applications/SimonAlgorithm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Simon_Algorithm) 3 | file(GLOB_RECURSE Simon_Algorithm_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) 4 | add_executable(${PROJECT_NAME} ${Simon_Algorithm_CPP}) 5 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA}) 6 | -------------------------------------------------------------------------------- /ThirdParty/gtest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(gtest) 3 | 4 | set(LIB_GTEST gtest) 5 | file(GLOB_RECURSE GTEST_SRC_H ${CMAKE_CURRENT_SOURCE_DIR}/*.h) 6 | file(GLOB_RECURSE GTEST_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cc) 7 | add_library(${LIB_GTEST} STATIC ${GTEST_SRC_H} ${GTEST_SRC_CPP}) 8 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/Token.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | 8 | antlr4::Token::~Token() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/bplus-tree/include/private/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_UTILS_H_ 2 | #define _PRIVATE_UTILS_H_ 3 | 4 | #include /* uint64_t */ 5 | 6 | uint64_t bp__compute_hashl(uint64_t key); 7 | uint64_t myhtonll(uint64_t value); 8 | uint64_t myntohll(uint64_t value); 9 | 10 | #endif /* _PRIVATE_UTILS_H_ */ 11 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | #ifndef _QPANDA_CONFIG_H_ 2 | #define _QPANDA_CONFIG_H_ 3 | 4 | #cmakedefine DOCKER 5 | #cmakedefine USE_CUDA 6 | #cmakedefine USE_PYQPANDA 7 | #cmakedefine USE_OPENMP 8 | #cmakedefine USE_CURL 9 | #cmakedefine USE_QHETU 10 | #cmakedefine USE_MPI 11 | #cmakedefine USE_EXTENSION 12 | #cmakedefine USE_SIMD 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/TokenSource.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenSource.h" 7 | 8 | antlr4::TokenSource::~TokenSource() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/WritableToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "WritableToken.h" 7 | 8 | antlr4::WritableToken::~WritableToken() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ErrorNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ErrorNode.h" 7 | 8 | antlr4::tree::ErrorNode::~ErrorNode() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/LexerAction.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "LexerAction.h" 7 | 8 | antlr4::atn::LexerAction::~LexerAction() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/bplus-tree/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(BplusTree) 3 | 4 | set(LIB_BPLUSTREE BplusTree) 5 | file(GLOB_RECURSE BPULS_TREE_SRC_H ${CMAKE_CURRENT_SOURCE_DIR}/*.h) 6 | file(GLOB_RECURSE BPULS_TREE_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 7 | add_library(${LIB_BPLUSTREE} STATIC ${BPULS_TREE_SRC_H} ${BPULS_TREE_SRC_CPP}) 8 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Variational/VariationalCircuit.py: -------------------------------------------------------------------------------- 1 | from pyqpanda.Variational import pyQPandaVariational 2 | import numpy as np 3 | 4 | 5 | 6 | 7 | if __name__ == "__main__": 8 | a = var(np.ones((3,3), dtype = 'float64')) 9 | b = var(np.ones((3,3), dtype = 'float64')) 10 | c = stack(0, a, b) 11 | s = eval(c) 12 | print(s) 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/pattern/Chunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/Chunk.h" 7 | 8 | antlr4::tree::pattern::Chunk::~Chunk() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/googletest/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | trigger: 2 | - master 3 | 4 | jobs: 5 | - job: Windows 6 | timeoutInMinutes: 120 7 | pool: 8 | vmImage: 'windows-2022' 9 | 10 | steps: 11 | - script: | 12 | mkdir build & cd build 13 | cmake -A x64 .. 14 | cmake --build . --target ALL_BUILD --config Release -- 15 | displayName: 'build QPanda on Windows vm' 16 | -------------------------------------------------------------------------------- /Core/QuantumNoise/OriginNoise.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QuantumNoise/OriginNoise.h" 2 | 3 | USING_QPANDA 4 | 5 | OriginNoise::OriginNoise(QVec vec, QStat matrix) 6 | : m_vec(vec), 7 | m_op(matrix) 8 | { 9 | } 10 | 11 | QVec OriginNoise::get_qvec() 12 | { 13 | return m_vec; 14 | } 15 | 16 | QStat OriginNoise::get_ops() 17 | { 18 | return m_op; 19 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/CharStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "CharStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | CharStream::~CharStream() { 11 | } 12 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/TerminalNode.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/TerminalNode.h" 7 | 8 | antlr4::tree::TerminalNode::~TerminalNode() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/TokenStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "TokenStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | TokenStream::~TokenStream() { 11 | } 12 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "BlockStartState.h" 7 | 8 | antlr4::atn::BlockStartState::~BlockStartState() { 9 | } 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/ANTLRErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorListener.h" 7 | 8 | antlr4::ANTLRErrorListener::~ANTLRErrorListener() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/ANTLRErrorStrategy.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ANTLRErrorStrategy.h" 7 | 8 | antlr4::ANTLRErrorStrategy::~ANTLRErrorStrategy() 9 | { 10 | } 11 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/support/Any.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Any.h" 7 | 8 | using namespace antlrcpp; 9 | 10 | Any::~Any() 11 | { 12 | delete _ptr; 13 | } 14 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ParseTreeVisitor.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeVisitor.h" 7 | 8 | antlr4::tree::ParseTreeVisitor::~ParseTreeVisitor() { 9 | } 10 | -------------------------------------------------------------------------------- /include/Core/QuantumNoise/AbstractNoiseNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Utilities/QPandaNamespace.h" 4 | #include "Core/QuantumMachine/QVec.h" 5 | 6 | QPANDA_BEGIN 7 | 8 | class AbstractQNoiseNode 9 | { 10 | public: 11 | virtual ~AbstractQNoiseNode() {} 12 | virtual QVec get_qvec() = 0; 13 | virtual QStat get_ops() = 0; 14 | }; 15 | 16 | QPANDA_END -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/QASMCompiler/parser/passes/CompilerPass.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Utilities/Compiler/QASMCompiler/parser/Statement.hpp" 4 | 5 | namespace qasm { 6 | class CompilerPass { 7 | public: 8 | virtual ~CompilerPass() = default; 9 | 10 | virtual void processStatement(Statement& statement) = 0; 11 | }; 12 | } // namespace qasm 13 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/CXX11/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(Eigen_CXX11_HEADERS Tensor TensorSymmetry ThreadPool) 2 | 3 | install(FILES 4 | ${Eigen_CXX11_HEADERS} 5 | DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11 COMPONENT Devel 6 | ) 7 | 8 | install(DIRECTORY src DESTINATION ${INCLUDE_INSTALL_DIR}/unsupported/Eigen/CXX11 COMPONENT Devel FILES_MATCHING PATTERN "*.h") 9 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ParseTreeListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ParseTreeListener.h" 7 | 8 | antlr4::tree::ParseTreeListener::~ParseTreeListener() { 9 | } 10 | -------------------------------------------------------------------------------- /test/Overall_scan/QMachine/CMemFactory.test.cpp: -------------------------------------------------------------------------------- 1 | /// CMemFactory test 2 | 3 | #include "QPanda.h" 4 | #include "gtest/gtest.h" 5 | 6 | USING_QPANDA 7 | 8 | TEST(CMemFactoryInfaceTest, test) { 9 | 10 | CMemFactory memFac = CMemFactory::GetFactoryInstance(); 11 | CMem* mem = memFac.GetInstanceFromSize(8); 12 | EXPECT_EQ(8, mem->getMaxMem()); 13 | mem->clearAll(); 14 | 15 | } -------------------------------------------------------------------------------- /ThirdParty/googletest/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest 5 | Description: GoogleTest (without main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 9 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 10 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BasicState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BasicState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t BasicState::getStateType() { 11 | return BASIC; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/include/pybind11/eigen.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/eigen.h: Transparent conversion for dense and sparse Eigen matrices 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include "eigen/matrix.h" 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/documentation.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Documentation 3 | about: '提交关于文档的issue' 4 | title: '' 5 | labels: documentation 6 | assignees: '' 7 | 8 | --- 9 | 10 | # 需要修改的文档Bug 11 | 12 | - 哪些文件有Bug? 13 | 14 | - 哪一段信息需要修改? (您可以复制粘贴到这) 15 | 16 | - 怎么修改? 17 | 18 | - 关于这个Bug还有其他相关的问题或请求吗? 19 | 20 | # 现有文档是否有新内容需要更新? 21 | 22 | - 哪一个文件需要更新? 23 | 24 | - 哪一段内容需要更新或替换? (您可以复制粘贴到这) 25 | 26 | - 需要更新的内容是什么? -------------------------------------------------------------------------------- /include/Core/Module/Operators.h: -------------------------------------------------------------------------------- 1 | #include "Module.h" 2 | 3 | QPANDA_BEGIN 4 | 5 | /** 6 | * @brief H quantum gate operation for each quantum bit 7 | * @ingroup Module 8 | * @param[in] qvec qubit vector 9 | * @return QCircuit quantum circuit 10 | */ 11 | QCircuit h(qvec qs) { 12 | QCircuit c; 13 | for (size_t i = 0; i < qs.size(); ++i) { 14 | c << H(qs[i]); 15 | } 16 | return c; 17 | } 18 | 19 | QPANDA_END -------------------------------------------------------------------------------- /Template/Python/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | import sys 4 | sys.path.append("../../") 5 | from pyQPanda.pyqpanda import * 6 | 7 | init(QMachineType.CPU) 8 | prog = QProg() 9 | q = qAlloc_many(2) 10 | c = cAlloc_many(2) 11 | prog.insert(H(q[0])).insert(CNOT(q[0],q[1])).insert(measure_all(q, c)) 12 | results = run_with_configuration(prog, c, 1000) 13 | print(results) 14 | 15 | finalize() 16 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/LoopEndState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/LoopEndState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t LoopEndState::getStateType() { 11 | return LOOP_END; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RuleStopState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStopState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t RuleStopState::getStateType() { 11 | return RULE_STOP; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/TokensStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/TokensStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t TokensStartState::getStateType() { 11 | return TOKEN_START; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/IntStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "IntStream.h" 7 | 8 | using namespace antlr4; 9 | 10 | const std::string IntStream::UNKNOWN_SOURCE_NAME = ""; 11 | 12 | IntStream::~IntStream() = default; 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PlusLoopbackState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PlusLoopbackState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t PlusLoopbackState::getStateType() { 11 | return PLUS_LOOP_BACK; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/googletest/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 2 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 3 | 4 | Name: gtest_main 5 | Description: GoogleTest (with main() function) 6 | Version: @PROJECT_VERSION@ 7 | URL: https://github.com/google/googletest 8 | Requires: gtest = @PROJECT_VERSION@ 9 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ 11 | -------------------------------------------------------------------------------- /ThirdParty/nlopt/include/praxis.h: -------------------------------------------------------------------------------- 1 | #ifndef PRAXIS_H 2 | #define PRAXIS_H 3 | 4 | #include "nlopt-util.h" 5 | #include "nlopt.h" 6 | 7 | 8 | 9 | typedef double (*praxis_func)(int n, const double *x, void *f_data); 10 | 11 | nlopt_result praxis_(double t0, double machep, double h0, 12 | int n, double *x, praxis_func f, void *f_data, 13 | nlopt_stopping *stop, double *minf); 14 | 15 | 16 | 17 | #endif /* PRAXIS_H */ 18 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BasicBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BasicBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t BasicBlockStartState::getStateType() { 11 | return BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PlusBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/PlusBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t PlusBlockStartState::getStateType() { 11 | return PLUS_BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarBlockStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarBlockStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t StarBlockStartState::getStateType() { 11 | return STAR_BLOCK_START; 12 | } 13 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/OrderedATNConfigSet.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/OrderedATNConfigSet.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | size_t OrderedATNConfigSet::getHash(ATNConfig *c) { 11 | return c->hashCode(); 12 | } 13 | -------------------------------------------------------------------------------- /include/Core/Debugger/AbstractQDebugNode.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Utilities/QPandaNamespace.h" 4 | 5 | QPANDA_BEGIN 6 | 7 | class AbstractQDebugNode 8 | { 9 | public: 10 | AbstractQDebugNode() {} 11 | virtual ~AbstractQDebugNode() {} 12 | virtual void save_qstate_ref(std::vector> &stat) = 0; 13 | virtual void save_qstate_ref(std::vector> &stat) = 0; 14 | }; 15 | 16 | QPANDA_END -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/OriginService/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Python\n 3 | Copyright (C) Origin Quantum 2017-2020\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | 7 | try: 8 | from .QCloudMachine import * 9 | except ImportError: 10 | import warnings 11 | warnings.warn("QCloudMachine could not be imported. Some features might not be available.", ImportWarning) 12 | 13 | from .QCloudPlot import * 14 | from .PilotOSMachine import * 15 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/include/pybind11/eigen/common.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2023 The pybind Community. 2 | 3 | #pragma once 4 | 5 | // Common message for `static_assert()`s, which are useful to easily 6 | // preempt much less obvious errors. 7 | #define PYBIND11_EIGEN_MESSAGE_POINTER_TYPES_ARE_NOT_SUPPORTED \ 8 | "Pointer types (in particular `PyObject *`) are not supported as scalar types for Eigen " \ 9 | "types." 10 | -------------------------------------------------------------------------------- /test/Overall_scan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Overall_scan.test) 3 | file(GLOB_RECURSE OverallScanSrc ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 4 | add_executable(${PROJECT_NAME} ${OverallScanSrc}) 5 | if (CURL_FOUND) 6 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${CURL_LIBRARY} ) 7 | else (CURL_FOUND) 8 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ) 9 | endif (CURL_FOUND) 10 | 11 | -------------------------------------------------------------------------------- /Applications/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | add_subdirectory(PennyGame_Algorithm) 4 | add_subdirectory(QPEAlgorithm) 5 | add_subdirectory(QuantumWalk) 6 | add_subdirectory(SimonAlgorithm) 7 | add_subdirectory(OptimizerTest) 8 | 9 | if (USE_EXTENSION) 10 | add_subdirectory(HHL_Algorithm) 11 | add_subdirectory(B_V_Algorithm) 12 | add_subdirectory(DJ_Algorithm) 13 | add_subdirectory(Grover_Algorithm) 14 | endif(USE_EXTENSION) -------------------------------------------------------------------------------- /test/QAlg/TestMain.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | using namespace std; 3 | 4 | 5 | int main(int argc, char** argv) 6 | { 7 | #if 0 8 | //Run a single test of Alg Part 9 | ::testing::GTEST_FLAG(filter) = "Encode_.test1"; 10 | #else 11 | //Run All Core Part 12 | #endif 13 | 14 | ::testing::InitGoogleTest(&argc, argv); 15 | const auto ret = RUN_ALL_TESTS(); 16 | cout << "Alg Part GTest over, press Enter to continue." << endl; 17 | getchar(); 18 | return ret; 19 | } -------------------------------------------------------------------------------- /test/Core/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Core.test) 3 | file(GLOB_RECURSE CoreTestSrc ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 4 | add_executable(${PROJECT_NAME} ${CoreTestSrc}) 5 | if (CURL_FOUND) 6 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${CURL_LIBRARY} ${LIB_COMPONENTS} ${LIB_FMT}) 7 | else (CURL_FOUND) 8 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${LIB_COMPONENTS} ${LIB_FMT}) 9 | endif (CURL_FOUND) -------------------------------------------------------------------------------- /test/Overall_scan/QMachine/CBitFactory.test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "QPanda.h" 3 | #include "gtest/gtest.h" 4 | 5 | USING_QPANDA 6 | 7 | 8 | TEST(CBitFactoryInfaceTest, test) { 9 | CBitFactory cbitFac = CBitFactory::GetFactoryInstance(); 10 | auto cbit = cbitFac.CreateCBitFromName("c1"); 11 | EXPECT_STREQ("c1", cbit->getName().c_str()); 12 | 13 | cbit->setOccupancy(true); 14 | EXPECT_TRUE(cbit->getOccupancy()); 15 | 16 | EXPECT_EQ(1,cbit->get_addr()); 17 | 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Core/QuantumNoise/QNoise.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QuantumNoise/QNoise.h" 2 | 3 | USING_QPANDA 4 | 5 | QNoise::QNoise(std::shared_ptr node) 6 | : m_noise_node(node) 7 | { 8 | } 9 | 10 | std::shared_ptr QNoise::getImplementationPtr() 11 | { 12 | return m_noise_node; 13 | } 14 | 15 | QVec QNoise::get_qvec() 16 | { 17 | return m_noise_node->get_qvec(); 18 | } 19 | 20 | QStat QNoise::get_ops() 21 | { 22 | return m_noise_node->get_ops(); 23 | } 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BlockEndState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/BlockEndState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | BlockEndState::BlockEndState() : startState(nullptr) { 11 | } 12 | 13 | size_t BlockEndState::getStateType() { 14 | return BLOCK_END; 15 | } 16 | -------------------------------------------------------------------------------- /test/QAlg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QAlg.test) 3 | file(GLOB_RECURSE QAlgTestSrc ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 4 | add_executable(${PROJECT_NAME} ${QAlgTestSrc} "GroverFrame.test.cpp") 5 | if (CURL_FOUND) 6 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${CURL_LIBRARY} ${LIB_COMPONENTS}) 7 | else (CURL_FOUND) 8 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${LIB_COMPONENTS}) 9 | endif (CURL_FOUND) 10 | 11 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ParseTree.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | 8 | using namespace antlr4::tree; 9 | 10 | ParseTree::ParseTree() : parent(nullptr) { 11 | } 12 | 13 | bool ParseTree::operator == (const ParseTree &other) const { 14 | return &other == this; 15 | } 16 | -------------------------------------------------------------------------------- /test/Overall_scan/TestMain.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | using namespace std; 3 | 4 | int main(int argc, char** argv) 5 | { 6 | #if 1 7 | //Run a single test of Alg Part 8 | ::testing::GTEST_FLAG(filter) = "QPilotOSMachine.test"; 9 | #else 10 | //Run All Overrall_scan Part 11 | #endif 12 | 13 | ::testing::InitGoogleTest(&argc, argv); 14 | const auto ret = RUN_ALL_TESTS(); 15 | cout << "Overrall_scan Part GTest over, press Enter to continue." << endl; 16 | getchar(); 17 | return ret; 18 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RuleStartState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/RuleStartState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | RuleStartState::RuleStartState() { 11 | isLeftRecursiveRule = false; 12 | } 13 | 14 | size_t RuleStartState::getStateType() { 15 | return RULE_START; 16 | } 17 | -------------------------------------------------------------------------------- /test/Overall_scan/QMachine/QubitFactory.test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "QPanda.h" 3 | #include "gtest/gtest.h" 4 | 5 | USING_QPANDA 6 | 7 | TEST(QubitFactoryInfaceTest,test) { 8 | QubitFactory qbitfac = QubitFactory::GetFactoryInstance(); 9 | 10 | PhysicalQubit* py = PhysicalQubitFactory::GetFactoryInstance().GetInstance(); 11 | py->setQubitAddr(0); 12 | py->setOccupancy(true); 13 | auto qbit = qbitfac.GetInstance(py); 14 | EXPECT_TRUE(qbit->getOccupancy()); 15 | EXPECT_EQ(0,qbit->get_phy_addr()); 16 | 17 | } -------------------------------------------------------------------------------- /include/Core/QuantumNoise/QNoise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/QuantumNoise/AbstractNoiseNode.h" 4 | 5 | QPANDA_BEGIN 6 | 7 | class QNoise : public AbstractQNoiseNode 8 | { 9 | private: 10 | std::shared_ptr m_noise_node; 11 | 12 | public: 13 | QNoise(std::shared_ptr); 14 | virtual ~QNoise(){} 15 | virtual QVec get_qvec(); 16 | virtual QStat get_ops(); 17 | std::shared_ptr getImplementationPtr(); 18 | }; 19 | 20 | QPANDA_END 21 | -------------------------------------------------------------------------------- /Template/VS/test.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QPanda.h" 2 | #include 3 | using namespace QPanda; 4 | int main() 5 | { 6 | init(QMachineType::CPU); 7 | QProg prog; 8 | auto q = qAllocMany(2); 9 | auto c = cAllocMany(2); 10 | prog << H(q[0]) 11 | << CNOT(q[0],q[1]) 12 | << MeasureAll(q, c); 13 | auto results = runWithConfiguration(prog, c, 1000); 14 | for (auto result : results){ 15 | printf("%s : %d\n", result.first.c_str(), result.second); 16 | } 17 | finalize(); 18 | } -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/QASMToOriginIR.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _QASM_TO_ORIGINIR_H 2 | #define _QASM_TO_ORIGINIR_H 3 | 4 | #include "Core/Utilities/Compiler/QuantumComputation.hpp" 5 | #include "Core/Utilities/QPandaNamespace.h" 6 | 7 | 8 | QPANDA_BEGIN 9 | using namespace qc; 10 | std::string qasmfile2str(const std::string& filename); 11 | 12 | std::string convert_qasm_to_originir(std::string file_path); 13 | std::string convert_qasm_string_to_originir(std::string qasm_str); 14 | 15 | QPANDA_END 16 | #endif //!_QASMTOQPORG_H -------------------------------------------------------------------------------- /test/Components/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(Components.test) 3 | 4 | 5 | file(GLOB_RECURSE ComponentsTestSrc ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 6 | 7 | add_executable(${PROJECT_NAME} ${ComponentsTestSrc}) 8 | 9 | 10 | if (CURL_FOUND) 11 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${CURL_LIBRARY} ${LIB_COMPONENTS}) 12 | else (CURL_FOUND) 13 | target_link_libraries(${PROJECT_NAME} ${LIB_QPANDA} ${LIB_GTEST} ${LIB_COMPONENTS}) 14 | endif (CURL_FOUND) 15 | 16 | -------------------------------------------------------------------------------- /QPANDAConfigVersion.cmake.in: -------------------------------------------------------------------------------- 1 | set(PACKAGE_VERSION "@QPANDA_VERSION@") 2 | 3 | if (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) 4 | set(PACKAGE_VERSION_EXACT "true") 5 | endif (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION) 6 | if (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 7 | set(PACKAGE_VERSION_COMPATIBLE "true") 8 | else (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 9 | set(PACKAGE_VERSION_UNSUITABLE "true") 10 | endif (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION) 11 | -------------------------------------------------------------------------------- /Template/MacOS/test.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QPanda.h" 2 | #include 3 | using namespace QPanda; 4 | int main() 5 | { 6 | init(QMachineType::CPU); 7 | QProg prog; 8 | auto q = qAllocMany(2); 9 | auto c = cAllocMany(2); 10 | prog << H(q[0]) 11 | << CNOT(q[0],q[1]) 12 | << MeasureAll(q, c); 13 | auto results = runWithConfiguration(prog, c, 1000); 14 | for (auto result : results){ 15 | printf("%s : %d\n", result.first.c_str(), result.second); 16 | } 17 | finalize(); 18 | } -------------------------------------------------------------------------------- /Template/MinGW/test.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QPanda.h" 2 | #include 3 | using namespace QPanda; 4 | int main() 5 | { 6 | init(QMachineType::CPU); 7 | QProg prog; 8 | auto q = qAllocMany(2); 9 | auto c = cAllocMany(2); 10 | prog << H(q[0]) 11 | << CNOT(q[0],q[1]) 12 | << MeasureAll(q, c); 13 | auto results = runWithConfiguration(prog, c, 1000); 14 | for (auto result : results){ 15 | printf("%s : %d\n", result.first.c_str(), result.second); 16 | } 17 | finalize(); 18 | } -------------------------------------------------------------------------------- /pyQPanda/example/test_draw_probability.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import os.path 3 | dir = os.path.abspath(__file__) 4 | model_path = os.path.abspath(os.path.join(dir, "../..")) 5 | sys.path.insert(0, model_path) 6 | 7 | import pyqpanda.pyQPanda as pq 8 | from pyqpanda.Visualization.circuit_draw import * 9 | from pyqpanda.Visualization.draw_probability_map import * 10 | 11 | if __name__=="__main__": 12 | list2 = {'000': 506, '010': 300, '001': 400, '110': 300, '111': 508} 13 | # list2 = {'000': 506} 14 | draw_probaility(list2) 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: "Bug issue" 3 | about: "提交Bug" 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | # QPanda 13 | 14 | ## 基本信息 15 | 16 | - **QPanda 版本**: 17 | - **操作系统**: 18 | 19 | ## Bug是什么? 20 | 21 | 22 | ## 复现Bug的步骤? 23 | 24 | 25 | ## 建议的解决方案 26 | 27 | # pyQPanda 28 | 29 | ## 基本信息 30 | 31 | - **pyQPanda 版本**: 32 | - **Python 版本**: 33 | - **操作系统**: 34 | 35 | ## Bug是什么? 36 | 37 | 38 | ## 复现Bug的步骤? 39 | 40 | 41 | 42 | ## 建议的解决方案 43 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarLoopEntryState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarLoopEntryState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | StarLoopEntryState::StarLoopEntryState() : DecisionState(), isPrecedenceDecision(false) { 11 | } 12 | 13 | size_t StarLoopEntryState::getStateType() { 14 | return STAR_LOOP_ENTRY; 15 | } 16 | -------------------------------------------------------------------------------- /include/QAlg/Base_QCircuit/SzegedyWalk.h: -------------------------------------------------------------------------------- 1 | #ifndef __SZEGEDY_WALK_H__ 2 | #define __SZEGEDY_WALK_H__ 3 | 4 | #include "QPanda.h" 5 | #include "Core/Utilities/Tools/QMatrixDef.h" 6 | 7 | QPANDA_BEGIN 8 | 9 | class SzegedyWalk { 10 | public: 11 | SzegedyWalk() {} 12 | virtual ~SzegedyWalk() {} 13 | 14 | QMatrixXcd expm(QMatrixXcd H); 15 | QMatrixXcd expm(QMatrixXd H); 16 | 17 | QMatrixXcd expm_i(QMatrixXcd H); 18 | QMatrixXcd expm_i(QMatrixXd H); 19 | 20 | private: 21 | 22 | }; 23 | 24 | QPANDA_END 25 | #endif // !__SZEGEDY_WALK_H__ 26 | -------------------------------------------------------------------------------- /Template/Linux/test.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/QPanda.h" 2 | #include 3 | using namespace QPanda; 4 | using namespace std; 5 | int main() 6 | { 7 | init(QMachineType::CPU); 8 | QProg prog; 9 | auto q = qAllocMany(2); 10 | auto c = cAllocMany(2); 11 | prog << H(q[0]) 12 | << CNOT(q[0],q[1]) 13 | << MeasureAll(q, c); 14 | auto results = runWithConfiguration(prog, c, 1000); 15 | for (auto result : results){ 16 | printf("%s : %d\n", result.first.c_str(), result.second); 17 | } 18 | finalize(); 19 | } 20 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/AbstractPredicateTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/AbstractPredicateTransition.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | AbstractPredicateTransition::AbstractPredicateTransition(ATNState *target) : Transition(target) { 11 | } 12 | 13 | AbstractPredicateTransition::~AbstractPredicateTransition() { 14 | } 15 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ErrorNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC ErrorNode : public virtual TerminalNode { 14 | public: 15 | ~ErrorNode() override; 16 | }; 17 | 18 | } // namespace tree 19 | } // namespace antlr4 20 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/ATNType.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Represents the type of recognizer an ATN applies to. 14 | enum class ATNType { 15 | LEXER = 0, 16 | PARSER = 1, 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/DecisionState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionState.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | void DecisionState::InitializeInstanceFields() { 11 | decision = -1; 12 | nonGreedy = false; 13 | } 14 | 15 | std::string DecisionState::toString() const { 16 | return "DECISION " + ATNState::toString(); 17 | } 18 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BasicState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC BasicState final : public ATNState { 14 | 15 | public: 16 | virtual size_t getStateType() override; 17 | 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/misc/Predicate.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace misc { 12 | 13 | class ANTLR4CPP_PUBLIC Predicate { 14 | public: 15 | virtual ~Predicate(); 16 | 17 | virtual bool test(tree::ParseTree *t) = 0; 18 | }; 19 | 20 | } // namespace tree 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/src/misc/lapacke_mangling.h: -------------------------------------------------------------------------------- 1 | #ifndef LAPACK_HEADER_INCLUDED 2 | #define LAPACK_HEADER_INCLUDED 3 | 4 | #ifndef LAPACK_GLOBAL 5 | #if defined(LAPACK_GLOBAL_PATTERN_LC) || defined(ADD_) 6 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 7 | #elif defined(LAPACK_GLOBAL_PATTERN_UC) || defined(UPPER) 8 | #define LAPACK_GLOBAL(lcname,UCNAME) UCNAME 9 | #elif defined(LAPACK_GLOBAL_PATTERN_MC) || defined(NOCHANGE) 10 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname 11 | #else 12 | #define LAPACK_GLOBAL(lcname,UCNAME) lcname##_ 13 | #endif 14 | #endif 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /pyQPandaCpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | 3 | set(PYQPANDA_POST_BUILD_TOOL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../pyQPanda/postbuildtool") 4 | set(PYQPANDA_STUBGEN ${PYQPANDA_POST_BUILD_TOOL_DIR}/stubgen/stubgen.py) 5 | # try pip install package required by stubgen on cmake config runtime 6 | if(PYQPANDA_STUBGEN) 7 | execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install -r ${PYQPANDA_POST_BUILD_TOOL_DIR}/stubgen/requirements.txt) 8 | endif(PYQPANDA_STUBGEN) 9 | 10 | add_subdirectory(pyQPanda.Core) 11 | add_subdirectory(pyQPanda.Operator) 12 | 13 | 14 | -------------------------------------------------------------------------------- /Components/Optimizer/AbstractOptimizer.cpp: -------------------------------------------------------------------------------- 1 | #include "Components/Optimizer/AbstractOptimizer.h" 2 | 3 | namespace QPanda 4 | { 5 | 6 | AbstractOptimizer::AbstractOptimizer() : 7 | m_optimized_para(2, 0), 8 | m_disp(false), 9 | m_adaptive(false), 10 | m_xatol(1e-4), 11 | m_fatol(1e-4), 12 | m_test_value(0.0), 13 | m_max_fcalls(0), 14 | m_max_iter(0), 15 | m_restore_from_cache_file(false) 16 | { 17 | m_result.message = "No exec."; 18 | } 19 | 20 | AbstractOptimizer::~AbstractOptimizer() 21 | { 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Extensions/Extensions.h: -------------------------------------------------------------------------------- 1 | #ifndef __EXTENSIONS_H_ 2 | #define __EXTENSIONS_H_ 3 | 4 | #include "QPandaConfig.h" 5 | 6 | #ifdef USE_EXTENSION 7 | 8 | #include "QAlg/QAlg.h" 9 | #include "CutQC/CutQC.h" 10 | 11 | #include "QMapping/QCodarMatch.h" 12 | #include "QMapping/MappingAdapter.h" 13 | 14 | #include "VirtualZTransfer/VirtualZTransfer.h" 15 | 16 | #include "QCircuitOptimize/QCircuitRewrite.h" 17 | #include "QCircuitOptimize/HouseholderDecompose.h" 18 | 19 | #include "PilotOSMachine/OSDef.h" 20 | #include "PilotOSMachine/QPilotOSMachine.h" 21 | 22 | #endif //USE_EXTENSION 23 | 24 | #endif // ! __EXTENSIONS_H_ 25 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/OrderedATNConfigSet.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNConfigSet.h" 9 | #include "atn/ATNConfig.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC OrderedATNConfigSet : public ATNConfigSet { 15 | protected: 16 | virtual size_t getHash(ATNConfig *c) override; 17 | }; 18 | 19 | } // namespace atn 20 | } // namespace antlr4 21 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathLexerErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPathLexerErrorListener.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::tree::xpath; 10 | 11 | void XPathLexerErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 12 | size_t /*line*/, size_t /*charPositionInLine*/, const std::string &/*msg*/, std::exception_ptr /*e*/) { 13 | } 14 | -------------------------------------------------------------------------------- /pyQPanda/Tensor.py: -------------------------------------------------------------------------------- 1 | import pyqpanda as pq 2 | import numpy as np 3 | 4 | #默认不合并同类项 5 | operator = pq.PauliOperator({"X0 Y2" : -0.044750, 6 | "Z0 Z1" : 0.189766, 7 | "Z1 Z0" : 0.270597, 8 | "Z3" : -0.242743}) 9 | 10 | print(operator) 11 | 12 | #合并同类项 13 | operator = pq.PauliOperator({"X0 Y2" : -0.044750, 14 | "Z0 Z1" : 0.189766, 15 | "Z1 Z0" : 0.270597, 16 | "Z3" : -0.242743},True) 17 | 18 | print(operator) 19 | 20 | #手动合并 21 | operator.reduce_duplicates() -------------------------------------------------------------------------------- /ThirdParty/googletest/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | sudo: false 3 | matrix: 4 | include: 5 | # works on Precise and Trusty 6 | - os: linux 7 | addons: 8 | apt: 9 | sources: 10 | - ubuntu-toolchain-r-test 11 | packages: 12 | - g++-9 13 | env: 14 | - MATRIX_EVAL="CC=gcc-9 && CXX=g++-9" 15 | addons: 16 | apt: 17 | packages: 18 | - cmake 19 | before_install: 20 | - eval "${MATRIX_EVAL}" 21 | before_script: 22 | - cmake --version 23 | - mkdir build 24 | - cd build 25 | - cmake . ${TRAVIS_BUILD_DIR} 26 | - make clean 27 | - make 28 | script: echo ok 29 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/ContextSensitivityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ContextSensitivityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | ContextSensitivityInfo::ContextSensitivityInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, 12 | size_t startIndex, size_t stopIndex) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, true) { 14 | } 15 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/ErrorInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNConfigSet.h" 7 | 8 | #include "atn/ErrorInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | ErrorInfo::ErrorInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 14 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 15 | } 16 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopbackState final : public ATNState { 14 | public: 15 | StarLoopEntryState *getLoopEntryState(); 16 | 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BasicBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | #include "atn/BlockStartState.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC BasicBlockStartState final : public BlockStartState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The block that begins a closure loop. 14 | class ANTLR4CPP_PUBLIC StarBlockStartState final : public BlockStartState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /include/Core/QuantumNoise/OriginNoise.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Core/Utilities/QPandaNamespace.h" 4 | #include "Core/QuantumCircuit/QNode.h" 5 | #include "Core/QuantumNoise/AbstractNoiseNode.h" 6 | 7 | QPANDA_BEGIN 8 | 9 | class OriginNoise : public QNode, public AbstractQNoiseNode 10 | { 11 | public: 12 | OriginNoise(QVec, QStat = QStat()); 13 | virtual ~OriginNoise() {} 14 | virtual NodeType getNodeType() const 15 | { 16 | return NodeType::NOISE_NODE; 17 | } 18 | virtual QVec get_qvec(); 19 | virtual QStat get_ops(); 20 | 21 | protected: 22 | QVec m_vec; 23 | QStat m_op; 24 | }; 25 | 26 | QPANDA_END -------------------------------------------------------------------------------- /include/Core/VirtualQuantumProcessor/MPSQVM/NoiseDefinition.h: -------------------------------------------------------------------------------- 1 | #ifndef NOISE_DEFINITION_H 2 | #define NOISE_DEFINITION_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | QPANDA_BEGIN 10 | 11 | std::vector get_noise_model_karus_matrices(NOISE_MODEL model, const std::vector& params); 12 | 13 | std::vector get_noise_model_unitary_probs(NOISE_MODEL model, double param); 14 | 15 | std::vector get_noise_model_unitary_matrices(NOISE_MODEL model, double param); 16 | 17 | QPANDA_END 18 | 19 | 20 | #endif //!NOISE_DEFINITION_H -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The start of a regular {@code (...)} block. 14 | class ANTLR4CPP_PUBLIC BlockStartState : public DecisionState { 15 | public: 16 | ~BlockStartState(); 17 | BlockEndState *endState = nullptr; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/LoopEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Mark the end of a * or + loop. 14 | class ANTLR4CPP_PUBLIC LoopEndState final : public ATNState { 15 | public: 16 | ATNState *loopBackState = nullptr; 17 | 18 | virtual size_t getStateType() override; 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /Core/Utilities/Compiler/operations/Expression.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Core/Utilities/Compiler/operations/Expression.hpp" 3 | 4 | namespace sym { 5 | 6 | Variable::Variable(const std::string& name) { 7 | const auto it = registered.find(name); 8 | if (it != registered.end()) { 9 | id = it->second; 10 | } else { 11 | registered[name] = nextId; 12 | names[nextId] = name; 13 | id = nextId; 14 | ++nextId; 15 | } 16 | } 17 | 18 | std::string Variable::getName() const { return names[id]; } 19 | 20 | std::ostream& operator<<(std::ostream& os, const Variable& var) { 21 | os << var.getName(); 22 | return os; 23 | } 24 | } // namespace sym 25 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarLoopbackState.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/StarLoopEntryState.h" 7 | #include "atn/Transition.h" 8 | 9 | #include "atn/StarLoopbackState.h" 10 | 11 | using namespace antlr4::atn; 12 | 13 | StarLoopEntryState *StarLoopbackState::getLoopEntryState() { 14 | return dynamic_cast(transitions[0]->target); 15 | } 16 | 17 | size_t StarLoopbackState::getStateType() { 18 | return STAR_LOOP_BACK; 19 | } 20 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/DecisionEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/DecisionEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | DecisionEventInfo::DecisionEventInfo(size_t decision, ATNConfigSet *configs, TokenStream *input, size_t startIndex, 12 | size_t stopIndex, bool fullCtx) 13 | : decision(decision), configs(configs), input(input), startIndex(startIndex), stopIndex(stopIndex), fullCtx(fullCtx) { 14 | } 15 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/TokensStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The Tokens rule start state linking to each lexer rule start state. 14 | class ANTLR4CPP_PUBLIC TokensStartState final : public DecisionState { 15 | 16 | public: 17 | virtual size_t getStateType() override; 18 | }; 19 | 20 | } // namespace atn 21 | } // namespace antlr4 22 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/InputMismatchException.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Parser.h" 7 | 8 | #include "InputMismatchException.h" 9 | 10 | using namespace antlr4; 11 | 12 | InputMismatchException::InputMismatchException(Parser *recognizer) 13 | : RecognitionException(recognizer, recognizer->getInputStream(), recognizer->getContext(), 14 | recognizer->getCurrentToken()) { 15 | } 16 | 17 | InputMismatchException::~InputMismatchException() { 18 | } 19 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/AbstractPredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTState; 14 | 15 | class ANTLR4CPP_PUBLIC AbstractPredicateTransition : public Transition { 16 | 17 | public: 18 | AbstractPredicateTransition(ATNState *target); 19 | ~AbstractPredicateTransition(); 20 | 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Visualization/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Python\n 3 | Copyright (C) Origin Quantum 2017-2024\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | 7 | from .circuit_draw import draw_qprog 8 | from .circuit_draw import show_prog_info_count 9 | from .draw_probability_map import draw_probability 10 | from .draw_probability_map import draw_probability_dict 11 | from .quantum_state_plot import plot_state_city 12 | from .quantum_state_plot import plot_density_matrix 13 | from .quantum_state_plot import state_to_density_matrix 14 | from .bloch_plot import plot_bloch_circuit 15 | from .bloch_plot import plot_bloch_vector 16 | from .bloch_plot import plot_bloch_multivector 17 | 18 | 19 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/LookaheadEventInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/LookaheadEventInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | LookaheadEventInfo::LookaheadEventInfo(size_t decision, ATNConfigSet *configs, size_t predictedAlt, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->predictedAlt = predictedAlt; 16 | } 17 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RuleStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RuleStartState final : public ATNState { 14 | public: 15 | RuleStartState(); 16 | 17 | RuleStopState *stopState = nullptr; 18 | bool isLeftRecursiveRule = false; 19 | 20 | virtual size_t getStateType() override; 21 | 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/dfa/LexerDFASerializer.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Vocabulary.h" 7 | 8 | #include "dfa/LexerDFASerializer.h" 9 | 10 | using namespace antlr4::dfa; 11 | 12 | LexerDFASerializer::LexerDFASerializer(DFA *dfa) : DFASerializer(dfa, Vocabulary::EMPTY_VOCABULARY) { 13 | } 14 | 15 | LexerDFASerializer::~LexerDFASerializer() { 16 | } 17 | 18 | std::string LexerDFASerializer::getEdgeLabel(size_t i) const { 19 | return std::string("'") + static_cast(i) + "'"; 20 | } 21 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/dfa/LexerDFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "dfa/DFASerializer.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | class ANTLR4CPP_PUBLIC LexerDFASerializer : public DFASerializer { 14 | public: 15 | LexerDFASerializer(DFA *dfa); 16 | virtual ~LexerDFASerializer(); 17 | 18 | protected: 19 | virtual std::string getEdgeLabel(size_t i) const override; 20 | }; 21 | 22 | } // namespace atn 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathWildcardElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardElement : public XPathElement { 15 | public: 16 | XPathWildcardElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/ConsoleErrorListener.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "ConsoleErrorListener.h" 7 | 8 | using namespace antlr4; 9 | 10 | ConsoleErrorListener ConsoleErrorListener::INSTANCE; 11 | 12 | void ConsoleErrorListener::syntaxError(Recognizer * /*recognizer*/, Token * /*offendingSymbol*/, 13 | size_t line, size_t charPositionInLine, const std::string &msg, std::exception_ptr /*e*/) { 14 | std::cerr << "line " << line << ":" << charPositionInLine << " " << msg << std::endl; 15 | } 16 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/BlockEndState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Terminal node of a simple {@code (a|b|c)} block. 14 | class ANTLR4CPP_PUBLIC BlockEndState final : public ATNState { 15 | public: 16 | BlockStartState *startState = nullptr; 17 | 18 | BlockEndState(); 19 | 20 | virtual size_t getStateType() override; 21 | }; 22 | 23 | } // namespace atn 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /pyQPanda/example/IBMQconfig.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | # class Test_IBMQconfig(unittest.TestCase): 4 | # def test_ibmqconfig(self): 5 | # APItoken = '49000a0a22dd2d69bf5c5f27353ee8538c6c4ebd666b7baadab86f154c2316b3777585677b43f00a7a5d9452aab309c31459c736a923535ce451bdd93cb1e3b1' 6 | # 7 | # config = { 8 | # 'url': 'https://auth.quantum-computing.ibm.com/api' 9 | # } 10 | # 11 | # if __name__ == '__main__': 12 | # unittest.main(verbosity=2) 13 | 14 | 15 | APItoken = '49000a0a22dd2d69bf5c5f27353ee8538c6c4ebd666b7baadab86f154c2316b3777585677b43f00a7a5d9452aab309c31459c736a923535ce451bdd93cb1e3b1' 16 | 17 | config = {'url': 'https://auth.quantum-computing.ibm.com/api'} -------------------------------------------------------------------------------- /pyQPanda/example/test_print_circuit_info.py: -------------------------------------------------------------------------------- 1 | import pyqpanda as pq 2 | from circuit_info import get_circuit_info 3 | from circuit_composer import CircuitComposer 4 | 5 | if __name__ == '__main__': 6 | circ = pq.QCircuit() 7 | qvm = pq.CPUQVM() 8 | qvm.init_qvm() 9 | 10 | q = qvm.qAlloc_many(4) 11 | c = qvm.cAlloc_many(4) 12 | 13 | circ1 = CircuitComposer(4) 14 | 15 | circ << pq.H(q[0]) << pq.CNOT(q[0], q[1]) << pq.CNOT(q[1], q[2]) \ 16 | << pq.RX(q[0], 1.0) << pq.U2(q[1], 2.0, 3.0) \ 17 | << pq.U3(q[2], 4.0, 5.0, 6.0) \ 18 | << pq.U4([7, 8, 9, 10], q[3]) 19 | 20 | circ1 << circ << circ 21 | 22 | info = get_circuit_info(circ1) 23 | print(info) 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/AmbiguityInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/AmbiguityInfo.h" 7 | 8 | using namespace antlr4; 9 | using namespace antlr4::atn; 10 | 11 | AmbiguityInfo::AmbiguityInfo(size_t decision, ATNConfigSet *configs, const antlrcpp::BitSet &ambigAlts, 12 | TokenStream *input, size_t startIndex, size_t stopIndex, bool fullCtx) 13 | : DecisionEventInfo(decision, configs, input, startIndex, stopIndex, fullCtx) { 14 | 15 | this->ambigAlts = ambigAlts; 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vs/* 2 | *.a 3 | *.o 4 | *.log 5 | Release/bin/test 6 | pyQPanda/pyqpanda.egg-info 7 | pyQPanda/build 8 | pyQPanda/dist 9 | pyQPanda/QPandaConfig.json 10 | pyQPanda/pyqpanda/*.dll 11 | *.so 12 | *.pyd 13 | *.dylib 14 | .vscode/ 15 | build/* 16 | doc/* 17 | config.h 18 | include/QPandaConfig.h 19 | include/QPandaVersion.h 20 | /pyQPanda/benchmark.py 21 | __pycache__/ 22 | *.dat 23 | /mingw-build 24 | /CMakeLists.txt.user 25 | out/* 26 | *.py[cod] 27 | pyQPanda/pyqpanda/*.pyi 28 | pyQPanda/pyqpanda/Operator/*.pyi 29 | /.scannerwork 30 | /reports 31 | /Applications/out/build/x64-Debug 32 | /ThirdParty/googletest/out/build/x64-Debug 33 | pyQPanda/pyqpanda/Kyber/build/ 34 | CMakeSettings.json 35 | CppProperties.json 36 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathWildcardAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathWildcardAnywhereElement : public XPathElement { 15 | public: 16 | XPathWildcardAnywhereElement(); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | }; 20 | 21 | } // namespace xpath 22 | } // namespace tree 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /test/Core/TestMain.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | using namespace std; 3 | 4 | int main(int argc, char** argv) 5 | { 6 | #if 1 7 | //Run a single test of Alg Part 8 | ::testing::GTEST_FLAG(filter) = "Stabilizer.test"; 9 | //::testing::GTEST_FLAG(filter) = "QPilotOSMachine.test"; 10 | //::testing::GTEST_FLAG(filter) = "QubitMapping.test1"; 11 | //::testing::FLAGS_gtest_filter("QASMToQProg2.test"); 12 | ::testing::FLAGS_gtest_filter = "DrawLatex.test3"; 13 | 14 | #else 15 | //Run All Core Part 16 | #endif 17 | 18 | ::testing::InitGoogleTest(&argc, argv); 19 | const auto ret = RUN_ALL_TESTS(); 20 | cout << "Core Part GTest over, press Enter to continue." << endl; 21 | getchar(); 22 | return ret; 23 | } -------------------------------------------------------------------------------- /QPANDAConfig.cmake.in: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # RapidJSON source dir 3 | set( RapidJSON_SOURCE_DIR "@CONFIG_SOURCE_DIR@") 4 | 5 | ################################################################################ 6 | # RapidJSON build dir 7 | set( RapidJSON_DIR "@CONFIG_DIR@") 8 | 9 | ################################################################################ 10 | # Compute paths 11 | get_filename_component(RapidJSON_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 12 | 13 | set( RapidJSON_INCLUDE_DIR "@RapidJSON_INCLUDE_DIR@" ) 14 | set( RapidJSON_INCLUDE_DIRS "@RapidJSON_INCLUDE_DIR@" ) 15 | message(STATUS "RapidJSON found. Headers: ${RapidJSON_INCLUDE_DIRS}") 16 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/MoreVectorization: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla 6 | // Public License v. 2.0. If a copy of the MPL was not distributed 7 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | #ifndef EIGEN_MOREVECTORIZATION_MODULE_H 10 | #define EIGEN_MOREVECTORIZATION_MODULE_H 11 | 12 | #include 13 | 14 | namespace Eigen { 15 | 16 | /** 17 | * \defgroup MoreVectorization More vectorization module 18 | */ 19 | 20 | } 21 | 22 | #include "src/MoreVectorization/MathFunctions.h" 23 | 24 | #endif // EIGEN_MOREVECTORIZATION_MODULE_H 25 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ErrorNodeImpl.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | #include "tree/ParseTreeVisitor.h" 8 | 9 | #include "tree/ErrorNodeImpl.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::misc; 13 | using namespace antlr4::tree; 14 | 15 | ErrorNodeImpl::ErrorNodeImpl(Token *token) : TerminalNodeImpl(token) { 16 | } 17 | 18 | ErrorNodeImpl::~ErrorNodeImpl() { 19 | } 20 | 21 | antlrcpp::Any ErrorNodeImpl::accept(ParseTreeVisitor *visitor) { 22 | return visitor->visitErrorNode(this); 23 | } 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/InterpreterRuleContext.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "InterpreterRuleContext.h" 7 | 8 | using namespace antlr4; 9 | 10 | InterpreterRuleContext::InterpreterRuleContext() : ParserRuleContext() { 11 | } 12 | 13 | InterpreterRuleContext::InterpreterRuleContext(ParserRuleContext *parent, size_t invokingStateNumber, size_t ruleIndex) 14 | : ParserRuleContext(parent, invokingStateNumber), _ruleIndex(ruleIndex) { 15 | } 16 | 17 | size_t InterpreterRuleContext::getRuleIndex() const { 18 | return _ruleIndex; 19 | } 20 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PlusLoopbackState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Decision state for {@code A+} and {@code (A|B)+}. It has two transitions: 14 | /// one to the loop back to start of the block and one to exit. 15 | class ANTLR4CPP_PUBLIC PlusLoopbackState final : public DecisionState { 16 | 17 | public: 18 | virtual size_t getStateType() override; 19 | }; 20 | 21 | } // namespace atn 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/src/Core/functors/TernaryFunctors.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Eugene Brevdo 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_TERNARY_FUNCTORS_H 11 | #define EIGEN_TERNARY_FUNCTORS_H 12 | 13 | namespace Eigen { 14 | 15 | namespace internal { 16 | 17 | //---------- associative ternary functors ---------- 18 | 19 | 20 | 21 | } // end namespace internal 22 | 23 | } // end namespace Eigen 24 | 25 | #endif // EIGEN_TERNARY_FUNCTORS_H 26 | -------------------------------------------------------------------------------- /include/Core/Variational/DataType.h: -------------------------------------------------------------------------------- 1 | #ifndef DATATYPE_H 2 | #define DATATYPE_H 3 | 4 | #include 5 | 6 | namespace QPanda { 7 | namespace Variational { 8 | 9 | /** 10 | * @brief Double variate 11 | * @ingroup Variational 12 | */ 13 | class Double 14 | { 15 | std::shared_ptr m_d; 16 | public: 17 | Double(); 18 | Double(double); 19 | Double(const Double&); 20 | operator double() 21 | { 22 | return *m_d; 23 | } 24 | }; 25 | 26 | inline Double::Double() { m_d = std::shared_ptr(new double(0)); } 27 | inline Double::Double(double val) { m_d = std::shared_ptr(new double(val)); } 28 | inline Double::Double(const Double& d) { m_d = d.m_d; } 29 | 30 | } // Variational 31 | } // QPanda 32 | #endif // !DATATYPE_H -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/DecisionState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC DecisionState : public ATNState { 14 | public: 15 | int decision; 16 | bool nonGreedy; 17 | 18 | private: 19 | void InitializeInstanceFields(); 20 | 21 | public: 22 | DecisionState() { 23 | InitializeInstanceFields(); 24 | } 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /test/QAlg/Shor.test.cpp: -------------------------------------------------------------------------------- 1 | #include "gtest/gtest.h" 2 | #include "QPanda.h" 3 | 4 | using namespace std; 5 | USING_QPANDA 6 | 7 | bool test_Shor() 8 | { 9 | int N = 6; 10 | auto p = Shor_factorization(N); 11 | //cout << p.second.first << "X" << p.second.second << endl; 12 | if (p.second.first == 2 && p.second.second == 3) 13 | return true; 14 | else 15 | return false; 16 | 17 | //return p.first; 18 | } 19 | 20 | // shor test 21 | TEST(Shor, test1) 22 | { 23 | bool test_val = false; 24 | try 25 | { 26 | test_val = test_Shor(); 27 | } 28 | catch (const std::exception& e) 29 | { 30 | cout << "Got a exception: " << e.what() << endl; 31 | } 32 | catch (...) 33 | { 34 | cout << "Got an unknow exception: " << endl; 35 | } 36 | 37 | ASSERT_TRUE(test_val); 38 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathWildcardElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardElement::XPathWildcardElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | 23 | return t->children; 24 | } 25 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathLexerErrorListener.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "BaseErrorListener.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathLexerErrorListener : public BaseErrorListener { 15 | public: 16 | virtual void syntaxError(Recognizer *recognizer, Token *offendingSymbol, size_t line, 17 | size_t charPositionInLine, const std::string &msg, std::exception_ptr e) override; 18 | }; 19 | 20 | } // namespace xpath 21 | } // namespace tree 22 | } // namespace antlr4 23 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathRuleElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathRuleElement : public XPathElement { 15 | public: 16 | XPathRuleElement(const std::string &ruleName, size_t ruleIndex); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _ruleIndex = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PredicateEvalInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "SemanticContext.h" 7 | 8 | #include "atn/PredicateEvalInfo.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | PredicateEvalInfo::PredicateEvalInfo(size_t decision, TokenStream *input, size_t startIndex, size_t stopIndex, 14 | Ref const& semctx, bool evalResult, size_t predictedAlt, bool fullCtx) 15 | : DecisionEventInfo(decision, nullptr, input, startIndex, stopIndex, fullCtx), 16 | semctx(semctx), predictedAlt(predictedAlt), evalResult(evalResult) { 17 | } 18 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/pattern/TextChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TextChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TextChunk::TextChunk(const std::string &text) : text(text) { 13 | if (text == "") { 14 | throw IllegalArgumentException("text cannot be nul"); 15 | } 16 | 17 | } 18 | 19 | TextChunk::~TextChunk() { 20 | } 21 | 22 | std::string TextChunk::getText() { 23 | return text; 24 | } 25 | 26 | std::string TextChunk::toString() { 27 | return std::string("'") + text + std::string("'"); 28 | } 29 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathRuleAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "tree/xpath/XPathRuleAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleAnywhereElement::XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllRuleNodes(t, _ruleIndex); 20 | } 21 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathTokenAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathTokenAnywhereElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathTokenAnywhereElement::XPathTokenAnywhereElement(const std::string &tokenName, int tokenType) : XPathElement(tokenName) { 15 | this->tokenType = tokenType; 16 | } 17 | 18 | std::vector XPathTokenAnywhereElement::evaluate(ParseTree *t) { 19 | return Trees::findAllTokenNodes(t, tokenType); 20 | } 21 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathTokenElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenElement : public XPathElement { 15 | public: 16 | XPathTokenElement(const std::string &tokenName, size_t tokenType); 17 | 18 | virtual std::vector evaluate(ParseTree *t) override; 19 | 20 | protected: 21 | size_t _tokenType = 0; 22 | }; 23 | 24 | } // namespace xpath 25 | } // namespace tree 26 | } // namespace antlr4 27 | -------------------------------------------------------------------------------- /include/Core/Debugger/OriginDebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "AbstractQDebugNode.h" 4 | #include "QPUDebugger.h" 5 | #include "Core/QuantumCircuit/QNode.h" 6 | 7 | QPANDA_BEGIN 8 | 9 | class OriginDebug : public QNode, public AbstractQDebugNode 10 | { 11 | public: 12 | OriginDebug() {} 13 | virtual ~OriginDebug() {} 14 | virtual NodeType getNodeType() const 15 | { 16 | return NodeType::DEBUG_NODE; 17 | } 18 | 19 | virtual void save_qstate_ref(std::vector> &stat) 20 | { 21 | QPUDebugger::instance().save_qstate_ref(stat); 22 | } 23 | 24 | virtual void save_qstate_ref(std::vector> &stat) 25 | { 26 | QPUDebugger::instance().save_qstate_ref(stat); 27 | } 28 | }; 29 | 30 | QPANDA_END -------------------------------------------------------------------------------- /test/Overall_scan/QMachine/QuantumMachineFactory.test.cpp: -------------------------------------------------------------------------------- 1 | /// QuantMachineFactory Inface test 2 | 3 | #include "QPanda.h" 4 | #include "gtest/gtest.h" 5 | 6 | USING_QPANDA 7 | 8 | TEST(QuantMachineFactoryTest, test) { 9 | QuantumMachineFactory qmfac = QuantumMachineFactory::GetFactoryInstance(); 10 | // QuantumMachine* cpuqm = qmfac.CreateByName("CPU"); 11 | QuantumMachine* cpuqm = qmfac.CreateByType(CPU); 12 | cpuqm->init(); 13 | QVec qv = cpuqm->allocateQubits(4); 14 | Qubit* qb = cpuqm->allocateQubitThroughPhyAddress(1); 15 | EXPECT_EQ(1,qb->get_phy_addr()); 16 | 17 | QuantumMachineFactory::constructor_t a; 18 | a = std::bind([](QuantumMachineFactory m_qm)->QuantumMachine* { 19 | return m_qm.CreateByType(NOISE); 20 | }, qmfac) ; 21 | qmfac.registerclass("CPU1", a); 22 | 23 | } -------------------------------------------------------------------------------- /Core/Utilities/QProgInfo/QGateCounter.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Utilities/QProgInfo/QGateCounter.h" 2 | using namespace std; 3 | USING_QPANDA 4 | 5 | QGateCounter::QGateCounter() : 6 | m_count(0), 7 | m_qgate_num_map() 8 | { 9 | 10 | } 11 | 12 | QGateCounter::~QGateCounter() 13 | { 14 | 15 | } 16 | 17 | void QGateCounter::execute(std::shared_ptr cur_node, std::shared_ptr parent_node) 18 | { 19 | if (cur_node) { 20 | m_count++; 21 | GateType gatetype = static_cast(cur_node->getQGate()->getGateType()); 22 | m_qgate_num_map[gatetype]++; 23 | } 24 | } 25 | 26 | size_t QGateCounter::count() 27 | { 28 | return m_count; 29 | } 30 | 31 | const std::map QGateCounter::getGateMap() { 32 | return m_qgate_num_map; 33 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathTokenAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | class ANTLR4CPP_PUBLIC XPathTokenAnywhereElement : public XPathElement { 15 | protected: 16 | int tokenType = 0; 17 | public: 18 | XPathTokenAnywhereElement(const std::string &tokenName, int tokenType); 19 | 20 | virtual std::vector evaluate(ParseTree *t) override; 21 | }; 22 | 23 | } // namespace xpath 24 | } // namespace tree 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /Template/VS/CMakeSettings.json: -------------------------------------------------------------------------------- 1 | 2 | 3 | { 4 | "configurations": [ 5 | { 6 | "name": "x64-Debug", 7 | "generator": "Ninja", 8 | "configurationType": "Debug", 9 | "inheritEnvironments": [ 10 | "msvc_x64_x64" 11 | ], 12 | "buildRoot": "${projectDir}\\build\\${name}", 13 | "cmakeCommandArgs": "", 14 | "buildCommandArgs": "-v", 15 | "ctestCommandArgs": "" 16 | }, 17 | { 18 | "name": "x64-Release", 19 | "generator": "Ninja", 20 | "configurationType": "Release", 21 | "inheritEnvironments": [ 22 | "msvc_x64_x64" 23 | ], 24 | "buildRoot": "${projectDir}\\build\\${name}", 25 | "cmakeCommandArgs": "", 26 | "buildCommandArgs": "-v", 27 | "ctestCommandArgs": "" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/WritableToken.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Token.h" 9 | 10 | namespace antlr4 { 11 | 12 | class ANTLR4CPP_PUBLIC WritableToken : public Token { 13 | public: 14 | virtual ~WritableToken(); 15 | virtual void setText(const std::string &text) = 0; 16 | virtual void setType(size_t ttype) = 0; 17 | virtual void setLine(size_t line) = 0; 18 | virtual void setCharPositionInLine(size_t pos) = 0; 19 | virtual void setChannel(size_t channel) = 0; 20 | virtual void setTokenIndex(size_t index) = 0; 21 | }; 22 | 23 | } // namespace antlr4 24 | -------------------------------------------------------------------------------- /include/Core/Utilities/UnitaryDecomposer/UniformlyControlledGates.h: -------------------------------------------------------------------------------- 1 | #ifndef _UNIFORMLY_CONTROLLED_GATES_H_ 2 | #define _UNIFORMLY_CONTROLLED_GATES_H_ 3 | #include "ThirdParty/Eigen/Eigen" 4 | #include "Core/QuantumCircuit/QCircuit.h" 5 | QPANDA_BEGIN 6 | 7 | QCircuit ucry_circuit(QVec controls, Qubit* target, prob_vec params); 8 | 9 | QCircuit ucry_decomposition(QVec controls, Qubit* target, prob_vec params); 10 | 11 | QCircuit ucrz_decomposition(QVec controls, Qubit* target, prob_vec params); 12 | 13 | QCircuit diagonal_decomposition(QVec qv, std::vector diag_vec); 14 | 15 | QCircuit uc_decomposition(QVec ctrl_qv, Qubit* target_q, 16 | const std::vector& um_vec, bool up_to_diagonal = false); 17 | 18 | 19 | QPANDA_END 20 | #endif // !_UNIFORMLY_CONTROLLED_GATES_H_ 21 | 22 | -------------------------------------------------------------------------------- /test/Core/Oracle.test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "QPanda.h" 3 | #include "Core/Utilities/Tools/JsonConfigParam.h" 4 | #include 5 | #include "gtest/gtest.h" 6 | using namespace std; 7 | USING_QPANDA 8 | 9 | TEST(Oracle, createoracle) 10 | { 11 | //std::cout << "======================================" << std::endl; 12 | /*auto qm = initQuantumMachine(); 13 | auto qs = qAllocMany(5); 14 | QProg prog; 15 | prog << oracle(qs, "test1"); 16 | std::string s = transformQProgToOriginIR(prog, qm); 17 | //cout << s<=1.6.0", torch.__version__) 10 | 11 | class TorchModel(torch.autograd.Function): 12 | @staticmethod 13 | def forward(ctx,func,input_): 14 | res = func(**input_) 15 | res = torch.as_tensor(torch.from_numpy(np.array(res))) 16 | ctx.save_for_backward(res) 17 | return res 18 | @staticmethod 19 | def backward(ctx, grad_outputs): # pragma: no cover 20 | outputs, = ctx.saved_tensors 21 | return grad_outputs * outputs 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/WildcardTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC WildcardTransition final : public Transition { 14 | public: 15 | WildcardTransition(ATNState *target); 16 | 17 | virtual SerializationType getSerializationType() const override; 18 | 19 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 20 | 21 | virtual std::string toString() const override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /Core/QuantumMachine/OriginQMachineStatus.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2023 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "OriginQuantumMachine.h" 18 | #include "Factory.h" 19 | USING_QPANDA 20 | OriginQMachineStatus::OriginQMachineStatus() 21 | {} -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathWildcardAnywhereElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "XPath.h" 7 | #include "tree/ParseTree.h" 8 | #include "tree/Trees.h" 9 | 10 | #include "XPathWildcardAnywhereElement.h" 11 | 12 | using namespace antlr4::tree; 13 | using namespace antlr4::tree::xpath; 14 | 15 | XPathWildcardAnywhereElement::XPathWildcardAnywhereElement() : XPathElement(XPath::WILDCARD) { 16 | } 17 | 18 | std::vector XPathWildcardAnywhereElement::evaluate(ParseTree *t) { 19 | if (_invert) { 20 | return {}; // !* is weird but valid (empty) 21 | } 22 | return Trees::getDescendants(t); 23 | } 24 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RuleStopState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/ATNState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// The last node in the ATN for a rule, unless that rule is the start symbol. 14 | /// In that case, there is one transition to EOF. Later, we might encode 15 | /// references to all calls to this rule to compute FOLLOW sets for 16 | /// error handling. 17 | class ANTLR4CPP_PUBLIC RuleStopState final : public ATNState { 18 | 19 | public: 20 | virtual size_t getStateType() override; 21 | 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /ThirdParty/bplus-tree/include/private/errors.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_ERRORS_H_ 2 | #define _PRIVATE_ERRORS_H_ 3 | 4 | #define BP_OK 0 5 | 6 | #define BP_EFILE 0x101 7 | #define BP_EFILEREAD_OOB 0x102 8 | #define BP_EFILEREAD 0x103 9 | #define BP_EFILEWRITE 0x104 10 | #define BP_EFILEFLUSH 0x105 11 | #define BP_EFILERENAME 0x106 12 | #define BP_ECOMPACT_EXISTS 0x107 13 | 14 | #define BP_ECOMP 0x201 15 | #define BP_EDECOMP 0x202 16 | 17 | #define BP_EALLOC 0x301 18 | #define BP_EMUTEX 0x302 19 | #define BP_ERWLOCK 0x303 20 | 21 | #define BP_ENOTFOUND 0x401 22 | #define BP_ESPLITPAGE 0x402 23 | #define BP_EEMPTYPAGE 0x403 24 | #define BP_EUPDATECONFLICT 0x404 25 | #define BP_EREMOVECONFLICT 0x405 26 | 27 | #endif /* _PRIVATE_ERRORS_H_ */ 28 | -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/QASMCompiler/parser/NestedEnvironment.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | template class NestedEnvironment { 9 | private: 10 | std::vector> env{}; 11 | 12 | public: 13 | NestedEnvironment() { env.push_back({}); }; 14 | 15 | void push() { env.push_back({}); } 16 | 17 | void pop() { env.pop_back(); } 18 | 19 | std::optional find(std::string key) { 20 | for (auto it = env.rbegin(); it != env.rend(); ++it) { 21 | auto found = it->find(key); 22 | if (found != it->end()) { 23 | return found->second; 24 | } 25 | } 26 | return std::nullopt; 27 | } 28 | 29 | void emplace(std::string key, T value) { env.back().emplace(key, value); } 30 | }; 31 | -------------------------------------------------------------------------------- /Template/Linux/README.md: -------------------------------------------------------------------------------- 1 | g++的编译命令为 2 | ```` 3 | 4 | 宿主机有libcurl时 5 | g++ test.cpp -std=c++14 -fopenmp -I{QPanda安装路径}/include/qpanda2/ -I{QPanda安装路径}/include/qpanda2/ThirdParty/ -L{QPanda安装路径}/lib/ -lQPanda2 -lTinyXML -lcurl -o test 6 | 7 | 宿主机没有libcurl时 8 | g++ test.cpp -std=c++14 -fopenmp -I{QPanda安装路径}/include/qpanda2/ -I{QPanda安装路径}/include/qpanda2/ThirdParty/ -L{QPanda安装路径}/lib/ -lQPanda2 -lTinyXML -o test 9 | ```` 10 | 11 | 使用MPI并行计算时的编译命令 12 | ```` 13 | 14 | 宿主机有libcurl时 15 | mpic++ test.cpp -std=c++14 -fopenmp -I{QPanda安装路径}/include/qpanda2/ -I{QPanda安装路径}/include/qpanda2/ThirdParty/ -L{QPanda安装路径}/lib/ -lQPanda2 -lTinyXML -lcurl -o test 16 | 17 | 宿主机没有libcurl时 18 | mpic++ test.cpp -std=c++14 -fopenmp -I{QPanda安装路径}/include/qpanda2/ -I{QPanda安装路径}/include/qpanda2/ThirdParty/ -L{QPanda安装路径}/lib/ -lQPanda2 -lTinyXML -o test 19 | ```` 20 | -------------------------------------------------------------------------------- /test/Core/QVec.test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "QPanda.h" 4 | #include "gtest/gtest.h" 5 | USING_QPANDA 6 | using namespace std; 7 | 8 | #ifdef QVEC 9 | 10 | 11 | 12 | TEST(QVec,test) 13 | { 14 | init(); 15 | auto prog = QProg(); 16 | 17 | //vector qvec; 18 | auto qvec = qAllocMany(5); 19 | auto cvec = cAllocMany(2); 20 | cvec[1].set_val(0); 21 | cvec[0].set_val(0); 22 | auto prog_in = QProg(); 23 | prog_in<<(cvec[1]=cvec[1]+1)< 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_STDLIST_MODULE_H 11 | #define EIGEN_STDLIST_MODULE_H 12 | 13 | #include "Core" 14 | #include 15 | 16 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 17 | 18 | #define EIGEN_DEFINE_STL_LIST_SPECIALIZATION(...) 19 | 20 | #else 21 | 22 | #include "src/StlSupport/StdList.h" 23 | 24 | #endif 25 | 26 | #endif // EIGEN_STDLIST_MODULE_H 27 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/NotSetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/SetTransition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC NotSetTransition final : public SetTransition { 14 | public: 15 | NotSetTransition(ATNState *target, const misc::IntervalSet &set); 16 | 17 | virtual SerializationType getSerializationType() const override; 18 | 19 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 20 | 21 | virtual std::string toString() const override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /ThirdParty/nlopt/include/slsqp.h: -------------------------------------------------------------------------------- 1 | #ifndef SLSQP_H 2 | #define SLSQP_H 3 | 4 | #include "nlopt.h" 5 | #include "nlopt-util.h" 6 | #include "ThirdParty/rapidjson/document.h" 7 | #include "ThirdParty/rapidjson/writer.h" 8 | #include "ThirdParty/rapidjson/filereadstream.h" 9 | #include "ThirdParty/rapidjson/filewritestream.h" 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace rapidjson; 17 | 18 | 19 | 20 | nlopt_result nlopt_slsqp(unsigned n, nlopt_func f, void* f_data, 21 | unsigned m, nlopt_constraint* fc, 22 | unsigned p, nlopt_constraint* h, 23 | const double* lb, const double* ub, 24 | double* x, double* minf, 25 | nlopt_stopping* stop, bool restore_flag = false, 26 | std::string save_file_name = "slsqp_break_point.json"); 27 | 28 | 29 | 30 | #endif -------------------------------------------------------------------------------- /Core/Utilities/Compiler/QASMCompiler/parser/Statement.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Core/Utilities/Compiler/QASMCompiler/parser/Statement.hpp" 3 | 4 | namespace qasm { 5 | 6 | std::optional getComparisonKind(BinaryExpression::Op op) { 7 | switch (op) { 8 | case BinaryExpression::Op::LessThan: 9 | return qc::ComparisonKind::Lt; 10 | case BinaryExpression::Op::LessThanOrEqual: 11 | return qc::ComparisonKind::Leq; 12 | case BinaryExpression::Op::GreaterThan: 13 | return qc::ComparisonKind::Gt; 14 | case BinaryExpression::Op::GreaterThanOrEqual: 15 | return qc::ComparisonKind::Geq; 16 | case BinaryExpression::Op::Equal: 17 | return qc::ComparisonKind::Eq; 18 | case BinaryExpression::Op::NotEqual: 19 | return qc::ComparisonKind::Neq; 20 | default: 21 | return std::nullopt; 22 | } 23 | } 24 | } // namespace qasm 25 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/CXX11/src/ThreadPool/ThreadYield.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_CXX11_THREADPOOL_THREAD_YIELD_H 11 | #define EIGEN_CXX11_THREADPOOL_THREAD_YIELD_H 12 | 13 | // Try to come up with a portable way to yield 14 | #if EIGEN_COMP_GNUC && EIGEN_GNUC_AT_MOST(4, 7) 15 | #define EIGEN_THREAD_YIELD() sched_yield() 16 | #else 17 | #define EIGEN_THREAD_YIELD() std::this_thread::yield() 18 | #endif 19 | 20 | #endif // EIGEN_CXX11_THREADPOOL_THREAD_YIELD_H 21 | -------------------------------------------------------------------------------- /ThirdParty/mpfit/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(mpfit) 3 | 4 | file(GLOB_RECURSE SRC_H ${CMAKE_CURRENT_SOURCE_DIR}/*.h) 5 | file(GLOB_RECURSE SRC_C ${CMAKE_CURRENT_SOURCE_DIR}/*.c) 6 | 7 | add_library(${LIB_MPFIT} STATIC ${SRC_H} ${SRC_C}) 8 | 9 | INSTALL(TARGETS ${LIB_MPFIT} 10 | EXPORT ${TARGETS_EXPORT_NAME} 11 | ARCHIVE DESTINATION lib 12 | LIBRARY DESTINATION lib 13 | RUNTIME DESTINATION bin) 14 | 15 | target_include_directories(${LIB_MPFIT} INTERFACE 16 | $ 17 | $) 18 | 19 | export(TARGETS ${LIB_MPFIT} 20 | APPEND FILE ${PROJECT_BINARY_DIR}/mpfit-target.cmake 21 | NAMESPACE QPANDA:: 22 | ) -------------------------------------------------------------------------------- /ThirdParty/bz2/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(BZ2Project) 3 | 4 | file(GLOB_RECURSE LIB_BZ2_SRC_H ${CMAKE_CURRENT_SOURCE_DIR}/*.h) 5 | file(GLOB_RECURSE LIB_BZ2_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.c) 6 | add_library(${LIB_BZ2} STATIC ${LIB_BZ2_SRC_H} ${LIB_BZ2_SRC_CPP}) 7 | 8 | INSTALL(TARGETS ${LIB_BZ2} 9 | EXPORT ${TARGETS_EXPORT_NAME} 10 | ARCHIVE DESTINATION lib 11 | LIBRARY DESTINATION lib 12 | RUNTIME DESTINATION bin) 13 | 14 | target_include_directories(${LIB_BZ2} INTERFACE 15 | $ 16 | $) 17 | 18 | export(TARGETS ${LIB_BZ2} 19 | APPEND FILE ${PROJECT_BINARY_DIR}/bz2-target.cmake 20 | NAMESPACE QPANDA:: 21 | ) -------------------------------------------------------------------------------- /Core/QuantumMachine/OriginQubit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2023 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "OriginQuantumMachine.h" 18 | USING_QPANDA 19 | OriginQubit::OriginQubit(PhysicalQubit *_Physical_Qubit) 20 | { 21 | ptPhysicalQubit = _Physical_Qubit; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /include/Core/Utilities/Compiler/QASMToQProg.hpp: -------------------------------------------------------------------------------- 1 | #ifndef _QASMTOQPORG_H 2 | #define _QASMTOQPORG_H 3 | 4 | //#include "Core/Utilities/Compiler/QuantumComputation.hpp" 5 | 6 | #include "Core/QuantumCircuit/QProgram.h" 7 | #include "Core/QuantumMachine/QuantumMachineInterface.h" 8 | #include "Core/Utilities/Compiler/QASMToOriginIR.hpp" 9 | 10 | 11 | //using namespace qc; 12 | 13 | 14 | QPANDA_BEGIN 15 | 16 | 17 | QProg convert_qasm_to_qprog(std::string file_path, QuantumMachine* qvm); 18 | QProg convert_qasm_to_qprog(std::string file_path, QuantumMachine* qvm, QVec& qv, std::vector& cv); 19 | 20 | QProg convert_qasm_string_to_qprog(std::string qasm_str, QuantumMachine* qvm); 21 | QProg convert_qasm_string_to_qprog(std::string qasm_str, QuantumMachine* qvm, QVec& qv, std::vector& cv); 22 | QPANDA_END 23 | #endif //!_QASMTOQPORG_H -------------------------------------------------------------------------------- /Core/VirtualQuantumProcessor/QPUImpl.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2023 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | 18 | #include 19 | #include "QPUImpl.h" 20 | USING_QPANDA 21 | using namespace std; 22 | 23 | QPUImpl::QPUImpl() 24 | {} 25 | 26 | QPUImpl::~QPUImpl() 27 | {} 28 | 29 | -------------------------------------------------------------------------------- /Core/Debugger/QPUDebugger.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Debugger/QPUDebugger.h" 2 | 3 | USING_QPANDA 4 | 5 | QPUDebugger &QPUDebugger::instance() 6 | { 7 | static QPUDebugger debugger; 8 | return debugger; 9 | } 10 | 11 | void QPUDebugger::save_qstate_ref(std::vector> &state) 12 | { 13 | m_qstate.double_state = &state; 14 | m_qstate.float_state = nullptr; 15 | } 16 | 17 | void QPUDebugger::save_qstate_ref(std::vector> &state) 18 | { 19 | m_qstate.float_state = &state; 20 | m_qstate.double_state = nullptr; 21 | } 22 | 23 | const QPUDebugger::State &QPUDebugger::get_qstate() const 24 | { 25 | QPANDA_ASSERT(m_qstate.double_state && m_qstate.float_state, "QVM state vector saved double complex same time."); 26 | QPANDA_ASSERT((!m_qstate.double_state) && (!m_qstate.float_state), "QVM state vector not saved yet."); 27 | return m_qstate; 28 | } -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathRuleAnywhereElement.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "XPathElement.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | namespace xpath { 13 | 14 | /// Either {@code ID} at start of path or {@code ...//ID} in middle of path. 15 | class ANTLR4CPP_PUBLIC XPathRuleAnywhereElement : public XPathElement { 16 | public: 17 | XPathRuleAnywhereElement(const std::string &ruleName, int ruleIndex); 18 | 19 | virtual std::vector evaluate(ParseTree *t) override; 20 | 21 | protected: 22 | int _ruleIndex = 0; 23 | }; 24 | 25 | } // namespace xpath 26 | } // namespace tree 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/RuleContextWithAltNum.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATN.h" 7 | 8 | #include "RuleContextWithAltNum.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RuleContextWithAltNum::RuleContextWithAltNum() : ParserRuleContext() { 14 | altNum = ATN::INVALID_ALT_NUMBER; 15 | } 16 | 17 | RuleContextWithAltNum::RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber) 18 | : ParserRuleContext(parent, invokingStateNumber) { 19 | } 20 | 21 | size_t RuleContextWithAltNum::getAltNumber() const { 22 | return altNum; 23 | } 24 | 25 | void RuleContextWithAltNum::setAltNumber(size_t number) { 26 | altNum = number; 27 | } 28 | -------------------------------------------------------------------------------- /include/Core/Utilities/QProgInfo/ConfigMap.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_MAP_H 2 | #define _CONFIG_MAP_H 3 | #include 4 | #include 5 | #include "Core/Utilities/QPandaNamespace.h" 6 | #include "Core/Utilities/Tools/JsonConfigParam.h" 7 | 8 | QPANDA_BEGIN 9 | 10 | typedef std::pair CONFIGPAIR; 11 | 12 | /** 13 | * @brief Configuration Map 14 | * @ingroup Utilities 15 | */ 16 | class ConfigMap 17 | { 18 | public: 19 | static ConfigMap &getInstance(); 20 | ~ConfigMap(); 21 | std::string operator [](const char *); 22 | protected: 23 | ConfigMap(const std::string &filename = CONFIG_PATH); 24 | ConfigMap(const ConfigMap &); 25 | ConfigMap &operator=(const ConfigMap &); 26 | private: 27 | void insert(CONFIGPAIR); 28 | std::map m_configMap; 29 | }; 30 | QPANDA_END 31 | 32 | #endif // !_CONFIG_MAP_H 33 | 34 | 35 | -------------------------------------------------------------------------------- /cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") 3 | endif() 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") 9 | if(EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if("${rm_retval}" STREQUAL 0) 16 | else() 17 | message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") 18 | endif() 19 | else() 20 | message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") 21 | endif() 22 | endforeach() 23 | -------------------------------------------------------------------------------- /include/Core/Debugger/QDebug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "AbstractQDebugNode.h" 5 | 6 | QPANDA_BEGIN 7 | 8 | class QDebug : public AbstractQDebugNode 9 | { 10 | private: 11 | std::shared_ptr m_debug_node; 12 | 13 | public: 14 | QDebug(std::shared_ptr origin_debug) 15 | : m_debug_node(origin_debug) 16 | { 17 | } 18 | virtual ~QDebug() {} 19 | virtual void save_qstate_ref(std::vector>& stat) override 20 | { 21 | m_debug_node->save_qstate_ref(stat); 22 | } 23 | 24 | virtual void save_qstate_ref(std::vector>& stat) override 25 | { 26 | m_debug_node->save_qstate_ref(stat); 27 | } 28 | 29 | std::shared_ptr getImplementationPtr() 30 | { 31 | return m_debug_node; 32 | } 33 | }; 34 | 35 | QPANDA_END -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/WildcardTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ATNState.h" 7 | 8 | #include "atn/WildcardTransition.h" 9 | 10 | using namespace antlr4::atn; 11 | 12 | WildcardTransition::WildcardTransition(ATNState *target) : Transition(target) { 13 | } 14 | 15 | Transition::SerializationType WildcardTransition::getSerializationType() const { 16 | return WILDCARD; 17 | } 18 | 19 | bool WildcardTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 20 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol; 21 | } 22 | 23 | std::string WildcardTransition::toString() const { 24 | return "WILDCARD " + Transition::toString() + " {}"; 25 | } 26 | -------------------------------------------------------------------------------- /Core/QuantumCloud/QCloudLog.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Core/QuantumCloud/QCloudLog.h" 3 | 4 | USING_QPANDA 5 | 6 | void QPanda::qcloud_log_out(LogLevel level, const std::string& message, const std::string& file, int line) 7 | { 8 | auto& logger = QCloudLogger::get_instance(); 9 | 10 | if (logger.is_enabled()) 11 | { 12 | std::string message_out; 13 | switch (level) 14 | { 15 | case LogLevel::CLOUD_DEBUG: message_out = ("DEBUG : " + message); break; 16 | case LogLevel::CLOUD_INFO: message_out = ("INFO : " + message); break; 17 | case LogLevel::CLOUD_WARNING: message_out = ("WARNING : " + message); break; 18 | case LogLevel::CLOUD_ERROR: message_out = ("ERROR : " + message); break; 19 | default: break; 20 | } 21 | 22 | std::cerr << file << ":" << line << " " << message_out << std::endl; 23 | } 24 | } -------------------------------------------------------------------------------- /ThirdParty/Eigen/StdDeque: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDDEQUE_MODULE_H 12 | #define EIGEN_STDDEQUE_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_DEQUE_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdDeque.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDDEQUE_MODULE_H 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/InputMismatchException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// 13 | /// This signifies any kind of mismatched input exceptions such as 14 | /// when the current input does not match the expected token. 15 | /// 16 | class ANTLR4CPP_PUBLIC InputMismatchException : public RecognitionException { 17 | public: 18 | InputMismatchException(Parser *recognizer); 19 | InputMismatchException(InputMismatchException const&) = default; 20 | ~InputMismatchException(); 21 | InputMismatchException& operator=(InputMismatchException const&) = default; 22 | }; 23 | 24 | } // namespace antlr4 25 | -------------------------------------------------------------------------------- /pyQPanda/postbuildtool/README(CN).md: -------------------------------------------------------------------------------- 1 | # QPanda编译后处理工具集 2 | 3 | 4 | 5 | ## stubgen工具 6 | 7 | ### 概述 8 | 9 | 该工具主要用于为使用pybind11封装的pyQPanda接口生成`.pyi`的stub文件,用于IDE的intelliSENCE(自动补全,参数提示等等)。 10 | 11 | 该工具基于[mypy](https://github.com/python/mypy)改造而来,主要修改其stubgenc.py文件中`generate_c_function_stub`和`generate_c_type_stub`函数,增强其功能。现已将关键流程中的函数独立出来,集中在stubgen.py和stubgencmod.py中。 12 | 13 | 主要修改: 14 | 15 | 1. 将pyQPanda包中的类,函数doc,添加到pyi文件中相应的注释位置 16 | 2. 将pyQPanda包的doc中保存的形参默认值填写到pyi文件中(通过python语法解析器工具[parso](https://github.com/davidhalter/parso)来将函数签名解析为语法树,从中提取形参的默认值字符串) 17 | 18 | ### 使用方法 19 | 20 | 主要的使用方法可参考mypy的stubgen工具,**使用`-h`参数查看工具的参数选项**。 21 | 22 | 安装依赖 23 | 24 | ``` 25 | pip install -r requirement.txt 26 | ``` 27 | 28 | 假设待处理的python二进制包为test.pyd或test.so,放在当前目录下,二进制包中定义的模块名为test 29 | 30 | ``` 31 | python stubgen/stubgen.py -m test 32 | ``` 33 | 34 | 默认会在当前目录的out文件夹下生成test.pyi。将test.pyi文件拷贝到test.pyd同一目录下,即可让IDE识别到python包接口提示。 -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | QPanda Python\n 3 | Copyright (C) Origin Quantum 2017-2018\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | # keep import Operator.pyQPandaOperator first if runtime error occure 7 | # this runtime error is from cases like this: QPanda and pyQPanda is linked with option /Mt instead of /Md 8 | # then if use pybind11 above version 2.5.0, pybind11 will do garbage_collection to free pybind11 internal type info object 9 | # this will cause error of "allocate object in one thread heap but dellocate it from another thread" 10 | # change link option back to /Md will fix this bug, but let QPanda depends on system dynamic thread dll 11 | 12 | from .pyQPanda import * 13 | from .Operator.pyQPandaOperator import * 14 | from .utils import * 15 | from .Variational import back 16 | from .Visualization import * 17 | from .OriginService import * 18 | import warnings 19 | 20 | One = True 21 | Zero = False 22 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/CPPUtils.h" 7 | 8 | #include "XPathElement.h" 9 | 10 | using namespace antlr4::tree; 11 | using namespace antlr4::tree::xpath; 12 | 13 | XPathElement::XPathElement(const std::string &nodeName) { 14 | _nodeName = nodeName; 15 | } 16 | 17 | XPathElement::~XPathElement() { 18 | } 19 | 20 | std::vector XPathElement::evaluate(ParseTree * /*t*/) { 21 | return {}; 22 | } 23 | 24 | std::string XPathElement::toString() const { 25 | std::string inv = _invert ? "!" : ""; 26 | return antlrcpp::toString(*this) + "[" + inv + _nodeName + "]"; 27 | } 28 | 29 | void XPathElement::setInvert(bool value) { 30 | _invert = value; 31 | } 32 | -------------------------------------------------------------------------------- /include/Core/Debugger/QPUDebugger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Core/Utilities/QPandaNamespace.h" 5 | #include "Core/VirtualQuantumProcessor/QuantumGateParameter.h" 6 | 7 | QPANDA_BEGIN 8 | /** 9 | * @brief singleton debugger for QPU virtual machine 10 | * get all qubits register state vector while running QProg 11 | */ 12 | class QPUDebugger 13 | { 14 | public: 15 | struct State{ 16 | std::vector>* float_state{nullptr}; 17 | std::vector> *double_state{nullptr}; 18 | }; 19 | 20 | static QPUDebugger &instance(); 21 | void save_qstate_ref(std::vector> &stat); 22 | void save_qstate_ref(std::vector> &stat); 23 | const State &get_qstate() const; 24 | 25 | private: 26 | QPUDebugger() = default; 27 | ~QPUDebugger() = default; 28 | 29 | State m_qstate; 30 | }; 31 | 32 | QPANDA_END -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/QuantumGradient/quantum_gradient_qaoa_test.py: -------------------------------------------------------------------------------- 1 | from pyqpanda.Algorithm.QuantumGradient.quantum_gradient import * 2 | 3 | 4 | 5 | 6 | 7 | step=2 8 | gamma=(1-2*np.random.random_sample(step))*2 9 | beta=(1-2*np.random.random_sample(step))*pi/4 10 | qubit_number=7 11 | hp_7=PauliOperator({'Z0 Z4':0.73,'Z0 Z5':0.33,'Z0 Z6':0.5,'Z1 Z4':0.69,'Z1 Z5':0.36,'Z2 Z5':0.88,'Z2 Z6':0.58, 12 | 'Z3 Z5':0.67,'Z3 Z6':0.43}) 13 | Hd_7=PauliOperator({'X0':1,'X1':1,'X2':1,'X3':1,'X4':1,'X5':1,'X6':1}) 14 | Hp=hp_7*0.5 15 | Hp=flatten(Hp) 16 | 17 | init() 18 | qlist=qAlloc_many(qubit_number) 19 | qqat=qaoa(qubit_number,step,gamma,beta,Hp,Hd_7) 20 | 21 | 22 | cost=qqat.get_exp(qlist) 23 | print('cost',cost) 24 | 25 | #qqat.optimize(qlist,20,0.01) 26 | qqat.momentum_optimize(qlist,50,0.02,0.9) 27 | print(qqat.beta,qqat.gamma) 28 | exp2=qqat.get_exp(qlist) 29 | print('exp2',exp2) 30 | finalize() 31 | 32 | 33 | -------------------------------------------------------------------------------- /QAlg/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(QAlg) 3 | 4 | file(GLOB_RECURSE ALG_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) 5 | 6 | add_library(${LIB_QALG} STATIC ${ALG_SRC_CPP}) 7 | target_link_libraries(${LIB_QALG} ${LIB_QPANDA} ${LIB_COMPONENTS}) 8 | 9 | set_target_properties(${LIB_SHARED_QALG} PROPERTIES OUTPUT_NAME "${LIB_SHARED_QALG}") 10 | 11 | INSTALL(TARGETS ${LIB_QALG} 12 | EXPORT ${TARGETS_EXPORT_NAME} 13 | ARCHIVE DESTINATION lib 14 | LIBRARY DESTINATION lib 15 | RUNTIME DESTINATION bin) 16 | 17 | target_include_directories(${LIB_QALG} INTERFACE 18 | $ 19 | $) 20 | 21 | export(TARGETS ${LIB_QALG} 22 | APPEND FILE ${PROJECT_BINARY_DIR}/qalg-target.cmake 23 | NAMESPACE QPANDA:: 24 | ) 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/StdVector: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2009 Gael Guennebaud 5 | // Copyright (C) 2009 Hauke Heibel 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_STDVECTOR_MODULE_H 12 | #define EIGEN_STDVECTOR_MODULE_H 13 | 14 | #include "Core" 15 | #include 16 | 17 | #if EIGEN_COMP_MSVC && EIGEN_OS_WIN64 && (EIGEN_MAX_STATIC_ALIGN_BYTES<=16) /* MSVC auto aligns up to 16 bytes in 64 bit builds */ 18 | 19 | #define EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(...) 20 | 21 | #else 22 | 23 | #include "src/StlSupport/StdVector.h" 24 | 25 | #endif 26 | 27 | #endif // EIGEN_STDVECTOR_MODULE_H 28 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/tools/JoinPaths.cmake: -------------------------------------------------------------------------------- 1 | # This module provides function for joining paths 2 | # known from most languages 3 | # 4 | # SPDX-License-Identifier: (MIT OR CC0-1.0) 5 | # Copyright 2020 Jan Tojnar 6 | # https://github.com/jtojnar/cmake-snips 7 | # 8 | # Modelled after Python’s os.path.join 9 | # https://docs.python.org/3.7/library/os.path.html#os.path.join 10 | # Windows not supported 11 | function(join_paths joined_path first_path_segment) 12 | set(temp_path "${first_path_segment}") 13 | foreach(current_segment IN LISTS ARGN) 14 | if(NOT ("${current_segment}" STREQUAL "")) 15 | if(IS_ABSOLUTE "${current_segment}") 16 | set(temp_path "${current_segment}") 17 | else() 18 | set(temp_path "${temp_path}/${current_segment}") 19 | endif() 20 | endif() 21 | endforeach() 22 | set(${joined_path} "${temp_path}" PARENT_SCOPE) 23 | endfunction() 24 | -------------------------------------------------------------------------------- /pyQPanda/pydtrace.d: -------------------------------------------------------------------------------- 1 | /* Python DTrace provider */ 2 | 3 | provider python { 4 | probe function__entry(const char *, const char *, int); 5 | probe function__return(const char *, const char *, int); 6 | probe instance__new__start(const char *, const char *); 7 | probe instance__new__done(const char *, const char *); 8 | probe instance__delete__start(const char *, const char *); 9 | probe instance__delete__done(const char *, const char *); 10 | probe line(const char *, const char *, int); 11 | probe gc__start(int); 12 | probe gc__done(long); 13 | }; 14 | 15 | #pragma D attributes Evolving/Evolving/Common provider python provider 16 | #pragma D attributes Evolving/Evolving/Common provider python module 17 | #pragma D attributes Evolving/Evolving/Common provider python function 18 | #pragma D attributes Evolving/Evolving/Common provider python name 19 | #pragma D attributes Evolving/Evolving/Common provider python args 20 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/CXX11/src/ThreadPool/ThreadLocal.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2016 Benoit Steiner 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_CXX11_THREADPOOL_THREAD_LOCAL_H 11 | #define EIGEN_CXX11_THREADPOOL_THREAD_LOCAL_H 12 | 13 | // Try to come up with a portable implementation of thread local variables 14 | #if EIGEN_COMP_GNUC && EIGEN_GNUC_AT_MOST(4, 7) 15 | #define EIGEN_THREAD_LOCAL static __thread 16 | #elif EIGEN_COMP_CLANG 17 | #define EIGEN_THREAD_LOCAL static __thread 18 | #else 19 | #define EIGEN_THREAD_LOCAL static thread_local 20 | #endif 21 | 22 | #endif // EIGEN_CXX11_THREADPOOL_THREAD_LOCAL_H 23 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PlusBlockStartState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/BlockStartState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// Start of {@code (A|B|...)+} loop. Technically a decision state, but 14 | /// we don't use for code generation; somebody might need it, so I'm defining 15 | /// it for completeness. In reality, the node is the 16 | /// real decision-making note for {@code A+}. 17 | class ANTLR4CPP_PUBLIC PlusBlockStartState final : public BlockStartState { 18 | public: 19 | PlusLoopbackState *loopBackState = nullptr; 20 | 21 | virtual size_t getStateType() override; 22 | }; 23 | 24 | } // namespace atn 25 | } // namespace antlr4 26 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RangeTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC RangeTransition final : public Transition { 14 | public: 15 | const size_t from; 16 | const size_t to; 17 | 18 | RangeTransition(ATNState *target, size_t from, size_t to); 19 | 20 | virtual SerializationType getSerializationType() const override; 21 | 22 | virtual misc::IntervalSet label() const override; 23 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 24 | 25 | virtual std::string toString() const override; 26 | }; 27 | 28 | } // namespace atn 29 | } // namespace antlr4 30 | -------------------------------------------------------------------------------- /pyQPanda/README.md: -------------------------------------------------------------------------------- 1 | # How to use 2 | 3 | 1. (Python==3.6) there is no need to update .pyd library. You can use it directly 4 | 5 | 2. (Python!=3.6) First compile the QPanda project, and replace pyqpanda/pyQPanda.pyd with the release library. 6 | - Before compiling the QPanda project, the python path must be configured first. 7 | - Add the $(PythonPath)/include to your includepath, and $(PythonPath)/libs to your library path 8 | - Compile and obtain .pyd file 9 | 10 | 3. The Config.xml and MetadataConfig.xml must be placed right at the root directory of your python script 11 | 12 | # Brief 13 | 14 | pyqpanda : QPanda Basic API 15 | pyqpanda.utils : Extended QPanda API 16 | pyqpanda.Algorithm : pyqpanda algorithm pack 17 | pyqpanda.Algorithm.demo: Some algorithm demonstration 18 | pyqpanda.Algorithm.test: Test for pyqpanda.Algorithm 19 | pyqpanda.Algorithm.fragments: Some algorithm fragments 20 | pyqpanda.Hamiltonian : pyqpanda Hamiltonian utilities 21 | -------------------------------------------------------------------------------- /pyQPanda/postbuildtool/stubgen/regfilter.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def filterFunc(func_str: str): 4 | """ 5 | Remove specific prefixes and symbols from a function signature string for use in the pyQPanda package. 6 | This utility function processes the input string by eliminating "pyQPanda." and "QPanda::" prefixes, 7 | as well as any inline type annotations enclosed in angle brackets. It is intended to streamline the 8 | function signature representation for documentation and analysis purposes within the pyQPanda framework. 9 | 10 | Parameters: 11 | func_str (str): The function signature string to be processed. 12 | 13 | Returns: 14 | str: The modified function signature string with prefixes and annotations removed. 15 | """ 16 | s = func_str.replace("pyQPanda.", "") 17 | s = s.replace("QPanda::", "") 18 | r = re.findall(r"<[\w\s\.]{0,}>", s) 19 | for i in r: 20 | s = s.replace(i, "...") 21 | return s 22 | -------------------------------------------------------------------------------- /test/Overall_scan/QMachine/FullAmplitudeQVM.test.cpp: -------------------------------------------------------------------------------- 1 | /// AmplitudeQVM Inface test 2 | 3 | #include "QPanda.h" 4 | #include "gtest/gtest.h" 5 | 6 | USING_QPANDA 7 | 8 | 9 | TEST(AmplitudeQVMCase,test) { 10 | CPUQVM qvm; 11 | qvm.init(); 12 | auto qubits = qvm.qAllocMany(4); 13 | auto cbits = qvm.cAllocMany(4); 14 | 15 | 16 | QProg prog; 17 | prog << H(qubits[0]) 18 | << CNOT(qubits[0], qubits[1]) 19 | << CNOT(qubits[1], qubits[2]) 20 | << CNOT(qubits[2], qubits[3]) 21 | << Measure(qubits[0], cbits[0]); 22 | 23 | auto result = qvm.runWithConfiguration(prog, cbits, 1000); 24 | 25 | for (auto& val : result) 26 | { 27 | //std::cout << val.first << ", " << val.second << std::endl; 28 | } 29 | 30 | auto result1 = directlyRun(prog); 31 | for (auto& val : result1) 32 | { 33 | //std::cout << val.first << ", " << val.second << std::endl; 34 | } 35 | qvm.finalize(); 36 | } -------------------------------------------------------------------------------- /pyQPanda/example/test_main.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | import unittest 4 | from unittest.runner import TextTestRunner 5 | from unittest.suite import TestSuite 6 | 7 | 8 | global TESTOPT 9 | TESTOPT = "single" 10 | 11 | 12 | if TESTOPT == "all": 13 | def test(): 14 | # Run all test cases 15 | case_dir = ".\\" 16 | discover = unittest.defaultTestLoader.discover(case_dir, pattern="test_*.py", top_level_dir=None) 17 | runner = TextTestRunner(verbosity=2) 18 | runner.run(discover) 19 | 20 | elif TESTOPT == "single": 21 | def test(): 22 | # Run a Single Test Case 23 | suite = unittest.TestSuite() 24 | suite.addTests(unittest.TestLoader().loadTestsFromName("test_Grover.Test_Grover.test_grover2")) 25 | runner = TextTestRunner(verbosity=2) 26 | runner.run(suite) 27 | 28 | else: 29 | def test(): 30 | print("TEST OPTION ERROR!") 31 | 32 | if __name__ == '__main__': 33 | test() 34 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/EmptyPredictionContext.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/SingletonPredictionContext.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC EmptyPredictionContext : public SingletonPredictionContext { 14 | public: 15 | EmptyPredictionContext(); 16 | 17 | virtual bool isEmpty() const override; 18 | virtual size_t size() const override; 19 | virtual Ref getParent(size_t index) const override; 20 | virtual size_t getReturnState(size_t index) const override; 21 | virtual std::string toString() const override; 22 | 23 | virtual bool operator == (const PredictionContext &o) const override; 24 | }; 25 | 26 | } // namespace atn 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/ANTLRFileStream.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "support/StringUtils.h" 7 | 8 | #include "ANTLRFileStream.h" 9 | 10 | using namespace antlr4; 11 | 12 | ANTLRFileStream::ANTLRFileStream(const std::string &fileName) { 13 | _fileName = fileName; 14 | loadFromFile(fileName); 15 | } 16 | 17 | void ANTLRFileStream::loadFromFile(const std::string &fileName) { 18 | _fileName = fileName; 19 | if (_fileName.empty()) { 20 | return; 21 | } 22 | 23 | #ifdef _MSC_VER 24 | std::ifstream stream(antlrcpp::s2ws(fileName), std::ios::binary); 25 | #else 26 | std::ifstream stream(fileName, std::ios::binary); 27 | #endif 28 | 29 | ANTLRInputStream::load(stream); 30 | } 31 | 32 | std::string ANTLRFileStream::getSourceName() const { 33 | return _fileName; 34 | } 35 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/TerminalNode.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/ParseTree.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNode : public ParseTree { 14 | public: 15 | ~TerminalNode() override; 16 | 17 | virtual Token* getSymbol() = 0; 18 | 19 | /** Set the parent for this leaf node. 20 | * 21 | * Technically, this is not backward compatible as it changes 22 | * the interface but no one was able to create custom 23 | * TerminalNodes anyway so I'm adding as it improves internal 24 | * code quality. 25 | * 26 | * @since 4.7 27 | */ 28 | virtual void setParent(RuleContext *parent) = 0; 29 | }; 30 | 31 | } // namespace tree 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /ThirdParty/nlopt/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(NLOPT) 3 | 4 | 5 | file(GLOB_RECURSE OPT_SRC_H ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h) 6 | file(GLOB_RECURSE OPT_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp) 7 | add_library(${LIB_NLOPT} STATIC ${OPT_SRC_H} ${OPT_SRC_CPP}) 8 | 9 | 10 | 11 | install(FILES ${OPT_SRC_H} DESTINATION 12 | ${CMAKE_INSTALL_PREFIX}/include/qpanda2/ThirdParty/nlopt/include) 13 | 14 | INSTALL(TARGETS ${LIB_NLOPT} 15 | EXPORT ${TARGETS_EXPORT_NAME} 16 | ARCHIVE DESTINATION lib 17 | LIBRARY DESTINATION lib 18 | RUNTIME DESTINATION bin) 19 | 20 | target_include_directories(${LIB_NLOPT} INTERFACE 21 | $ 22 | $) 23 | 24 | export(TARGETS ${LIB_NLOPT} 25 | APPEND FILE ${PROJECT_BINARY_DIR}/nlopt-target.cmake 26 | NAMESPACE QPANDA:: 27 | ) -------------------------------------------------------------------------------- /ThirdParty/Eigen/src/Core/util/ReenableStupidWarnings.h: -------------------------------------------------------------------------------- 1 | #ifdef EIGEN_WARNINGS_DISABLED 2 | #undef EIGEN_WARNINGS_DISABLED 3 | 4 | #ifndef EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS 5 | #ifdef _MSC_VER 6 | #pragma warning( pop ) 7 | #elif defined __INTEL_COMPILER 8 | #pragma warning pop 9 | #elif defined __clang__ 10 | #pragma clang diagnostic pop 11 | #elif defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) 12 | #pragma GCC diagnostic pop 13 | #endif 14 | 15 | #if defined __NVCC__ 16 | // Don't reenable the diagnostic messages, as it turns out these messages need 17 | // to be disabled at the point of the template instantiation (i.e the user code) 18 | // otherwise they'll be triggered by nvcc. 19 | // #pragma diag_default code_is_unreachable 20 | // #pragma diag_default initialization_not_reachable 21 | // #pragma diag_default 2651 22 | // #pragma diag_default 2653 23 | #endif 24 | 25 | #endif 26 | 27 | #endif // EIGEN_WARNINGS_DISABLED 28 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/Householder: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_HOUSEHOLDER_MODULE_H 9 | #define EIGEN_HOUSEHOLDER_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Householder_Module Householder module 16 | * This module provides Householder transformations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | */ 22 | 23 | #include "src/Householder/Householder.h" 24 | #include "src/Householder/HouseholderSequence.h" 25 | #include "src/Householder/BlockHouseholder.h" 26 | 27 | #include "src/Core/util/ReenableStupidWarnings.h" 28 | 29 | #endif // EIGEN_HOUSEHOLDER_MODULE_H 30 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 31 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/SetTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// 14 | /// A transition containing a set of values. 15 | class ANTLR4CPP_PUBLIC SetTransition : public Transition { 16 | public: 17 | const misc::IntervalSet set; 18 | 19 | SetTransition(ATNState *target, const misc::IntervalSet &set); 20 | 21 | virtual SerializationType getSerializationType() const override; 22 | 23 | virtual misc::IntervalSet label() const override; 24 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/ANTLRFileStream.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ANTLRInputStream.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// This is an ANTLRInputStream that is loaded from a file all at once 13 | /// when you construct the object (or call load()). 14 | // TODO: this class needs testing. 15 | class ANTLR4CPP_PUBLIC ANTLRFileStream : public ANTLRInputStream { 16 | protected: 17 | std::string _fileName; // UTF-8 encoded file name. 18 | 19 | public: 20 | // Assumes a file name encoded in UTF-8 and file content in the same encoding (with or w/o BOM). 21 | ANTLRFileStream(const std::string &fileName); 22 | 23 | virtual void loadFromFile(const std::string &fileName); 24 | virtual std::string getSourceName() const override; 25 | }; 26 | 27 | } // namespace antlr4 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/dfa/DFASerializer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Vocabulary.h" 9 | 10 | namespace antlr4 { 11 | namespace dfa { 12 | 13 | /// A DFA walker that knows how to dump them to serialized strings. 14 | class ANTLR4CPP_PUBLIC DFASerializer { 15 | public: 16 | DFASerializer(const DFA *dfa, const std::vector& tnames); 17 | DFASerializer(const DFA *dfa, const Vocabulary &vocabulary); 18 | virtual ~DFASerializer(); 19 | 20 | virtual std::string toString() const; 21 | 22 | protected: 23 | virtual std::string getEdgeLabel(size_t i) const; 24 | virtual std::string getStateString(DFAState *s) const; 25 | 26 | private: 27 | const DFA *_dfa; 28 | const Vocabulary &_vocabulary; 29 | }; 30 | 31 | } // namespace atn 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/pattern/TagChunk.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Exceptions.h" 7 | 8 | #include "tree/pattern/TagChunk.h" 9 | 10 | using namespace antlr4::tree::pattern; 11 | 12 | TagChunk::TagChunk(const std::string &tag) : TagChunk("", tag) { 13 | } 14 | 15 | TagChunk::TagChunk(const std::string &label, const std::string &tag) : _tag(tag), _label(label) { 16 | if (tag.empty()) { 17 | throw IllegalArgumentException("tag cannot be null or empty"); 18 | } 19 | 20 | } 21 | 22 | TagChunk::~TagChunk() { 23 | } 24 | 25 | std::string TagChunk::getTag() { 26 | return _tag; 27 | } 28 | 29 | std::string TagChunk::getLabel() { 30 | return _label; 31 | } 32 | 33 | std::string TagChunk::toString() { 34 | if (!_label.empty()) { 35 | return _label + ":" + _tag; 36 | } 37 | 38 | return _tag; 39 | } 40 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/Splines: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 20010-2011 Hauke Heibel 5 | // 6 | // This Source Code Form is subject to the terms of the Mozilla 7 | // Public License v. 2.0. If a copy of the MPL was not distributed 8 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | #ifndef EIGEN_SPLINES_MODULE_H 11 | #define EIGEN_SPLINES_MODULE_H 12 | 13 | namespace Eigen 14 | { 15 | /** 16 | * \defgroup Splines_Module Spline and spline fitting module 17 | * 18 | * This module provides a simple multi-dimensional spline class while 19 | * offering most basic functionality to fit a spline to point sets. 20 | * 21 | * \code 22 | * #include 23 | * \endcode 24 | */ 25 | } 26 | 27 | #include "src/Splines/SplineFwd.h" 28 | #include "src/Splines/Spline.h" 29 | #include "src/Splines/SplineFitting.h" 30 | 31 | #endif // EIGEN_SPLINES_MODULE_H 32 | -------------------------------------------------------------------------------- /pyQPanda/test_circuit_layer.py: -------------------------------------------------------------------------------- 1 | import pyqpanda.pyQPanda as pq 2 | 3 | class InitQMachine: 4 | def __init__(self, quBitCnt, cBitCnt, machineType=pq.QMachineType.CPU): 5 | self.m_machine = pq.init_quantum_machine(machineType) 6 | self.m_qlist = self.m_machine.qAlloc_many(quBitCnt) 7 | self.m_clist = self.m_machine.cAlloc_many(cBitCnt) 8 | 9 | 10 | if __name__ == "__main__": 11 | init_machine = InitQMachine(8, 8) 12 | qlist = init_machine.m_qlist 13 | clist = init_machine.m_clist 14 | prog = pq.QProg() 15 | 16 | cir = pq.QCircuit() 17 | cir.insert( pq.H(qlist[0])).insert( pq.S(qlist[1])).insert( 18 | pq.CNOT(qlist[0], qlist[1])).insert(pq.CZ(qlist[1],qlist[2])) 19 | 20 | prog.insert(cir).insert(pq.CU(1, 2, 3, 4,qlist[0],qlist[2])).insert(pq.S(qlist[2])).insert( 21 | pq.CR(qlist[2],qlist[1],3.14 / 2)) 22 | 23 | 24 | layerinfo = pq.circuit_layer(prog); 25 | print( "circuit layer : " , layerinfo[0].size()) 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /CMakeSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "x64-Debug", 5 | "generator": "Ninja", 6 | "configurationType": "Debug", 7 | "inheritEnvironments": [ "msvc_x64_x64" ], 8 | "buildRoot": "${projectDir}\\build\\${name}", 9 | "installRoot": "C:\\QPanda2", 10 | "cmakeCommandArgs": "-DUSE_PYQPANDA=ON -DFIND_CUDA=ON -DUSE_EXTENSION=OFF -DDOCKER=OFF -DUSE_GTEST=ON -DUSE_APPLICATIONS=ON -DUSE_CURL=ON -DUSE_QHETU=OFF", 11 | "buildCommandArgs": "-j8", 12 | "ctestCommandArgs": "" 13 | }, 14 | { 15 | "name": "x64-Release", 16 | "generator": "Ninja", 17 | "configurationType": "Release", 18 | "inheritEnvironments": [ "msvc_x64_x64" ], 19 | "buildRoot": "${projectDir}\\build\\${name}", 20 | "installRoot": "C:\\QPanda2", 21 | "cmakeCommandArgs": "-DUSE_PYQPANDA=ON -DFIND_CUDA=ON -DUSE_EXTENSION=OFF -DUSE_GTEST=ON -DUSE_APPLICATIONS=ON -DUSE_CURL=ON -DUSE_QHETU=OFF", 22 | "buildCommandArgs": "-j4", 23 | "ctestCommandArgs": "" 24 | } 25 | ] 26 | } -------------------------------------------------------------------------------- /Core/Utilities/Compiler/QASMToOriginIR.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Utilities/Compiler/QASMToOriginIR.hpp" 2 | 3 | 4 | QPANDA_BEGIN 5 | 6 | std::string qasmfile2str(const std::string& filename) { 7 | std::stringstream ss; 8 | std::ifstream ifs; 9 | ifs.open(filename); 10 | if (ifs.is_open()) { 11 | std::string line; 12 | std::cout << "### opened qasm file:" << filename << std::endl; 13 | while (std::getline(ifs, line)) { 14 | ss << line; 15 | } 16 | ifs.close(); 17 | } 18 | else { 19 | std::cerr << "###Error: qasmfile2str open " << filename << "failed." << std::endl; 20 | exit(-1); 21 | return {}; 22 | } 23 | return ss.str(); 24 | } 25 | 26 | std::string convert_qasm_to_originir(std::string qasm_filepath) { 27 | return QuantumComputation::fromQASM(qasmfile2str(qasm_filepath)).toOriginIR(); 28 | } 29 | std::string convert_qasm_string_to_originir(std::string qasm_str) { 30 | return QuantumComputation::fromQASM(qasm_str).toOriginIR(); 31 | } 32 | 33 | QPANDA_END 34 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/AtomTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | /// TO_DO: make all transitions sets? no, should remove set edges. 14 | class ANTLR4CPP_PUBLIC AtomTransition final : public Transition { 15 | public: 16 | /// The token type or character value; or, signifies special label. 17 | const size_t _label; 18 | 19 | AtomTransition(ATNState *target, size_t label); 20 | 21 | virtual SerializationType getSerializationType() const override; 22 | 23 | virtual misc::IntervalSet label() const override; 24 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 25 | 26 | virtual std::string toString() const override; 27 | }; 28 | 29 | } // namespace atn 30 | } // namespace antlr4 31 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/ArpackSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla 6 | // Public License v. 2.0. If a copy of the MPL was not distributed 7 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | #ifndef EIGEN_ARPACKSUPPORT_MODULE_H 10 | #define EIGEN_ARPACKSUPPORT_MODULE_H 11 | 12 | #include 13 | 14 | #include 15 | 16 | /** \defgroup ArpackSupport_Module Arpack support module 17 | * 18 | * This module provides a wrapper to Arpack, a library for sparse eigenvalue decomposition. 19 | * 20 | * \code 21 | * #include 22 | * \endcode 23 | */ 24 | 25 | #include 26 | #include "src/Eigenvalues/ArpackSelfAdjointEigenSolver.h" 27 | 28 | #include 29 | 30 | #endif // EIGEN_ARPACKSUPPORT_MODULE_H 31 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 32 | -------------------------------------------------------------------------------- /ThirdParty/bplus-tree/include/private/tree.h: -------------------------------------------------------------------------------- 1 | #ifndef _PRIVATE_TREE_H_ 2 | #define _PRIVATE_TREE_H_ 3 | 4 | #include "private/writer.h" 5 | #include "private/pages.h" 6 | #include "Core/Utilities/Tools/ReadWriteLock.h" 7 | 8 | #define BP__HEAD_SIZE sizeof(uint64_t) * 4 9 | 10 | #define BP_TREE_PRIVATE \ 11 | BP_WRITER_PRIVATE \ 12 | SharedMutex rwlock; \ 13 | bp__tree_head_t head; \ 14 | bp_compare_cb compare_cb; 15 | 16 | typedef struct bp__tree_head_s bp__tree_head_t; 17 | 18 | int bp__init(bp_db_t *tree); 19 | void bp__destroy(bp_db_t *tree); 20 | 21 | int bp__tree_read_head(bp__writer_t *w, void *data); 22 | int bp__tree_write_head(bp__writer_t *w, void *data); 23 | 24 | int bp__default_compare_cb(const bp_key_t *a, const bp_key_t *b); 25 | int bp__default_filter_cb(void *arg, const bp_key_t *key); 26 | 27 | 28 | struct bp__tree_head_s { 29 | uint64_t offset; 30 | uint64_t config; 31 | uint64_t page_size; 32 | uint64_t hash; 33 | 34 | bp__page_t *page; 35 | }; 36 | 37 | #endif /* _PRIVATE_TREE_H_ */ 38 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/DecisionInfo.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/ErrorInfo.h" 7 | #include "atn/LookaheadEventInfo.h" 8 | 9 | #include "atn/DecisionInfo.h" 10 | 11 | using namespace antlr4::atn; 12 | 13 | DecisionInfo::DecisionInfo(size_t decision) : decision(decision) { 14 | } 15 | 16 | std::string DecisionInfo::toString() const { 17 | std::stringstream ss; 18 | 19 | ss << "{decision=" << decision << ", contextSensitivities=" << contextSensitivities.size() << ", errors="; 20 | ss << errors.size() << ", ambiguities=" << ambiguities.size() << ", SLL_lookahead=" << SLL_TotalLook; 21 | ss << ", SLL_ATNTransitions=" << SLL_ATNTransitions << ", SLL_DFATransitions=" << SLL_DFATransitions; 22 | ss << ", LL_Fallback=" << LL_Fallback << ", LL_lookahead=" << LL_TotalLook << ", LL_ATNTransitions=" << LL_ATNTransitions << '}'; 23 | 24 | return ss.str(); 25 | } 26 | -------------------------------------------------------------------------------- /pyQPanda/pyqpanda/Algorithm/test/__init__.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Test Module\n 3 | Copyright (C) Origin Quantum 2017-2024\n 4 | Licensed Under Apache Licence 2.0 5 | ''' 6 | from pyqpanda import * 7 | from . import state_preparation_test 8 | 9 | def full_test(): 10 | """ 11 | Executes a series of full tests on the quantum algorithms within the test list. 12 | 13 | The function iterates over a list of test objects, each of which should have a 14 | `full_test()` method to perform the actual test. After each test, it prints the 15 | result and the current test number out of the total number of tests. 16 | 17 | This function is intended for internal use within the pyQPanda package to validate 18 | the functionality of quantum algorithms when running on a quantum circuit simulator 19 | or quantum cloud service. 20 | """ 21 | test_list=[state_preparation_test] 22 | 23 | for i in range(len(test_list)): 24 | test_list[i].full_test() 25 | print(" ") 26 | print('Full test: %d/%d pass' % (i+1,len(test_list))) 27 | print(" ") 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/AtomTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | #include "atn/Transition.h" 8 | 9 | #include "atn/AtomTransition.h" 10 | 11 | using namespace antlr4::misc; 12 | using namespace antlr4::atn; 13 | 14 | AtomTransition::AtomTransition(ATNState *target, size_t label) : Transition(target), _label(label) { 15 | } 16 | 17 | Transition::SerializationType AtomTransition::getSerializationType() const { 18 | return ATOM; 19 | } 20 | 21 | IntervalSet AtomTransition::label() const { 22 | return IntervalSet::of((int)_label); 23 | } 24 | 25 | bool AtomTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 26 | return _label == symbol; 27 | } 28 | 29 | std::string AtomTransition::toString() const { 30 | return "ATOM " + Transition::toString() + " { label: " + std::to_string(_label) + " }"; 31 | } 32 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/EmptyPredictionContext.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/EmptyPredictionContext.h" 7 | 8 | using namespace antlr4::atn; 9 | 10 | EmptyPredictionContext::EmptyPredictionContext() : SingletonPredictionContext(nullptr, EMPTY_RETURN_STATE) { 11 | } 12 | 13 | bool EmptyPredictionContext::isEmpty() const { 14 | return true; 15 | } 16 | 17 | size_t EmptyPredictionContext::size() const { 18 | return 1; 19 | } 20 | 21 | Ref EmptyPredictionContext::getParent(size_t /*index*/) const { 22 | return nullptr; 23 | } 24 | 25 | size_t EmptyPredictionContext::getReturnState(size_t /*index*/) const { 26 | return returnState; 27 | } 28 | 29 | bool EmptyPredictionContext::operator == (const PredictionContext &o) const { 30 | return this == &o; 31 | } 32 | 33 | std::string EmptyPredictionContext::toString() const { 34 | return "$"; 35 | } 36 | -------------------------------------------------------------------------------- /ThirdParty/pybind11/tools/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # Source: https://gitlab.kitware.com/cmake/community/-/wikis/FAQ#can-i-do-make-uninstall-with-cmake 2 | 3 | if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt") 5 | endif() 6 | 7 | file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 8 | string(REGEX REPLACE "\n" ";" files "${files}") 9 | foreach(file ${files}) 10 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 11 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 12 | exec_program( 13 | "@CMAKE_COMMAND@" ARGS 14 | "-E remove \"$ENV{DESTDIR}${file}\"" 15 | OUTPUT_VARIABLE rm_out 16 | RETURN_VALUE rm_retval) 17 | if(NOT "${rm_retval}" STREQUAL 0) 18 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 19 | endif() 20 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 22 | endif() 23 | endforeach() 24 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/Sparse: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_SPARSE_MODULE_H 9 | #define EIGEN_SPARSE_MODULE_H 10 | 11 | /** \defgroup Sparse_Module Sparse meta-module 12 | * 13 | * Meta-module including all related modules: 14 | * - \ref SparseCore_Module 15 | * - \ref OrderingMethods_Module 16 | * - \ref SparseCholesky_Module 17 | * - \ref SparseLU_Module 18 | * - \ref SparseQR_Module 19 | * - \ref IterativeLinearSolvers_Module 20 | * 21 | \code 22 | #include 23 | \endcode 24 | */ 25 | 26 | #include "SparseCore" 27 | #include "OrderingMethods" 28 | #ifndef EIGEN_MPL2_ONLY 29 | #include "SparseCholesky" 30 | #endif 31 | #include "SparseLU" 32 | #include "SparseQR" 33 | #include "IterativeLinearSolvers" 34 | 35 | #endif // EIGEN_SPARSE_MODULE_H 36 | 37 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/TerminalNodeImpl.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "tree/TerminalNode.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC TerminalNodeImpl : public virtual TerminalNode { 14 | public: 15 | Token *symbol; 16 | 17 | TerminalNodeImpl(Token *symbol); 18 | 19 | virtual Token* getSymbol() override; 20 | virtual void setParent(RuleContext *parent) override; 21 | virtual misc::Interval getSourceInterval() override; 22 | 23 | virtual antlrcpp::Any accept(ParseTreeVisitor *visitor) override; 24 | 25 | virtual std::string getText() override; 26 | virtual std::string toStringTree(Parser *parser) override; 27 | virtual std::string toString() override; 28 | virtual std::string toStringTree() override; 29 | 30 | }; 31 | 32 | } // namespace tree 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/Jacobi: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_JACOBI_MODULE_H 9 | #define EIGEN_JACOBI_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | /** \defgroup Jacobi_Module Jacobi module 16 | * This module provides Jacobi and Givens rotations. 17 | * 18 | * \code 19 | * #include 20 | * \endcode 21 | * 22 | * In addition to listed classes, it defines the two following MatrixBase methods to apply a Jacobi or Givens rotation: 23 | * - MatrixBase::applyOnTheLeft() 24 | * - MatrixBase::applyOnTheRight(). 25 | */ 26 | 27 | #include "src/Jacobi/Jacobi.h" 28 | 29 | #include "src/Core/util/ReenableStupidWarnings.h" 30 | 31 | #endif // EIGEN_JACOBI_MODULE_H 32 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 33 | 34 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/LexerNoViableAltException.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "RecognitionException.h" 9 | #include "atn/ATNConfigSet.h" 10 | 11 | namespace antlr4 { 12 | 13 | class ANTLR4CPP_PUBLIC LexerNoViableAltException : public RecognitionException { 14 | public: 15 | LexerNoViableAltException(Lexer *lexer, CharStream *input, size_t startIndex, 16 | atn::ATNConfigSet *deadEndConfigs); 17 | 18 | virtual size_t getStartIndex(); 19 | virtual atn::ATNConfigSet* getDeadEndConfigs(); 20 | virtual std::string toString(); 21 | 22 | private: 23 | /// Matching attempted at what input index? 24 | const size_t _startIndex; 25 | 26 | /// Which configurations did we try at input.index() that couldn't match input.LA(1)? 27 | atn::ATNConfigSet *_deadEndConfigs; 28 | 29 | }; 30 | 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/NotSetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "atn/NotSetTransition.h" 7 | #include "atn/ATNState.h" 8 | #include "misc/IntervalSet.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | NotSetTransition::NotSetTransition(ATNState *target, const misc::IntervalSet &set) : SetTransition(target, set) { 14 | } 15 | 16 | Transition::SerializationType NotSetTransition::getSerializationType() const { 17 | return NOT_SET; 18 | } 19 | 20 | bool NotSetTransition::matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const { 21 | return symbol >= minVocabSymbol && symbol <= maxVocabSymbol 22 | && !SetTransition::matches(symbol, minVocabSymbol, maxVocabSymbol); 23 | } 24 | 25 | std::string NotSetTransition::toString() const { 26 | return "NOT_SET " + Transition::toString() + " { " + SetTransition::toString() + " }"; 27 | } 28 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/PrecedencePredicateTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/AbstractPredicateTransition.h" 9 | #include "SemanticContext.h" 10 | 11 | namespace antlr4 { 12 | namespace atn { 13 | 14 | class ANTLR4CPP_PUBLIC PrecedencePredicateTransition final : public AbstractPredicateTransition { 15 | public: 16 | const int precedence; 17 | 18 | PrecedencePredicateTransition(ATNState *target, int precedence); 19 | 20 | virtual SerializationType getSerializationType() const override; 21 | virtual bool isEpsilon() const override; 22 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 23 | Ref getPredicate() const; 24 | virtual std::string toString() const override; 25 | 26 | }; 27 | 28 | } // namespace atn 29 | } // namespace antlr4 30 | -------------------------------------------------------------------------------- /Core/Variational/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "Core/Variational/utils.h" 2 | 3 | namespace QPanda 4 | { 5 | namespace Variational { 6 | 7 | MatrixXd eval(var root, bool iter){ 8 | expression exp(root); 9 | if(iter) 10 | return exp.propagate(exp.findLeaves()); 11 | else 12 | return exp.propagate(); 13 | } 14 | 15 | void back(const var& root, 16 | std::unordered_map& derivative){ 17 | expression exp(root); 18 | exp.backpropagate(derivative); 19 | } 20 | 21 | void back(expression& exp, 22 | std::unordered_map& derivative) { 23 | exp.backpropagate(derivative); 24 | } 25 | 26 | void back(expression& exp, 27 | std::unordered_map& derivative, 28 | const std::vector& leaves) 29 | { 30 | exp.backpropagate(derivative, leaves); 31 | } 32 | 33 | void back(const var& root, 34 | std::unordered_map& derivative, 35 | const std::vector& leaves) 36 | { 37 | expression exp(root); 38 | exp.backpropagate(derivative, leaves); 39 | } 40 | 41 | } 42 | 43 | 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Core/QuantumMachine/OriginPhysicalQubit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2023 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "OriginQuantumMachine.h" 18 | using namespace std; 19 | USING_QPANDA 20 | OriginPhysicalQubit::OriginPhysicalQubit() 21 | { 22 | bIsOccupied = false; 23 | } 24 | 25 | bool OriginPhysicalQubit::getOccupancy() const 26 | { 27 | return bIsOccupied; 28 | } 29 | 30 | void OriginPhysicalQubit::setOccupancy(bool bStat) 31 | { 32 | bIsOccupied = bStat; 33 | } 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/misc/InterpreterDataReader.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace misc { 12 | 13 | struct InterpreterData { 14 | atn::ATN atn; 15 | dfa::Vocabulary vocabulary; 16 | std::vector ruleNames; 17 | std::vector channels; // Only valid for lexer grammars. 18 | std::vector modes; // ditto 19 | 20 | InterpreterData() {}; // For invalid content. 21 | InterpreterData(std::vector const& literalNames, std::vector const& symbolicNames); 22 | }; 23 | 24 | // A class to read plain text interpreter data produced by ANTLR. 25 | class ANTLR4CPP_PUBLIC InterpreterDataReader { 26 | public: 27 | static InterpreterData parseFile(std::string const& fileName); 28 | }; 29 | 30 | } // namespace atn 31 | } // namespace antlr4 32 | -------------------------------------------------------------------------------- /pyQPanda/Stabilizer.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | x = [5,10,15,20,25,30] 4 | y = [27,36,52,64,90,101] 5 | 6 | plt.xlabel('depth') # x轴标题 7 | plt.ylabel('Time(s)') # y轴标题 8 | 9 | 10 | plt.title("1000 qubits random clifford circuit with 1 million shots") 11 | plt.plot(x, y, marker='o', markersize=3) # 绘制折线图,添加数据点,设置点的大小 12 | 13 | # 设置横纵坐标 14 | plt.xticks(x) 15 | 16 | # plt.yticks([0.84,0.86,0.88,0.90]) 17 | plt.yticks([20,40,60,80,100,120]) 18 | 19 | # for a, b in zip(x, y1): 20 | # plt.text(a, b, b, ha='center', va='bottom', fontsize=10) # 设置数据标签位置及大小 21 | # for a, b in zip(x, y2): 22 | # plt.text(a, b, b, ha='center', va='bottom', fontsize=10) 23 | # for a, b in zip(x, y3): 24 | # plt.text(a, b, b, ha='center', va='bottom', fontsize=10) 25 | # for a, b in zip(x, y4): 26 | # plt.text(a, b, b, ha='center', va='bottom', fontsize=10) 27 | 28 | # plt.legend(['$\lambda_{2}$ = 0.2', '$\lambda_{2}$ = 0.4', '$\lambda_{2}$ = 0.6', '$\lambda_{2}$ = 0.8'], loc="lower right") # 设置折线名称 29 | 30 | plt.show() # 显示折线图 31 | # plt.savefig('./figure2/line_lamda_shs148k.jpg', dpi=200) -------------------------------------------------------------------------------- /test/Overall_scan/QCricut/ProbMeasure.test.cpp: -------------------------------------------------------------------------------- 1 | /// ProbMeasure class inface test 2 | 3 | #include "QPanda.h" 4 | #include "gtest/gtest.h" 5 | 6 | USING_QPANDA 7 | 8 | TEST(ProbMeasureCase,test) { 9 | auto qvm = CPUQVM(); 10 | qvm.init(); 11 | auto qubits = qvm.qAllocMany(2); 12 | 13 | QProg prog; 14 | prog << H(qubits[0]) 15 | << CNOT(qubits[0], qubits[1]); 16 | 17 | //std::cout << "probRunDict: " << std::endl; 18 | auto result1 = qvm.probRunDict(prog, qubits); 19 | for (auto& val : result1) 20 | { 21 | //std::cout << val.first << ", " << val.second << std::endl; 22 | } 23 | 24 | //std::cout << "probRunTupleList: " << std::endl; 25 | auto result2 = qvm.probRunTupleList(prog, qubits); 26 | for (auto& val : result2) 27 | { 28 | //std::cout << val.first << ", " << val.second << std::endl; 29 | } 30 | 31 | //std::cout << "probRunList: " << std::endl; 32 | auto result3 = qvm.probRunList(prog, qubits); 33 | for (auto& val : result3) 34 | { 35 | // std::cout << val << std::endl; 36 | } 37 | 38 | 39 | } -------------------------------------------------------------------------------- /test/Overall_scan/Utilities/QProgInfo/QdrawAndlayerProg.test.cpp: -------------------------------------------------------------------------------- 1 | #include "QPanda.h" 2 | #include "gtest/gtest.h" 3 | 4 | USING_QPANDA 5 | 6 | TEST(drawAndlayerPro,test) { 7 | auto qvm = CPUQVM(); 8 | qvm.init(); 9 | auto q = qvm.qAllocMany(3); 10 | auto c = qvm.cAllocMany(3); 11 | QProg prog; 12 | QCircuit cir1, cir2; 13 | 14 | auto gate = S(q[1]); 15 | // gate.setDagger(true); 16 | cir1 << H(q[0]) << S(q[1]) << CNOT(q[0], q[1]) << CZ(q[1], q[2]); 17 | //cir1.setDagger(true); 18 | cir2 << cir1 << CU(1, 2, 3, 4, q[0], q[2]) << S(q[2]) << CR(q[2], q[1], PI / 2); 19 | //cir2.setDagger(true); 20 | prog << cir2;// << MeasureAll(q, c); 21 | 22 | 23 | 24 | std::cout << prog << std::endl; 25 | 26 | auto layerinfo = circuit_layer(prog); 27 | 28 | std::cout << " circuit layer " << layerinfo.first << std::endl; 29 | 30 | 31 | for (auto& ve : layerinfo.second) { 32 | for (int i = 0; i < ve.size(); ++i) { 33 | std::cout << ve[i].m_gate_type << " "; 34 | } 35 | std::cout << std::endl; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/Skyline: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla 6 | // Public License v. 2.0. If a copy of the MPL was not distributed 7 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | #ifndef EIGEN_SKYLINE_MODULE_H 10 | #define EIGEN_SKYLINE_MODULE_H 11 | 12 | 13 | #include "Eigen/Core" 14 | 15 | #include "Eigen/src/Core/util/DisableStupidWarnings.h" 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /** 23 | * \defgroup Skyline_Module Skyline module 24 | * 25 | * 26 | * 27 | * 28 | */ 29 | 30 | #include "src/Skyline/SkylineUtil.h" 31 | #include "src/Skyline/SkylineMatrixBase.h" 32 | #include "src/Skyline/SkylineStorage.h" 33 | #include "src/Skyline/SkylineMatrix.h" 34 | #include "src/Skyline/SkylineInplaceLU.h" 35 | #include "src/Skyline/SkylineProduct.h" 36 | 37 | #include "Eigen/src/Core/util/ReenableStupidWarnings.h" 38 | 39 | #endif // EIGEN_SKYLINE_MODULE_H 40 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/SetTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "Token.h" 7 | #include "misc/IntervalSet.h" 8 | 9 | #include "atn/SetTransition.h" 10 | 11 | using namespace antlr4; 12 | using namespace antlr4::atn; 13 | 14 | SetTransition::SetTransition(ATNState *target, const misc::IntervalSet &aSet) 15 | : Transition(target), set(aSet.isEmpty() ? misc::IntervalSet::of(Token::INVALID_TYPE) : aSet) { 16 | } 17 | 18 | Transition::SerializationType SetTransition::getSerializationType() const { 19 | return SET; 20 | } 21 | 22 | misc::IntervalSet SetTransition::label() const { 23 | return set; 24 | } 25 | 26 | bool SetTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 27 | return set.contains(symbol); 28 | } 29 | 30 | std::string SetTransition::toString() const { 31 | return "SET " + Transition::toString() + " { set: " + set.toString() + "}"; 32 | } 33 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/StarLoopEntryState.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/DecisionState.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC StarLoopEntryState final : public DecisionState { 14 | public: 15 | StarLoopEntryState(); 16 | 17 | /** 18 | * Indicates whether this state can benefit from a precedence DFA during SLL 19 | * decision making. 20 | * 21 | *

This is a computed property that is calculated during ATN deserialization 22 | * and stored for use in {@link ParserATNSimulator} and 23 | * {@link ParserInterpreter}.

24 | * 25 | * @see DFA#isPrecedenceDfa() 26 | */ 27 | bool isPrecedenceDecision = false; 28 | 29 | StarLoopbackState *loopBackState = nullptr; 30 | 31 | virtual size_t getStateType() override; 32 | }; 33 | 34 | } // namespace atn 35 | } // namespace antlr4 36 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/src/Core/DiagonalProduct.h: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // Copyright (C) 2008 Gael Guennebaud 5 | // Copyright (C) 2007-2009 Benoit Jacob 6 | // 7 | // This Source Code Form is subject to the terms of the Mozilla 8 | // Public License v. 2.0. If a copy of the MPL was not distributed 9 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 10 | 11 | #ifndef EIGEN_DIAGONALPRODUCT_H 12 | #define EIGEN_DIAGONALPRODUCT_H 13 | 14 | namespace Eigen { 15 | 16 | /** \returns the diagonal matrix product of \c *this by the diagonal matrix \a diagonal. 17 | */ 18 | template 19 | template 20 | inline const Product 21 | MatrixBase::operator*(const DiagonalBase &a_diagonal) const 22 | { 23 | return Product(derived(),a_diagonal.derived()); 24 | } 25 | 26 | } // end namespace Eigen 27 | 28 | #endif // EIGEN_DIAGONALPRODUCT_H 29 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/ActionTransition.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "atn/Transition.h" 9 | 10 | namespace antlr4 { 11 | namespace atn { 12 | 13 | class ANTLR4CPP_PUBLIC ActionTransition final : public Transition { 14 | public: 15 | const size_t ruleIndex; 16 | const size_t actionIndex; 17 | const bool isCtxDependent; // e.g., $i ref in action 18 | 19 | ActionTransition(ATNState *target, size_t ruleIndex); 20 | 21 | ActionTransition(ATNState *target, size_t ruleIndex, size_t actionIndex, bool isCtxDependent); 22 | 23 | virtual SerializationType getSerializationType() const override; 24 | 25 | virtual bool isEpsilon() const override; 26 | 27 | virtual bool matches(size_t symbol, size_t minVocabSymbol, size_t maxVocabSymbol) const override; 28 | 29 | virtual std::string toString() const override; 30 | }; 31 | 32 | } // namespace atn 33 | } // namespace antlr4 34 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/atn/RangeTransition.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "misc/IntervalSet.h" 7 | 8 | #include "atn/RangeTransition.h" 9 | 10 | using namespace antlr4; 11 | using namespace antlr4::atn; 12 | 13 | RangeTransition::RangeTransition(ATNState *target, size_t from, size_t to) : Transition(target), from(from), to(to) { 14 | } 15 | 16 | Transition::SerializationType RangeTransition::getSerializationType() const { 17 | return RANGE; 18 | } 19 | 20 | misc::IntervalSet RangeTransition::label() const { 21 | return misc::IntervalSet::of((int)from, (int)to); 22 | } 23 | 24 | bool RangeTransition::matches(size_t symbol, size_t /*minVocabSymbol*/, size_t /*maxVocabSymbol*/) const { 25 | return symbol >= from && symbol <= to; 26 | } 27 | 28 | std::string RangeTransition::toString() const { 29 | return "RANGE " + Transition::toString() + " { from: " + std::to_string(from) + ", to: " + std::to_string(to) + " }"; 30 | } 31 | -------------------------------------------------------------------------------- /Core/QuantumMachine/QuantumMachineInterface.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017-2023 Origin Quantum Computing. All Right Reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | #include "QuantumMachineInterface.h" 18 | USING_QPANDA 19 | using namespace std; 20 | int QubitAddr::getX() const 21 | { 22 | return x; 23 | } 24 | 25 | int QubitAddr::getY() const 26 | { 27 | return y; 28 | } 29 | 30 | void QubitAddr::setX(int x) 31 | { 32 | x = x; 33 | } 34 | 35 | void QubitAddr::setY(int y) 36 | { 37 | y = y; 38 | } 39 | 40 | QubitAddr::QubitAddr(int ix, int iy) 41 | :x(ix), y(iy) 42 | { 43 | } 44 | -------------------------------------------------------------------------------- /include/Core/QuantumCircuit/QNodeManager.h: -------------------------------------------------------------------------------- 1 | /*! \file QNodeManager.h */ 2 | #ifndef _MANAGER_H 3 | #define _MANAGER_H 4 | 5 | #include "Core/Utilities/QPandaNamespace.h" 6 | #include "Core/QuantumCircuit/QNode.h" 7 | #include "Core/Utilities/Tools/QPandaException.h" 8 | #include "Core/Utilities/Tools/ReadWriteLock.h" 9 | 10 | QPANDA_BEGIN 11 | 12 | class QNodeManager 13 | { 14 | public: 15 | QNodeManager(const QNode* parent); 16 | QNodeManager() = delete; 17 | ~QNodeManager(); 18 | 19 | void push_back_node(std::shared_ptr node); 20 | NodeIter get_first_node_iter(); 21 | NodeIter get_last_node_iter(); 22 | NodeIter get_end_node_iter(); 23 | NodeIter get_head_node_iter(); 24 | NodeIter insert_QNode(const NodeIter &perIter, std::shared_ptr node); 25 | NodeIter delete_QNode(NodeIter &target_iter); 26 | void clear(); 27 | 28 | protected: 29 | QNodeManager(const QNodeManager&); 30 | QNodeManager& operator=(const QNodeManager&); 31 | 32 | private: 33 | const QNode* m_parent; 34 | Item *m_head{ nullptr }; 35 | Item *m_end{ nullptr }; 36 | SharedMutex m_sm; 37 | }; 38 | 39 | QPANDA_END 40 | 41 | #endif // !_MANAGER_H -------------------------------------------------------------------------------- /ThirdParty/Eigen/QtAlignedMalloc: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_QTMALLOC_MODULE_H 9 | #define EIGEN_QTMALLOC_MODULE_H 10 | 11 | #include "Core" 12 | 13 | #if (!EIGEN_MALLOC_ALREADY_ALIGNED) 14 | 15 | #include "src/Core/util/DisableStupidWarnings.h" 16 | 17 | void *qMalloc(std::size_t size) 18 | { 19 | return Eigen::internal::aligned_malloc(size); 20 | } 21 | 22 | void qFree(void *ptr) 23 | { 24 | Eigen::internal::aligned_free(ptr); 25 | } 26 | 27 | void *qRealloc(void *ptr, std::size_t size) 28 | { 29 | void* newPtr = Eigen::internal::aligned_malloc(size); 30 | std::memcpy(newPtr, ptr, size); 31 | Eigen::internal::aligned_free(ptr); 32 | return newPtr; 33 | } 34 | 35 | #include "src/Core/util/ReenableStupidWarnings.h" 36 | 37 | #endif 38 | 39 | #endif // EIGEN_QTMALLOC_MODULE_H 40 | /* vim: set filetype=cpp et sw=2 ts=2 ai: */ 41 | -------------------------------------------------------------------------------- /ThirdParty/EigenUnsupported/Eigen/KroneckerProduct: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla 6 | // Public License v. 2.0. If a copy of the MPL was not distributed 7 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | #ifndef EIGEN_KRONECKER_PRODUCT_MODULE_H 10 | #define EIGEN_KRONECKER_PRODUCT_MODULE_H 11 | 12 | #include "../../Eigen/Core" 13 | 14 | #include "../../Eigen/src/Core/util/DisableStupidWarnings.h" 15 | 16 | #include "../../Eigen/src/SparseCore/SparseUtil.h" 17 | 18 | namespace Eigen { 19 | 20 | /** 21 | * \defgroup KroneckerProduct_Module KroneckerProduct module 22 | * 23 | * This module contains an experimental Kronecker product implementation. 24 | * 25 | * \code 26 | * #include 27 | * \endcode 28 | */ 29 | 30 | } // namespace Eigen 31 | 32 | #include "src/KroneckerProduct/KroneckerTensorProduct.h" 33 | 34 | #include "../../Eigen/src/Core/util/ReenableStupidWarnings.h" 35 | 36 | #endif // EIGEN_KRONECKER_PRODUCT_MODULE_H 37 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/xpath/XPathRuleElement.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/ParseTree.h" 7 | #include "tree/Trees.h" 8 | 9 | #include "XPathRuleElement.h" 10 | 11 | using namespace antlr4::tree; 12 | using namespace antlr4::tree::xpath; 13 | 14 | XPathRuleElement::XPathRuleElement(const std::string &ruleName, size_t ruleIndex) : XPathElement(ruleName) { 15 | _ruleIndex = ruleIndex; 16 | } 17 | 18 | std::vector XPathRuleElement::evaluate(ParseTree *t) { 19 | // return all children of t that match nodeName 20 | std::vector nodes; 21 | for (auto c : t->children) { 22 | if (antlrcpp::is(c)) { 23 | ParserRuleContext *ctx = dynamic_cast(c); 24 | if ((ctx->getRuleIndex() == _ruleIndex && !_invert) || (ctx->getRuleIndex() != _ruleIndex && _invert)) { 25 | nodes.push_back(ctx); 26 | } 27 | } 28 | } 29 | return nodes; 30 | } 31 | -------------------------------------------------------------------------------- /include/Components/MaxCutProblemGenerator/MaxCutProblemGenerator.h: -------------------------------------------------------------------------------- 1 | #ifndef PYQPANDA_MAXCUTGENERATOR_H 2 | #define PYQPANDA_MAXCUTGENERATOR_H 3 | 4 | #include 5 | #include 6 | #include "Core/Utilities/QPandaNamespace.h" 7 | QPANDA_BEGIN 8 | 9 | /** 10 | * @brief vector dot product 11 | * @ingroup MaxCutProblemGenerator 12 | * @param[in] std::vector& vector x, x will be clear 13 | * @param[in] std::vector& vector y, y will be clear 14 | * @return double the dot product result of the two input vectors 15 | */ 16 | double vector_dot(std::vector &x, std::vector &y); 17 | 18 | /** 19 | * @brief all cut of graph 20 | * @ingroup MaxCutProblemGenerator 21 | * @param[in] std::vector> the adjacent matrix 22 | * @param[out] std::vector& all cut list 23 | * @param[out] std::vector& target value list 24 | * @return double the max cut value 25 | */ 26 | double all_cut_of_graph(std::vector> adjacent_matrix, 27 | std::vector & all_cut_list, 28 | std::vector & target_value_list); 29 | QPANDA_END 30 | 31 | #endif // ! PYQPANDA_MAXCUTGENERATOR_H -------------------------------------------------------------------------------- /Core/Utilities/Compiler/operations/ClassicControlledOperation.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Core/Utilities/Compiler/operations/ClassicControlledOperation.hpp" 3 | 4 | namespace qc { 5 | 6 | std::string toString(const ComparisonKind& kind) { 7 | switch (kind) { 8 | case ComparisonKind::Eq: 9 | return "=="; 10 | case ComparisonKind::Neq: 11 | return "!="; 12 | case ComparisonKind::Lt: 13 | return "<"; 14 | case ComparisonKind::Leq: 15 | return "<="; 16 | case ComparisonKind::Gt: 17 | return ">"; 18 | case ComparisonKind::Geq: 19 | return ">="; 20 | default: 21 | unreachable(); 22 | } 23 | } 24 | 25 | std::ostream& operator<<(std::ostream& os, const ComparisonKind& kind) { 26 | os << toString(kind); 27 | return os; 28 | } 29 | 30 | ComparisonKind getInvertedComparsionKind(const ComparisonKind kind) { 31 | switch (kind) { 32 | case Lt: 33 | return Geq; 34 | case Leq: 35 | return Gt; 36 | case Gt: 37 | return Leq; 38 | case Geq: 39 | return Lt; 40 | case Eq: 41 | return Neq; 42 | case Neq: 43 | return Eq; 44 | default: 45 | unreachable(); 46 | } 47 | } 48 | } // namespace qc 49 | -------------------------------------------------------------------------------- /ThirdParty/Eigen/MetisSupport: -------------------------------------------------------------------------------- 1 | // This file is part of Eigen, a lightweight C++ template library 2 | // for linear algebra. 3 | // 4 | // This Source Code Form is subject to the terms of the Mozilla 5 | // Public License v. 2.0. If a copy of the MPL was not distributed 6 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | #ifndef EIGEN_METISSUPPORT_MODULE_H 9 | #define EIGEN_METISSUPPORT_MODULE_H 10 | 11 | #include "SparseCore" 12 | 13 | #include "src/Core/util/DisableStupidWarnings.h" 14 | 15 | extern "C" { 16 | #include 17 | } 18 | 19 | 20 | /** \ingroup Support_modules 21 | * \defgroup MetisSupport_Module MetisSupport module 22 | * 23 | * \code 24 | * #include 25 | * \endcode 26 | * This module defines an interface to the METIS reordering package (http://glaros.dtc.umn.edu/gkhome/views/metis). 27 | * It can be used just as any other built-in method as explained in \link OrderingMethods_Module here. \endlink 28 | */ 29 | 30 | 31 | #include "src/MetisSupport/MetisSupport.h" 32 | 33 | #include "src/Core/util/ReenableStupidWarnings.h" 34 | 35 | #endif // EIGEN_METISSUPPORT_MODULE_H 36 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/pattern/TokenTagToken.cpp: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #include "tree/pattern/TokenTagToken.h" 7 | 8 | using namespace antlr4::tree::pattern; 9 | 10 | TokenTagToken::TokenTagToken(const std::string &/*tokenName*/, int type) 11 | : CommonToken(type), tokenName(""), label("") { 12 | } 13 | 14 | TokenTagToken::TokenTagToken(const std::string &tokenName, int type, const std::string &label) 15 | : CommonToken(type), tokenName(tokenName), label(label) { 16 | } 17 | 18 | std::string TokenTagToken::getTokenName() const { 19 | return tokenName; 20 | } 21 | 22 | std::string TokenTagToken::getLabel() const { 23 | return label; 24 | } 25 | 26 | std::string TokenTagToken::getText() const { 27 | if (!label.empty()) { 28 | return "<" + label + ":" + tokenName + ">"; 29 | } 30 | 31 | return "<" + tokenName + ">"; 32 | } 33 | 34 | std::string TokenTagToken::toString() const { 35 | return tokenName + ":" + std::to_string(_type); 36 | } 37 | -------------------------------------------------------------------------------- /include/Core/Utilities/QProgTransform/QProgToDAG/TopologSequence.h: -------------------------------------------------------------------------------- 1 | #ifndef TOPOLOG_SEQUENCE_H 2 | #define TOPOLOG_SEQUENCE_H 3 | 4 | #include "Core/Utilities/QPandaNamespace.h" 5 | #include 6 | #include 7 | #include 8 | #include "Core/Utilities/QProgInfo/QCircuitInfo.h" 9 | //#include "Core/Utilities/QProgTransform/QProgToDAG/QProgToDAG.h" 10 | #include 11 | 12 | QPANDA_BEGIN 13 | 14 | /* 15 | * store the sequence node and the next sequence node, 16 | * for double qubits gate, control qubit first, and then target qubit 17 | */ 18 | //template 19 | //struct SeqNode 20 | //{ 21 | // T m_cur_node; 22 | // std::vector m_successor_nodes; 23 | //}; 24 | 25 | template 26 | using SeqNode = std::pair>; 27 | 28 | template 29 | using SeqLayer = std::vector>; 30 | 31 | template 32 | class TopologSequence : public std::vector> 33 | { 34 | public: 35 | TopologSequence() 36 | :m_cur_layer(0) 37 | {} 38 | virtual ~TopologSequence() {} 39 | 40 | private: 41 | size_t m_cur_layer; 42 | }; 43 | 44 | QPANDA_END 45 | 46 | #endif // TOPOLOG_SEQUENCE_H -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/RuleContextWithAltNum.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ParserRuleContext.h" 9 | 10 | namespace antlr4 { 11 | 12 | /// A handy class for use with 13 | /// 14 | /// options {contextSuperClass=org.antlr.v4.runtime.RuleContextWithAltNum;} 15 | /// 16 | /// that provides a backing field / impl for the outer alternative number 17 | /// matched for an internal parse tree node. 18 | /// 19 | /// I'm only putting into Java runtime as I'm certain I'm the only one that 20 | /// will really every use this. 21 | class ANTLR4CPP_PUBLIC RuleContextWithAltNum : public ParserRuleContext { 22 | public: 23 | size_t altNum = 0; 24 | 25 | RuleContextWithAltNum(); 26 | RuleContextWithAltNum(ParserRuleContext *parent, int invokingStateNumber); 27 | 28 | virtual size_t getAltNumber() const override; 29 | virtual void setAltNumber(size_t altNum) override; 30 | }; 31 | 32 | } // namespace antlr4 33 | -------------------------------------------------------------------------------- /ThirdParty/antlr4/runtime/src/tree/ParseTreeWalker.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved. 2 | * Use of this file is governed by the BSD 3-clause license that 3 | * can be found in the LICENSE.txt file in the project root. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "antlr4-common.h" 9 | 10 | namespace antlr4 { 11 | namespace tree { 12 | 13 | class ANTLR4CPP_PUBLIC ParseTreeWalker { 14 | public: 15 | static ParseTreeWalker &DEFAULT; 16 | 17 | virtual ~ParseTreeWalker(); 18 | 19 | virtual void walk(ParseTreeListener *listener, ParseTree *t) const; 20 | 21 | protected: 22 | /// The discovery of a rule node, involves sending two events: the generic 23 | /// and a 24 | /// -specific event. First we trigger the generic and then 25 | /// the rule specific. We do them in reverse order upon finishing the node. 26 | virtual void enterRule(ParseTreeListener *listener, ParseTree *r) const; 27 | virtual void exitRule(ParseTreeListener *listener, ParseTree *r) const; 28 | }; 29 | 30 | } // namespace tree 31 | } // namespace antlr4 32 | --------------------------------------------------------------------------------