mimiqcircuits.operations.rescaledgates¶
Rescaled gate operation.
Functions
|
Classes
|
RescaledGate operation. |
- class mimiqcircuits.operations.rescaledgates.RescaledGate(gate, p)[source]¶
Bases:
AbstractOperator,Generic[T]RescaledGate operation.
The RescaledGate represents an operation where a quantum gate is rescaled by a factor p, typically between 0 and 1. This rescaling modifies the action of the gate, multiplying its matrix representation by p. The gate to be rescaled must be an instance of the Gate class, and p must be a valid scalar (real or symbolic) in the range [0, 1].
- Parameters:
gate (-) – The quantum gate to be rescaled.
p (-) – The rescaling factor, must be between 0 and 1.
- Raises:
- TypeError – If the provided gate is not an instance of Gate.
- ValueError – If the rescaling factor p is not between 0 and 1.
- - get_operation()
Returns the underlying gate.
- - get_param(name)
Retrieves the value of a parameter (such as p).
- - _matrix(*args)
Returns the matrix representation of the rescaled gate.
- - get_scale()
Returns the scaling factor p.
- - rescale(p)
Returns a new RescaledGate with a different scaling factor.
- - rescale_in_place(p)
Rescales the gate in place by multiplying the current p with the new value.
- - evaluate(d)
Substitutes values in the parameters (useful when symbolic values are used).
Examples
Creating and rescaling a gate:
>>> from mimiqcircuits import * >>> g = GateH() >>> rg = RescaledGate(g, 0.5)
>>> rg.get_scale() 0.5
>>> rg.rescale(0.8) 0.4*H
- evaluate(d)[source]¶
Substitute the symbolic parameters of the operator with numerical values.
This method evaluates the operator’s symbolic parameters using the values provided in the dictionary d. If the operator has no parameters, it returns the same instance. Otherwise, it creates a new instance of the operator with updated numerical parameters.
- Parameters:
d (dict) – A dictionary where keys are symbolic parameter names and values are values for substitution.
Example
>>> from symengine import * >>> from mimiqcircuits import * >>> theta = symbols('theta') >>> op = GateRX(theta) >>> evaluated_op = op.evaluate({'theta': 0.5}) >>> print(evaluated_op) RX(0.5)