Quantum 3xplorer (Q3)
An AI-native quantum simulation engine
Loading...
Searching...
No Matches
phase_factor.hpp
Go to the documentation of this file.
1#pragma once
2
3/**
4 * Phase factor utility functions.
5 *
6 * Computes complex phase factors e^{±iφ} and angular phase factors (-i)^l.
7 * Pure math utilities with no domain-specific dependencies.
8 */
9
10#include <cmath>
11
13
14namespace q3 {
15
16/// Compute e^{-iφ} = cos(φ) - i·sin(φ) (standard structure factor phase).
17[[nodiscard]] inline Complex compute_phase_factor(Real phase) {
18 return Complex(std::cos(phase), -std::sin(phase));
19}
20
21/// Compute e^{+iφ} = cos(φ) + i·sin(φ) (conjugate structure factor phase).
22[[nodiscard]] inline Complex compute_phase_factor_conjugate(Real phase) {
23 return Complex(std::cos(phase), std::sin(phase));
24}
25
26/**
27 * Compute the angular phase factor (-i)^l for a given angular momentum l.
28 *
29 * Returns the complex power of -i:
30 * l % 4 == 0 → 1
31 * l % 4 == 1 → -i
32 * l % 4 == 2 → -1
33 * l % 4 == 3 → i
34 */
35[[nodiscard]] inline Complex compute_angular_phase_factor(int angular_momentum) {
36 switch (angular_momentum % 4) {
37 case 1:
38 return Complex(0.0, -1.0);
39 case 2:
40 return Complex(-1.0, 0.0);
41 case 3:
42 return Complex(0.0, 1.0);
43 default:
44 return Complex(1.0, 0.0);
45 }
46}
47
48} // namespace q3
double Real
Complex compute_phase_factor(Real phase)
Compute e^{-iφ} = cos(φ) - i·sin(φ) (standard structure factor phase).
Complex compute_angular_phase_factor(int angular_momentum)
std::complex< double > Complex
Complex compute_phase_factor_conjugate(Real phase)
Compute e^{+iφ} = cos(φ) + i·sin(φ) (conjugate structure factor phase).