Skip to content

♻️ Refactor functions to avoid the generateDensityMatrix flag #124

@WingCode

Description

@WingCode

Copied from munich-quantum-toolkit/core #337

I am not a fan of adding the generateDensityMatrix flag to a ton of functions.

Unfortunately, C++ does not allow two functions that only differ in their return values. Otherwise it would be rather easy to get rid of this generateDensityMatrix parameter, which is only relevant for density matrices.

One potential solution for this would be to refactor these methods in the following fashion:

template<class LeftOperandNode, class RightOperandNode, class ResultNode>
void multiply2(const const Edge<LeftOperandNode>& x, const Edge<RightOperandNode>& y, Edge<ResultNode>& result, Qubit var, Qubit start = 0) {
  ...
}

This would allow for specializations of Matrix * Matrix -> Matrix and Matrix * Matrix -> Density Matrix.

Originally posted by @burgholzer in cda-tum/dd_package#72 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions