Struct Scalar
Source pub struct Scalar<B: Backend, T: Element>();
Expand description
A scalar of element type T on backend B.
On Native it is a T; on Trace it is a traced value. It is Copy
on both backends.
§Examples
use ruxla_core::{Backend, F32, Native};
fn hypot<B: Backend>(x: F32<B>, y: F32<B>) -> F32<B> {
(x * x + y * y).sqrt()
}
assert_eq!(hypot::<Native>(F32::new(3.0), F32::new(4.0)).value(), 5.0);
Returns the backend value.
The maximum, propagating NaN (logical or for booleans).
The minimum, propagating NaN (logical and for booleans).
Converts to another element type, as lax.convert_element_type.
Reinterprets the bits as another type of the same size.
The value as an array of rank 0.
|x| (signed integers wrap around; unsigned integers are returned
unchanged; the magnitude of a complex number is real).
-1, 0, or 1 (x / |x| for complex numbers).
x^y for a static integer y (lax.integer_pow).
Clamps to [lo, hi], propagating NaN.
A complex number from its real and imaginary parts (lax.complex).
The argument (atan2(imag, real), as jnp.angle).
Natural logarithm (the principal value for complex numbers).
Square root (the principal value for complex numbers).
Round toward negative infinity.
Round toward positive infinity.
Round to the nearest integer, halfway cases away from zero.
Round to the nearest integer, halfway cases to even.
The inverse error function.
The logarithm of the absolute value of the gamma function.
The complementary error function.
Whether the value is neither infinite nor NaN.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
The resulting type after applying the + operator.
Converts to an array.
Calls f with the array, without copying a borrowed array.
The resulting type after applying the & operator.
The resulting type after applying the & operator.
The resulting type after applying the & operator.
The resulting type after applying the & operator.
The resulting type after applying the | operator.
The resulting type after applying the | operator.
The resulting type after applying the | operator.
The resulting type after applying the | operator.
The resulting type after applying the ^ operator.
The resulting type after applying the ^ operator.
The resulting type after applying the ^ operator.
The resulting type after applying the ^ operator.
Performs copy-assignment from
source.
Read more
Formats the value using the given formatter.
Read more
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
The resulting type after applying the / operator.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the * operator.
The resulting type after applying the - operator.
The resulting type after applying the ! operator.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
The resulting type after applying the % operator.
The resulting type after applying the << operator.
The resulting type after applying the << operator.
A logical shift for unsigned types and an arithmetic shift for signed
types, as Rust’s >>.
The resulting type after applying the >> operator.
The resulting type after applying the >> operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The resulting type after applying the - operator.
The same structure on backend C.
Appends the leaves, in order.
Builds a value of the same structure from leaves.
Builds a value of the same structure on backend C from leaves
(static fields are copied from self).
Describes the structure.
Selects on_true or on_false leaf by leaf.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from
self to
dest.
Read more
Returns the argument unchanged.
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.