pub struct U1 { /* private fields */ }Expand description
An element of U(1), the circle group
Represented as a phase angle θ ∈ [0, 2π), corresponding to e^{iθ}.
§Representation
We use the angle representation rather than storing the complex number directly to avoid floating-point accumulation errors and to make the group structure (angle addition) explicit.
§Examples
use lie_groups::{LieGroup, U1};
use std::f64::consts::PI;
// Create elements
let g = U1::from_angle(0.5);
let h = U1::from_angle(0.3);
// Group multiplication (angle addition)
let product = g.compose(&h);
assert!((product.angle() - 0.8).abs() < 1e-10);
// Inverse (angle negation)
let g_inv = g.inverse();
assert!((g_inv.angle() - (2.0 * PI - 0.5)).abs() < 1e-10);Implementations§
Source§impl U1
impl U1
Sourcepub fn from_angle(theta: f64) -> Self
pub fn from_angle(theta: f64) -> Self
Create U(1) element from angle in radians
Automatically normalizes to [0, 2π)
§Arguments
theta- Phase angle in radians (any real number)
§Examples
use lie_groups::U1;
let g = U1::from_angle(0.5);
assert!((g.angle() - 0.5).abs() < 1e-10);
// Normalization
let h = U1::from_angle(2.0 * std::f64::consts::PI + 0.3);
assert!((h.angle() - 0.3).abs() < 1e-10);Sourcepub fn from_complex(z: Complex<f64>) -> Self
pub fn from_complex(z: Complex<f64>) -> Self
Create U(1) element from complex number
Extracts the phase angle from z = re^{iθ}, ignoring the magnitude.
§Arguments
z- Complex number (does not need to have unit modulus)
§Examples
use lie_groups::U1;
use num_complex::Complex;
let z = Complex::new(0.0, 1.0); // i
let g = U1::from_complex(z);
assert!((g.angle() - std::f64::consts::PI / 2.0).abs() < 1e-10);Sourcepub fn angle(&self) -> f64
pub fn angle(&self) -> f64
Get the phase angle θ ∈ [0, 2π)
§Examples
use lie_groups::U1;
let g = U1::from_angle(1.5);
assert!((g.angle() - 1.5).abs() < 1e-10);Sourcepub fn to_complex(&self) -> Complex<f64>
pub fn to_complex(&self) -> Complex<f64>
Convert to complex number e^{iθ}
Returns the complex number representation with unit modulus.
§Examples
use lie_groups::U1;
let g = U1::from_angle(std::f64::consts::PI / 2.0); // π/2
let z = g.to_complex();
assert!(z.re.abs() < 1e-10); // cos(π/2) ≈ 0
assert!((z.im - 1.0).abs() < 1e-10); // sin(π/2) = 1
assert!((z.norm() - 1.0).abs() < 1e-10); // |z| = 1Sourcepub fn trace_complex(&self) -> Complex<f64>
pub fn trace_complex(&self) -> Complex<f64>
Trace of the 1×1 matrix representation
For U(1), the trace is just the complex number itself: Tr(e^{iθ}) = e^{iθ}
§Examples
use lie_groups::U1;
let g = U1::from_angle(0.0); // Identity
let tr = g.trace_complex();
assert!((tr.re - 1.0).abs() < 1e-10);
assert!(tr.im.abs() < 1e-10);Sourcepub fn random<R: Rng>(rng: &mut R) -> Self
pub fn random<R: Rng>(rng: &mut R) -> Self
Random U(1) element uniformly distributed on the circle
Requires the rand feature (enabled by default).
Samples θ uniformly from [0, 2π).
§Examples
use lie_groups::U1;
use rand::SeedableRng;
let mut rng = rand::rngs::StdRng::seed_from_u64(42);
let g = U1::random(&mut rng);
assert!(g.angle() >= 0.0 && g.angle() < 2.0 * std::f64::consts::PI);Sourcepub fn random_small<R: Rng>(step_size: f64, rng: &mut R) -> Self
pub fn random_small<R: Rng>(step_size: f64, rng: &mut R) -> Self
Random small perturbation for MCMC proposals
Samples θ uniformly from [-step_size, +step_size]
§Arguments
step_size- Maximum angle deviation
§Examples
use lie_groups::{U1, LieGroup};
use rand::SeedableRng;
let mut rng = rand::rngs::StdRng::seed_from_u64(42);
let delta = U1::random_small(0.1, &mut rng);
// Should be close to identity
assert!(delta.distance_to_identity() <= 0.1);Trait Implementations§
Source§impl LieGroup for U1
impl LieGroup for U1
Source§fn adjoint(&self) -> Self
fn adjoint(&self) -> Self
Source§fn adjoint_action(&self, algebra_element: &U1Algebra) -> U1Algebra
fn adjoint_action(&self, algebra_element: &U1Algebra) -> U1Algebra
Ad_g: 𝔤 → 𝔤 Read moreSource§fn distance_to_identity(&self) -> f64
fn distance_to_identity(&self) -> f64
Source§fn distance(&self, other: &Self) -> f64
fn distance(&self, other: &Self) -> f64
Source§fn is_near_identity(&self, tolerance: f64) -> bool
fn is_near_identity(&self, tolerance: f64) -> bool
Source§fn trace_identity() -> f64
fn trace_identity() -> f64
Source§fn reorthogonalize(&self) -> Self
fn reorthogonalize(&self) -> Self
Source§impl MulAssign<&U1> for U1
impl MulAssign<&U1> for U1
Source§fn mul_assign(&mut self, rhs: &U1)
fn mul_assign(&mut self, rhs: &U1)
*= operation. Read moreimpl Abelian for U1
U(1) is abelian.
Complex multiplication commutes: e^{iα} · e^{iβ} = e^{iβ} · e^{iα}
§Mathematical Structure
For all g, h ∈ U(1):
g · h = e^{i(α+β)} = e^{i(β+α)} = h · gThis makes U(1) the structure group for Maxwell’s electromagnetism.
§Type Safety Example
// This function requires an abelian gauge group
fn compute_chern_number<G: Abelian>(conn: &NetworkConnection<G>) -> i32 {
// Chern class computation requires commutativity
}
// ✅ Compiles: U(1) is abelian
let u1_conn = NetworkConnection::<U1>::new(graph);
compute_chern_number(&u1_conn);
// ❌ Won't compile: SU(2) is not abelian
let su2_conn = NetworkConnection::<SU2>::new(graph);
// compute_chern_number(&su2_conn); // Compile error!§Physical Significance
- Gauge transformations commute (no self-interaction)
- Field strength is linear: F = dA (no
[A,A]term) - Maxwell’s equations are linear PDEs
- Superposition principle holds
impl Compact for U1
U(1) is compact.
The circle group {e^{iθ} : θ ∈ ℝ} is diffeomorphic to S¹. All elements have unit modulus: |e^{iθ}| = 1.
§Topological Structure
U(1) ≅ SO(2) ≅ S¹ (the unit circle)
- Closed and bounded in ℂ
- Every sequence has a convergent subsequence (Bolzano-Weierstrass)
- Admits a finite Haar measure
§Physical Significance
Compactness of U(1) ensures:
- Well-defined Yang-Mills action
- Completely reducible representations
- Quantization of electric charge
impl Copy for U1
impl StructuralPartialEq for U1
Auto Trait Implementations§
impl Freeze for U1
impl RefUnwindSafe for U1
impl Send for U1
impl Sync for U1
impl Unpin for U1
impl UnsafeUnpin for U1
impl UnwindSafe for U1
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.