Maestro 0.3.1
Unified interface for quantum circuit simulation
Loading...
Searching...
No Matches
State.h
Go to the documentation of this file.
1
18
19#pragma once
20
21#ifndef _SIMULATOR_STATE_H_
22#define _SIMULATOR_STATE_H_
23
24#include <Eigen/Eigen>
25#include <cmath>
26#include <complex>
27#include <stdexcept>
28#include <unordered_map>
29#include <unordered_set>
30#include <utility>
31#include <vector>
32
33#ifndef NO_QISKIT_AER
34#include "framework/linalg/vector.hpp"
35#endif
36
37#include "QuantumChannel.h"
38#include "SimulatorObserver.h"
39
40namespace Circuits {
41template <typename Time> class IOperation;
42}
43
44namespace Simulators {
45
58/*
59template<class T> class avoid_init_allocator : public std::allocator<T>
60{
61public:
62 using std::allocator<T>::allocator;
63
64 template <class U, class... Args> void construct(U*, Args&&...) {}
65};
66*/
67
72enum class SimulatorType : int {
73#ifndef NO_QISKIT_AER
75#endif
77#ifndef NO_QISKIT_AER
79#endif
85};
86
90inline bool IsGpuSimulator(SimulatorType type) {
92}
93
111
119class IState {
120 public:
126 virtual ~IState() = default;
127
129 virtual void SetSeed(uint64_t seed) {
130 const std::string value = std::to_string(seed);
131 Configure("seed", value.c_str());
132 }
133
134 static uint64_t DeriveSeed(uint64_t seed, uint64_t stream) {
135 uint64_t value = seed + 0x9e3779b97f4a7c15ULL * (stream + 1);
136 value = (value ^ (value >> 30)) * 0xbf58476d1ce4e5b9ULL;
137 value = (value ^ (value >> 27)) * 0x94d049bb133111ebULL;
138 return value ^ (value >> 31);
139 }
140
148 virtual void Initialize() = 0;
149
162 virtual void InitializeState(
163 size_t num_qubits, std::vector<std::complex<double>> &amplitudes) = 0;
164
177#ifndef NO_QISKIT_AER
178 virtual void InitializeState(
179 size_t num_qubits, AER::Vector<std::complex<double>> &amplitudes) = 0;
180#endif
181
194 virtual void InitializeState(size_t num_qubits,
195 Eigen::VectorXcd &amplitudes) = 0;
196
214 virtual void InitializeToBasisState(size_t num_qubits,
215 Types::qubit_t basisState) {
216 (void)num_qubits;
217 (void)basisState;
218 throw std::runtime_error(
219 "This simulator does not support initialization to a computational "
220 "basis state");
221 }
222
232 virtual void InitializeToBasisState(size_t num_qubits,
233 const std::vector<bool> &basisState) {
234 (void)num_qubits;
235 (void)basisState;
236 throw std::runtime_error(
237 "This simulator does not support initialization to a computational "
238 "basis state");
239 }
240
261 size_t num_qubits,
262 const std::vector<std::pair<Types::qubit_t, double>> &mixture) {
263 (void)num_qubits;
264 (void)mixture;
265 throw std::runtime_error(
266 "This simulator does not support initialization to a mixture of "
267 "computational basis states");
268 }
269
282 size_t num_qubits,
283 const std::vector<std::pair<std::vector<bool>, double>> &mixture) {
284 (void)num_qubits;
285 (void)mixture;
286 throw std::runtime_error(
287 "This simulator does not support initialization to a mixture of "
288 "computational basis states");
289 }
290
297 virtual void Reset() = 0;
298
306 virtual bool SupportsMPSSwapOptimization() const { return false; }
307
317 const std::vector<long long int> &initialMap) {}
318
327 virtual void SetUseOptimalMeetingPosition(bool /*enable*/) {}
328
337 virtual void SetLookaheadDepth(int /*depth*/) {}
338
348 virtual void SetLookaheadDepthWithHeuristic(int /*depth*/) {}
349
357 virtual void SetUpcomingGates(
358 const std::vector<std::shared_ptr<Circuits::IOperation<double>>> & /*gates*/) {}
359
367 virtual long long int GetGatesCounter() const { return 0; }
368
376 virtual void SetGatesCounter(long long int /*counter*/) {}
377
384 virtual void IncrementGatesCounter() {}
385
386 // the following four functions are also for MPS swaps optimizations, might be removed in the future
387
388 virtual double getGrowthFactorSwap() const { return 0.; }
389 virtual double getGrowthFactorGate() const { return 0.; }
390
391 virtual void setGrowthFactorSwap(double factor) { }
392 virtual void setGrowthFactorGate(double factor) { }
393
403 virtual void Configure(const char *key, const char *value) = 0;
404
412 virtual std::string GetConfiguration(const char *key) const = 0;
413
421 virtual size_t AllocateQubits(size_t num_qubits) = 0;
422
429 virtual size_t GetNumberOfQubits() const = 0;
430
438 virtual void Clear() = 0;
439
450 virtual size_t Measure(const Types::qubits_vector &qubits) = 0;
451
458 virtual std::vector<bool> MeasureMany(const Types::qubits_vector &qubits) = 0;
459
466 virtual void ApplyReset(const Types::qubits_vector &qubits) = 0;
467
476 virtual bool SupportsQuantumChannels() const { return false; }
477
485 virtual void ApplyQuantumChannel(const Types::qubits_vector &targets,
486 const QuantumChannel &channel) {
487 (void)targets;
488 (void)channel;
489 throw std::runtime_error(
490 "This simulator does not support exact quantum-channel evolution");
491 }
492
494 virtual std::complex<double> DensityMatrixTrace() const {
495 throw std::runtime_error("This simulator does not expose a density-matrix trace");
496 }
497 virtual double DensityMatrixPurity() const {
498 throw std::runtime_error("This simulator does not expose density-matrix purity");
499 }
500 virtual std::complex<double> DensityMatrixTraceOfSquare() const {
501 throw std::runtime_error("This simulator does not expose Tr(rho^2)");
502 }
503 virtual std::complex<double> DensityMatrixOverlap(const IState &) const {
504 throw std::runtime_error("This simulator does not support density-matrix overlap");
505 }
506 virtual double DensityMatrixHermiticityResidual() const {
507 throw std::runtime_error("This simulator does not expose a Hermiticity residual");
508 }
509 virtual bool IsDensityMatrixHermitian(double = 1e-10) const {
510 throw std::runtime_error("This simulator does not expose a Hermiticity test");
511 }
512 virtual Eigen::MatrixXcd PartialTrace(const Types::qubits_vector &) const {
513 throw std::runtime_error("This simulator does not support partial trace");
514 }
515 virtual double FidelityWithStatevector(const Eigen::VectorXcd &) const {
516 throw std::runtime_error("This simulator does not support mixed-state fidelity");
517 }
519 throw std::runtime_error("This simulator cannot restore density-matrix trace");
520 }
521 virtual void HermitizeDensityMatrix() {
522 throw std::runtime_error("This simulator cannot hermitize its density matrix");
523 }
525 throw std::runtime_error("This simulator is not a matrix-product operator");
526 }
528 throw std::runtime_error("This simulator is not a matrix-product operator");
529 }
530
533 const Types::qubits_vector &targets,
534 const QuantumChannel::KrausOperators &krausOperators) {
535 ApplyQuantumChannel(targets, QuantumChannel(krausOperators));
536 }
537
540 const Types::qubits_vector &targets,
541 const QuantumChannel::KrausOperators &krausOperators) {
542 ApplyKrausChannel(targets, krausOperators);
543 }
544
547 const std::vector<double> &probabilities) {
548 ApplyQuantumChannel(targets, QuantumChannel::Pauli(probabilities));
549 }
550
552 void ApplyPauliChannel(Types::qubit_t qubit, double px, double py,
553 double pz) {
554 ApplyQuantumChannel({qubit}, QuantumChannel::Pauli(px, py, pz));
555 }
556
557 void ApplyBitFlipNoise(Types::qubit_t qubit, double probability) {
558 ApplyQuantumChannel({qubit}, QuantumChannel::BitFlip(probability));
559 }
560
561 void ApplyBitPhaseFlipNoise(Types::qubit_t qubit, double probability) {
562 ApplyQuantumChannel({qubit},
563 QuantumChannel::BitPhaseFlip(probability));
564 }
565
566 void ApplyPhaseFlipNoise(Types::qubit_t qubit, double probability) {
567 ApplyQuantumChannel({qubit}, QuantumChannel::PhaseFlip(probability));
568 }
569
571 void ApplyDephasingNoise(Types::qubit_t qubit, double probability) {
572 ApplyPhaseFlipNoise(qubit, probability);
573 }
574
577 double errorProbability) {
578 ApplyQuantumChannel({qubit},
579 QuantumChannel::Depolarizing(errorProbability));
580 }
581
584 double mixingProbability) {
586 {qubit}, QuantumChannel::DepolarizingMixing(mixingProbability));
587 }
588
589 void ApplyAmplitudeDamping(Types::qubit_t qubit, double gamma) {
591 }
592
594 void ApplyT1Relaxation(Types::qubit_t qubit, double gamma) {
595 ApplyAmplitudeDamping(qubit, gamma);
596 }
597
599 void ApplyT1RelaxationFromTime(Types::qubit_t qubit, double duration,
600 double t1) {
601 if (!std::isfinite(duration) || duration < 0.0)
602 throw std::invalid_argument(
603 "T1-relaxation duration must be finite and nonnegative");
604 if (std::isnan(t1) || t1 <= 0.0)
605 throw std::invalid_argument(
606 "T1 must be positive (infinity is allowed)");
607 const double gamma =
608 std::isinf(t1) ? 0.0 : -std::expm1(-duration / t1);
609 ApplyAmplitudeDamping(qubit, gamma);
610 }
611
613 void ApplyPhaseDamping(Types::qubit_t qubit, double gamma) {
615 }
616
621 void ApplyPhaseDampingFromTime(Types::qubit_t qubit, double duration,
622 double tPhi) {
623 if (!std::isfinite(duration) || duration < 0.0)
624 throw std::invalid_argument(
625 "Phase-damping duration must be finite and nonnegative");
626 if (std::isnan(tPhi) || tPhi <= 0.0)
627 throw std::invalid_argument(
628 "T_phi must be positive (infinity is allowed)");
629 const double gamma =
630 std::isinf(tPhi) ? 0.0 : -std::expm1(-2.0 * duration / tPhi);
631 ApplyPhaseDamping(qubit, gamma);
632 }
633
635 double excitedStatePopulation) {
638 gamma, excitedStatePopulation));
639 }
640
641 void ApplyThermalRelaxation(Types::qubit_t qubit, double duration,
642 double t1, double t2,
643 double excitedStatePopulation = 0.0) {
646 duration, t1, t2, excitedStatePopulation));
647 }
648
650 Types::qubit_t qubit1,
651 double probability) {
653 {qubit0, qubit1},
655 }
656
658 Types::qubit_t qubit1,
659 double probability,
660 double correlation) {
662 {qubit0, qubit1},
663 QuantumChannel::CorrelatedPhaseFlip(probability, correlation));
664 }
665
667 Types::qubit_t qubit1,
668 double errorProbability) {
670 {qubit0, qubit1},
671 QuantumChannel::TwoQubitDepolarizing(errorProbability));
672 }
673
675 Types::qubit_t qubit0, Types::qubit_t qubit1,
676 double mixingProbability) {
678 {qubit0, qubit1},
680 }
681
693 virtual double Probability(Types::qubit_t outcome) = 0;
694
705 virtual std::complex<double> Amplitude(Types::qubit_t outcome) = 0;
706
720 virtual std::complex<double> ProjectOnZero() = 0;
721
732 virtual std::vector<double> AllProbabilities() = 0;
733
745 virtual std::vector<double> Probabilities(
746 const Types::qubits_vector &qubits) = 0;
747
764 virtual std::unordered_map<Types::qubit_t, Types::qubit_t> SampleCounts(
765 const Types::qubits_vector &qubits, size_t shots = 1000) = 0;
766
780 virtual std::unordered_map<std::vector<bool>, Types::qubit_t>
781 SampleCountsMany(const Types::qubits_vector &qubits, size_t shots = 1000) = 0;
782
794 virtual double ExpectationValue(const std::string &pauliString) = 0;
795
804 void RegisterObserver(const std::shared_ptr<ISimulatorObserver> &observer) {
805 observers.insert(observer);
806 }
807
816 void UnregisterObserver(const std::shared_ptr<ISimulatorObserver> &observer) {
817 observers.erase(observer);
818 }
819
825 void ClearObservers() { observers.clear(); }
826
835 virtual SimulatorType GetType() const = 0;
836
846
854 virtual void Flush() = 0;
855
866
874
884 virtual void SaveState() = 0;
885
894 virtual void RestoreState() = 0;
895
903 virtual std::complex<double> AmplitudeRaw(Types::qubit_t outcome) = 0;
904
913 virtual void SetMultithreading(bool multithreading = true) = 0;
914
922 virtual bool GetMultithreading() const = 0;
923
934 virtual bool IsQcsim() const = 0;
935
953
968 virtual std::vector<bool> MeasureNoCollapseMany() = 0;
969
975 virtual size_t GetCurrentMaxBondDimension() const { return 0; }
976
977 virtual const std::unordered_map<std::string, std::string>& GetConfigMap() const = 0;
978
979 protected:
985 void DontNotify() { notifyObservers = false; }
986
992 void Notify() { notifyObservers = true; }
993
1001 void NotifyObservers(const Types::qubits_vector &affectedQubits) {
1002 if (!notifyObservers) return;
1003
1004 for (auto &observer : observers) {
1005 observer->Update(affectedQubits);
1006 }
1007 }
1008
1009
1010 private:
1011 std::unordered_set<std::shared_ptr<ISimulatorObserver>>
1012 observers;
1013 bool notifyObservers =
1014 true;
1015};
1016
1017} // namespace Simulators
1018
1019#endif // !_SIMULATOR_STATE_H_
Backend-independent constructors for local CPTP quantum channels.
The operation interface.
Definition Operations.h:360
Interface class for a quantum computing simulator state.
Definition State.h:119
virtual void ApplyReset(const Types::qubits_vector &qubits)=0
Performs a reset of the specified qubits.
virtual bool IsQcsim() const =0
Returns if the simulator is a qcsim simulator.
virtual void SaveStateToInternalDestructive()=0
Saves the state to internal storage.
void ApplyTwoQubitDepolarizingNoise(Types::qubit_t qubit0, Types::qubit_t qubit1, double errorProbability)
Definition State.h:666
void Notify()
Starts notifying observers.
Definition State.h:992
virtual double getGrowthFactorSwap() const
Definition State.h:388
virtual void SetSeed(uint64_t seed)
Seed every random stream owned by this simulator.
Definition State.h:129
virtual std::vector< double > Probabilities(const Types::qubits_vector &qubits)=0
Returns the probabilities of the specified outcomes.
void ApplyTwoQubitDepolarizingMixingNoise(Types::qubit_t qubit0, Types::qubit_t qubit1, double mixingProbability)
Definition State.h:674
void ApplyPauliChannel(Types::qubit_t qubit, double px, double py, double pz)
Apply a single-qubit Pauli channel specified by X/Y/Z probabilities.
Definition State.h:552
virtual void SetInitialQubitsMap(const std::vector< long long int > &initialMap)
Sets the initial qubits map, if possible.
Definition State.h:316
virtual bool IsDensityMatrixHermitian(double=1e-10) const
Definition State.h:509
virtual void SetUpcomingGates(const std::vector< std::shared_ptr< Circuits::IOperation< double > > > &)
Supplies upcoming gates for lookahead swap optimization.
Definition State.h:357
void ApplyPhaseDampingFromTime(Types::qubit_t qubit, double duration, double tPhi)
Pure phase damping for a physical duration and T_phi.
Definition State.h:621
void UnregisterObserver(const std::shared_ptr< ISimulatorObserver > &observer)
Unregisters an observer.
Definition State.h:816
virtual void InitializeToBasisState(size_t num_qubits, const std::vector< bool > &basisState)
Initializes the state to a computational basis state.
Definition State.h:232
virtual void RestoreState()=0
Restores the state from the internally saved state.
void ApplyCorrelatedPhaseFlipNoise(Types::qubit_t qubit0, Types::qubit_t qubit1, double probability)
Definition State.h:649
virtual void SaveState()=0
Saves the state to internal storage.
virtual std::complex< double > ProjectOnZero()=0
Projects the state onto the zero state.
virtual double DensityMatrixPurity() const
Definition State.h:497
virtual std::complex< double > DensityMatrixOverlap(const IState &) const
Definition State.h:503
void ApplyKrausChannel(const Types::qubits_vector &targets, const QuantumChannel::KrausOperators &krausOperators)
Apply an arbitrary CPTP map supplied in Kraus form.
Definition State.h:532
virtual double Probability(Types::qubit_t outcome)=0
Returns the probability of the specified outcome.
virtual double DensityMatrixHermiticityResidual() const
Definition State.h:506
virtual void Initialize()=0
Initializes the state.
void ApplyPhaseFlipNoise(Types::qubit_t qubit, double probability)
Definition State.h:566
virtual size_t AllocateQubits(size_t num_qubits)=0
Allocates qubits.
virtual void ReCanonicalizeMatrixProductOperator()
Definition State.h:527
void DontNotify()
Stops notifying observers.
Definition State.h:985
void ApplyBitFlipNoise(Types::qubit_t qubit, double probability)
Definition State.h:557
void ApplyDepolarizingNoise(Types::qubit_t qubit, double errorProbability)
Depolarizing noise using total nonidentity-Pauli probability p.
Definition State.h:576
virtual void InitializeState(size_t num_qubits, std::vector< std::complex< double > > &amplitudes)=0
Initializes the state.
virtual void setGrowthFactorGate(double factor)
Definition State.h:392
void ApplyT1Relaxation(Types::qubit_t qubit, double gamma)
Alias for the exact T1 amplitude-damping channel.
Definition State.h:594
virtual std::vector< double > AllProbabilities()=0
Returns the probabilities of all possible outcomes.
virtual void RestoreDensityMatrixTrace()
Definition State.h:518
virtual void InitializeState(size_t num_qubits, AER::Vector< std::complex< double > > &amplitudes)=0
Initializes the state.
virtual double FidelityWithStatevector(const Eigen::VectorXcd &) const
Definition State.h:515
virtual SimulationType GetSimulationType() const =0
Returns the type of simulation.
virtual void InitializeToBasisState(size_t num_qubits, Types::qubit_t basisState)
Initializes the state to a computational basis state.
Definition State.h:214
void ApplyPhaseDamping(Types::qubit_t qubit, double gamma)
Phase damping with coherence multiplier sqrt(1-gamma).
Definition State.h:613
virtual std::vector< bool > MeasureMany(const Types::qubits_vector &qubits)=0
Performs a measurement on the specified qubits.
virtual void ApplyQuantumChannel(const Types::qubits_vector &targets, const QuantumChannel &channel)
Applies a local CPTP quantum channel to one or two qubits.
Definition State.h:485
virtual long long int GetGatesCounter() const
Returns the gates counter.
Definition State.h:367
void RegisterObserver(const std::shared_ptr< ISimulatorObserver > &observer)
Registers an observer.
Definition State.h:804
void ApplyCorrelatedPhaseFlipNoise(Types::qubit_t qubit0, Types::qubit_t qubit1, double probability, double correlation)
Definition State.h:657
virtual void RestoreInternalDestructiveSavedState()=0
Restores the state from the internally saved state.
virtual void SetMultithreading(bool multithreading=true)=0
Enable/disable multithreading.
virtual void SetGatesCounter(long long int)
Sets the gates counter.
Definition State.h:376
virtual double ExpectationValue(const std::string &pauliString)=0
Returns the expected value of a Pauli string.
void ApplyBitPhaseFlipNoise(Types::qubit_t qubit, double probability)
Definition State.h:561
virtual std::complex< double > Amplitude(Types::qubit_t outcome)=0
Returns the amplitude of the specified state.
virtual size_t GetNumberOfQubits() const =0
Returns the number of qubits.
virtual void InitializeToMixtureOfBasisStates(size_t num_qubits, const std::vector< std::pair< std::vector< bool >, double > > &mixture)
Initializes the state to a classical mixture of computational basis states.
Definition State.h:281
virtual SimulatorType GetType() const =0
Returns the type of simulator.
void ApplyDephasingNoise(Types::qubit_t qubit, double probability)
noise.h dephasing is a stochastic phase flip, not phase damping.
Definition State.h:571
virtual std::complex< double > AmplitudeRaw(Types::qubit_t outcome)=0
Gets the amplitude.
virtual size_t GetCurrentMaxBondDimension() const
Returns the maximum bond dimension reached.
Definition State.h:975
virtual void SetUseOptimalMeetingPosition(bool)
Enables or disables optimal meeting position for MPS swaps.
Definition State.h:327
virtual void HermitizeDensityMatrix()
Definition State.h:521
virtual void Flush()=0
Flushes the applied operations.
virtual std::complex< double > DensityMatrixTraceOfSquare() const
Definition State.h:500
virtual std::unordered_map< std::vector< bool >, Types::qubit_t > SampleCountsMany(const Types::qubits_vector &qubits, size_t shots=1000)=0
Returns the counts of the outcomes of measurement of the specified qubits, for repeated measurements.
virtual void Configure(const char *key, const char *value)=0
Configures the state.
virtual void Clear()=0
Clears the state.
virtual const std::unordered_map< std::string, std::string > & GetConfigMap() const =0
void ApplyPauliChannel(const Types::qubits_vector &targets, const std::vector< double > &probabilities)
Apply an arbitrary one- or two-qubit Pauli channel.
Definition State.h:546
void ClearObservers()
Clears all observers.
Definition State.h:825
void NotifyObservers(const Types::qubits_vector &affectedQubits)
Notifies observers.
Definition State.h:1001
virtual void SetLookaheadDepth(int)
Sets the lookahead depth for swap optimization.
Definition State.h:337
virtual bool GetMultithreading() const =0
Get the multithreading flag.
virtual void SetLookaheadDepthWithHeuristic(int)
Sets the lookahead depth for swap optimization.
Definition State.h:348
virtual bool SupportsQuantumChannels() const
Returns whether this state retains channel ensembles directly.
Definition State.h:476
void ApplyT1RelaxationFromTime(Types::qubit_t qubit, double duration, double t1)
Exact T1 relaxation for a physical duration and time constant.
Definition State.h:599
virtual size_t Measure(const Types::qubits_vector &qubits)=0
Performs a measurement on the specified qubits.
virtual std::vector< bool > MeasureNoCollapseMany()=0
Measures all the qubits without collapsing the state.
virtual ~IState()=default
Virtual destructor.
void ApplyChannel(const Types::qubits_vector &targets, const QuantumChannel::KrausOperators &krausOperators)
Alias matching the channel terminology used by QCSim's dense backend.
Definition State.h:539
void ApplyGeneralizedAmplitudeDamping(Types::qubit_t qubit, double gamma, double excitedStatePopulation)
Definition State.h:634
void ApplyThermalRelaxation(Types::qubit_t qubit, double duration, double t1, double t2, double excitedStatePopulation=0.0)
Definition State.h:641
virtual std::complex< double > DensityMatrixTrace() const
Mixed-state diagnostics.
Definition State.h:494
virtual void IncrementGatesCounter()
Increments the gates counter.
Definition State.h:384
virtual void InitializeState(size_t num_qubits, Eigen::VectorXcd &amplitudes)=0
Initializes the state.
void ApplyDepolarizingMixingNoise(Types::qubit_t qubit, double mixingProbability)
Depolarizing replacement (1-p)rho + p I/2, fully mixed at p=1.
Definition State.h:583
virtual bool SupportsMPSSwapOptimization() const
Returns if the simulator supports MPS swap optimization.
Definition State.h:306
virtual void TrimMatrixProductOperator()
Definition State.h:524
virtual double getGrowthFactorGate() const
Definition State.h:389
virtual Eigen::MatrixXcd PartialTrace(const Types::qubits_vector &) const
Definition State.h:512
void ApplyAmplitudeDamping(Types::qubit_t qubit, double gamma)
Definition State.h:589
virtual void Reset()=0
Just resets the state to 0.
virtual void InitializeToMixtureOfBasisStates(size_t num_qubits, const std::vector< std::pair< Types::qubit_t, double > > &mixture)
Initializes the state to a classical mixture of computational basis states.
Definition State.h:260
virtual std::string GetConfiguration(const char *key) const =0
Returns configuration value.
static uint64_t DeriveSeed(uint64_t seed, uint64_t stream)
Definition State.h:134
virtual std::unordered_map< Types::qubit_t, Types::qubit_t > SampleCounts(const Types::qubits_vector &qubits, size_t shots=1000)=0
Returns the counts of the outcomes of measurement of the specified qubits, for repeated measurements.
virtual void setGrowthFactorSwap(double factor)
Definition State.h:391
virtual Types::qubit_t MeasureNoCollapse()=0
Measures all the qubits without collapsing the state.
A local completely-positive, trace-preserving map in Kraus form.
static QuantumChannel Depolarizing(double errorProbability)
Depolarizing channel in the NoiseModel/QCSim convention: (1-p)rho + p/3 (XrhoX + YrhoY + ZrhoZ).
static QuantumChannel PhaseDamping(double gamma)
Phase damping with coherence multiplier sqrt(1-gamma).
static QuantumChannel Pauli(double px, double py, double pz)
Single-qubit Pauli channel with X, Y and Z error probabilities.
static QuantumChannel AmplitudeDamping(double gamma)
|1> -> |0> relaxation with probability gamma.
static QuantumChannel GeneralizedAmplitudeDamping(double gamma, double excitedStatePopulation)
Finite-temperature amplitude damping.
static QuantumChannel DepolarizingMixing(double mixingProbability)
Depolarizing channel in the replacement convention: (1-p)rho + p I/2.
static QuantumChannel CorrelatedPhaseFlip(double probability)
(1-p)rho + p (Z (x) Z) rho (Z (x) Z).
static QuantumChannel BitPhaseFlip(double probability)
(1-p) rho + p Y rho Y.
static QuantumChannel ThermalRelaxation(double duration, double t1, double t2, double excitedStatePopulation=0.0)
Hardware-style thermal relaxation for a duration, T1 and T2.
static QuantumChannel TwoQubitDepolarizingMixing(double mixingProbability)
Two-qubit replacement depolarizing, fully mixed at probability one.
static QuantumChannel PhaseFlip(double probability)
(1-p) rho + p Z rho Z.
static QuantumChannel TwoQubitDepolarizing(double errorProbability)
Two-qubit depolarizing in the total-Pauli-error convention: identity has probability 1-p and each oth...
std::vector< Matrix > KrausOperators
static QuantumChannel BitFlip(double probability)
(1-p) rho + p X rho X.
SimulationType
The type of simulation.
Definition State.h:98
@ kExtendedStabilizer
Extended stabilizer simulation type.
Definition State.h:104
@ kOther
other simulation type, could occur for the aer simulator, which also has unitary and superop methods
Definition State.h:108
@ kStatevector
statevector simulation type
Definition State.h:99
@ kMatrixProductState
matrix product state simulation type
Definition State.h:100
@ kDensityMatrix
Density matrix simulation type.
Definition State.h:106
@ kStabilizer
Clifford gates simulation type.
Definition State.h:101
@ kMatrixProductOperator
Matrix product operator simulation type.
Definition State.h:107
@ kPauliPropagator
Pauli propagator simulation type.
Definition State.h:103
@ kTensorNetwork
Tensor network simulation type.
Definition State.h:102
@ kPathIntegral
Path integral simulation type.
Definition State.h:105
SimulatorType
The type of simulator.
Definition State.h:72
@ kCompositeQCSim
composite qcsim simulator type
Definition State.h:80
@ kQCSim
qcsim simulator type
Definition State.h:76
@ kQiskitAer
qiskit aer simulator type
Definition State.h:74
@ kQuestSim
quest simulator type
Definition State.h:82
@ kDistMpiGpuSim
state distributed across MPI ranks/GPUs
Definition State.h:84
@ kCompositeQiskitAer
composite qiskit aer simulator type
Definition State.h:78
@ kDistGpuSim
state distributed across local GPUs
Definition State.h:83
@ kGpuSim
gpu simulator type
Definition State.h:81
bool IsDistributedGpuSimulator(SimulatorType type)
Definition State.h:87
bool IsGpuSimulator(SimulatorType type)
Definition State.h:90
std::vector< qubit_t > qubits_vector
The type of a vector of qubits.
Definition Types.h:22
uint_fast64_t qubit_t
The type of a qubit.
Definition Types.h:21