Add simple simulator stub.
This commit is contained in:
parent
a74dfd5f5f
commit
426ea55b3b
23 changed files with 139 additions and 11 deletions
|
@ -1,5 +1,7 @@
|
|||
#include "Qubit.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
Qubit::Qubit(const ComplexNumber& alpha, const ComplexNumber& beta)
|
||||
: mAlpha(alpha),
|
||||
mBeta(beta)
|
||||
|
@ -25,4 +27,12 @@ bool Qubit::isIn0State() const
|
|||
bool Qubit::isIn1State() const
|
||||
{
|
||||
return mBeta.getReal() == 1.0 && mAlpha.getMagnitude() == 0.0;
|
||||
}
|
||||
|
||||
std::string Qubit::toString(std::size_t precision) const
|
||||
{
|
||||
std::stringstream sstr;
|
||||
sstr.precision(precision);
|
||||
sstr << "alpha " << mAlpha.getReal() << " " << mAlpha.getImaginary() << "i , beta " << mBeta.getReal() << " " << mBeta.getImaginary() << "i";
|
||||
return sstr.str();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue