pub struct AdScalar<T>(pub AdValue<T>);Expand description
Scalar newtype carrying AD mode information.
§Examples
use ad_tensors_rs::{AdMode, AdScalar};
let x: AdScalar<f64> = 2.0_f64.into();
assert_eq!(x.mode(), AdMode::Primal);Tuple Fields§
§0: AdValue<T>Implementations§
Source§impl<T> AdScalar<T>
impl<T> AdScalar<T>
Sourcepub fn new_primal(value: T) -> Self
pub fn new_primal(value: T) -> Self
Creates a primal scalar.
§Examples
use ad_tensors_rs::{AdMode, AdScalar};
let x = AdScalar::new_primal(1.5_f64);
assert_eq!(x.mode(), AdMode::Primal);Sourcepub fn new_forward(primal: T, tangent: T) -> Self
pub fn new_forward(primal: T, tangent: T) -> Self
Creates a forward-mode scalar.
§Examples
use ad_tensors_rs::{AdMode, AdScalar};
let x = AdScalar::new_forward(2.0_f64, 1.0_f64);
assert_eq!(x.mode(), AdMode::Forward);Sourcepub fn new_reverse(
primal: T,
node: NodeId,
tape: TapeId,
tangent: Option<T>,
) -> Self
pub fn new_reverse( primal: T, node: NodeId, tape: TapeId, tangent: Option<T>, ) -> Self
Creates a reverse-mode scalar.
§Examples
use ad_tensors_rs::{AdMode, AdScalar, NodeId, TapeId};
let x = AdScalar::new_reverse(2.0_f64, NodeId(1), TapeId(2), Some(0.4));
assert_eq!(x.mode(), AdMode::Reverse);Sourcepub fn mode(&self) -> AdMode
pub fn mode(&self) -> AdMode
Returns AD mode.
§Examples
use ad_tensors_rs::{AdMode, AdScalar};
let x = AdScalar::new_primal(2.0_f64);
assert_eq!(x.mode(), AdMode::Primal);Sourcepub fn into_value(self) -> AdValue<T>
pub fn into_value(self) -> AdValue<T>
Trait Implementations§
Source§impl<T: Clone> Differentiable for AdScalar<T>
impl<T: Clone> Differentiable for AdScalar<T>
impl<T> StructuralPartialEq for AdScalar<T>
Auto Trait Implementations§
impl<T> Freeze for AdScalar<T>where
T: Freeze,
impl<T> RefUnwindSafe for AdScalar<T>where
T: RefUnwindSafe,
impl<T> Send for AdScalar<T>where
T: Send,
impl<T> Sync for AdScalar<T>where
T: Sync,
impl<T> Unpin for AdScalar<T>where
T: Unpin,
impl<T> UnwindSafe for AdScalar<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
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