matrix#
Implements the semantic category Matrix
.
In this category, a box with domain PRO(n)
and codomain PRO(m)
represents
an \(n \times m\) matrix.
The >>
and <<
operations correspond to matrix multiplication
and @
operation corresponds to the direct sum of matrices:
\[\begin{split}\mathbf{A} \oplus \mathbf{B}
= \begin{pmatrix} \mathbf{A} & 0 \\ 0 & \mathbf{B} \end{pmatrix}\end{split}\]
Example
>>> x = Matrix(PRO(2), PRO(1), [2, 4])
>>> x.array
array([[2],
[4]])
>>> x @ x
Matrix(dom=PRO(4), cod=PRO(2), array=[2, 0, 4, 0, 0, 2, 0, 4])
>>> (x @ x).array
array([[2, 0],
[4, 0],
[0, 2],
[0, 4]])
Matrix
can be used to evaluate
optics.Diagram
s from quantum.optics
.
|
Implements a matrix with dom, cod and numpy array. |