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,
impl<S> TauSampling<S>where
S: StatisticsType,
Sourcepub fn new(basis: &impl Basis<S>) -> Selfwhere
S: 'static,
pub fn new(basis: &impl Basis<S>) -> Selfwhere
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 theBasistrait
§Returns
A new TauSampling object
Sourcepub fn with_sampling_points(
basis: &impl Basis<S>,
sampling_points: Vec<f64>,
) -> Selfwhere
S: 'static,
pub fn with_sampling_points(
basis: &impl Basis<S>,
sampling_points: Vec<f64>,
) -> Selfwhere
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 theBasistraitsampling_points- Custom sampling points in τ ∈ [-β, β]
§Returns
A new TauSampling object
§Panics
Panics if sampling_points is empty or if any point is outside [-β, β]
Sourcepub fn from_matrix(sampling_points: Vec<f64>, matrix: DTensor<f64, 2>) -> Self
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
Sourcepub fn sampling_points(&self) -> &[f64]
pub fn sampling_points(&self) -> &[f64]
Get the sampling points
Sourcepub fn n_sampling_points(&self) -> usize
pub fn n_sampling_points(&self) -> usize
Get the number of sampling points
Sourcepub fn basis_size(&self) -> usize
pub fn basis_size(&self) -> usize
Get the basis size
Sourcepub fn evaluate_nd<T>(
&self,
backend: Option<&GemmBackendHandle>,
coeffs: &Tensor<T, DynRank>,
dim: usize,
) -> Tensor<T, DynRank>
pub fn evaluate_nd<T>( &self, backend: Option<&GemmBackendHandle>, coeffs: &Tensor<T, DynRank>, dim: usize, ) -> Tensor<T, DynRank>
Evaluate basis coefficients at sampling points (N-dimensional)
Evaluates along the specified dimension, keeping other dimensions intact.
Supports both real (f64) and complex (Complex<f64>) coefficients.
§Type Parameters
T- Element type (f64 or Complex)
§Arguments
coeffs- N-dimensional array withcoeffs.shape().dim(dim) == basis_sizedim- Dimension along which to evaluate (0-indexed)
§Returns
N-dimensional array with result.shape().dim(dim) == n_sampling_points
§Panics
Panics if coeffs.shape().dim(dim) != basis_size or if dim >= rank
§Example
use num_complex::Complex;
use mdarray::tensor;
// Real coefficients
let values_real = sampling.evaluate_nd::<f64>(&coeffs_real, 0);
// Complex coefficients
let values_complex = sampling.evaluate_nd::<Complex<f64>>(&coeffs_complex, 0);Sourcepub fn fit_nd<T>(
&self,
backend: Option<&GemmBackendHandle>,
values: &Tensor<T, DynRank>,
dim: usize,
) -> Tensor<T, DynRank>
pub fn fit_nd<T>( &self, backend: Option<&GemmBackendHandle>, values: &Tensor<T, DynRank>, dim: usize, ) -> Tensor<T, DynRank>
Fit basis coefficients from values at sampling points (N-dimensional)
Fits along the specified dimension, keeping other dimensions intact.
Supports both real (f64) and complex (Complex<f64>) values.
§Type Parameters
T- Element type (f64 or Complex)
§Arguments
values- N-dimensional array withvalues.shape().dim(dim) == n_sampling_pointsdim- Dimension along which to fit (0-indexed)
§Returns
N-dimensional array with result.shape().dim(dim) == basis_size
§Panics
Panics if values.shape().dim(dim) != n_sampling_points, if dim >= rank, or if SVD not computed
§Example
use num_complex::Complex;
use mdarray::tensor;
// Real values
let coeffs_real = sampling.fit_nd::<f64>(&values_real, 0);
// Complex values
let coeffs_complex = sampling.fit_nd::<Complex<f64>>(&values_complex, 0);Auto Trait Implementations§
impl<S> !Freeze for TauSampling<S>
impl<S> !RefUnwindSafe for TauSampling<S>
impl<S> Send for TauSampling<S>where
S: Send,
impl<S> !Sync for TauSampling<S>
impl<S> Unpin for TauSampling<S>where
S: Unpin,
impl<S> UnwindSafe for TauSampling<S>where
S: UnwindSafe,
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoCloned<T> for T
impl<T> IntoCloned<T> for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.