Struct Integraal

Source
pub struct Integraal<X: Scalar> { /* private fields */ }
Expand description

Main integral computation structure

This structure is used as the entrypoint for integral definition and computation. It follows a pseudo-builder patterns where the function description is reset after a computation. This is the preferred behavior as many different integrals may be computed over the same domain in scientific applications.

§Usage

§Components

The structure is made up of three components that are used to describe the integral the user wishes to compute:

  • a DomainDescriptor instance, used to describe the space over which the integral span
  • a FunctionDescriptor instance, used to describe the integrated function
  • a ComputeMethod instance, used to choose which numerical integration method will be used for value approximation

In the future, another object might be included to control the execution backend.

§Example

// describe domain; 0 to 1, with a step of 10^-5
let domain = DomainDescriptor::Uniform {
    start: 0.0,
    step: 0.00001,
    n_step: 100_001,
};

// decribe the function; f(x) = 2 * x
let function = FunctionDescriptor::Closure(Box::new(|x: f64| 2.0 * x));

// choose the numerical integration method
let method = ComputeMethod::Trapezoid;

// build the integral & compute it
let mut integral = Integraal::default()
    .domain(domain)
    .function(function)
    .method(method);

assert!(integral.compute().is_ok())

Implementations§

Source§

impl<X: Scalar> Integraal<X>

Source

pub fn domain(self, domain_descriptor: DomainDescriptor<X>) -> Self

Set the domain descriptor.

Source

pub fn function(self, function_descriptor: FunctionDescriptor<X>) -> Self

Set the function descriptor.

Source

pub fn method(self, compute_method: ComputeMethod) -> Self

Set the numerical integration method.

Source

pub fn compute(&mut self) -> Result<X, IntegraalError>

This method attempts to compute the integral. If it is successful, it will clear the internal FunctionDescriptor object before returning the result.

§Return / Errors

This method returns a Result taking the following values:

  • Ok(X: Scalar) – The computation succeeded.
  • Err(IntegraalError) – The computation failed for the reason specified by the enum.

Trait Implementations§

Source§

impl<X: Default + Scalar> Default for Integraal<X>

Source§

fn default() -> Integraal<X>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<X> Freeze for Integraal<X>
where X: Freeze,

§

impl<X> !RefUnwindSafe for Integraal<X>

§

impl<X> !Send for Integraal<X>

§

impl<X> !Sync for Integraal<X>

§

impl<X> Unpin for Integraal<X>
where X: Unpin,

§

impl<X> !UnwindSafe for Integraal<X>

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