pub struct AnyScalar { /* private fields */ }Expand description
Dynamic scalar compatibility wrapper for tensor4all-core.
This owns a rank-0 TensorDynLen so that scalar values can participate in
the same eager autodiff graph as tensors while preserving the existing
dynamic scalar API shape.
Implementations§
Source§impl AnyScalar
impl AnyScalar
pub fn from_value<T: TensorElement>(value: T) -> Self
pub fn from_real(x: f64) -> Self
pub fn from_complex(re: f64, im: f64) -> Self
pub fn new_real(x: f64) -> Self
pub fn new_complex(re: f64, im: f64) -> Self
pub fn primal(&self) -> Self
pub fn enable_grad(self) -> Self
pub fn tracks_grad(&self) -> bool
pub fn grad(&self) -> Result<Option<Self>>
pub fn clear_grad(&self) -> Result<()>
pub fn backward(&self) -> Result<()>
pub fn detach(&self) -> Self
pub fn real(&self) -> f64
pub fn imag(&self) -> f64
pub fn abs(&self) -> f64
pub fn is_complex(&self) -> bool
pub fn is_real(&self) -> bool
pub fn is_zero(&self) -> bool
pub fn as_f64(&self) -> Option<f64>
pub fn as_c64(&self) -> Option<Complex64>
pub fn conj(&self) -> Self
pub fn real_part(&self) -> Self
pub fn imag_part(&self) -> Self
pub fn compose_complex(real: Self, imag: Self) -> Result<Self>
pub fn sqrt(&self) -> Self
pub fn powf(&self, exponent: f64) -> Self
pub fn powi(&self, exponent: i32) -> Self
Trait Implementations§
Source§impl PartialOrd for AnyScalar
impl PartialOrd for AnyScalar
Source§impl SumFromStorage for AnyScalar
impl SumFromStorage for AnyScalar
Source§fn sum_from_storage(storage: &Storage) -> Self
fn sum_from_storage(storage: &Storage) -> Self
Compute the sum of all elements in the storage.
Auto Trait Implementations§
impl Freeze for AnyScalar
impl RefUnwindSafe for AnyScalar
impl Send for AnyScalar
impl Sync for AnyScalar
impl Unpin for AnyScalar
impl UnsafeUnpin for AnyScalar
impl UnwindSafe for AnyScalar
Blanket Implementations§
§impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
type Output = Output
fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output
§impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
type Output = Output
fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output
§impl<U> As for U
impl<U> As for U
§fn as_<T>(self) -> Twhere
T: CastFrom<U>,
fn as_<T>(self) -> Twhere
T: CastFrom<U>,
Casts
self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read moreSource§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>,
§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>,
§impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
type Output = Output
fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output
§impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
type Output = Output
fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output
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