Skip to content

Commit 1d919e4

Browse files
Merge pull request #94 from OriginQ/develop
Develop
2 parents cbf1f5b + 4133b5d commit 1d919e4

File tree

235 files changed

+21110
-10505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+21110
-10505
lines changed

Applications/B_V_Algorithm/BernsteinVaziraniAlgorithm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
#include "Core/QPanda.h"
17-
#include "Utilities/Utilities.h"
16+
#include "Core/Core.h"
17+
#include "Utilities/Tools/Utils.h"
1818
#include "QAlg/B_V_Algorithm/BernsteinVaziraniAlgorithm.h"
1919
#include <bitset>
2020

Applications/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ add_subdirectory(QuantumWalk)
99
add_subdirectory(SimonAlgorithm)
1010
if(USE_CHEMIQ)
1111
add_subdirectory(ChemiQCalc)
12-
add_subdirectory(QApplication)
1312
endif(USE_CHEMIQ)

Applications/DJ_Algorithm/DJ_Algorithm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Utilities/Utilities.h"
17+
#include "Core/Utilities/Tools/Utils.h"
1818
#include "QAlg/DJ_Algorithm/DJ_Algorithm.h"
1919
#include "QPandaNamespace.h"
20-
#include "Core/QPanda.h"
20+
#include "Core/Core.h"
2121
#include <vector>
2222

2323
using namespace std;

Applications/Grover_Algorithm/Grover_Algorithm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
16-
#include "Core/QPanda.h"
17-
#include "Core/Utilities/Utilities.h"
16+
#include "Core/Core.h"
17+
#include "Core/Utilities/Tools/Utils.h"
1818
#include "QAlg/Grover_Algorithm/Grover_Algorithm.h"
1919

2020
USING_QPANDA

Applications/HHL_Algorithm/HHL_Algorithm.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Core/QPanda.h"
17+
#include "Core/Core.h"
1818

1919
using namespace std;
2020
using namespace QPanda;
@@ -56,7 +56,7 @@ QProg hhl_no_measure(vector<Qubit*> qVec, vector<ClassicalCondition> cVec)
5656
QCircuit PSEcircuitdag = hhlPse(qVec);
5757
QProg PSEdagger = CreateEmptyQProg();
5858
PSEdagger << PSEcircuitdag.dagger();
59-
QIfProg ifnode = CreateIfProg(cVec[0], &PSEdagger);
59+
QIfProg ifnode = CreateIfProg(cVec[0], PSEdagger);
6060
QProg hhlProg = CreateEmptyQProg();
6161

6262
hhlProg << PSEcircuit << CRot << Measure(qVec[0], cVec[0]) << ifnode;

Applications/PennyGame_Algorithm/CoinFlipGame.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Core/QPanda.h"
17+
#include "Core/Core.h"
1818
using namespace std;
1919
using namespace QPanda;
2020

Applications/QPEAlgorithm/QPE_Algorithm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Core/QPanda.h"
17+
#include "Core/Core.h"
1818
using namespace std;
1919
using namespace QPanda;
2020
#define QGEN function<QCircuit (vector<Qubit*>)>

Applications/QuantumWalk/QuantumWalk.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Core/QPanda.h"
17+
#include "Core/Core.h"
1818
#include <bitset>
1919
using namespace std;
2020
using namespace QPanda;

Applications/SimonAlgorithm/SimonAlgorithm.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#include "Core/QPanda.h"
17+
#include "Core/Core.h"
1818
#include <bitset>
1919
#include <vector>
2020

CMakeLists.txt

+10-20
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ cmake_minimum_required(VERSION 3.1)
22
project(QPANDA)
33

44
set(QPANDA_MAJOR_VERSION 2)
5-
set(QPANDA_MINOR_VERSION 0)
5+
set(QPANDA_MINOR_VERSION 1)
66
set(QPANDA_PATCH_VERSION 0)
77
set(QPANDA_VERSION "${QPANDA_MAJOR_VERSION}.${QPANDA_MINOR_VERSION}.${QPANDA_PATCH_VERSION}")
88
message(STATUS "QPANDA VERSION = " "[${QPANDA_VERSION}]")
99

