Skip to main contentIBM Quantum Documentation Mirror

ParameterVectorElement

class qiskit.circuit.ParameterVectorElement

Bases: Parameter

An element of a ParameterVector.

Note

There is very little reason to ever construct this class directly. Objects of this type are automatically constructed efficiently as part of creating a ParameterVector.


Attributes

index

Get the index of this element in the parent vector.

name

Returns the name of the Parameter.

parameters

Get the parameters present in the expression.

Note

Qiskit guarantees equality (via ==) of parameters retrieved from an expression with the original Parameter objects used to create this expression, but does not guarantee is comparisons to succeed.

uuid

Returns the UUID of the Parameter.

In advanced use cases, this property can be passed to the Parameter constructor to produce an instance that compares equal to another instance.

vector

Get the parent vector instance.


Methods

abs

abs()

Take the absolute value of the expression.

arccos

arccos()

Arccosine of the expression.

arcsin

arcsin()

Arcsine of the expression.

arctan

arctan()

Arctangent of the expression.

assign

assign(parameter, value)

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

Parameters

  • parameter – A parameter in this expression whose value will be updated.
  • value – The new value to bind to.

Returns

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

bind

bind(parameter_values, allow_unknown_parameters=False)

Binds the provided set of parameters to their corresponding values.

Parameters

  • parameter_values – Mapping of Parameter instances to the numeric value to which they will be bound.
  • allow_unknown_parameters – 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.

Raises

  • 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.

Returns

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

bind_all

bind_all(values)

Bind all of the parameters in self to numeric values in the dictionary, returning a numeric value.

This is a special case of bind() which can reach higher performance. It is no problem for the values dictionary to contain parameters that are not used in this expression; the expectation is that the same bindings dictionary will be fed to other expressions as well.

It is an error to call this method with a values dictionary that does not bind all of the values, or to call this method with non-numeric values, but this is not explicitly checked, since this method is intended for performance-sensitive use. Passing an incorrect dictionary may result in unexpected behavior.

Unlike bind(), this method will not raise an exception if non-finite floating-point values are encountered.

Parameters

values – mapping of parameters to numeric values.

conjugate

conjugate()

Return the complex conjugate of the expression.

cos

cos()

Cosine of the expression.

exp

exp()

Exponentiate the expression.

gradient

gradient(param)

Return derivative of this expression with respect to the input parameter.

Parameters

param – The parameter with respect to which the derivative is calculated.

Returns

The derivative as either a constant numeric value or a symbolic ParameterExpression.

is_real

is_real()

Check whether the expression represents a real number.

Note that this will return None if there are unbound parameters, in which case it cannot be determined whether the expression is real.

is_symbol

is_symbol()

Check if the expression corresponds to a plain symbol.

Returns

True is this expression corresponds to a symbol, False otherwise.

log

log()

Take the natural logarithm of the expression.

numeric

numeric(strict=True)

Cast this expression to a numeric value.

Parameters

strict – If True (default) this function raises an error if there are any unbound symbols in the expression. If False, this allows casting if the expression represents a numeric value, regardless of unbound symbols. For example (0 * Parameter("x")) is 0 but has the symbol x present.

sign

sign()

Return the sign of the expression.

sin

sin()

Sine of the expression.

subs

subs(parameter_map, allow_unknown_parameters=False)

Returns a new expression with replacement parameters.

Parameters

  • parameter_map – Mapping from Parameters in self to the ParameterExpression instances with which they should be replaced.
  • allow_unknown_parameters – If False, raises an error if parameter_map contains Parameters in the keys outside those present in the expression. If True, any such parameters are simply ignored.

Raises

CircuitError

  • If parameter_map contains parameters outside those in self. - If the replacement parameters in parameter_map would result in a name conflict in the generated expression.

Returns

A new expression with the specified parameters replaced.

sympify

sympify()

Return a SymPy equivalent of this expression.

Returns

A SymPy equivalent of this expression.

tan

tan()

Tangent of the expression.