Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.84k stars 2.29k forks source link

Add `inner` method to `BindingsArray` #12438

Open chriseclectic opened 1 month ago

chriseclectic commented 1 month ago

What should we add?

Add an inner method to BindingsArray that allows combining two bindings arrays with the same shape

Eg

class BindingsArray:

    def inner(self, other: BindingsArray) -> BindingsArray:
         # validate self and other have distinct parameters
         # validate self and other have same shape (or more generally broadcast compatible shapes?)
         # construct the data dict combining the two bas
    ... 

This method could either require the arrays have the same shape, or alternatively that they have broadcastable shapes (eg if other.shape = (*extra_dims, *self.shape) the return would be other.shape, or if other.shape = shape + self.ndim * (1,) the return would be equivalent to the outer product (up to ordering of dimensions). Maybe this method could be called combine or something like that instead.

Related to #12437

arujjval commented 3 weeks ago

@chriseclectic can I work on this issue?