Trait finitediff::FiniteDiff[][src]

pub trait FiniteDiff where
    Self: Sized
{ type Jacobian; type Hessian; type OperatorOutput;
Show methods fn forward_diff(&self, f: &dyn Fn(&Self) -> f64) -> Self;
fn central_diff(&self, f: &dyn Fn(&Self) -> f64) -> Self;
fn forward_jacobian(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput
    ) -> Self::Jacobian;
fn central_jacobian(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput
    ) -> Self::Jacobian;
fn forward_jacobian_vec_prod(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput,
        p: &Self
    ) -> Self;
fn central_jacobian_vec_prod(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput,
        p: &Self
    ) -> Self;
fn forward_jacobian_pert(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput,
        pert: &PerturbationVectors
    ) -> Self::Jacobian;
fn central_jacobian_pert(
        &self,
        fs: &dyn Fn(&Self) -> Self::OperatorOutput,
        pert: &PerturbationVectors
    ) -> Self::Jacobian;
fn forward_hessian(
        &self,
        g: &dyn Fn(&Self) -> Self::OperatorOutput
    ) -> Self::Hessian;
fn central_hessian(
        &self,
        g: &dyn Fn(&Self) -> Self::OperatorOutput
    ) -> Self::Hessian;
fn forward_hessian_vec_prod(
        &self,
        g: &dyn Fn(&Self) -> Self::OperatorOutput,
        p: &Self
    ) -> Self;
fn central_hessian_vec_prod(
        &self,
        g: &dyn Fn(&Self) -> Self::OperatorOutput,
        p: &Self
    ) -> Self;
fn forward_hessian_nograd(&self, f: &dyn Fn(&Self) -> f64) -> Self::Hessian;
fn forward_hessian_nograd_sparse(
        &self,
        f: &dyn Fn(&Self) -> f64,
        indices: Vec<[usize; 2]>
    ) -> Self::Hessian;
}

Associated Types

type Jacobian[src]

type Hessian[src]

type OperatorOutput[src]

Loading content...

Required methods

fn forward_diff(&self, f: &dyn Fn(&Self) -> f64) -> Self[src]

Forward difference calculated as

df/dx_i (x) \approx (f(x + sqrt(EPS_F64) * e_i) - f(x))/sqrt(EPS_F64) \forall i

where f is the cost function and e_i is the ith unit vector. For a parameter vector of length n, this requires n+1 evaluations of f.

fn central_diff(&self, f: &dyn Fn(&Self) -> f64) -> Self[src]

Central difference calculated as

df/dx_i (x) \approx (f(x + sqrt(EPS_F64) * e_i) - f(x - sqrt(EPS_F64) * e_i))/(2.0 * sqrt(EPS_F64)) \forall i

where f is the cost function and e_i is the ith unit vector. For a parameter vector of length n, this requires 2*n evaluations of f.

fn forward_jacobian(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput
) -> Self::Jacobian
[src]

Calculation of the Jacobian J(x) of a vector function fs using forward differences:

dfs/dx_i (x) \approx (fs(x + sqrt(EPS_F64) * e_i) - fs(x))/sqrt(EPS_F64) \forall i

where e_i is the ith unit vector. For a parameter vector of length n, this requires n+1 evaluations of fs.

fn central_jacobian(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput
) -> Self::Jacobian
[src]

Calculation of the Jacobian J(x) of a vector function fs using central differences:

dfs/dx_i (x) \approx (fs(x + sqrt(EPS_F64) * e_i) - fs(x - sqrt(EPS_F64) * e_i))/(2.0 * sqrt(EPS_F64)) \forall i

where e_i is the ith unit vector. For a parameter vector of length n, this requires 2*n evaluations of fs.

fn forward_jacobian_vec_prod(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput,
    p: &Self
) -> Self
[src]

Calculation of the product of the Jacobian J(x) of a vector function fs with a vector p using forward differences:

J(x)*p \approx (fs(x + sqrt(EPS_F64) * p) - fs(x))/sqrt(EPS_F64) \forall i

where e_i is the ith unit vector. This requires 2 evaluations of fs.

fn central_jacobian_vec_prod(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput,
    p: &Self
) -> Self
[src]

Calculation of the product of the Jacobian J(x) of a vector function fs with a vector p using central differences:

