Add support for vectors of parameters
See original GitHub issueSome circuits need to make use of a large, fixed number of parameters. For example, variational algorithms setting rotation angles as independent parameters, to be sourced as an array from a classical optimizer. See the VariationalForm class and RYRZ algorithm in aqua as an example.
With the current Parameter definition, this is possible but cumbersome. It requires the user to define, name and manage a Parameter instance for each gate they plan to vary.
It should be possible to define a parameter vector of fixed length, and access elements of that vector as individual parameters.
Possible syntax:
v = ParameterVector('v', 99)
v[10] # => Parameter(v[10])
qc = QuantumCircuit(3)
qr = qc.qregs[0]
for (t1, t2, t3) in zip(v[::3], v[1::3], v[2::3]):
qc.cx(qr[:-1], qr[1:])
qc.u3(t1, t2, t3, qr[0])
qc.bind_parameters({v = [...]})
When binding, we should verify that the supplied list matches the length of the vector and that all parameters in the vector are bound. (Partial binding within a vector is not supported.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)

Top Related StackOverflow Question
Just to close this loop before I submit, the interface now looks like:
producing:
I like the array (
ΞΈ[n]) notation better, will change to that.