Skip to main content

MatsubaraSamplingPositiveOnly

Struct MatsubaraSamplingPositiveOnly 

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

Matsubara sampling for positive frequencies only

Exploits the symmetry G(-iωn) = conj(G(iωn)) of physical Green’s functions to fit real coefficients from values at non-negative frequencies. Supports: {0, 1, 2, 3, …} (no negative frequencies)

Implementations§

Source§

impl<S: StatisticsType> MatsubaraSamplingPositiveOnly<S>

Source

pub fn new(basis: &impl Basis<S>) -> Result<Self>
where S: 'static,

Create Matsubara sampling with default positive-only sampling points

Uses the default sampling points of the basis (non-negative frequencies only). Exploits symmetry to reconstruct real coefficients.

§Errors

The errors of Basis::default_matsubara_sampling_points (NotSupported for a DLR or for basis functions without a definite parity, #183)

Source

pub fn with_sampling_points( basis: &impl Basis<S>, sampling_points: Vec<MatsubaraFreq<S>>, ) -> Result<Self>
where S: 'static,

Create Matsubara sampling with custom positive-only sampling points

The points may be in any order, and are kept in the given order: Self::sampling_points returns them unchanged, and index i along the sampling-point axis of evaluate and fit refers to sampling_points[i].

Duplicate points are accepted; they only raise the condition number.

§Errors
Source

pub fn from_matrix( sampling_points: Vec<MatsubaraFreq<S>>, matrix: &Matrix<Complex<f64>>, ) -> Result<Self>

Create Matsubara sampling (positive-only) with custom sampling points and pre-computed matrix

This constructor is useful when the sampling matrix is already computed. Uses symmetry to fit real coefficients from complex values at non-negative frequencies.

§Arguments
  • sampling_points - Matsubara frequency sampling points (must be non-negative), in any order
  • matrix - Pre-computed sampling matrix (n_points × basis_size); row i belongs to sampling_points[i]

The points are kept in the given order: Self::sampling_points returns them unchanged, and index i along the sampling-point axis of evaluate and fit refers to sampling_points[i].

Duplicate points are accepted; they only raise the condition number.

§Errors
Source

pub fn sampling_points(&self) -> &[MatsubaraFreq<S>]

Get sampling points

Source

pub fn n_sampling_points(&self) -> usize

Number of sampling points

Source

pub fn basis_size(&self) -> usize

Basis size

Source

pub fn matrix(&self) -> &Matrix<Complex<f64>>

Get the original complex sampling matrix

Source

pub fn condition_number(&self) -> Result<f64>

Condition number of the real least-squares problem that fitting solves

Fitting real coefficients x to complex values g at non-negative frequencies solves [Re A; Im A] x = [Re g; Im g], where A is the complex n_sampling_points × basis_size matrix Self::matrix. This returns σ_max / σ_min, the ratio of the largest to the smallest of the min(2 n_sampling_points, basis_size) singular values of that real 2 n_sampling_points × basis_size matrix; it bounds how much Self::fit can amplify relative errors in the values. It is not the condition number of A: with n_sampling_points ≈ basis_size / 2, A is wide, and its condition number can understate that amplification by orders of magnitude.

Returns f64::INFINITY if the smallest singular value is below 1e-15 (numerically singular matrix). The singular value decomposition is the one fitting uses: it is computed by the first call to this method or to a fit, then cached.

§Errors

Error::DecompositionFailed if the singular value decomposition fails, which a matrix of finite entries does not cause in practice (the constructors reject non-finite entries)

Source

pub fn evaluate(&self, coeffs: &[f64]) -> Result<Vec<Complex<f64>>>

Evaluate basis coefficients at sampling points

§Errors
Source

pub fn fit(&self, values: &[Complex<f64>]) -> Result<Vec<f64>>

Fit basis coefficients from values at sampling points

§Errors
Source

pub fn evaluate_nd( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensor<f64>, dim: usize, ) -> Result<TypedTensor<Complex<f64>>>

Evaluate N-dimensional array of real basis coefficients at sampling points

§Arguments
  • coeffs - N-dimensional tensor of real basis coefficients
  • dim - Dimension along which to evaluate (must have size = basis_size)
§Returns

N-dimensional tensor of complex values at Matsubara frequencies

§Errors
Source

pub fn fit_nd( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensor<Complex<f64>>, dim: usize, ) -> Result<TypedTensor<f64>>

Fit N-dimensional array of complex values to real basis coefficients

§Arguments
  • backend - Optional GEMM backend handle (None uses default)
  • values - N-dimensional tensor of complex values at Matsubara frequencies
  • dim - Dimension along which to fit (must have size = n_sampling_points)
§Returns

N-dimensional tensor of real basis coefficients

§Errors
Source

pub fn evaluate_nd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensorView<'_, f64>, dim: usize, out: &mut TypedTensorViewMut<'_, Complex<f64>>, ) -> Result<()>

