Struct Dual2

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

A dual number data type supporting second order derivatives.

Implementations§

Source§

impl Dual2

Source

pub fn new(real: f64, vars: Vec<String>) -> Self

Constructs a new Dual2.

  • vars should be unique; duplicates will be removed by the IndexSet.

Gradient values for each of the provided vars is set to 1.0_f64. Second order gradient values for each combination of provided vars is set to 0.0_f64.

§Examples
let x = Dual2::new(2.5, vec!["x".to_string()]);
// x: <Dual2: 2.5, (x), [1.0], [[0.0]]>
Source

pub fn try_new( real: f64, vars: Vec<String>, dual: Vec<f64>, dual2: Vec<f64>, ) -> Result<Self, PyErr>

Constructs a new Dual2.

  • vars should be unique; duplicates will be removed by the IndexSet.
  • dual can be empty; if so each gradient with respect to each vars is set to 1.0_f64.
  • dual2 can be empty; if so each gradient with respect to each vars is set to 0.0_f64. Input as a flattened 2d-array in row major order.
§Errors

If the length of dual and of vars are not the same after parsing. If the shape of two dimension dual2 does not match vars after parsing.

§Examples
let x = Dual2::try_new(2.5, vec!["x".to_string()], vec![], vec![]).unwrap();
// x: <Dual2: 2.5, (x), [1.0], [[0.0]]>
Source

pub fn new_from<T: Vars>(other: &T, real: f64, vars: Vec<String>) -> Self

Construct a new Dual2 cloning the vars Arc pointer from another.

§Examples
let x = Dual2::try_new(2.5, vec!["x".to_string(), "y".to_string()], vec![1.0, 0.0], vec![]).unwrap();
let y1 = Dual2::new_from(&x, 1.5, vec!["y".to_string()]);

This is semantically the same as:

let y = Dual2::new(1.5, vec!["y".to_string()]).to_new_vars(x.vars(), None);
Source

pub fn try_new_from<T: Vars>( other: &T, real: f64, vars: Vec<String>, dual: Vec<f64>, dual2: Vec<f64>, ) -> Result<Self, PyErr>

Construct a new Dual2 cloning the vars Arc pointer from another.

§Examples
let x = Dual2::try_new(2.5, vec!["x".to_string(), "y".to_string()], vec![1.0, 0.0], vec![]).unwrap();
let y1 = Dual2::new_from(&x, 1.5, vec!["y".to_string()]);

This is semantically the same as:

let y2 = Dual2::new(1.5, vec!["y".to_string()]).to_new_vars(x.vars(), None);
assert_eq!(y1, y2);
Source

pub fn clone_from<T: Vars>( other: &T, real: f64, dual: Array1<f64>, dual2: Array2<f64>, ) -> Self

Construct a new Dual2 cloning the vars Arc pointer from another.

Source

pub fn real(&self) -> f64

Get the real component value of the struct.

Source§

impl Dual2

Source

pub fn new_py( real: f64, vars: Vec<String>, dual: Vec<f64>, dual2: Vec<f64>, ) -> PyResult<Self>

Python wrapper to construct a new Dual2.

Source

pub fn vars_from( other: &Dual2, real: f64, vars: Vec<String>, dual: Vec<f64>, dual2: Vec<f64>, ) -> PyResult<Self>

Create a :class:~rateslib.dual.Dual2 object with vars linked with another.

§Parameters

other: Dual The other Dual from which vars are linked. real: float The real coefficient of the dual number. vars: list(str) The labels of the variables for which to record derivatives. If empty, the dual number represents a constant, equivalent to a float. dual: list(float) First derivative information contained as coefficient of linear manifold. Defaults to an array of ones the length of vars if empty. dual2: list(float) Second derivative information contained as coefficients of a quadratic manifold. These values represent a 2d array but must be given as a 1d list of values in row-major order. Defaults to a 2-d array of zeros of size NxN where N is length of vars if not given.

