quantum_lib¶
wield.control.SFLU.test.quantum_lib
Functions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This routing allows one to construct 2D matrices out of heterogeneously shaped inputs. |
|
|
|
|
|
|
|
|
|
|
|
|
|
Details
- matrix_stack(arr, dtype=None, **kwargs)[source][github]¶
This routing allows one to construct 2D matrices out of heterogeneously shaped inputs. it should be called with a list, of list of np.array objects The outer two lists will form the 2D matrix in the last two axis, and the internal arrays will be broadcasted to allow the array construction to succeed
example
- matrix_stack([
[np.linspace(1, 10, 10), 0], [2, np.linspace(1, 10, 10)]
])
will create an array with shape (10, 2, 2), even though the 0, and 2 elements usually must be the same shape as the inputs to an array.
This allows using the matrix-multiply “@” operator for many more constructions, as it multiplies only in the last-two-axis. Similarly, np.linalg.inv() also inverts only in the last two axis.