Skip to main content

AnyScalar

Struct AnyScalar 

Source
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

Source

pub fn from_value<T: TensorElement>(value: T) -> Self

Source

pub fn from_real(x: f64) -> Self

Source

pub fn from_complex(re: f64, im: f64) -> Self

Source

pub fn new_real(x: f64) -> Self

Source

pub fn new_complex(re: f64, im: f64) -> Self

Source

pub fn primal(&self) -> Self

Source

pub fn enable_grad(self) -> Self

Source

pub fn tracks_grad(&self) -> bool

Source

pub fn grad(&self) -> Result<Option<Self>>

Source

pub fn clear_grad(&self) -> Result<()>

Source

pub fn backward(&self) -> Result<()>

Source

pub fn detach(&self) -> Self

Source

pub fn real(&self) -> f64

Source

pub fn imag(&self) -> f64

Source

pub fn abs(&self) -> f64

Source

pub fn is_complex(&self) -> bool

Source

pub fn is_real(&self) -> bool

Source

pub fn is_zero(&self) -> bool

Source

pub fn as_f64(&self) -> Option<f64>

Source

pub fn as_c64(&self) -> Option<Complex64>

Source

pub fn conj(&self) -> Self

Source

pub fn real_part(&self) -> Self

Source

pub fn imag_part(&self) -> Self

Source

pub fn compose_complex(real: Self, imag: Self) -> Result<Self>

Source

pub fn sqrt(&self) -> Self

Source

pub fn powf(&self, exponent: f64) -> Self

Source

pub fn powi(&self, exponent: i32) -> Self

Trait Implementations§

Source§

impl Add<&AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<&AnyScalar> for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add<AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Add for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for AnyScalar

Source§

fn clone(&self) -> AnyScalar

Returns a duplicate 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 AnyScalar

Source§

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

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

impl Default for AnyScalar

Source§

fn default() -> Self

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

impl Display for AnyScalar

Source§

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

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

impl Div<&AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<&AnyScalar> for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div<AnyScalar> for Complex64

Source§

type Output = AnyScalar

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl Div for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl From<AnyScalar> for Complex64

Source§

fn from(value: AnyScalar) -> Self

Converts to this type from the input type.
Source§

impl From<Complex<f32>> for AnyScalar

Source§

fn from(value: Complex32) -> Self

Converts to this type from the input type.
Source§

impl From<Complex<f64>> for AnyScalar

Source§

fn from(value: Complex64) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for AnyScalar

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for AnyScalar

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl Mul<&AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<&AnyScalar> for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<AnyScalar> for Complex64

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul<AnyScalar> for f64

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Mul for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl Neg for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl One for AnyScalar

Source§

fn one() -> Self

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 for AnyScalar

Source§

fn eq(&self, other: &Self) -> 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 for AnyScalar

Source§

fn partial_cmp(&self, other: &Self) -> 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 Sub<&AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<&AnyScalar> for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub<AnyScalar> for &AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl Sub for AnyScalar

Source§

type Output = AnyScalar

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more
Source§

impl SumFromStorage for AnyScalar

Source§

fn sum_from_storage(storage: &Storage) -> Self

Compute the sum of all elements in the storage.
Source§

impl TryFrom<AnyScalar> for f64

Source§

type Error = &'static str

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

fn try_from(value: AnyScalar) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Zero for AnyScalar

Source§

fn zero() -> Self

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.

Auto Trait Implementations§

Blanket Implementations§

§

impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Add<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output

§

impl<Rhs, Lhs, Output> AddByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Add<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn add_by_ref(&self, rhs: &Rhs) -> <Lhs as AddByRef<Rhs>>::Output

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<U> As for U

§

fn as_<T>(self) -> T
where 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 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
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

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
§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<T> DistributionExt for T
where T: ?Sized,

§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

§

impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Div<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output

§

impl<Rhs, Lhs, Output> DivByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Div<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn div_by_ref(&self, rhs: &Rhs) -> <Lhs as DivByRef<Rhs>>::Output

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> 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<Rhs, Lhs, Output> MulByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Mul<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn mul_by_ref(&self, rhs: &Rhs) -> <Lhs as MulByRef<Rhs>>::Output

§

impl<Rhs, Lhs, Output> MulByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Mul<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn mul_by_ref(&self, rhs: &Rhs) -> <Lhs as MulByRef<Rhs>>::Output

§

impl<T, Output> NegByRef for T
where &'a T: for<'a> Neg<Output = Output>,

§

type Output = Output

§

fn neg_by_ref(&self) -> <T as NegByRef>::Output

§

impl<T, Output> NegByRef for T
where &'a T: for<'a> Neg<Output = Output>,

§

type Output = Output

§

fn neg_by_ref(&self) -> <T as NegByRef>::Output

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<Rhs, Lhs, Output> SubByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Sub<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn sub_by_ref(&self, rhs: &Rhs) -> <Lhs as SubByRef<Rhs>>::Output

§

impl<Rhs, Lhs, Output> SubByRef<Rhs> for Lhs
where &'a Lhs: for<'a> Sub<&'a Rhs, Output = Output>,

§

type Output = Output

§

fn sub_by_ref(&self, rhs: &Rhs) -> <Lhs as SubByRef<Rhs>>::Output

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

impl<T> MaybeSend for T

§

impl<T> MaybeSendSync for T

§

impl<T> MaybeSync for T

Source§

impl<M> Measure for M
where M: Debug + PartialOrd + Add<Output = M> + Default + Clone,