§Returns

Dual2

§Notes

For examples see also…

.. seealso::

:meth:~rateslib.dual.Dual.vars_from: Create a Dual with vars linked to another.

Trait Implementations§

Source§

impl Add<&Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Dual2> for Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for Dual2

Source§

type Output = Dual2

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Dual2) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Dual2

Source§

fn clone(&self) -> Dual2

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Dual2

Source§

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

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

impl Default for Dual2

Source§

fn default() -> Dual2

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

impl<'de> Deserialize<'de> for Dual2

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Div<&Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Dual2> for Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Dual2

Source§

type Output = Dual2

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Dual2) -> Self::Output

Performs the / operation. Read more
Source§

impl Element for Dual2

Source§

const IS_COPY: bool = false

Flag that indicates whether this type is trivially copyable. Read more
Source§

fn get_dtype(py: Python<'_>) -> Bound<'_, PyArrayDescr>

Returns the associated type descriptor (“dtype”) for the given element type.
Source§

fn clone_ref(&self, _py: Python<'_>) -> Self

Create a clone of the value while the GIL is guaranteed to be held.
§

fn vec_from_slice(py: Python<'_>, slc: &[Self]) -> Vec<Self>

Create an owned copy of the slice while the GIL is guaranteed to be held. Read more
§

fn array_from_view<D>( py: Python<'_>, view: ArrayBase<ViewRepr<&Self>, D>, ) -> ArrayBase<OwnedRepr<Self>, D>
where D: Dimension,

Create an owned copy of the array while the GIL is guaranteed to be held. Read more
Source§

impl From<&Dual> for Dual2

Source§

fn from(value: &Dual) -> Self

Converts to this type from the input type.
Source§

impl From<&Dual2> for Dual

Source§

fn from(value: &Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<&Dual2> for Number

Source§

fn from(value: &Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<&Dual2> for f64

Source§

fn from(value: &Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<&Number> for Dual2

Source§

fn from(value: &Number) -> Self

Converts to this type from the input type.
Source§

impl From<Dual> for Dual2

Source§

fn from(value: Dual) -> Self

Converts to this type from the input type.
Source§

impl From<Dual2> for Dual

Source§

fn from(value: Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<Dual2> for Number

Source§

fn from(value: Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<Dual2> for f64

Source§

fn from(value: Dual2) -> Self

Converts to this type from the input type.
Source§

impl From<Number> for Dual2

Source§

fn from(value: Number) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Dual2

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl Gradient1 for Dual2

Source§

fn dual(&self) -> &Array1<f64>

Get a reference to the Array containing the first order gradients.
Source§

fn gradient1(&self, vars: Vec<String>) -> Array1<f64>

Return a set of first order gradients ordered by the given vector. Read more
Source§

impl Gradient2 for Dual2

Source§

fn dual2(&self) -> &Array2<f64>

Get a reference to the Array containing the second order gradients.
Source§

fn gradient2(&self, vars: Vec<String>) -> Array2<f64>

Return a set of first order gradients ordered by the given vector. Read more
Source§

fn gradient1_manifold(&self, vars: Vec<String>) -> Array1<Dual2>

Source§

impl<'py> IntoPyObject<'py> for Dual2

Source§

type Target = Dual2

The Python output type
Source§

type Output = Bound<'py, <Dual2 as IntoPyObject<'py>>::Target>

The smart pointer type to use. Read more
Source§

type Error = PyErr

The type returned in the event of a conversion error.
Source§

fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>

Performs the conversion.
Source§

impl MathFuncs for Dual2

Source§

fn exp(&self) -> Self

Return the exponential of a value.
Source§

fn log(&self) -> Self

Return the natural logarithm of a value.
Source§

fn norm_cdf(&self) -> Self

Return the standard normal cumulative distribution function of a value.
Source§

fn inv_norm_cdf(&self) -> Self

Return the inverse standard normal cumulative distribution function of a value.
Source§

impl Mul<&Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Dual2> for Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Dual2

Source§

type Output = Dual2

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Dual2) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for &Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Num for Dual2

Source§

type FromStrRadixErr = String

Source§

fn from_str_radix( _src: &str, _radix: u32, ) -> Result<Self, Self::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl One for Dual2

Source§

fn one() -> Dual2

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl PartialEq<Dual2> for f64

Source§

fn eq(&self, other: &Dual2) -> 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 PartialEq<f64> for Dual2

Source§

fn eq(&self, other: &f64) -> 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 PartialEq for Dual2

Source§

fn eq(&self, other: &Dual2) -> 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 PartialOrd<Dual2> for f64

Source§

fn partial_cmp(&self, other: &Dual2) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<f64> for Dual2

Source§

fn partial_cmp(&self, other: &f64) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for Dual2

Source§

fn partial_cmp(&self, other: &Dual2) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Pow<&Dual2> for &Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<&Dual2> for &f64

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<&Dual2> for Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<&Dual2> for f64

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<&f64> for &Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &f64) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<&f64> for Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: &f64) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<Dual2> for &Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<Dual2> for &f64

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<Dual2> for Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<Dual2> for f64

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: Dual2) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<f64> for &Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: f64) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl Pow<f64> for Dual2

Source§

type Output = Dual2

The result after applying the operator.
Source§

fn pow(self, power: f64) -> Self::Output

Returns self to the power rhs. Read more
Source§

impl PyClass for Dual2

Source§

type Frozen = False

Whether the pyclass is frozen. Read more
Source§

impl PyClassImpl for Dual2

Source§

const IS_BASETYPE: bool = false

#[pyclass(subclass)]
Source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
Source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
Source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
Source§

const IS_IMMUTABLE_TYPE: bool = false

#[pyclass(immutable_type)]
Source§

type BaseType = PyAny

Base class
Source§

type ThreadChecker = SendablePyClass<Dual2>

This handles following two situations: Read more
Source§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
Source§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
Source§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
Source§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
Source§

fn items_iter() -> PyClassItemsIter

Source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
Source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

§

fn dict_offset() -> Option<isize>

§

fn weaklist_offset() -> Option<isize>

Source§

impl PyClassNewTextSignature<Dual2> for PyClassImplCollector<Dual2>

Source§

fn new_text_signature(self) -> Option<&'static str>

Source§

impl PyClass__add__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __add__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__eq__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __eq__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__ge__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __ge__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__gt__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __gt__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__le__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __le__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__lt__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __lt__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__mul__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __mul__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__pow__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __pow__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, arg1: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__radd__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __radd__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__rmul__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __rmul__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__rpow__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __rpow__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, arg1: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__rsub__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __rsub__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__rtruediv__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __rtruediv__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__sub__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __sub__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl PyClass__truediv__SlotFragment<Dual2> for PyClassImplCollector<Dual2>

Source§

unsafe fn __truediv__( self, py: Python<'_>, _raw_slf: *mut PyObject, arg0: *mut PyObject, ) -> PyResult<*mut PyObject>

Safety: _slf and _other must be valid non-null Python objects Read more
Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a Dual2

Source§

type Holder = Option<PyRef<'py, Dual2>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl<'a, 'py> PyFunctionArgument<'a, 'py, false> for &'a mut Dual2

Source§

type Holder = Option<PyRefMut<'py, Dual2>>

Source§

fn extract( obj: &'a Bound<'py, PyAny>, holder: &'a mut Self::Holder, ) -> PyResult<Self>

Source§

impl PyMethods<Dual2> for PyClassImplCollector<Dual2>

Source§

fn py_methods(self) -> &'static PyClassItems

Source§

impl PyTypeInfo for Dual2

Source§

const NAME: &'static str = "Dual2"

Class name.
Source§

const MODULE: Option<&'static str>

Module name, if any.
Source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
§

fn type_object(py: Python<'_>) -> Bound<'_, PyType>

Returns the safe abstraction over the type object.
§

fn is_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type or a subclass of this type.
§

fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of this type.
Source§

impl Rem<&Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&Dual2> for Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: f64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem for Dual2

Source§

type Output = Dual2

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Dual2) -> Self::Output

Performs the % operation. Read more
Source§

impl Serialize for Dual2

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Signed for Dual2

Source§

fn abs(&self) -> Self

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> Self

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl Sub<&Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&Dual2> for Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Dual2> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Dual2> for &f64

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<Dual2> for f64

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for &Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for Dual2

Source§

type Output = Dual2

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Dual2) -> Self::Output

Performs the - operation. Read more
Source§

impl Sum for Dual2

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = Dual2>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Vars for Dual2

Source§

fn vars(&self) -> &Arc<IndexSet<String>>

Get a reference to the Arc pointer for the IndexSet containing the struct’s variables.

Source§

fn to_new_vars( &self, arc_vars: &Arc<IndexSet<String>>, state: Option<VarsRelationship>, ) -> Self

Construct a new Dual2 with vars set as the given Arc pointer and gradients shuffled in memory.

Examples

let x = Dual2::new(1.5, vec!["x".to_string()]);
let xy = Dual2::new(2.5, vec!["x".to_string(), "y".to_string()]);
let x_y = x.to_new_vars(xy.vars(), None);
// x_y: <Dual2: 1.5, (x, y), [1.0, 0.0], [[0.0, 0.0], [0.0, 0.0]]>
assert_eq!(x_y, Dual2::try_new(1.5, vec!["x".to_string(), "y".to_string()], vec![1.0, 0.0], vec![]).unwrap());
Source§

fn vars_cmp(&self, arc_vars: &Arc<IndexSet<String>>) -> VarsRelationship

Compare the vars on a Dual with a given Arc pointer.
Source§

fn to_union_vars( &self, other: &Self, state: Option<VarsRelationship>, ) -> (Self, Self)
where Self: Sized,

Construct a tuple of 2 Self types whose vars are linked by an Arc pointer. Read more
Source§

fn to_combined_vars(&self, other: &Self) -> (Self, Self)
where Self: Sized,

Construct a tuple of 2 Self types whose vars are linked by the explicit union of their own variables. Read more
Source§

fn ptr_eq(&self, other: &Self) -> bool

Compare if two Dual structs share the same vars by Arc pointer equivalence. Read more
Source§

impl Zero for Dual2

Source§

fn zero() -> Dual2

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl DerefToPyAny for Dual2

Source§

impl NumberOps<Dual2> for Dual2

Auto Trait Implementations§

§

impl Freeze for Dual2

§

impl RefUnwindSafe for Dual2

§

impl Send for Dual2

§

impl Sync for Dual2

§

impl Unpin for Dual2

§

impl UnwindSafe for Dual2

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromPyObject<'_> for T
where T: PyClass + Clone,

§

fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
§

impl<'py, T> FromPyObjectBound<'_, 'py> for T
where T: FromPyObject<'py>,

§

fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>

Extracts Self from the bound smart pointer obj. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<'py, T> IntoPyObjectExt<'py> for T
where T: IntoPyObject<'py>,

§

fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>

Converts self into an owned Python object, dropping type information.
§

fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>

Converts self into an owned Python object, dropping type information and unbinding it from the 'py lifetime.
§

fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>

Converts self into a Python object. Read more
§

impl<T> PyErrArguments for T
where T: for<'py> IntoPyObject<'py> + Send + Sync,

§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
§

impl<T> PyTypeCheck for T
where T: PyTypeInfo,

§

const NAME: &'static str = <T as PyTypeInfo>::NAME

Name of self. This is used in error messages, for example.
§

fn type_check(object: &Bound<'_, PyAny>) -> bool

Checks if object is an instance of Self, which may include a subtype. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

§

impl<T> ClosedNeg for T
where T: Neg<Output = T>,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

§

impl<T> Ungil for T
where T: Send,