pub enum Param {
Value(f64),
Ref {
index: usize,
multiplier: f64,
value: f64,
},
}Expand description
A numeric parameter for rotation and phase gates.
A Param is either a concrete floating-point value (Param::Value) or a
symbolic reference to an entry in a parameter vector (Param::Ref). The
Ref variant enables deferred parameter binding for variational algorithms
where the same circuit is evaluated at multiple parameter points.
Variants§
Value(f64)
A concrete, pre-bound rotation angle (in radians).
Ref
A symbolic reference to a parameter vector entry.
The effective angle is value * multiplier. The value field stores
the base value at binding time; multiplier can be adjusted (e.g.,
negated for inversion) without touching the underlying vector.
Implementations§
Source§impl Param
impl Param
Sourcepub fn inverse(&self) -> Self
pub fn inverse(&self) -> Self
Returns the mathematical inverse of the parameter (i.e., the negation).
For Value(v) this returns Value(-v); for Ref this negates the
multiplier field.
Sourcepub fn value(&self) -> f64
pub fn value(&self) -> f64
Returns the current floating-point value of the parameter.
For Param::Value this is a direct read. For Param::Ref the
effective value is value * multiplier.
Sourcepub fn set_parameter(&self, parameters: &[f64]) -> Self
pub fn set_parameter(&self, parameters: &[f64]) -> Self
Binds a symbolic Param::Ref to a concrete value from parameters.
If self is already a Param::Value it is returned unchanged.
Otherwise the result is Value(base_value * multiplier * parameters[index]).
Sourcepub fn add(&self, other: &Self) -> Option<Self>
pub fn add(&self, other: &Self) -> Option<Self>
Attempts to add two parameters together.
Returns Some(Value(a + b)) only when both operands are
Param::Value. Any combination involving a Param::Ref returns
None, because symbolic parameters cannot be merged algebraically at
compile time.
Sourcepub fn is_near_zero(&self, epsilon: f64) -> bool
pub fn is_near_zero(&self, epsilon: f64) -> bool
Returns true if the parameter’s effective rotation angle is within
epsilon of zero.
For Param::Ref only the multiplier is inspected, since the actual
parameter value is not known at compile time.
Trait Implementations§
impl Copy for Param
Source§impl<'de> Deserialize<'de> for Param
impl<'de> Deserialize<'de> for Param
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Param
Auto Trait Implementations§
impl Freeze for Param
impl RefUnwindSafe for Param
impl Send for Param
impl Sync for Param
impl Unpin for Param
impl UnsafeUnpin for Param
impl UnwindSafe for Param
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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>
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>
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