Commit d98bc2da authored by Mccaskey, Alex's avatar Mccaskey, Alex
Browse files

Making MPI not required

parent a9aa9afd
......@@ -54,7 +54,7 @@ set(CppMicroServices_INCLUDE_DIR ${CppMicroServices_BASE_DIR}/include/cppmicrose
set(CppMicroServices_LIBRARY_DIR ${CppMicroServices_BASE_DIR}/lib)
# We require MPI
find_package(MPI REQUIRED)
find_package(MPI)
# We require Boost
find_package(Boost COMPONENTS system program_options filesystem python REQUIRED)
......
......@@ -35,6 +35,7 @@
#include <complex>
#include "Tensor.hpp"
#include <bitset>
#include <unsupported/Eigen/KroneckerProduct>
namespace xacc {
......@@ -59,6 +60,8 @@ protected:
*/
QubitState bufferState;
Eigen::MatrixXcd Z;
public:
/**
......@@ -70,6 +73,17 @@ public:
SimulatedQubits(const std::string& str, const int N) :
AcceleratorBuffer(str, N), bufferState((int) std::pow(2, N)) {
bufferState(0) = 1.0;
Eigen::MatrixXcd z(2,2), temp;
z << 1, 0, 0, -1;
temp = z;
for (int i = 0; i < N-1; i++) {
temp = Eigen::kroneckerProduct(z, temp).eval();
}
Z = temp;
assert(temp.rows() == std::pow(2,N));
}
/**
......@@ -126,6 +140,12 @@ public:
bufferState = st;
}
virtual const double getExpectationValueZ() {
auto data = bufferState.createReference().first.data();
Eigen::VectorXcd state = Eigen::Map<Eigen::VectorXcd, Eigen::Unaligned>(data, bufferState.size());
return std::real(state.transpose().dot(Z * state));
}
/**
* Print the state to the provided output stream.
*
......
......@@ -172,7 +172,7 @@ public:
*
* @return expVal The expectation value
*/
virtual const double getExpectationValueZ() const {
virtual const double getExpectationValueZ() {
std::stringstream ss;
double aver = 0.;
long n_measurements = measurements.size();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment