Struct FND

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

Representation of an n-dimensional function

Implementations§

Source§

impl FND

Source

pub fn derive(&self, var: char, order: usize) -> Self

Computes the nth-derivative wrt a variable

use ruut_functions::{fnd,FND};
let vars = ['f', 'z'];
assert_eq!(fnd!("f^2+z", &vars).derive('f', 1), fnd!("2f", &vars));
Source

pub fn gradient(&self) -> Vec<Self>

Computes the gradient

use ruut_functions::{fnd,FND};
let vars = ['f', 'z'];
assert_eq!(fnd!("f^2+z", &vars).gradient(), vec![fnd!("2f", &vars), fnd!("1", &vars)]);
Source

pub fn hessian(&self) -> Vec<Vec<Self>>

Computes the hessian

use ruut_functions::{fnd,FND};
let vars = ['f', 'z'];
assert_eq!(fnd!("f^3+zf", &vars).hessian(), vec![vec![fnd!("6f", &vars), fnd!("1", &vars)],
                                                 vec![fnd!("1", &vars), fnd!("0", &vars)]]);
Source§

impl FND

Source

pub fn eval(&self, val: &[(char, f64)]) -> f64

Evaluates function

Source§

impl FND

Source

pub fn new(input: &str, vars: &[char]) -> Result<Self, ParsingError>

Creates a new function from a string

Trait Implementations§

Source§

impl Debug for FND

Source§

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

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

impl PartialEq for FND

Source§

fn eq(&self, other: &FND) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FND

Auto Trait Implementations§

§

impl Freeze for FND

§

impl RefUnwindSafe for FND

§

impl Send for FND

§

impl Sync for FND

§

impl Unpin for FND

§

impl UnwindSafe for FND

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.