Skip to main content

QuadratureBatch

Struct QuadratureBatch 

Source
pub struct QuadratureBatch { /* private fields */ }
Expand description

A batch of N quadrature outcomes, in the same order as the intervals handed in.

Lane i of the result corresponds to intervals[i], always — the parallel path preserves order.

§Getting values out

§Units

See QuadratureSolution.

Implementations§

Source§

impl QuadratureBatch

Source

pub fn solutions(&self) -> &[QuadratureSolution]

Every lane’s outcome, in input order.

Source

pub fn into_solutions(self) -> Vec<QuadratureSolution>

Consume the batch and take the outcomes.

Source

pub fn len(&self) -> usize

Number of lanes, dimensionless.

Source

pub fn is_empty(&self) -> bool

Whether the batch has no lanes.

Source

pub fn get(&self, i: usize) -> Option<QuadratureSolution>

Lane i’s outcome, or None if i is out of range.

Source

pub fn all_evaluated(&self) -> bool

Whether every lane ran to completion. Vacuously true when empty.

Source

pub fn failure_count(&self) -> usize

How many lanes failed, dimensionless.

Source

pub fn first_failure(&self) -> Option<(usize, QuadratureSolution)>

The first failing lane and its outcome, if any.

Source

pub fn failures(&self) -> Vec<(usize, QuadratureSolution)>

Every failing lane, as (index, outcome) pairs.

Allocates, so prefer Self::first_failure on a hot path.

Source

pub fn total_evaluations(&self) -> u64

Total integrand evaluations over every lane, dimensionless.

Source

pub fn values(&self) -> Result<Vec<f64>, QuadratureBatchFailure>

All integrals, or an error naming the failures — the all-or-nothing path.

§Returns

Ok(v) with v[i] the integral over intervals[i], in the integral’s units, when every lane ran to completion. Otherwise Err(QuadratureBatchFailure). No Vec of plausible-looking numbers is ever returned for a batch that contained a failure.

An empty batch returns Ok(vec![]).

§Errors

QuadratureBatchFailure when one or more lanes failed.

§Example
use outram_foam_basic_lib::compute::ComputeBackend;
use outram_foam_basic_lib::ode::parallel::{
    quadrature_batch, QuadratureInterval, QuadratureRule, QuadratureStatus,
};

// Lane 1's upper limit is not finite.
let intervals = [
    QuadratureInterval::new(0.0, 1.0),
    QuadratureInterval::new(0.0, f64::INFINITY),
];
let batch = quadrature_batch(
    &intervals,
    QuadratureRule::Simpson { panels: 8 },
    ComputeBackend::Serial,
    |_, x| x * x,
);

let err = batch.values().expect_err("lane 1 has no finite interval");
assert_eq!(err.failure_count, 1);
assert_eq!(err.first_index, 1);
assert_eq!(err.first_status, QuadratureStatus::InvalidInterval);

// The good lane is still individually readable, and Simpson is exact
// for x^2.
let v = batch.solutions()[0].value().unwrap();
assert!((v - 1.0 / 3.0).abs() < 1e-15);
assert!(batch.solutions()[1].value().is_none());

Trait Implementations§

Source§

impl Clone for QuadratureBatch

Source§

fn clone(&self) -> Self

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 Debug for QuadratureBatch

Source§

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

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

impl PartialEq for QuadratureBatch

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 StructuralPartialEq for QuadratureBatch

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, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.