10-
find_package(PythonInterp 3 REQUIRED)
11-
find_package(PythonLibs 3 REQUIRED)
12-
1310
include_directories(${PROJECT_SOURCE_DIR}/include
1411
${PROJECT_SOURCE_DIR}/include/Applications
1512
${PROJECT_SOURCE_DIR}/include/QAlg
@@ -38,8 +35,7 @@ include_directories(${PROJECT_SOURCE_DIR}/include
3835
${PROJECT_SOURCE_DIR}/ThirdParty/bplus-tree
3936
${PROJECT_SOURCE_DIR}/ThirdParty/bplus-tree/include
4037
${PROJECT_SOURCE_DIR}/ThirdParty/antlr4/runtime/src
41-
${PROJECT_SOURCE_DIR}
42-
${PYTHON_INCLUDE_DIRS})
38+
${PROJECT_SOURCE_DIR})
4339

4440
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
4541
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
@@ -90,12 +86,14 @@ if (MSVC)
9086
CMAKE_CXX_FLAGS_MINSIZEREL
9187
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
9288

93-
if (${flag} MATCHES "/MD")
94-
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
95-
endif()
9689
if (${flag} MATCHES "/MDd")
9790
string(REGEX REPLACE "/MDd" "/MTd" ${flag} "${${flag}}")
9891
endif()
92+
93+
if (${flag} MATCHES "/MD")
94+
string(REGEX REPLACE "/MD" "/MT" ${flag} "${${flag}}")
95+
endif()
96+
9997
if (${flag} MATCHES "/W3")
10098
string(REGEX REPLACE "/W3" "/W0" ${flag} "${${flag}}")
10199
endif()
@@ -125,9 +123,6 @@ endif()
125123
add_definitions(${EXTRA_LDFLAGS})
126124

127125

128-
129-
option(FIND_CUDA "find cuda" OFF)
130-
131126
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
132127
find_package(PkgConfig REQUIRED)
133128
pkg_check_modules(UUID REQUIRED uuid)
@@ -136,6 +131,7 @@ if(APPLE)
136131
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
137132
endif()
138133

134+
option(FIND_CUDA "find cuda" OFF)
139135
if (FIND_CUDA)
140136
find_package(CUDA)
141137
endif(FIND_CUDA)
@@ -180,6 +176,8 @@ elseif(MPI_FOUND)
180176
option(USE_MPI "not find MPI" OFF)
181177
endif (MPI_FOUND)
182178

179+
option(USE_CHEMIQ "use ChemiQ" OFF)
180+
183181
add_subdirectory(ThirdParty)
184182
add_subdirectory(Core)
185183
add_subdirectory(Components)
@@ -203,14 +201,6 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in
203201
@ONLY)
204202

205203

206-
message("\r\n")
207-
if (NOT CUDA_FOUND)
208-
message(WARNING "CUDA is not found, GPUQVM is unuseable !!!")
209-
endif()
210-
if (NOT CURL_FOUND)
211-
message(WARNING "Curl is not found, CloudHTTP is unuseable !!!")
212-
endif()
213-
214204
#add extra search paths for libraries and includes
215205
set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in")
216206
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install")

CMakeSettings.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
],
1010
"buildRoot": "${projectDir}\\build\\${name}",
1111
"installRoot": "C:\\QPanda2",
12-
"cmakeCommandArgs": "-DUSE_PYQPANDA=OFF -DFIND_CUDA=OFF",
12+
"cmakeCommandArgs": "-DUSE_PYQPANDA=OFF -DFIND_CUDA=OFF -DUSE_CHEMIQ=OFF",
1313
"buildCommandArgs": "-v",
1414
"ctestCommandArgs": ""
1515
},
@@ -22,7 +22,7 @@
2222
],
2323
"buildRoot": "${projectDir}\\build\\${name}",
2424
"installRoot": "C:\\QPanda2",
25-
"cmakeCommandArgs": "-DUSE_PYQPANDA=OFF -DFIND_CUDA=OFF",
25+
"cmakeCommandArgs": "-DUSE_PYQPANDA=OFF -DFIND_CUDA=OFF -DUSE_CHEMIQ=OFF",
2626
"buildCommandArgs": "-v",
2727
"ctestCommandArgs": ""
2828
}

