API — operator-valued maps
covariance_map(B, A)
Apply the completely positive (Kraus) map \(\eta(B) = \sum_{i=1}^s A_i\, B\, A_i^{\ast}\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
B
|
(n, n) ndarray
|
Square matrix the map acts on. |
required |
A
|
sequence of (n, n) ndarrays or (s, n, n) ndarray
|
Kraus operators \(A_i\) (no self-adjointness assumed). |
required |
Returns:
| Type | Description |
|---|---|
(n, n) ndarray
|
The value of \(\eta(B)\). |
Notes
• Uses \(A_i^{\ast}\) (conjugate transpose), not \(A_i^{\mathsf T}\).
• Accepts a list/tuple of \((n,n)\) or a stacked array \((s,n,n)\).
Source code in src/free_matrix_laws/opvalued.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | |
ds_distance(A)
Distance to doubly stochastic class $$ \mathrm{DS}(T) \;=\; |T(I)-I|_F^2 \;+\; |T^\ast(I)-I|_F^2, $$ for \(T(X)=\sum_i A_i X A_i^\ast\) with Kraus \(A_i\).
Source code in src/free_matrix_laws/opvalued.py
225 226 227 228 229 230 231 232 233 234 235 236 237 | |
symmetric_osi(A, maxiter=50, tol=1e-10, eps=1e-12, return_history=False)
Run symmetric OSI: \(T,\ \mathcal S(T),\ \mathcal S^2(T),\dots\) on Kraus operators until (approximately) doubly stochastic: \(T(I)\approx I\) and \(T^\ast(I)\approx I\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
list/tuple of (n,n) arrays or stacked (s,n,n)
|
Initial Kraus operators. |
required |
maxiter
|
int
|
Maximum iterations. |
50
|
tol
|
float
|
Stop when \(\|T(I)-I\|_F^2 + \|T^\ast(I)-I\|_F^2 \le \text{tol}\). |
1e-10
|
eps
|
float
|
Eigenvalue floor for inverse square roots. |
1e-12
|
return_history
|
bool
|
If True, also return a dict with diagnostics. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
B |
stacked (s,n,n) array
|
Final Kraus operators after scaling. |
info |
dict(optional)
|
Keys: 'iters', 'ds', 'history' (list of DS distances). |
Source code in src/free_matrix_laws/opvalued.py
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
symmetric_sinkhorn_apply(X, A, eps=1e-12)
Apply the symmetric OSI scaled map \(\mathcal S(T)\) to a matrix \(X\).
Given \(T(X)=\sum_i A_i X A_i^\ast\) and \(c_1=(T(I))^{-1/4}\), \(c_2=(T^\ast(I))^{-1/4}\), this returns $$ \mathcal S(T)(X) \;=\; \sum_i (c_1 A_i c_2)\, X \,(c_1 A_i c_2)^\ast. $$
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
(n,n) array
|
Input matrix. |
required |
A
|
list/tuple of (n,n) arrays, or stacked array (s,n,n), or single (n,n)
|
Kraus operators \(A_i\). |
required |
eps
|
float
|
Eigenvalue floor in the inverse square roots. |
1e-12
|
Returns:
| Name | Type | Description |
|---|---|---|
Y |
(n,n) array
|
\((\mathcal S(T))(X)\). |
Source code in src/free_matrix_laws/opvalued.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
symmetric_sinkhorn_scale(A, eps=1e-12, return_factors=False, preserve_input_type=True)
One symmetric OSI step: given a CP map \(T(X)=\sum_i A_i X A_i^\ast\), form $$ c_1 := \big(T(I)\big)^{-1/4}, \qquad c_2 := \big(T^\ast(I)\big)^{-1/4}, $$ and return Kraus operators \(B_i := c_1 A_i c_2\) for \(\mathcal S(T)=S_{c_1,c_2}(T)\).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
A
|
list/tuple of (n,n) arrays, or stacked array (s,n,n), or single (n,n)
|
Kraus operators \(A_i\). |
required |
eps
|
float
|
Eigenvalue floor used in the inverse square root of \(T(I)\) and \(T^\ast(I)\). |
1e-12
|
return_factors
|
bool
|
If True, also return \((c_1, c_2)\). |
False
|
preserve_input_type
|
bool
|
If True, return a list if input was a list; otherwise return a stacked array. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
B |
same container type as A (unless preserve_input_type=False)
|
Scaled Kraus operators for \(\mathcal S(T)\). |
(optional) c1, c2 : (n,n) arrays
|
The scaling factors. |
Source code in src/free_matrix_laws/opvalued.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |