Skip to content

Commit c189c20

Browse files
Copilotburgholzerpre-commit-ci[bot]
authored
Add Doxygen documentation for R(θ, φ) gate matrix implementation (#1284)
Addresses review feedback on PR #1283 requesting documentation for the `rMat` function implementation. ## Changes - Added proper Doxygen-style function docstring with `@brief`, `@param`, `@return`, and `@details` sections - Documented the mathematical formula: `R(θ, φ) = exp(-i*θ/2*(cos(φ)X + sin(φ)Y))` - Documented the explicit matrix representation: `[[cos(θ/2), -i*e^(-iφ)*sin(θ/2)], [-i*e^(iφ)*sin(θ/2), cos(θ/2)]]` - Added parameter descriptions for `theta` (rotation angle) and `phi` (rotation axis angle) The documentation clarifies the relationship between the exponential form and the matrix elements computed in the implementation, following the standard Doxygen format used throughout the codebase. ```cpp /** * @brief Computes the matrix representation of the R(θ, φ) gate. * @param theta The rotation angle θ. * @param phi The rotation axis angle φ. * @return The gate matrix for the R(θ, φ) rotation. * * @details The R(θ, φ) gate is defined as R(θ, φ) = exp(-i*θ/2*(cos(φ)X + sin(φ)Y)), * which results in the matrix: * [[cos(θ/2), -i*e^(-iφ)*sin(θ/2)], * [-i*e^(iφ)*sin(θ/2), cos(θ/2)]] */ GateMatrix rMat(const fp theta, const fp phi) { // ... implementation } ``` <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: burgholzer <6358767+burgholzer@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Lukas Burgholzer <burgholzer@me.com>
1 parent f1cc80f commit c189c20

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/dd/GateMatrixDefinitions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ GateMatrix rzMat(const fp lambda) {
6565
{std::cos(lambda / 2.), std::sin(lambda / 2.)}}};
6666
}
6767

68+
/**
69+
* @brief Computes the matrix representation of the R(θ, φ) gate.
70+
* @param theta The rotation angle θ.
71+
* @param phi The rotation axis angle φ.
72+
* @return The gate matrix for the R(θ, φ) rotation.
73+
*
74+
* @details The R(θ, φ) gate is defined as R(θ, φ) = exp(-i*θ/2*(cos(φ)X +
75+
* sin(φ)Y)), which results in the matrix:
76+
* [[cos(θ/2), -i*e^(-iφ)*sin(θ/2)],
77+
* [-i*e^(iφ)*sin(θ/2), cos(θ/2)]]
78+
*/
6879
GateMatrix rMat(const fp theta, const fp phi) {
6980
const auto cosTheta = std::cos(theta / 2.);
7081
const auto sinTheta = std::sin(theta / 2.);

0 commit comments

Comments
 (0)