Skip to main content

MatsubaraFreq

Struct MatsubaraFreq 

Source
pub struct MatsubaraFreq<S: StatisticsType> { /* private fields */ }
Expand description

Matsubara frequency for a specific statistics type

This represents the Matsubara frequency ν = nπ/β, where:

  • n is the stored integer (the reduced Matsubara frequency, returned by n): odd for fermionic statistics (n = ±1, ±3, …) and even for bosonic statistics (n = 0, ±2, ±4, …)
  • β is the inverse temperature, passed to value and value_imaginary

In terms of the conventional Matsubara index m of ν = (2m + ζ)π/β, with ζ = 1 for fermionic and ζ = 0 for bosonic statistics, the stored integer is n = 2m + ζ; it is not m itself. new rejects an n whose parity does not match the statistics.

The statistics type S is checked at compile time to ensure type safety.

§Examples

use sparse_ir::{BosonicFreq, FermionicFreq};
use std::f64::consts::PI;

let beta = 10.0;

// n = 1 is the lowest positive fermionic frequency, ω = π/β (k = 0).
let w = FermionicFreq::new(1).unwrap();
assert_eq!(w.n(), 1);
assert!((w.value(beta) - PI / beta).abs() < 1e-15);

// n = 2 is the lowest positive bosonic frequency, ω = 2π/β (k = 1).
let nu = BosonicFreq::new(2).unwrap();
assert!((nu.value(beta) - 2.0 * PI / beta).abs() < 1e-15);

// The parity of n must match the statistics.
assert!(FermionicFreq::new(2).is_err());
assert!(BosonicFreq::new(1).is_err());

Adding or subtracting frequencies gives the statistics of the result: FermionicFreq ± FermionicFreq is a BosonicFreq, and a fermionic and a bosonic frequency (in either order) give a FermionicFreq.

Implementations§

Source§

impl<S: StatisticsType> MatsubaraFreq<S>

Source

pub fn n(&self) -> i64

Get the reduced Matsubara frequency n, where ν = nπ/β

n is odd for fermionic and even for bosonic statistics.

Source

pub fn new(n: i64) -> Result<Self, Error>

Create a new Matsubara frequency

§Arguments
  • n - The reduced Matsubara frequency n of ν = nπ/β: odd for fermionic statistics, even for bosonic statistics
§Errors

Error::InvalidMatsubaraIndex if n is even for fermionic or odd for bosonic statistics

§Examples
use sparse_ir::freq::{FermionicFreq, BosonicFreq};

let fermionic = FermionicFreq::new(1).unwrap();  // OK: odd n for fermionic
let bosonic = BosonicFreq::new(0).unwrap();      // OK: even n for bosonic
Source

pub unsafe fn new_unchecked(n: i64) -> Self

Create a Matsubara frequency without validation

§Safety

This function bypasses the validation in new(). Only use when you’re certain the frequency is valid for the statistics type.

Source

pub fn get_n(&self) -> i64

Get the reduced Matsubara frequency n, where ν = nπ/β (same as n)

Source

pub fn value(&self, beta: f64) -> f64

Compute the real frequency value: n * π / β

§Arguments
  • beta - Inverse temperature
§Returns

The real frequency value

Source

pub fn value_imaginary(&self, beta: f64) -> Complex64

Compute the imaginary frequency value: i * n * π / β

§Arguments
  • beta - Inverse temperature
§Returns

The imaginary frequency value as a complex number

Source

pub fn statistics(&self) -> Statistics

Get the statistics type

Source

pub fn into_i64(self) -> i64

Convert to i64 (for compatibility with C++ operator long long())

Trait Implementations§

Source§

impl Add<MatsubaraFreq<Bosonic>> for FermionicFreq

Source§

type Output = MatsubaraFreq<Fermionic>

The resulting type after applying the + operator.
Source§

fn add(self, other: BosonicFreq) -> FermionicFreq

Performs the + operation. Read more
Source§

impl Add<MatsubaraFreq<Fermionic>> for BosonicFreq

Source§

type Output = MatsubaraFreq<Fermionic>

The resulting type after applying the + operator.
Source§

fn add(self, other: FermionicFreq) -> FermionicFreq

Performs the + operation. Read more
Source§

impl<S: Clone + StatisticsType> Clone for MatsubaraFreq<S>

Source§

fn clone(&self) -> MatsubaraFreq<S>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S: Copy + StatisticsType> Copy for MatsubaraFreq<S>

Source§

impl<S: Debug + StatisticsType> Debug for MatsubaraFreq<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: StatisticsType> Display for MatsubaraFreq<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S: StatisticsType> Eq for MatsubaraFreq<S>

Source§

impl<S: StatisticsType> From<MatsubaraFreq<S>> for i64

Source§

fn from(freq: MatsubaraFreq<S>) -> Self

Converts to this type from the input type.
Source§

impl<S: StatisticsType> Hash for MatsubaraFreq<S>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<S: StatisticsType> Neg for MatsubaraFreq<S>

Source§

type Output = MatsubaraFreq<S>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl<S: StatisticsType> Ord for MatsubaraFreq<S>

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<S: StatisticsType> PartialEq for MatsubaraFreq<S>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<S: StatisticsType> PartialOrd for MatsubaraFreq<S>

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<MatsubaraFreq<Bosonic>> for FermionicFreq

Source§

type Output = MatsubaraFreq<Fermionic>

The resulting type after applying the - operator.
Source§

fn sub(self, other: BosonicFreq) -> FermionicFreq

Performs the - operation. Read more
Source§

impl Sub<MatsubaraFreq<Fermionic>> for BosonicFreq

Source§

type Output = MatsubaraFreq<Fermionic>

The resulting type after applying the - operator.
Source§

fn sub(self, other: FermionicFreq) -> FermionicFreq

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<S> Freeze for MatsubaraFreq<S>

§

impl<S> RefUnwindSafe for MatsubaraFreq<S>
where S: RefUnwindSafe,

§

impl<S> Send for MatsubaraFreq<S>
where S: Send,

§

impl<S> Sync for MatsubaraFreq<S>
where S: Sync,

§

impl<S> Unpin for MatsubaraFreq<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for MatsubaraFreq<S>

§

impl<S> UnwindSafe for MatsubaraFreq<S>
where S: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Boilerplate for T
where T: Copy + Send + Sync + Debug + PartialEq + 'static,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> RuleType for T
where T: Copy + Debug + Eq + Hash + Ord,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V