Components/CMakeLists.txt

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
cmake_minimum_required(VERSION 3.1)
22
project(Components)
33

4-
file(GLOB_RECURSE COMPONENTS_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
5-
add_library(${LIB_COMPONENTS} STATIC ${COMPONENTS_SRC_CPP})
6-
target_link_libraries(${LIB_COMPONENTS} ${LIB_QPANDA} ${PYTHON_LIBRARIES} )
4+
file(GLOB_RECURSE COMPONENTS_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/HamiltonianSimulation/*.cpp
5+
${CMAKE_CURRENT_SOURCE_DIR}/MaxCutProblemGenerator/*.cpp
6+
${CMAKE_CURRENT_SOURCE_DIR}/Optimizer/*.cpp
7+
${CMAKE_CURRENT_SOURCE_DIR}/Utils/*.cpp)
8+
9+
file(GLOB_RECURSE COMPONENTS_CHEMIQ_SRC_CPP ${CMAKE_CURRENT_SOURCE_DIR}/ChemiQ/*.cpp)
10+
11+
if (USE_CHEMIQ)
12+
find_package(PythonInterp REQUIRED)
13+
find_package(PythonLibs 3 REQUIRED)
14+
include_directories(${PYTHON_INCLUDE_DIRS})
15+
add_library(${LIB_COMPONENTS} STATIC ${COMPONENTS_SRC_CPP} ${COMPONENTS_CHEMIQ_SRC_CPP})
16+
target_link_libraries(${LIB_COMPONENTS} ${LIB_QPANDA} ${PYTHON_LIBRARIES})
17+
else ()
18+
add_library(${LIB_COMPONENTS} STATIC ${COMPONENTS_SRC_CPP})
19+
target_link_libraries(${LIB_COMPONENTS} ${LIB_QPANDA} ${PYTHON_LIBRARIES})
20+
endif()
21+
22+
723

824
if (UNIX)
925
set(LIB_SHARED_COMPONENTS DLL_COMPONENTS)

Components/ChemiQ/Psi4Wrapper.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Components/ChemiQ/Psi4Wrapper.h"
2-
#include "QString.h"
2+
#include "Core/Utilities/Tools/QString.h"
3+
34
#include <math.h>
45

56
#if defined(_DEBUG)

Components/HamiltonianSimulation/HamiltonianSimulation.cpp

+16-33
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Components/HamiltonianSimulation/HamiltonianSimulation.h"
22
#include "Core/QuantumCircuit/QGate.h"
3-
#include "Core/Utilities/Utilities.h"
3+
#include "Core/Utilities/Tools/Utils.h"
44

55
namespace QPanda
66
{
@@ -17,14 +17,12 @@ namespace QPanda
1717
}
1818
else if (1 == qubit_vec.size())
1919
{
20-
circuit << QGateNodeFactory::getInstance()->getGateNode(
21-
"RZ", qubit_vec[0], 2*coef*t);
20+
circuit << RZ(qubit_vec[0], 2 * coef*t);
2221
}
2322
else
2423
{
2524
circuit << parityCheckCircuit(qubit_vec);
26-
circuit << QGateNodeFactory::getInstance()->getGateNode(
27-
"RZ", qubit_vec[qubit_vec.size() - 1], 2*coef * t);
25+
circuit << RZ(qubit_vec[qubit_vec.size() - 1], 2 * coef * t);
2826
circuit << parityCheckCircuit(qubit_vec);
2927
}
3028

@@ -56,12 +54,10 @@ namespace QPanda
5654
switch (ch)
5755
{
5856
case 'X':
59-
transform << QGateNodeFactory::getInstance()->getGateNode(
60-
"H", qubit_vec[key]);
57+
transform << H(qubit_vec[key]);
6158
break;
6259
case 'Y':
63-
transform << QGateNodeFactory::getInstance()->getGateNode(
64-
"RX", qubit_vec[key], Q_PI_2);
60+
transform << RX(qubit_vec[key], Q_PI_2);
6561
break;
6662
case 'Z':
6763
break;
@@ -151,7 +147,7 @@ namespace QPanda
151147
QCircuit circuit;
152148
for_each(qubit_vec.begin(), qubit_vec.end(), [&](Qubit* qubit)
153149
{
154-
circuit << QGateNodeFactory::getInstance()->getGateNode(gate, qubit);
150+
circuit << QGateNodeFactory::getInstance()->getGateNode(gate, { qubit });
155151
});
156152

157153
return circuit;
@@ -164,7 +160,7 @@ namespace QPanda
164160
{
165161
for_each(qubit_vec.begin(), qubit_vec.end(), [&](Qubit* qubit)
166162
{
167-
circuit << QGateNodeFactory::getInstance()->getGateNode(gate, qubit);
163+
circuit << QGateNodeFactory::getInstance()->getGateNode(gate, { qubit });
168164
});
169165
}
170166

@@ -180,21 +176,12 @@ namespace QPanda
180176
QCircuit qcirc = QCircuit();
181177
for_each(graph.begin(), graph.end(), [&](const QGraphItem &item)
182178
{
183-
qcirc << QGateNodeFactory::getInstance()->getGateNode(
184-
"CNOT",
185-
qubit_vec[item.first],
186-
qubit_vec[item.second]
187-
);
188-
qcirc << QGateNodeFactory::getInstance()->getGateNode(
189-
"RZ",
190-
qubit_vec[item.second],
191-
2 * gamma[i] * item.weight
192-
);
193-
qcirc << QGateNodeFactory::getInstance()->getGateNode(
194-
"CNOT",
195-
qubit_vec[item.first],
196-
qubit_vec[item.second]
197-
);
179+
qcirc << CNOT(qubit_vec[item.first],
180+
qubit_vec[item.second]);
181+
qcirc << RZ(qubit_vec[item.second],
182+
2 * gamma[i] * item.weight);
183+
qcirc << CNOT(qubit_vec[item.first],
184+
qubit_vec[item.second]);
198185
});
199186

200187
circuit << qcirc;
@@ -212,13 +199,9 @@ namespace QPanda
212199
for (size_t i = 0; i < beta.size(); i++)
213200
{
214201
QCircuit qcirc = QCircuit();
215-
for_each(qubit_vec.begin(), qubit_vec.end(), [&](Qubit* qubit)
216-
{
217-
qcirc << QGateNodeFactory::getInstance()->getGateNode(
218-
"RX",
219-
qubit,
220-
2 * beta[i]
221-
);
202+
for_each(qubit_vec.begin(), qubit_vec.end(), [&](Qubit* qubit)
203+
{
204+
qcirc << RX(qubit,2 * beta[i]);
222205

223206
circuit << qcirc;
224207
});

Components/Optimizer/OriginNelderMead.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <iostream>
22
#include <fstream>
33
#include "Components/Optimizer/OriginNelderMead.h"
4-
#include "Core/Utilities/OriginCollection.h"
5-
#include "QString.h"
4+
#include "Core/Utilities/Tools/OriginCollection.h"
5+
#include "Core/Utilities/Tools/QString.h"
66

77
const std::string NM_CACHE_HEADER = "NELDER_MEAD CACHE FILE";
88

Components/Optimizer/OriginPowell.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <iostream>
22
#include <fstream>
33
#include "Components/Optimizer/OriginPowell.h"
4-
#include "Core/Utilities/OriginCollection.h"
5-
#include "QString.h"
4+
#include "Core/Utilities/Tools/OriginCollection.h"
5+
#include "Core/Utilities/Tools/QString.h"
66

77
const std::string POWELL_CACHE_HEADER = "POWELL CACHE FILE";
88

Core/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.1)
22
project(QPanda2.0)
33

44
if(CUDA_FOUND)
5-
set(LIB_GPUGATES QPanda-2.0.GPUQGates)
5+
set(LIB_GPUGATES GPUQGates)
66
add_subdirectory(VirtualQuantumProcessor/GPUGates)
77
list(APPEND LIB_LIST ${LIB_GPUGATES})
88
endif (CUDA_FOUND)

0 commit comments

Comments
 (0)