Struct FrequencyGrid

Source
pub struct FrequencyGrid {
    pub x: Vec<f64>,
    pub dx: Vec<f64>,
    pub x_half: Vec<f64>,
    pub x_half_cubed: Vec<f64>,
    pub n: usize,
}
Expand description

The frequency grid with precomputed helper arrays.

Fields§

§x: Vec<f64>

Grid points x_i

§dx: Vec<f64>

Grid spacing dx_i = x_{i+1} - x_i (length n-1)

§x_half: Vec<f64>

Cell-center values: x_{i+1/2} = (x_i + x_{i+1}) / 2 (length n-1)

§x_half_cubed: Vec<f64>

Precomputed x_half[j]³ (length n-1).

§n: usize

Number of points

Implementations§

Source§

impl FrequencyGrid

Source

pub fn from_points(x: Vec<f64>) -> Self

Build a FrequencyGrid from a sorted vector of grid points.

§Panics

Panics if x has fewer than 2 elements.

Source

pub fn new(config: &GridConfig) -> Self

Create a frequency grid from configuration.

Uses logarithmic spacing for x < x_transition and linear spacing above, with a smooth blending zone around x_transition. The blending uses a cubic Hermite (smoothstep) interpolation of the local spacing, avoiding the discontinuous 30× jump in dx that a hard log-to-linear transition would produce. This improves local truncation error near x_transition.

Source

pub fn log_uniform(x_min: f64, x_max: f64, n: usize) -> Self

Create a purely logarithmic grid (useful for testing).

§Panics

Panics if n < 2.

Source

pub fn uniform(x_min: f64, x_max: f64, n: usize) -> Self

Create a uniform grid (useful for testing).

§Panics

Panics if n < 2.

Source

pub fn find_index(&self, x_target: f64) -> usize

Find the index of the grid point closest to a given x value.

Trait Implementations§

Source§

impl Clone for FrequencyGrid

Source§

fn clone(&self) -> FrequencyGrid

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FrequencyGrid

Source§

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

Formats the value using the given formatter. Read more

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
Source§

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

Source§

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

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> 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, 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.