TauSampling

Struct TauSampling 

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

Sparse sampling in imaginary time

Allows transformation between the IR basis and a set of sampling points in imaginary time (τ).

Implementations§

Source§

impl<S> TauSampling<S>
where S: StatisticsType,

Source

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

Create a new TauSampling with default sampling points

The default sampling points are chosen as the extrema of the highest-order basis function, which gives near-optimal conditioning. SVD is computed lazily on first call to fit or fit_nd.

§Arguments
  • basis - Any basis implementing the Basis trait
§Returns

A new TauSampling object

Source

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

Create a new TauSampling with custom sampling points

SVD is computed lazily on first call to fit or fit_nd.

§Arguments
  • basis - Any basis implementing the Basis trait
  • sampling_points - Custom sampling points in τ ∈ [-β, β]
§Returns

A new TauSampling object

§Panics

Panics if sampling_points is empty or if any point is outside [-β, β]

Source

pub fn from_matrix(sampling_points: Vec<f64>, matrix: DTensor<f64, 2>) -> Self

Create a new TauSampling with custom sampling points and pre-computed matrix

This constructor is useful when the sampling matrix is already computed (e.g., from external sources or for testing).

§Arguments
  • sampling_points - Sampling points in τ ∈ [-β, β]
  • matrix - Pre-computed sampling matrix (n_points × basis_size)
§Returns

A new TauSampling object

§Panics

Panics if sampling_points is empty or if matrix dimensions don’t match

Source

pub fn sampling_points(&self) -> &[f64]

Get the sampling points

Source

pub fn n_sampling_points(&self) -> usize

Get the number of sampling points

Source

pub fn basis_size(&self) -> usize

Get the basis size

Source

pub fn matrix(&self) -> &DTensor<f64, 2>

Get the sampling matrix

Source

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

Evaluate basis coefficients at sampling points

Computes g(τ_i) = Σ_l a_l * u_l(τ_i) for all sampling points

§Arguments
  • coeffs - Basis coefficients (length = basis_size)
§Returns

Values at sampling points (length = n_sampling_points)

Source

pub fn evaluate_to(&self, coeffs: &[f64], out: &mut [f64])

Evaluate basis coefficients at sampling points, writing to output slice

Source

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

Fit values at sampling points to basis coefficients

Source

pub fn fit_to(&self, values: &[f64], out: &mut [f64])

Fit values at sampling points to basis coefficients, writing to output slice

Source

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

Evaluate complex basis coefficients at sampling points

Source

pub fn evaluate_zz_to(&self, coeffs: &[Complex<f64>], out: &mut [Complex<f64>])

Evaluate complex basis coefficients, writing to output slice

Source

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

Fit complex values at sampling points to basis coefficients

Source

pub fn fit_zz_to(&self, values: &[Complex<f64>], out: &mut [Complex<f64>])

Fit complex values, writing to output slice

Source

pub fn evaluate_nd( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<f64, DynRank>, dim: usize, ) -> Tensor<f64, DynRank>

Evaluate N-D real coefficients at sampling points

§Arguments
  • coeffs - N-dimensional array with coeffs.shape().dim(dim) == basis_size
  • dim - Dimension along which to evaluate (0-indexed)
§Returns

N-dimensional array with result.shape().dim(dim) == n_sampling_points

Source

pub fn evaluate_nd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, )

Evaluate N-D real coefficients, writing to a mutable view

Source

pub fn fit_nd( &self, backend: Option<&GemmBackendHandle>, values: &Slice<f64, DynRank>, dim: usize, ) -> Tensor<f64, DynRank>

Fit N-D real values at sampling points to basis coefficients

§Arguments
  • values - N-dimensional array with values.shape().dim(dim) == n_sampling_points
  • dim - Dimension along which to fit (0-indexed)
§Returns

N-dimensional array with result.shape().dim(dim) == basis_size

Source

pub fn fit_nd_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, )

Fit N-D real values, writing to a mutable view

Source

pub fn evaluate_nd_zz( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<Complex<f64>, DynRank>, dim: usize, ) -> Tensor<Complex<f64>, DynRank>

Evaluate N-D complex coefficients at sampling points

§Arguments
  • coeffs - N-dimensional complex array with coeffs.shape().dim(dim) == basis_size
  • dim - Dimension along which to evaluate (0-indexed)
§Returns

N-dimensional complex array with result.shape().dim(dim) == n_sampling_points

Source

pub fn evaluate_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, )

Evaluate N-D complex coefficients, writing to a mutable view

Source

pub fn fit_nd_zz( &self, backend: Option<&GemmBackendHandle>, values: &Slice<Complex<f64>, DynRank>, dim: usize, ) -> Tensor<Complex<f64>, DynRank>

Fit N-D complex values at sampling points to basis coefficients

§Arguments
  • values - N-dimensional complex array with values.shape().dim(dim) == n_sampling_points
  • dim - Dimension along which to fit (0-indexed)
§Returns

N-dimensional complex array with result.shape().dim(dim) == basis_size

Source

pub fn fit_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, )

Fit N-D complex values, writing to a mutable view

Trait Implementations§

Source§

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

InplaceFitter implementation for TauSampling

Delegates to RealMatrixFitter which supports dd and zz operations.

Source§

fn n_points(&self) -> usize

Number of sampling points
Source§

fn basis_size(&self) -> usize

Number of basis functions
Source§

fn evaluate_nd_dd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, ) -> bool

Evaluate ND: f64 coeffs → f64 values
Source§

fn evaluate_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, ) -> bool

Evaluate ND: Complex coeffs → Complex values
Source§

fn fit_nd_dd_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, ) -> bool

Fit ND: f64 values → f64 coeffs
Source§

fn fit_nd_zz_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, ) -> bool

Fit ND: Complex values → Complex coeffs
Source§

fn evaluate_nd_dz_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, ) -> bool

Evaluate ND: f64 coeffs → Complex values
Source§

fn evaluate_nd_zd_to( &self, backend: Option<&GemmBackendHandle>, coeffs: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, ) -> bool

Evaluate ND: Complex coeffs → f64 values
Source§

fn fit_nd_dz_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<f64, DynRank>, dim: usize, out: &mut ViewMut<'_, Complex<f64>, DynRank>, ) -> bool

Fit ND: f64 values → Complex coeffs
Source§

fn fit_nd_zd_to( &self, backend: Option<&GemmBackendHandle>, values: &Slice<Complex<f64>, DynRank>, dim: usize, out: &mut ViewMut<'_, f64, DynRank>, ) -> bool

Fit ND: Complex values → f64 coeffs

Auto Trait Implementations§

§

impl<S> !Freeze for TauSampling<S>

§

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

§

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

§

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

§

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

§

impl<S> UnwindSafe for TauSampling<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
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
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

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

Source§

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.

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> IntoCloned<T> for T

Source§

fn clone_to(self, target: &mut T)

Moves an existing object or clones from a reference to the target object.
Source§

fn into_cloned(self) -> T

Returns an existing object or a new clone from a reference.
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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.
Source§

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

Source§

fn vzip(self) -> V