Evaluate real basis coefficients at Matsubara sampling points (N-dimensional) with in-place output

§Arguments
  • coeffs - N-dimensional tensor of real coefficients with coeffs.shape().dim(dim) == basis_size
  • dim - Dimension along which to evaluate (0-indexed)
  • out - Output tensor with out.shape().dim(dim) == n_sampling_points (Complex)
§Errors
  • Error::AxisOutOfRange if dim is not an axis of coeffs
  • Error::ShapeMismatch of the input if coeffs does not have basis_size along dim, and of the output if out does not have the shape of coeffs with n_sampling_points along dim

Nothing is written to out then.

Source

pub fn fit_nd_to( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensorView<'_, Complex<f64>>, dim: usize, out: &mut TypedTensorViewMut<'_, f64>, ) -> Result<()>

Fit N-dimensional complex values to real coefficients with in-place output

§Arguments
  • values - N-dimensional tensor with values.shape().dim(dim) == n_sampling_points
  • dim - Dimension along which to fit (0-indexed)
  • out - Output tensor with out.shape().dim(dim) == basis_size (f64)
§Errors

Nothing is written to out then.

Trait Implementations§

Source§

impl<S: StatisticsType> InplaceFitter for MatsubaraSamplingPositiveOnly<S>

Source§

fn n_points(&self) -> usize

Number of sampling points.
Source§

fn basis_size(&self) -> usize

Number of basis functions.
Source§

fn evaluate_nd_dz_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensorView<'_, f64>, dim: usize, out: &mut TypedTensorViewMut<'_, Complex<f64>>, ) -> Result<()>

Evaluate: f64 coefficients to Complex<f64> values.
Source§

fn evaluate_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensorView<'_, Complex<f64>>, dim: usize, out: &mut TypedTensorViewMut<'_, Complex<f64>>, ) -> Result<()>

Evaluate: Complex<f64> coefficients to Complex<f64> values.
Source§

fn fit_nd_zd_to( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensorView<'_, Complex<f64>>, dim: usize, out: &mut TypedTensorViewMut<'_, f64>, ) -> Result<()>

Fit: Complex<f64> values to f64 coefficients.
Source§

fn fit_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensorView<'_, Complex<f64>>, dim: usize, out: &mut TypedTensorViewMut<'_, Complex<f64>>, ) -> Result<()>

Fit: Complex<f64> values to Complex<f64> coefficients.
Source§

fn evaluate_nd_dd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensorView<'_, f64>, dim: usize, out: &mut TypedTensorViewMut<'_, f64>, ) -> Result<()>

Evaluate: f64 coefficients to f64 values.
Source§

fn evaluate_nd_zd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &TypedTensorView<'_, Complex<f64>>, dim: usize, out: &mut TypedTensorViewMut<'_, f64>, ) -> Result<()>

Evaluate: Complex<f64> coefficients to f64 values.
Source§

fn fit_nd_dd_to( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensorView<'_, f64>, dim: usize, out: &mut TypedTensorViewMut<'_, f64>, ) -> Result<()>

Fit: f64 values to f64 coefficients.
Source§

fn fit_nd_dz_to( &self, backend: Option<&GemmBackendHandle>, values: &TypedTensorView<'_, f64>, dim: usize, out: &mut TypedTensorViewMut<'_, Complex<f64>>, ) -> Result<()>

Fit: f64 values to Complex<f64> coefficients.

Auto Trait Implementations§

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
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,

§

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

§

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

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, 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