Skip to main content

UnitaryExpression

Struct UnitaryExpression 

Source
pub struct UnitaryExpression { /* private fields */ }

Implementations§

Source§

impl UnitaryExpression

Source

pub fn new<T: AsRef<str>>(input: T) -> Self

Source

pub fn identity<S: Into<String>, T: Into<Radices>>(name: S, radices: T) -> Self

Source

pub fn set_radices(&mut self, new_radices: Radices)

Source

pub fn transpose(&mut self)

Source

pub fn dagger(&mut self)

Source

pub fn classically_multiplex( expressions: &[&UnitaryExpression], new_dim_radices: &[usize], ) -> UnitarySystemExpression

Source

pub fn classically_control( &self, positions: &[usize], new_dim_radices: &[usize], ) -> UnitarySystemExpression

Source

pub fn embed( &mut self, sub_matrix: UnitaryExpression, top_left_row_idx: usize, top_left_col_idx: usize, )

Source

pub fn otimes<U: AsRef<UnitaryExpression>>(&self, other: U) -> Self

Source

pub fn dot<U: AsRef<UnitaryExpression>>(&self, other: U) -> Self

Source

pub fn get_arg_map<C: ComplexScalar>( &self, args: &[C::R], ) -> HashMap<&str, C::R>

Source

pub fn eval<C: ComplexScalar>(&self, args: &[C::R]) -> UnitaryMatrix<C>

Source

pub fn eval_grad<C: ComplexScalar>(&self, args: &[C::R]) -> Vec<Mat<C>> ⓘ

Evaluates the matrix-by-vector derivative of this expression at args.

Returns one matrix per parameter (in the same order as variables()), where the k-th matrix is the elementwise partial derivative of the unitary with respect to the k-th parameter.

Source

pub fn qasm_name(&self) -> Option<&'static str>

Returns the canonical OpenQASM 2.0 (qelib1.inc) gate name for this expression, if one exists, based on its name, qudit count, and parameter count. Returns None for expressions with no fixed QASM 2.0 equivalent (e.g. arbitrary/custom unitaries).

Methods from Deref<Target = NamedExpression>§

Source

pub fn name(&self) -> &str

Source

pub fn set_name(&mut self, new_name: impl Into<String>)

Source

pub fn set_variables(&mut self, new_variables: Vec<String>)

Source

pub fn apply_element_permutation(&mut self, elem_perm: &[usize])

Trait Implementations§

Source§

impl AsRef<NamedExpression> for UnitaryExpression

Source§

fn as_ref(&self) -> &NamedExpression

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<UnitaryExpression> for UnitaryExpression

Source§

fn as_ref(&self) -> &UnitaryExpression

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for UnitaryExpression

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnitaryExpression

Source§

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

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

impl Deref for UnitaryExpression

Source§

type Target = NamedExpression

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for UnitaryExpression

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'de> Deserialize<'de> for UnitaryExpression

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for UnitaryExpression

Source§

impl From<UnitaryExpression> for NamedExpression

Source§

fn from(value: UnitaryExpression) -> Self

Converts to this type from the input type.
Source§

impl From<UnitaryExpression> for TensorExpression

Source§

fn from(value: UnitaryExpression) -> Self

Converts to this type from the input type.
Source§

impl<C: ComplexScalar> From<UnitaryMatrix<C>> for UnitaryExpression

Source§

fn from(value: UnitaryMatrix<C>) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for UnitaryExpression

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl QuditSystem for UnitaryExpression

Source§

fn radices(&self) -> Radices

Returns the radices of the qudits in the system. Read more
Source§

fn num_qudits(&self) -> usize

Returns the number of qudits in the system. Read more
Source§

fn dimension(&self) -> usize

Returns the total dimension of the quantum system. Read more
Source§

fn is_qubit_only(&self) -> bool

Checks if the system consists only of qubits (2-level systems). Read more
Source§

fn is_qutrit_only(&self) -> bool

Checks if the system consists only of qutrits (3-level systems). Read more
Source§

fn is_qudit_only<T>(&self, radix: T) -> bool
where T: Into<Radix>,

Checks if the system consists only of qudits with a specified radix. Read more
Source§

fn is_homogenous(&self) -> bool

Checks if the system is homogenous, i.e., all qudits have the same radix. Read more
Source§

impl Serialize for UnitaryExpression

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UnitaryExpression

Source§

impl TryFrom<TensorExpression> for UnitaryExpression

Source§

type Error = String

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

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

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'short, T, Target> AsGeneralizedRef<'short, &'short Target> for T
where T: AsRef<Target> + ?Sized, Target: ?Sized,

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
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

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

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V