[−][src]Function reikna::integral::integral
pub fn integral(f: &Function, c: f64, p: u64) -> Function
Return a Function
that estimates the integral of f
, using a
constant of c
and a positive precision constant of p
.
This is a helper function that calls nth_integral()
with an
n
value of 1
. See the documentation for nth_integral()
for
more information.
Panics
Panics if nth_integral()
panics. See the documentation of
nth_integral()
for more information.
Examples
#[macro_use] extern crate reikna; use reikna::integral::*; let f = func!(|x| x * x); let integral = integral(&f, 1.0, DEFAULT_PRECISION); println!("integral({}) = {}", 0.0, integral( 0.0)); println!("integral({}) = {}", 1.0, integral( 1.0)); println!("integral({}) = {}", -2.0, integral(-2.0));
Outputs:
integral(0.0) = 1.0
integral(1.0) = 1.3333333333333333
integral(-2.0) = -1.6666666666666665