Do bulk replace of stl types.
This commit is contained in:
parent
521486be62
commit
c25a56ee19
531 changed files with 2274 additions and 2181 deletions
|
@ -28,22 +28,22 @@ void QuantumCircuit::addLogicGate(QuantumGatePtr gate)
|
|||
mElements.push_back(std::move(gate));
|
||||
}
|
||||
|
||||
const std::vector<QuantumTerminal*>& QuantumCircuit::getInputTerminals() const
|
||||
const Vector<QuantumTerminal*>& QuantumCircuit::getInputTerminals() const
|
||||
{
|
||||
return mInputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<QuantumTerminal*>& QuantumCircuit::getOutputTerminals() const
|
||||
const Vector<QuantumTerminal*>& QuantumCircuit::getOutputTerminals() const
|
||||
{
|
||||
return mOutputTerminals;
|
||||
}
|
||||
|
||||
const std::vector<QuantumGate*>& QuantumCircuit::getLogicGates() const
|
||||
const Vector<QuantumGate*>& QuantumCircuit::getLogicGates() const
|
||||
{
|
||||
return mGates;
|
||||
}
|
||||
|
||||
const std::vector<QuantumWire*>& QuantumCircuit::getQuantumWires() const
|
||||
const Vector<QuantumWire*>& QuantumCircuit::getQuantumWires() const
|
||||
{
|
||||
return mWires;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "QuantumWire.h"
|
||||
#include "QuantumState.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class QuantumCircuit
|
||||
{
|
||||
|
@ -21,24 +21,24 @@ public:
|
|||
|
||||
void buildWireConnections();
|
||||
|
||||
const std::vector<QuantumTerminal*>& getInputTerminals() const;
|
||||
const Vector<QuantumTerminal*>& getInputTerminals() const;
|
||||
|
||||
const std::vector<QuantumTerminal*>& getOutputTerminals() const;
|
||||
const Vector<QuantumTerminal*>& getOutputTerminals() const;
|
||||
|
||||
const std::vector<QuantumGate*>& getLogicGates() const;
|
||||
const Vector<QuantumGate*>& getLogicGates() const;
|
||||
|
||||
const std::vector<QuantumWire*>& getQuantumWires() const;
|
||||
const Vector<QuantumWire*>& getQuantumWires() const;
|
||||
|
||||
QuantumState getInputState() const;
|
||||
|
||||
private:
|
||||
bool connectivityIsValid() const;
|
||||
|
||||
std::vector<QuantumTerminal*> mInputTerminals;
|
||||
std::vector<QuantumTerminal*> mOutputTerminals;
|
||||
Vector<QuantumTerminal*> mInputTerminals;
|
||||
Vector<QuantumTerminal*> mOutputTerminals;
|
||||
|
||||
std::vector<QuantumWire*> mWires;
|
||||
std::vector<QuantumGate*> mGates;
|
||||
Vector<QuantumWire*> mWires;
|
||||
Vector<QuantumGate*> mGates;
|
||||
|
||||
std::vector<std::unique_ptr<QuantumCircuitElement> > mElements;
|
||||
Vector<Ptr<QuantumCircuitElement> > mElements;
|
||||
};
|
|
@ -10,13 +10,13 @@
|
|||
#include "StringUtils.h"
|
||||
#include "FileLogger.h"
|
||||
|
||||
std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const Path& path)
|
||||
Ptr<QuantumCircuit> QuantumCircuitReader::read(const Path& path)
|
||||
{
|
||||
File file(path);
|
||||
return read(file.readText());
|
||||
}
|
||||
|
||||
std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const std::string& content)
|
||||
Ptr<QuantumCircuit> QuantumCircuitReader::read(const String& content)
|
||||
{
|
||||
auto circuit = std::make_unique<QuantumCircuit>();
|
||||
mWorkingCircuit = circuit.get();
|
||||
|
@ -31,7 +31,7 @@ std::unique_ptr<QuantumCircuit> QuantumCircuitReader::read(const std::string& co
|
|||
return circuit;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onLine(const std::string& line, std::size_t jdx)
|
||||
void QuantumCircuitReader::onLine(const String& line, std::size_t jdx)
|
||||
{
|
||||
mWorkingString.clear();
|
||||
std::size_t cursor = 0;
|
||||
|
@ -39,7 +39,7 @@ void QuantumCircuitReader::onLine(const std::string& line, std::size_t jdx)
|
|||
while (cursor < line.size())
|
||||
{
|
||||
const auto c = line[cursor];
|
||||
MLOG_INFO("Working char: " << std::string(1, c));
|
||||
MLOG_INFO("Working char: " << String(1, c));
|
||||
|
||||
if (c == '|')
|
||||
{
|
||||
|
@ -103,7 +103,7 @@ void QuantumCircuitReader::onLineEnd()
|
|||
mWorkingElement = nullptr;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onGate(Location, const std::string value)
|
||||
void QuantumCircuitReader::onGate(Location, const String value)
|
||||
{
|
||||
MLOG_INFO("Got gate: " << value);
|
||||
|
||||
|
@ -128,9 +128,9 @@ void QuantumCircuitReader::onGate(Location, const std::string value)
|
|||
}
|
||||
}
|
||||
|
||||
std::string QuantumCircuitReader::checkForGate(const std::string& segment)
|
||||
String QuantumCircuitReader::checkForGate(const String& segment)
|
||||
{
|
||||
std::string working_string;
|
||||
String working_string;
|
||||
for (const auto c : segment)
|
||||
{
|
||||
if (c == '-')
|
||||
|
@ -142,7 +142,7 @@ std::string QuantumCircuitReader::checkForGate(const std::string& segment)
|
|||
return working_string;
|
||||
}
|
||||
|
||||
void QuantumCircuitReader::onKet(Location, const std::string value)
|
||||
void QuantumCircuitReader::onKet(Location, const String value)
|
||||
{
|
||||
MLOG_INFO("Got input state: " << value);
|
||||
Qubit qubit;
|
||||
|
@ -157,7 +157,7 @@ void QuantumCircuitReader::onKet(Location, const std::string value)
|
|||
mWorkingCircuit->addInputTerminal(std::move(input_terminal));
|
||||
}
|
||||
|
||||
std::size_t QuantumCircuitReader::getWireEnd(const std::string& segment)
|
||||
std::size_t QuantumCircuitReader::getWireEnd(const String& segment)
|
||||
{
|
||||
std::size_t idx = 0;
|
||||
for (const auto c : segment)
|
||||
|
@ -171,9 +171,9 @@ std::size_t QuantumCircuitReader::getWireEnd(const std::string& segment)
|
|||
return idx;
|
||||
}
|
||||
|
||||
std::string QuantumCircuitReader::checkForKet(const std::string& segment)
|
||||
String QuantumCircuitReader::checkForKet(const String& segment)
|
||||
{
|
||||
std::string working_string;
|
||||
String working_string;
|
||||
bool found{ false };
|
||||
|
||||
for (const auto c : segment)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
using Path = std::filesystem::path;
|
||||
|
||||
|
@ -11,30 +11,30 @@ class QuantumCircuitElement;
|
|||
class QuantumCircuitReader
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<QuantumCircuit> read(const Path& path);
|
||||
Ptr<QuantumCircuit> read(const Path& path);
|
||||
|
||||
std::unique_ptr<QuantumCircuit> read(const std::string& content);
|
||||
Ptr<QuantumCircuit> read(const String& content);
|
||||
|
||||
private:
|
||||
using Location = std::pair<std::size_t, std::size_t>;
|
||||
|
||||
void onLine(const std::string& line, std::size_t jdx);
|
||||
void onLine(const String& line, std::size_t jdx);
|
||||
|
||||
std::string checkForKet(const std::string& segment);
|
||||
String checkForKet(const String& segment);
|
||||
|
||||
std::string checkForGate(const std::string& segment);
|
||||
String checkForGate(const String& segment);
|
||||
|
||||
std::size_t getWireEnd(const std::string& segment);
|
||||
std::size_t getWireEnd(const String& segment);
|
||||
|
||||
void onGate(Location loc, const std::string value);
|
||||
void onGate(Location loc, const String value);
|
||||
|
||||
void onKet(Location loc, const std::string value);
|
||||
void onKet(Location loc, const String value);
|
||||
|
||||
void onLineEnd();
|
||||
|
||||
void onVertialQuantumWire(Location loc);
|
||||
|
||||
std::string mWorkingString;
|
||||
String mWorkingString;
|
||||
QuantumCircuitElement* mWorkingElement{ nullptr };
|
||||
QuantumCircuit* mWorkingCircuit{ nullptr };
|
||||
};
|
|
@ -1,13 +1,13 @@
|
|||
#include "QuantumState.h"
|
||||
|
||||
const std::vector<Qubit>& QuantumState::getData() const
|
||||
const Vector<Qubit>& QuantumState::getData() const
|
||||
{
|
||||
return mState;
|
||||
}
|
||||
|
||||
std::string QuantumState::toString() const
|
||||
String QuantumState::toString() const
|
||||
{
|
||||
std::string out;
|
||||
String out;
|
||||
for (const auto& qubit : mState)
|
||||
{
|
||||
out += "|" + qubit.toString() + "\n";
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
#include "Qubit.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "Vector.h"
|
||||
#include "String.h"
|
||||
|
||||
class QuantumState
|
||||
{
|
||||
|
@ -13,10 +13,10 @@ public:
|
|||
mState.push_back(data);
|
||||
}
|
||||
|
||||
const std::vector<Qubit>& getData() const;
|
||||
const Vector<Qubit>& getData() const;
|
||||
|
||||
std::string toString() const;
|
||||
String toString() const;
|
||||
|
||||
private:
|
||||
std::vector<Qubit> mState;
|
||||
Vector<Qubit> mState;
|
||||
};
|
||||
|
|
|
@ -29,9 +29,9 @@ bool Qubit::isIn1State() const
|
|||
return mBeta.getReal() == 1.0 && mAlpha.getMagnitude() == 0.0;
|
||||
}
|
||||
|
||||
std::string Qubit::toString(std::size_t precision) const
|
||||
String Qubit::toString(std::size_t precision) const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
Stringstream sstr;
|
||||
sstr.precision(precision);
|
||||
sstr << "alpha " << mAlpha.getReal() << " " << mAlpha.getImaginary() << "i , beta " << mBeta.getReal() << " " << mBeta.getImaginary() << "i";
|
||||
return sstr.str();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "ComplexNumber.h"
|
||||
|
||||
#include <string>
|
||||
#include "String.h"
|
||||
|
||||
class Qubit
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
bool isIn1State() const;
|
||||
|
||||
std::string toString(std::size_t precision=3) const;
|
||||
String toString(std::size_t precision=3) const;
|
||||
private:
|
||||
ComplexNumber mAlpha;
|
||||
ComplexNumber mBeta;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class QuantumCircuitElement
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "QuantumGate.h"
|
||||
|
||||
NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, std::vector<AbstractQuantumWire*> inputs, std::vector<AbstractQuantumWire*> outputs)
|
||||
NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, Vector<AbstractQuantumWire*> inputs, Vector<AbstractQuantumWire*> outputs)
|
||||
: QuantumGate(),
|
||||
mNumIn(numIn),
|
||||
mNumOut(numOut)
|
||||
|
@ -11,7 +11,7 @@ NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, st
|
|||
}
|
||||
else
|
||||
{
|
||||
mInputs = std::vector<AbstractQuantumWire*>(numIn, nullptr);
|
||||
mInputs = Vector<AbstractQuantumWire*>(numIn, nullptr);
|
||||
}
|
||||
|
||||
if (outputs.size() == mNumOut)
|
||||
|
@ -20,7 +20,7 @@ NInMOutQuantumGate::NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, st
|
|||
}
|
||||
else
|
||||
{
|
||||
mOutputs = std::vector<AbstractQuantumWire*>(numOut, nullptr);
|
||||
mOutputs = Vector<AbstractQuantumWire*>(numOut, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "QuantumWire.h"
|
||||
|
||||
#include <vector>
|
||||
#include "Vector.h"
|
||||
|
||||
class QuantumGate : public QuantumCircuitElement
|
||||
{
|
||||
|
@ -39,13 +39,13 @@ public:
|
|||
return Type::GATE;
|
||||
}
|
||||
};
|
||||
using QuantumGatePtr = std::unique_ptr<QuantumGate>;
|
||||
using QuantumGatePtr = Ptr<QuantumGate>;
|
||||
|
||||
|
||||
class NInMOutQuantumGate : public QuantumGate
|
||||
{
|
||||
public:
|
||||
NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, std::vector<AbstractQuantumWire*> inputs = {}, std::vector<AbstractQuantumWire*> outputs = {});
|
||||
NInMOutQuantumGate(std::size_t numIn, std::size_t numOut, Vector<AbstractQuantumWire*> inputs = {}, Vector<AbstractQuantumWire*> outputs = {});
|
||||
|
||||
virtual ~NInMOutQuantumGate() = default;
|
||||
|
||||
|
@ -85,8 +85,8 @@ private:
|
|||
std::size_t mNumIn{ 1 };
|
||||
std::size_t mNumOut{ 1 };
|
||||
|
||||
std::vector<AbstractQuantumWire*> mInputs;
|
||||
std::vector<AbstractQuantumWire*> mOutputs;
|
||||
Vector<AbstractQuantumWire*> mInputs;
|
||||
Vector<AbstractQuantumWire*> mOutputs;
|
||||
};
|
||||
|
||||
class TwoInOneOutQuantumGate : public NInMOutQuantumGate
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "QuantumTerminal.h"
|
||||
|
||||
QuantumTerminal::QuantumTerminal(TerminalType type, const std::string& label)
|
||||
QuantumTerminal::QuantumTerminal(TerminalType type, const String& label)
|
||||
: mLabel(label),
|
||||
mType(type)
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#include "QuantumCircuitElement.h"
|
||||
#include "Qubit.h"
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "String.h"
|
||||
#include "Memory.h"
|
||||
|
||||
class QuantumWire;
|
||||
|
||||
|
@ -17,7 +17,7 @@ public:
|
|||
OUTPUT
|
||||
};
|
||||
|
||||
QuantumTerminal(TerminalType type, const std::string& label = {});
|
||||
QuantumTerminal(TerminalType type, const String& label = {});
|
||||
|
||||
QuantumWire* getConnection() const;
|
||||
|
||||
|
@ -40,9 +40,9 @@ public:
|
|||
void setValue(const Qubit& value);
|
||||
|
||||
private:
|
||||
std::string mLabel;
|
||||
String mLabel;
|
||||
TerminalType mType;
|
||||
Qubit mValue;
|
||||
QuantumWire* mConnection{ nullptr };
|
||||
};
|
||||
using QuantumTerminalPtr = std::unique_ptr<QuantumTerminal>;
|
||||
using QuantumTerminalPtr = Ptr<QuantumTerminal>;
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
Type getType() const override;
|
||||
WireType getWireType() const override;
|
||||
};
|
||||
using QuantumWirePtr = std::unique_ptr<QuantumWire>;
|
||||
using QuantumWirePtr = Ptr<QuantumWire>;
|
||||
|
||||
class ClassicalWire : public AbstractQuantumWire
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ void BlochSphereNode::update(SceneInfo*)
|
|||
mOuterCircle = std::make_unique<CircleNode>(loc, mSize/2.0);
|
||||
|
||||
const auto end_point_x = Point2(loc.getX() + 1.2 * mSize / 2.0, loc.getY());
|
||||
const std::vector<Point2> points{end_point_x };
|
||||
const Vector<Point2> points{end_point_x };
|
||||
mXAxis = std::make_unique<LineNode>(loc, points);
|
||||
|
||||
mCentreCircle = std::make_unique<CircleNode>(loc, mSize / 50.0);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "AbstractVisualNode.h"
|
||||
|
||||
#include <memory>
|
||||
#include "Memory.h"
|
||||
|
||||
class BlochSphere;
|
||||
class CircleNode;
|
||||
|
@ -23,12 +23,12 @@ private:
|
|||
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;
|
||||
Ptr<CircleNode> mOuterCircle;
|
||||
Ptr<CircleNode> mInnerCircle;
|
||||
Ptr<CircleNode> mCentreCircle;
|
||||
Ptr<CircleNode> mStateMarkerCircle;
|
||||
Ptr<LineNode> mXAxis;
|
||||
Ptr<LineNode> mYAxis;
|
||||
Ptr<LineNode> mZAxis;
|
||||
Ptr<LineNode> mStateVector;
|
||||
};
|
||||
|
|
|
@ -29,10 +29,10 @@ private:
|
|||
bool mContentDirty{ true };
|
||||
QuantumCircuit* mContent{ nullptr };
|
||||
|
||||
std::vector<std::unique_ptr<QuantumTerminalNode> > mInputTerminalNodes;
|
||||
std::vector<std::unique_ptr<QuantumTerminalNode> > mOutputTerminalNodes;
|
||||
std::vector<std::unique_ptr<QuantumGateNode> > mGateNodes;
|
||||
std::vector<std::unique_ptr<QuantumWireNode> > mWireNodes;
|
||||
Vector<Ptr<QuantumTerminalNode> > mInputTerminalNodes;
|
||||
Vector<Ptr<QuantumTerminalNode> > mOutputTerminalNodes;
|
||||
Vector<Ptr<QuantumGateNode> > mGateNodes;
|
||||
Vector<Ptr<QuantumWireNode> > mWireNodes;
|
||||
|
||||
std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireInputConnections;
|
||||
std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireOutputConnections;
|
||||
|
|
|
@ -44,7 +44,7 @@ void QuantumGateNode::createOrUpdateGeometry(SceneInfo*)
|
|||
{
|
||||
mLabel = std::make_unique<EquationNode>(Point(mBodyWidth /3.0, mBodyHeight / 3.0));
|
||||
|
||||
std::string label_content;
|
||||
String label_content;
|
||||
if (mContent->getGateType() == QuantumGate::GateType::X)
|
||||
{
|
||||
label_content = "X";
|
||||
|
|
|
@ -25,10 +25,10 @@ private:
|
|||
QuantumGate* mContent{ nullptr };
|
||||
bool mContentDirty{ true };
|
||||
|
||||
std::unique_ptr<RectangleNode> mBody;
|
||||
Ptr<RectangleNode> mBody;
|
||||
|
||||
double mBodyWidth = 30;
|
||||
double mBodyHeight = 24;
|
||||
std::unique_ptr<LatexMathExpression> mLabelExpression;
|
||||
std::unique_ptr<EquationNode> mLabel;
|
||||
Ptr<LatexMathExpression> mLabelExpression;
|
||||
Ptr<EquationNode> mLabel;
|
||||
};
|
|
@ -30,7 +30,7 @@ void QuantumTerminalNode::createOrUpdateGeometry(SceneInfo*)
|
|||
if (!mLabel && mContent->getTerminalType() != QuantumTerminal::TerminalType::OUTPUT)
|
||||
{
|
||||
const auto value = mContent->getValue();
|
||||
std::string label;
|
||||
String label;
|
||||
if (value.isIn0State())
|
||||
{
|
||||
label = "\\ket{0}";
|
||||
|
|
|
@ -25,6 +25,6 @@ private:
|
|||
double mWidth = 20.0;
|
||||
double mHeight = 10.0;
|
||||
|
||||
std::unique_ptr<LatexMathExpression> mLabelExpression;
|
||||
std::unique_ptr<EquationNode> mLabel;
|
||||
Ptr<LatexMathExpression> mLabelExpression;
|
||||
Ptr<EquationNode> mLabel;
|
||||
};
|
|
@ -54,7 +54,7 @@ void QuantumWireNode::createOrUpdateGeometry(SceneInfo*)
|
|||
auto loc = mOutputLocation;
|
||||
loc.moveBy(-mInputLocation.getX(), -mInputLocation.getY(), -mInputLocation.getZ());
|
||||
|
||||
std::vector<Point2> points;
|
||||
Vector<Point2> points;
|
||||
|
||||
if (loc.getY() == 0.0)
|
||||
{
|
||||
|
|
|
@ -29,5 +29,5 @@ private:
|
|||
Point2 mInputLocation;
|
||||
Point2 mOutputLocation;
|
||||
|
||||
std::unique_ptr<LineNode> mLine;
|
||||
Ptr<LineNode> mLine;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue