pub struct HessianOperations;Expand description
Hessian matrix operations
Implementations§
Source§impl HessianOperations
impl HessianOperations
Sourcepub fn compute(expr: &Expression, variables: &[Symbol]) -> Vec<Vec<Expression>>
pub fn compute(expr: &Expression, variables: &[Symbol]) -> Vec<Vec<Expression>>
Compute Hessian matrix
§Examples
use mathhook_core::simplify::Simplify;
use mathhook_core::calculus::derivatives::Derivative;
use mathhook_core::{Expression};
use mathhook_core::symbol;
use mathhook_core::calculus::derivatives::HessianOperations;
let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::add(vec![
Expression::pow(Expression::symbol(x.clone()), Expression::integer(2)),
Expression::pow(Expression::symbol(y.clone()), Expression::integer(2))
]);
let hessian = HessianOperations::compute(&expr, &[x, y]);Sourcepub fn determinant(expr: &Expression, variables: Vec<Symbol>) -> Expression
pub fn determinant(expr: &Expression, variables: Vec<Symbol>) -> Expression
Compute Hessian determinant
§Examples
use mathhook_core::{Expression, Symbol};
use mathhook_core::symbol;
use mathhook_core::calculus::derivatives::HessianOperations;
let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::add(vec![
Expression::pow(Expression::symbol(x.clone()), Expression::integer(2)),
Expression::pow(Expression::symbol(y.clone()), Expression::integer(2))
]);
let det = HessianOperations::determinant(&expr, vec![x, y]);Sourcepub fn is_positive_definite(expr: &Expression, variables: Vec<Symbol>) -> bool
pub fn is_positive_definite(expr: &Expression, variables: Vec<Symbol>) -> bool
Check if Hessian is positive definite (for optimization)
§Examples
use mathhook_core::{Expression};
use mathhook_core::symbol;
use mathhook_core::calculus::derivatives::HessianOperations;
let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::add(vec![
Expression::pow(Expression::symbol(x.clone()), Expression::integer(2)),
Expression::pow(Expression::symbol(y.clone()), Expression::integer(2))
]);
let is_pos_def = HessianOperations::is_positive_definite(&expr, vec![x, y]);Sourcepub fn trace(expr: &Expression, variables: Vec<Symbol>) -> Expression
pub fn trace(expr: &Expression, variables: Vec<Symbol>) -> Expression
Compute trace of Hessian matrix
§Examples
use mathhook_core::{Expression, Symbol};
use mathhook_core::symbol;
use mathhook_core::calculus::derivatives::HessianOperations;
let x = symbol!(x);
let y = symbol!(y);
let expr = Expression::add(vec![
Expression::mul(vec![Expression::integer(3), Expression::pow(Expression::symbol(x.clone()), Expression::integer(2))]),
Expression::mul(vec![Expression::integer(5), Expression::pow(Expression::symbol(y.clone()), Expression::integer(2))])
]);
let trace = HessianOperations::trace(&expr, vec![x, y]);Auto Trait Implementations§
impl Freeze for HessianOperations
impl RefUnwindSafe for HessianOperations
impl Send for HessianOperations
impl Sync for HessianOperations
impl Unpin for HessianOperations
impl UnsafeUnpin for HessianOperations
impl UnwindSafe for HessianOperations
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more