J(x)*p \approx (fs(x + sqrt(EPS_F64) * p) - fs(x - sqrt(EPS_F64) * p))/(2.0 * sqrt(EPS_F64)) \forall i

where e_i is the ith unit vector. This requires 2 evaluations of fs.

fn forward_jacobian_pert(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput,
    pert: &PerturbationVectors
) -> Self::Jacobian
[src]

fn central_jacobian_pert(
    &self,
    fs: &dyn Fn(&Self) -> Self::OperatorOutput,
    pert: &PerturbationVectors
) -> Self::Jacobian
[src]

fn forward_hessian(
    &self,
    g: &dyn Fn(&Self) -> Self::OperatorOutput
) -> Self::Hessian
[src]

Calculation of the Hessian using forward differences

dg/dx_i (x) \approx (g(x + sqrt(EPS_F64) * e_i) - g(x))/sqrt(EPS_F64) \forall i

where g is a function which computes the gradient of some other function f and e_i is the ith unit vector. For a parameter vector of length n, this requires n+1 evaluations of g.

fn central_hessian(
    &self,
    g: &dyn Fn(&Self) -> Self::OperatorOutput
) -> Self::Hessian
[src]

Calculation of the Hessian using central differences

dg/dx_i (x) \approx (g(x + sqrt(EPS_F64) * e_i) - g(x - sqrt(EPS_F64) * e_i))/(2.0 * sqrt(EPS_F64)) \forall i

where g is a function which computes the gradient of some other function f and e_i is the ith unit vector. For a parameter vector of length n, this requires 2*n evaluations of g.

fn forward_hessian_vec_prod(
    &self,
    g: &dyn Fn(&Self) -> Self::OperatorOutput,
    p: &Self
) -> Self
[src]

Calculation of the product of the Hessian H(x) of a function g with a vector p using forward differences:

H(x)*p \approx (g(x + sqrt(EPS_F64) * p) - g(x))/sqrt(EPS_F64) \forall i

where g is a function which computes the gradient of some other function f and e_i is the ith unit vector. This requires 2 evaluations of g.

fn central_hessian_vec_prod(
    &self,
    g: &dyn Fn(&Self) -> Self::OperatorOutput,
    p: &Self
) -> Self
[src]

Calculation of the product of the Hessian H(x) of a function g with a vector p using central differences:

H(x)*p \approx (g(x + sqrt(EPS_F64) * p) - g(x - sqrt(EPS_F64) * p))/(2.0 * sqrt(EPS_F64)) \forall i

where g is a function which computes the gradient of some other function f and e_i is the ith unit vector. This requires 2 evaluations of g.

fn forward_hessian_nograd(&self, f: &dyn Fn(&Self) -> f64) -> Self::Hessian[src]

Calculation of the Hessian using forward differences without knowledge of the gradient:

df/(dx_i dx_j) (x) \approx (f(x + sqrt(EPS_F64) * e_i + sqrt(EPS_F64) * e_j) - f(x + sqrt(EPS_F64) + e_i) - f(x + sqrt(EPS_F64) * e_j) + f(x))/EPS_F64 \forall i

where e_i and e_j are the ith and jth unit vector, respectively.

fn forward_hessian_nograd_sparse(
    &self,
    f: &dyn Fn(&Self) -> f64,
    indices: Vec<[usize; 2]>
) -> Self::Hessian
[src]

Calculation of a sparse Hessian using forward differences without knowledge of the gradient:

df/(dx_i dx_j) (x) \approx (f(x + sqrt(EPS_F64) * e_i + sqrt(EPS_F64) * e_j) - f(x + sqrt(EPS_F64) + e_i) - f(x + sqrt(EPS_F64) * e_j) + f(x))/EPS_F64 \forall i

where e_i and e_j are the ith and jth unit vector, respectively. The indices which are to be evaluated need to be provided via indices. Note that due to the symmetry of the Hessian, an index (a, b) will also compute the value of the Hessian at (b, a).

Loading content...

Implementations on Foreign Types

impl FiniteDiff for Vec<f64> where
    Self: Sized
[src]

type Jacobian = Vec<Vec<f64>>

type Hessian = Vec<Vec<f64>>

type OperatorOutput = Vec<f64>

impl FiniteDiff for Array1<f64> where
    Self: Sized
[src]

type Jacobian = Array2<f64>

type Hessian = Array2<f64>

type OperatorOutput = Array1<f64>

Loading content...

Implementors

Loading content...