Parameter#

class qiskit.circuit.Parameter(name, uuid=None)[fuente]#

Bases: ParameterExpression

Parameter Class for variable parameters.

A parameter is a variable value that is not required to be fixed at circuit definition.

Ejemplos

Construct a variable-rotation X gate using circuit parameters.

from qiskit.circuit import QuantumCircuit, Parameter

# create the parameter
phi = Parameter('phi')
qc = QuantumCircuit(1)

# parameterize the rotation
qc.rx(phi, 0)
qc.draw('mpl')

# bind the parameters after circuit to create a bound circuit
bc = qc.bind_parameters({phi: 3.14})
bc.measure_all()
bc.draw('mpl')

(Source code)

../_images/qiskit-circuit-Parameter-1_00.png
../_images/qiskit-circuit-Parameter-1_01.png

Create a new named Parameter.

Par谩metros:

name 鈥 name of the Parameter, used for visual representation. This can be any unicode string, e.g. 芦蠒禄.

Attributes

name#

Returns the name of the Parameter.

parameters#

Returns a set of the unbound Parameters in the expression.

Methods

abs()#

Absolute of a ParameterExpression

arccos()#

Arccos of a ParameterExpression

arcsin()#

Arcsin of a ParameterExpression

arctan()#

Arctan of a ParameterExpression

assign(parameter, value)#

Assign one parameter to a value, which can either be numeric or another parameter expression.

Par谩metros:
Devuelve:

A new expression parameterized by any parameters which were not bound by assignment.

Tipo del valor devuelto:

ParameterExpression

bind(parameter_values, allow_unknown_parameters=False)#

Binds the provided set of parameters to their corresponding values.

Par谩metros:
  • parameter_values (dict) 鈥 Mapping of Parameter instances to the numeric value to which they will be bound.

  • allow_unknown_parameters (bool) 鈥 If False, raises an error if parameter_values contains Parameters in the keys outside those present in the expression. If True, any such parameters are simply ignored.

Muestra:
  • CircuitError

    • If parameter_values contains Parameters outside those in self. - If a non-numeric value is passed in parameter_values.

  • ZeroDivisionError

    • If binding the provided values requires division by zero.

Devuelve:

A new expression parameterized by any parameters which were not bound by parameter_values.

Tipo del valor devuelto:

ParameterExpression

conjugate()#

Return the conjugate.

Tipo del valor devuelto:

ParameterExpression

cos()#

Cosine of a ParameterExpression

exp()#

Exponential of a ParameterExpression

gradient(param)#

Get the derivative of a parameter expression w.r.t. a specified parameter expression.

Par谩metros:

param (Parameter) 鈥 Parameter w.r.t. which we want to take the derivative

Devuelve:

ParameterExpression representing the gradient of param_expr w.r.t. param or complex or float number

Tipo del valor devuelto:

ParameterExpression | complex

is_real()#

Return whether the expression is real

log()#

Logarithm of a ParameterExpression

sin()#

Sine of a ParameterExpression

subs(parameter_map, allow_unknown_parameters=False)[fuente]#

Substitute self with the corresponding parameter in parameter_map.

sympify()#

Return symbolic expression as a raw Sympy or Symengine object.

Symengine is used preferentially; if both are available, the result will always be a symengine object. Symengine is a separate library but has integration with Sympy.

Nota

This is for interoperability only. Qiskit will not accept or work with raw Sympy or Symegine expressions in its parameters, because they do not contain the tracking information used in circuit-parameter binding and assignment.

tan()#

Tangent of a ParameterExpression