Initial quantum compute and cleaning up win server.
This commit is contained in:
parent
af50eea208
commit
5362b694e0
45 changed files with 884 additions and 429 deletions
|
@ -1,15 +1,2 @@
|
|||
set(PLUGIN_NAME quantum_computing)
|
||||
|
||||
list(APPEND client_HEADERS
|
||||
QuantumCircuit.h)
|
||||
|
||||
list(APPEND client_LIB_INCLUDES
|
||||
QuantumCircuit.cpp)
|
||||
|
||||
add_library(${PLUGIN_NAME} SHARED ${client_LIB_INCLUDES})
|
||||
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
target_link_libraries(${PLUGIN_NAME} PUBLIC core)
|
||||
set_property(TARGET ${PLUGIN_NAME} PROPERTY FOLDER plugins)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(test)
|
||||
|
|
12
plugins/quantum_computing/src/BlochSphere.cpp
Normal file
12
plugins/quantum_computing/src/BlochSphere.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include "BlochSphere.h"
|
||||
|
||||
BlochSphere::BlochSphere(const Qubit& state)
|
||||
: mState(state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const Qubit& BlochSphere::getState() const
|
||||
{
|
||||
return mState;
|
||||
}
|
13
plugins/quantum_computing/src/BlochSphere.h
Normal file
13
plugins/quantum_computing/src/BlochSphere.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include "Qubit.h"
|
||||
|
||||
class BlochSphere
|
||||
{
|
||||
public:
|
||||
BlochSphere(const Qubit& state);
|
||||
|
||||
const Qubit& getState() const;
|
||||
private:
|
||||
Qubit mState;
|
||||
};
|
30
plugins/quantum_computing/src/CMakeLists.txt
Normal file
30
plugins/quantum_computing/src/CMakeLists.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
set(PLUGIN_NAME quantum_computing)
|
||||
|
||||
list(APPEND quantum_computing_HEADERS
|
||||
QuantumCircuit.h
|
||||
BlochSphere.h
|
||||
QuantumState.h
|
||||
Qubit.h
|
||||
QuantumGate.h
|
||||
QuantumOperator.h
|
||||
visuals/BlochSphereNode.h
|
||||
)
|
||||
|
||||
list(APPEND quantum_computing_LIB_INCLUDES
|
||||
QuantumCircuit.cpp
|
||||
BlochSphere.cpp
|
||||
QuantumState.cpp
|
||||
Qubit.cpp
|
||||
QuantumGate.cpp
|
||||
QuantumOperator.cpp
|
||||
visuals/BlochSphereNode.cpp
|
||||
)
|
||||
|
||||
add_library(${PLUGIN_NAME} SHARED ${quantum_computing_LIB_INCLUDES} ${quantum_computing_HEADERS})
|
||||
|
||||
target_include_directories(${PLUGIN_NAME} PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/visuals
|
||||
)
|
||||
target_link_libraries(${PLUGIN_NAME} PUBLIC core visual_elements ntk_math)
|
||||
set_property(TARGET ${PLUGIN_NAME} PROPERTY FOLDER plugins)
|
0
plugins/quantum_computing/src/QuantumGate.cpp
Normal file
0
plugins/quantum_computing/src/QuantumGate.cpp
Normal file
0
plugins/quantum_computing/src/QuantumGate.h
Normal file
0
plugins/quantum_computing/src/QuantumGate.h
Normal file
0
plugins/quantum_computing/src/QuantumOperator.cpp
Normal file
0
plugins/quantum_computing/src/QuantumOperator.cpp
Normal file
0
plugins/quantum_computing/src/QuantumOperator.h
Normal file
0
plugins/quantum_computing/src/QuantumOperator.h
Normal file
0
plugins/quantum_computing/src/QuantumState.cpp
Normal file
0
plugins/quantum_computing/src/QuantumState.cpp
Normal file
0
plugins/quantum_computing/src/QuantumState.h
Normal file
0
plugins/quantum_computing/src/QuantumState.h
Normal file
18
plugins/quantum_computing/src/Qubit.cpp
Normal file
18
plugins/quantum_computing/src/Qubit.cpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#include "Qubit.h"
|
||||
|
||||
Qubit::Qubit(const ComplexNumber& alpha, const ComplexNumber& beta)
|
||||
: mAlpha(alpha),
|
||||
mBeta(beta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const ComplexNumber& Qubit::getAlpha() const
|
||||
{
|
||||
return mAlpha;
|
||||
}
|
||||
|
||||
const ComplexNumber& Qubit::getBeta() const
|
||||
{
|
||||
return mBeta;
|
||||
}
|
16
plugins/quantum_computing/src/Qubit.h
Normal file
16
plugins/quantum_computing/src/Qubit.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "ComplexNumber.h"
|
||||
|
||||
class Qubit
|
||||
{
|
||||
public:
|
||||
Qubit(const ComplexNumber& alpha, const ComplexNumber& beta);
|
||||
|
||||
const ComplexNumber& getAlpha() const;
|
||||
|
||||
const ComplexNumber& getBeta() const;
|
||||
private:
|
||||
ComplexNumber mAlpha;
|
||||
ComplexNumber mBeta;
|
||||
};
|
40
plugins/quantum_computing/src/visuals/BlochSphereNode.cpp
Normal file
40
plugins/quantum_computing/src/visuals/BlochSphereNode.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include "BlochSphereNode.h"
|
||||
|
||||
#include "CircleNode.h"
|
||||
|
||||
BlochSphereNode::BlochSphereNode(const DiscretePoint& location)
|
||||
: AbstractVisualNode(location, "BlochSphereNode")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BlochSphereNode::setContent(BlochSphere* content)
|
||||
{
|
||||
mContent = content;
|
||||
mContentDirty = true;
|
||||
}
|
||||
|
||||
void BlochSphereNode::setSize(double size)
|
||||
{
|
||||
if (size != mSize)
|
||||
{
|
||||
mSize = size;
|
||||
mContentDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
void BlochSphereNode::update(FontsManager* fontsManager)
|
||||
{
|
||||
if (!mContentDirty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mChildren.clear();
|
||||
|
||||
auto loc = DiscretePoint(mSize / 2.0, mSize / 2.0);
|
||||
mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0);
|
||||
|
||||
addChild(mOuterCircle.get());
|
||||
|
||||
}
|
34
plugins/quantum_computing/src/visuals/BlochSphereNode.h
Normal file
34
plugins/quantum_computing/src/visuals/BlochSphereNode.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class BlochSphere;
|
||||
class CircleNode;
|
||||
class LineNode;
|
||||
|
||||
class BlochSphereNode : public AbstractVisualNode
|
||||
{
|
||||
public:
|
||||
BlochSphereNode(const DiscretePoint& location);
|
||||
|
||||
void setContent(BlochSphere* content);
|
||||
|
||||
void update(FontsManager* fontsManager) override;
|
||||
|
||||
void setSize(double size);
|
||||
private:
|
||||
double mSize{ 1.0 };
|
||||
bool mContentDirty{ true };
|
||||
BlochSphere* mContent{ nullptr };
|
||||
|
||||
std::unique_ptr<CircleNode> mOuterCircle;
|
||||
std::unique_ptr<CircleNode> mInnerCircle;
|
||||
std::unique_ptr<CircleNode> mCentreCircle;
|
||||
std::unique_ptr<CircleNode> mStateMarkerCircle;
|
||||
std::unique_ptr<LineNode> mXAxis;
|
||||
std::unique_ptr<LineNode> mYAxis;
|
||||
std::unique_ptr<LineNode> mZAxis;
|
||||
std::unique_ptr<LineNode> mStateVector;
|
||||
};
|
8
plugins/quantum_computing/test/CMakeLists.txt
Normal file
8
plugins/quantum_computing/test/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
|
||||
list(APPEND UNIT_TEST_FILES
|
||||
TestBlochSphereNode.cpp
|
||||
)
|
||||
|
||||
add_executable(quantum_computing_unit_tests ${CMAKE_SOURCE_DIR}/test/test_runner.cpp ${UNIT_TEST_FILES})
|
||||
target_link_libraries(quantum_computing_unit_tests PUBLIC test_utils quantum_computing)
|
||||
set_property(TARGET quantum_computing_unit_tests PROPERTY FOLDER plugins)
|
35
plugins/quantum_computing/test/TestBlochSphereNode.cpp
Normal file
35
plugins/quantum_computing/test/TestBlochSphereNode.cpp
Normal file
|
@ -0,0 +1,35 @@
|
|||
#include "TestFramework.h"
|
||||
#include "TestUtils.h"
|
||||
|
||||
#include "BlochSphereNode.h"
|
||||
#include "BlochSphere.h"
|
||||
#include "Scene.h"
|
||||
|
||||
#include "SvgConverter.h"
|
||||
#include "SvgWriter.h"
|
||||
|
||||
#include "File.h"
|
||||
|
||||
TEST_CASE(TestBlochSphereNode, "quantum_computing")
|
||||
{
|
||||
auto node = std::make_unique<BlochSphereNode>();
|
||||
|
||||
Qubit state({ 1.0, 0.0 }, { 0.0, 0.0 });
|
||||
|
||||
auto bloch_sphere = std::make_unique<BlochSphere>(state);
|
||||
|
||||
node->setContent(bloch_sphere.get());
|
||||
|
||||
auto scene = std::make_unique<Scene>();
|
||||
scene->addNode(node.get());
|
||||
scene->update();
|
||||
|
||||
SvgConverter converter;
|
||||
auto svg_document = converter.convert(scene.get());
|
||||
|
||||
SvgWriter writer;
|
||||
auto svg_content = writer.toString(svg_document.get());
|
||||
|
||||
File svg_file(TestUtils::getTestOutputDir(__FILE__) / "bloch_sphere.svg");
|
||||
svg_file.writeText(svg_content);
|
||||
}
|
0
plugins/quantum_computing/test/TestBlochSphereNode.h
Normal file
0
plugins/quantum_computing/test/TestBlochSphereNode.h
Normal file
Loading…
Add table
Add a link
Reference in a new issue