File DensityDDPackage.hpp¶
Self-contained engine for density-matrix decision diagrams.
This reconstructs the density-matrix operations that used to be member functions of the MQT Core dd::Package before they were removed in https://github.com/munich-quantum-toolkit/core/pull/1466. The engine owns the density-matrix node space (memory manager, unique table, compute tables) and borrows a dd::Package for the (surviving) matrix/complex-number infrastructure it needs (gate construction, conjugate transpose, complex number pool).
The density DD reuses matrix nodes and complex numbers from the borrowed package (via the layout-compatible densityFromMatrixEdge reinterpretation). To keep those shared entries alive across the package’s own garbage collection, every density root is additionally registered in the package’s matrix root set (again via reinterpretation). The density node space itself is collected by this engine’s own garbageCollect.
-
namespace dd
-
namespace ddsim
Functions
-
inline dd::mEdge matrixFromDensityEdge(const dEdge &e)¶
Reinterpret a density-matrix edge as a matrix edge (inverse of densityFromMatrixEdge). Only safe for aligned (untagged) edges.
Variables
-
constexpr auto DENSITY_MATRIX_SIMULATOR_DD_PACKAGE_CONFIG =
[]() {dd::DDPackageConfig config{};config.utMatNumBucket = 16384U;config.ctMatAddNumBucket = 4096U;config.ctVecAddNumBucket = 4096U;config.ctMatConjTransNumBucket = 4096U;config.ctMatMatMultNumBucket = 1U;config.ctMatVecMultNumBucket = 1U;config.utVecNumBucket = 1U;config.utVecInitialAllocationSize = 1U;config.utMatInitialAllocationSize = 1U;config.ctVecKronNumBucket = 1U;config.ctMatKronNumBucket = 1U;config.ctMatTraceNumBucket = 1U;config.ctVecInnerProdNumBucket = 1U;config.ctVecAddMagNumBucket = 1U;config.ctMatAddMagNumBucket = 1U;config.ctVecConjNumBucket = 1U;return config;}()¶ Configuration for the (borrowed) matrix/vector
dd::Packageused by the deterministic (density-matrix) noise-aware simulator.
-
constexpr auto STOCHASTIC_NOISE_SIMULATOR_DD_PACKAGE_CONFIG =
[]() {dd::DDPackageConfig config{};config.ctVecAddMagNumBucket = 1U;config.ctMatAddMagNumBucket = 1U;config.ctVecConjNumBucket = 1U;return config;}()¶ Configuration for the (borrowed) matrix/vector
dd::Packageused by the stochastic noise-aware simulator.
-
class DensityDDPackage¶
- #include <DensityDDPackage.hpp>
Engine that provides density-matrix DD operations on top of a
dd::Package.Public Functions
-
inline DensityDDPackage(dd::Package &package, std::size_t nqubits, const DensityDDPackageConfig &config = {})¶
-
dEdge makeZeroDensityOperator(std::size_t n)¶
Construct the all-zero density operator \(|0...0><0...0|\).
-
dEdge applyOperationToDensity(dEdge &e, const dd::mEdge &operation)¶
Apply a matrix operation to a density matrix.
-
char measureOneCollapsing(dEdge &e, dd::Qubit index, std::mt19937_64 &mt)¶
Perform a collapsing measurement of a single qubit.
-
dEdge multiply(const dEdge &x, const dEdge &y, bool generateDensityMatrix = false)¶
Multiply two density-matrix DDs.
-
dCachedEdge add2(const dCachedEdge &x, const dCachedEdge &y, dd::Qubit var)¶
Add two (cached) density-matrix DDs.
-
dd::ComplexValue trace(const dEdge &a, std::size_t numQubits)¶
Compute the trace of a density-matrix DD.
-
dEdge makeDDNode(dd::Qubit var, const std::array<dEdge, dd::NEDGE> &edges, bool generateDensityMatrix = false)¶
Create a normalized density-matrix node from a list of edges.
-
dCachedEdge makeDDNode(dd::Qubit var, const std::array<dCachedEdge, dd::NEDGE> &edges, bool generateDensityMatrix = false)¶
-
bool garbageCollect(bool force = false)¶
Trigger garbage collection of the density node space.
-
std::size_t computeActiveNodeCount() const¶
Number of active density-matrix nodes.
Private Functions
-
dCachedEdge multiply2(const dEdge &x, const dEdge &y, dd::Qubit var, bool generateDensityMatrix)¶
-
dCachedEdge trace(const dEdge &a, const std::vector<bool> &eliminate, std::size_t level, std::size_t alreadyEliminated = 0)¶
Private Members
-
DensityUniqueTable dUniqueTable¶
-
DensityComputeTable<dCachedEdge, dCachedEdge, dCachedEdge> densityAdd¶
-
DensityComputeTable<dNode*, dNode*, dCachedEdge> densityDensityMultiplication¶
-
dd::UnaryComputeTable<dNode*, dCachedEdge> densityTrace¶
-
inline DensityDDPackage(dd::Package &package, std::size_t nqubits, const DensityDDPackageConfig &config = {})¶
-
struct DensityDDPackageConfig¶
- #include <DensityDDPackage.hpp>
Bucket sizes for the density-matrix compute and unique tables.
-
inline dd::mEdge matrixFromDensityEdge(const dEdge &e)¶
-
namespace ddsim