pyGSTi 0.9.12__cp38-cp38-win_amd64.whl → 0.9.13__cp38-cp38-win_amd64.whl
Sign up to get free protection for your applications and to get access to all the features.
- pyGSTi-0.9.13.dist-info/METADATA +185 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/RECORD +211 -220
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/WHEEL +1 -1
- pygsti/_version.py +2 -2
- pygsti/algorithms/contract.py +1 -1
- pygsti/algorithms/core.py +62 -35
- pygsti/algorithms/fiducialpairreduction.py +95 -110
- pygsti/algorithms/fiducialselection.py +17 -8
- pygsti/algorithms/gaugeopt.py +2 -2
- pygsti/algorithms/germselection.py +87 -77
- pygsti/algorithms/mirroring.py +0 -388
- pygsti/algorithms/randomcircuit.py +165 -1333
- pygsti/algorithms/rbfit.py +0 -234
- pygsti/baseobjs/basis.py +94 -396
- pygsti/baseobjs/errorgenbasis.py +0 -132
- pygsti/baseobjs/errorgenspace.py +0 -10
- pygsti/baseobjs/label.py +52 -168
- pygsti/baseobjs/opcalc/fastopcalc.cp38-win_amd64.pyd +0 -0
- pygsti/baseobjs/opcalc/fastopcalc.pyx +2 -2
- pygsti/baseobjs/polynomial.py +13 -595
- pygsti/baseobjs/protectedarray.py +72 -132
- pygsti/baseobjs/statespace.py +1 -0
- pygsti/circuits/__init__.py +1 -1
- pygsti/circuits/circuit.py +753 -504
- pygsti/circuits/circuitconstruction.py +0 -4
- pygsti/circuits/circuitlist.py +47 -5
- pygsti/circuits/circuitparser/__init__.py +8 -8
- pygsti/circuits/circuitparser/fastcircuitparser.cp38-win_amd64.pyd +0 -0
- pygsti/circuits/circuitstructure.py +3 -3
- pygsti/circuits/cloudcircuitconstruction.py +27 -14
- pygsti/data/datacomparator.py +4 -9
- pygsti/data/dataset.py +51 -46
- pygsti/data/hypothesistest.py +0 -7
- pygsti/drivers/bootstrap.py +0 -49
- pygsti/drivers/longsequence.py +46 -10
- pygsti/evotypes/basereps_cython.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/chp/opreps.py +0 -61
- pygsti/evotypes/chp/statereps.py +0 -32
- pygsti/evotypes/densitymx/effectcreps.cpp +9 -10
- pygsti/evotypes/densitymx/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/effectreps.pyx +1 -1
- pygsti/evotypes/densitymx/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/opreps.pyx +2 -2
- pygsti/evotypes/densitymx/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/densitymx/statereps.pyx +1 -1
- pygsti/evotypes/densitymx_slow/effectreps.py +7 -23
- pygsti/evotypes/densitymx_slow/opreps.py +16 -23
- pygsti/evotypes/densitymx_slow/statereps.py +10 -3
- pygsti/evotypes/evotype.py +39 -2
- pygsti/evotypes/stabilizer/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/effectreps.pyx +0 -4
- pygsti/evotypes/stabilizer/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/opreps.pyx +0 -4
- pygsti/evotypes/stabilizer/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/statereps.pyx +1 -5
- pygsti/evotypes/stabilizer/termreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/stabilizer/termreps.pyx +0 -7
- pygsti/evotypes/stabilizer_slow/effectreps.py +0 -22
- pygsti/evotypes/stabilizer_slow/opreps.py +0 -4
- pygsti/evotypes/stabilizer_slow/statereps.py +0 -4
- pygsti/evotypes/statevec/effectreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/effectreps.pyx +1 -1
- pygsti/evotypes/statevec/opreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/opreps.pyx +2 -2
- pygsti/evotypes/statevec/statereps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/statereps.pyx +1 -1
- pygsti/evotypes/statevec/termreps.cp38-win_amd64.pyd +0 -0
- pygsti/evotypes/statevec/termreps.pyx +0 -7
- pygsti/evotypes/statevec_slow/effectreps.py +0 -3
- pygsti/evotypes/statevec_slow/opreps.py +0 -5
- pygsti/extras/__init__.py +0 -1
- pygsti/extras/drift/signal.py +1 -1
- pygsti/extras/drift/stabilityanalyzer.py +3 -1
- pygsti/extras/interpygate/__init__.py +12 -0
- pygsti/extras/interpygate/core.py +0 -36
- pygsti/extras/interpygate/process_tomography.py +44 -10
- pygsti/extras/rpe/rpeconstruction.py +0 -2
- pygsti/forwardsims/__init__.py +1 -0
- pygsti/forwardsims/forwardsim.py +50 -93
- pygsti/forwardsims/mapforwardsim.py +78 -20
- pygsti/forwardsims/mapforwardsim_calc_densitymx.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/mapforwardsim_calc_densitymx.pyx +65 -66
- pygsti/forwardsims/mapforwardsim_calc_generic.py +91 -13
- pygsti/forwardsims/matrixforwardsim.py +72 -17
- pygsti/forwardsims/termforwardsim.py +9 -111
- pygsti/forwardsims/termforwardsim_calc_stabilizer.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.cp38-win_amd64.pyd +0 -0
- pygsti/forwardsims/termforwardsim_calc_statevec.pyx +0 -651
- pygsti/forwardsims/torchfwdsim.py +265 -0
- pygsti/forwardsims/weakforwardsim.py +2 -2
- pygsti/io/__init__.py +1 -2
- pygsti/io/mongodb.py +0 -2
- pygsti/io/stdinput.py +6 -22
- pygsti/layouts/copalayout.py +10 -12
- pygsti/layouts/distlayout.py +0 -40
- pygsti/layouts/maplayout.py +103 -25
- pygsti/layouts/matrixlayout.py +99 -60
- pygsti/layouts/prefixtable.py +1534 -52
- pygsti/layouts/termlayout.py +1 -1
- pygsti/modelmembers/instruments/instrument.py +3 -3
- pygsti/modelmembers/instruments/tpinstrument.py +2 -2
- pygsti/modelmembers/modelmember.py +0 -17
- pygsti/modelmembers/operations/__init__.py +3 -4
- pygsti/modelmembers/operations/affineshiftop.py +206 -0
- pygsti/modelmembers/operations/composederrorgen.py +1 -1
- pygsti/modelmembers/operations/composedop.py +1 -24
- pygsti/modelmembers/operations/denseop.py +5 -5
- pygsti/modelmembers/operations/eigpdenseop.py +2 -2
- pygsti/modelmembers/operations/embeddederrorgen.py +1 -1
- pygsti/modelmembers/operations/embeddedop.py +0 -1
- pygsti/modelmembers/operations/experrorgenop.py +5 -2
- pygsti/modelmembers/operations/fullarbitraryop.py +1 -0
- pygsti/modelmembers/operations/fullcptpop.py +2 -2
- pygsti/modelmembers/operations/fulltpop.py +28 -6
- pygsti/modelmembers/operations/fullunitaryop.py +5 -4
- pygsti/modelmembers/operations/lindbladcoefficients.py +93 -78
- pygsti/modelmembers/operations/lindbladerrorgen.py +268 -441
- pygsti/modelmembers/operations/linearop.py +7 -27
- pygsti/modelmembers/operations/opfactory.py +1 -1
- pygsti/modelmembers/operations/repeatedop.py +1 -24
- pygsti/modelmembers/operations/staticstdop.py +1 -1
- pygsti/modelmembers/povms/__init__.py +3 -3
- pygsti/modelmembers/povms/basepovm.py +7 -36
- pygsti/modelmembers/povms/complementeffect.py +4 -9
- pygsti/modelmembers/povms/composedeffect.py +0 -320
- pygsti/modelmembers/povms/computationaleffect.py +1 -1
- pygsti/modelmembers/povms/computationalpovm.py +3 -1
- pygsti/modelmembers/povms/effect.py +3 -5
- pygsti/modelmembers/povms/marginalizedpovm.py +3 -81
- pygsti/modelmembers/povms/tppovm.py +74 -2
- pygsti/modelmembers/states/__init__.py +2 -5
- pygsti/modelmembers/states/composedstate.py +0 -317
- pygsti/modelmembers/states/computationalstate.py +3 -3
- pygsti/modelmembers/states/cptpstate.py +4 -4
- pygsti/modelmembers/states/densestate.py +10 -8
- pygsti/modelmembers/states/fullpurestate.py +0 -24
- pygsti/modelmembers/states/purestate.py +1 -1
- pygsti/modelmembers/states/state.py +5 -6
- pygsti/modelmembers/states/tpstate.py +28 -10
- pygsti/modelmembers/term.py +3 -6
- pygsti/modelmembers/torchable.py +50 -0
- pygsti/modelpacks/_modelpack.py +1 -1
- pygsti/modelpacks/smq1Q_ZN.py +3 -1
- pygsti/modelpacks/smq2Q_XXYYII.py +2 -1
- pygsti/modelpacks/smq2Q_XY.py +3 -3
- pygsti/modelpacks/smq2Q_XYI.py +2 -2
- pygsti/modelpacks/smq2Q_XYICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYICPHASE.py +3 -3
- pygsti/modelpacks/smq2Q_XYXX.py +1 -1
- pygsti/modelpacks/smq2Q_XYZICNOT.py +3 -3
- pygsti/modelpacks/smq2Q_XYZZ.py +1 -1
- pygsti/modelpacks/stdtarget.py +0 -121
- pygsti/models/cloudnoisemodel.py +1 -2
- pygsti/models/explicitcalc.py +3 -3
- pygsti/models/explicitmodel.py +3 -13
- pygsti/models/fogistore.py +5 -3
- pygsti/models/localnoisemodel.py +1 -2
- pygsti/models/memberdict.py +0 -12
- pygsti/models/model.py +801 -68
- pygsti/models/modelconstruction.py +4 -4
- pygsti/models/modelnoise.py +2 -2
- pygsti/models/modelparaminterposer.py +1 -1
- pygsti/models/oplessmodel.py +1 -1
- pygsti/models/qutrit.py +15 -14
- pygsti/objectivefns/objectivefns.py +75 -140
- pygsti/objectivefns/wildcardbudget.py +2 -7
- pygsti/optimize/__init__.py +1 -0
- pygsti/optimize/arraysinterface.py +28 -0
- pygsti/optimize/customcg.py +0 -12
- pygsti/optimize/customlm.py +129 -323
- pygsti/optimize/customsolve.py +2 -2
- pygsti/optimize/optimize.py +0 -84
- pygsti/optimize/simplerlm.py +841 -0
- pygsti/optimize/wildcardopt.py +19 -598
- pygsti/protocols/confidenceregionfactory.py +28 -14
- pygsti/protocols/estimate.py +31 -14
- pygsti/protocols/gst.py +238 -142
- pygsti/protocols/modeltest.py +19 -12
- pygsti/protocols/protocol.py +9 -37
- pygsti/protocols/rb.py +450 -79
- pygsti/protocols/treenode.py +8 -2
- pygsti/protocols/vb.py +108 -206
- pygsti/protocols/vbdataframe.py +1 -1
- pygsti/report/factory.py +0 -15
- pygsti/report/fogidiagram.py +1 -17
- pygsti/report/modelfunction.py +12 -3
- pygsti/report/mpl_colormaps.py +1 -1
- pygsti/report/plothelpers.py +11 -3
- pygsti/report/report.py +16 -0
- pygsti/report/reportables.py +41 -37
- pygsti/report/templates/offline/pygsti_dashboard.css +6 -0
- pygsti/report/templates/offline/pygsti_dashboard.js +12 -0
- pygsti/report/workspace.py +2 -14
- pygsti/report/workspaceplots.py +328 -505
- pygsti/tools/basistools.py +9 -36
- pygsti/tools/edesigntools.py +124 -96
- pygsti/tools/fastcalc.cp38-win_amd64.pyd +0 -0
- pygsti/tools/fastcalc.pyx +35 -81
- pygsti/tools/internalgates.py +151 -15
- pygsti/tools/jamiolkowski.py +5 -5
- pygsti/tools/lindbladtools.py +19 -11
- pygsti/tools/listtools.py +0 -114
- pygsti/tools/matrixmod2.py +1 -1
- pygsti/tools/matrixtools.py +173 -339
- pygsti/tools/nameddict.py +1 -1
- pygsti/tools/optools.py +154 -88
- pygsti/tools/pdftools.py +0 -25
- pygsti/tools/rbtheory.py +3 -320
- pygsti/tools/slicetools.py +64 -12
- pyGSTi-0.9.12.dist-info/METADATA +0 -157
- pygsti/algorithms/directx.py +0 -711
- pygsti/evotypes/qibo/__init__.py +0 -33
- pygsti/evotypes/qibo/effectreps.py +0 -78
- pygsti/evotypes/qibo/opreps.py +0 -376
- pygsti/evotypes/qibo/povmreps.py +0 -98
- pygsti/evotypes/qibo/statereps.py +0 -174
- pygsti/extras/rb/__init__.py +0 -13
- pygsti/extras/rb/benchmarker.py +0 -957
- pygsti/extras/rb/dataset.py +0 -378
- pygsti/extras/rb/io.py +0 -814
- pygsti/extras/rb/simulate.py +0 -1020
- pygsti/io/legacyio.py +0 -385
- pygsti/modelmembers/povms/denseeffect.py +0 -142
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/LICENSE +0 -0
- {pyGSTi-0.9.12.dist-info → pyGSTi-0.9.13.dist-info}/top_level.txt +0 -0
@@ -8,78 +8,73 @@ import warnings as _warnings
|
|
8
8
|
from pygsti.tools import lindbladtools as _lt
|
9
9
|
from pygsti.tools import matrixtools as _mt
|
10
10
|
from pygsti.tools import optools as _ot
|
11
|
+
from pygsti.tools import fastcalc as _fc
|
11
12
|
from pygsti.baseobjs.basis import Basis as _Basis, BuiltinBasis as _BuiltinBasis
|
12
13
|
from pygsti.modelmembers import term as _term
|
13
14
|
from pygsti.baseobjs.polynomial import Polynomial as _Polynomial
|
14
15
|
from pygsti.baseobjs.nicelyserializable import NicelySerializable as _NicelySerializable
|
15
16
|
|
17
|
+
from functools import lru_cache
|
18
|
+
|
16
19
|
IMAG_TOL = 1e-7 # tolerance for imaginary part being considered zero
|
17
20
|
|
18
21
|
|
19
22
|
class LindbladCoefficientBlock(_NicelySerializable):
|
20
|
-
"""
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
L(rho) = sum_i( h_i [A_i,rho] ) +
|
26
|
-
sum_ij( o_ij * (B_i rho B_j^dag -
|
27
|
-
0.5( rho B_j^dag B_i + B_j^dag B_i rho) ) )
|
28
|
-
|
29
|
-
where {A_i} and {B_i} are bases (possibly the same) for Hilbert Schmidt
|
30
|
-
(density matrix) space with the identity element removed so that each
|
31
|
-
A_i and B_i are traceless. If we write L(rho) in terms of superoperators
|
32
|
-
H_i and O_ij,
|
33
|
-
|
34
|
-
L(rho) = sum_i( h_i H_i(rho) ) + sum_ij( o_ij O_ij(rho) )
|
35
|
-
|
36
|
-
then this function computes the matrices for H_i and O_ij using the given
|
37
|
-
density matrix basis. Thus, if `dmbasis` is expressed in the standard
|
38
|
-
basis (as it should be), the returned matrices are also in this basis.
|
39
|
-
|
40
|
-
If these elements are used as projectors it may be usedful to normalize
|
41
|
-
them (by setting `normalize=True`). Note, however, that these projectors
|
42
|
-
are not all orthogonal - in particular the O_ij's are not orthogonal to
|
43
|
-
one another.
|
44
|
-
|
45
|
-
Parameters
|
46
|
-
----------
|
47
|
-
dmbasis_ham : list
|
48
|
-
A list of basis matrices {B_i} *including* the identity as the first
|
49
|
-
element, for the returned Hamiltonian-type error generators. This
|
50
|
-
argument is easily obtained by call to :func:`pp_matrices` or a
|
51
|
-
similar function. The matrices are expected to be in the standard
|
52
|
-
basis, and should be traceless except for the identity. Matrices
|
53
|
-
should be NumPy arrays or SciPy CSR sparse matrices.
|
54
|
-
|
55
|
-
dmbasis_other : list
|
56
|
-
A list of basis matrices {B_i} *including* the identity as the first
|
57
|
-
element, for the returned Stochastic-type error generators. This
|
58
|
-
argument is easily obtained by call to :func:`pp_matrices` or a
|
59
|
-
similar function. The matrices are expected to be in the standard
|
60
|
-
basis, and should be traceless except for the identity. Matrices
|
61
|
-
should be NumPy arrays or SciPy CSR sparse matrices.
|
62
|
-
|
63
|
-
normalize : bool
|
64
|
-
Whether or not generators should be normalized so that
|
65
|
-
numpy.linalg.norm(generator.flat) == 1.0 Note that the generators
|
66
|
-
will still, in general, be non-orthogonal.
|
67
|
-
|
68
|
-
other_mode : {"diagonal", "diag_affine", "all"}
|
69
|
-
Which non-Hamiltonian Lindblad error generators to construct.
|
70
|
-
Allowed values are: `"diagonal"` (only the diagonal Stochastic
|
71
|
-
generators are returned; that is, the generators corresponding to the
|
72
|
-
`i==j` terms in the Lindblad expression.), `"diag_affine"` (diagonal +
|
73
|
-
affine generators), and `"all"` (all generators).
|
23
|
+
"""
|
24
|
+
Class for storing and managing the parameters associated with particular subblocks of error-generator
|
25
|
+
parameters. Responsible for management of different internal representations utilized when employing
|
26
|
+
various error generator constraints.
|
74
27
|
"""
|
75
28
|
|
76
29
|
_superops_cache = {} # a custom cache for create_lindblad_term_superoperators method calls
|
77
30
|
|
78
31
|
def __init__(self, block_type, basis, basis_element_labels=None, initial_block_data=None, param_mode='static',
|
79
32
|
truncate=False):
|
33
|
+
"""
|
34
|
+
Parameters
|
35
|
+
----------
|
36
|
+
block_type : str
|
37
|
+
String specifying the type of error generator parameters contained within this block. Allowed
|
38
|
+
values are 'ham' (for Hamiltonian error generators), 'other_diagonal' (for Pauli stochastic error generators),
|
39
|
+
and 'other' (for Pauli stochastic, Pauli correlation and active error generators).
|
40
|
+
|
41
|
+
basis : `Basis`
|
42
|
+
`Basis` object to be used by this coefficient block. Not this must be an actual `Basis` object, and not
|
43
|
+
a string (as the coefficient block doesn't have the requisite dimensionality information needed for casting).
|
44
|
+
|
45
|
+
basis_element_labels : list or tuple of str
|
46
|
+
Iterable of strings corresponding to the basis element subscripts used by the error generators managed by
|
47
|
+
this coefficient block.
|
48
|
+
|
49
|
+
initial_block_data : _np.ndarray, optional (default None)
|
50
|
+
Numpy array with initial parameter values to use in setting initial state of this coefficient block.
|
51
|
+
|
52
|
+
param_mode : str, optional (default 'static')
|
53
|
+
String specifying the type of internal parameterization used by this coefficient block. Allowed options are:
|
54
|
+
|
55
|
+
- For all block types: 'static'
|
56
|
+
- For 'ham': 'elements'
|
57
|
+
- For 'other_diagonal': 'elements', 'cholesky', 'depol', 'reldepol'
|
58
|
+
- For 'other': 'elements', 'cholesky'
|
59
|
+
|
60
|
+
Note that the most commonly encounted settings in practice are 'elements' and 'cholesky',
|
61
|
+
which when used in the right combination are utilized in the construction of GLND and CPTPLND
|
62
|
+
parameterized models. For both GLND and CPTPLND the 'ham' block used the 'elements' `param_mode`.
|
63
|
+
GLND the 'other' block uses 'elements', and for CPTPLND it uses 'cholesky'.
|
64
|
+
|
65
|
+
'depol' and 'reldepol' are special modes used only for Pauli stochastic only coefficient blocks
|
66
|
+
(i.e. 'other_diagonal'), and correspond to special reduced parameterizations applicable to depolarizing
|
67
|
+
channels. (TODO: Add better explanation of the difference between depol and reldepol).
|
68
|
+
|
69
|
+
truncate : bool, optional (default False)
|
70
|
+
Flag specifying whether to truncate the parameters given by `initial_block_data` in order to meet
|
71
|
+
constraints (e.g. to preserve CPTP) when necessary. If False, then an error is thrown when the
|
72
|
+
given intial data cannot be parameterized as specified.
|
73
|
+
"""
|
74
|
+
|
80
75
|
super().__init__()
|
81
76
|
self._block_type = block_type # 'ham' or 'other' or 'other_diagonal'
|
82
|
-
self._param_mode = param_mode # 'static', 'elements', 'cholesky',
|
77
|
+
self._param_mode = param_mode # 'static', 'elements', 'cholesky', 'depol', 'reldepol'
|
83
78
|
self._basis = basis # must be a full Basis object, not just a string, as we otherwise don't know dimension
|
84
79
|
self._bel_labels = tuple(basis_element_labels) if (basis_element_labels is not None) \
|
85
80
|
else tuple(basis.labels[1:]) # Note: don't include identity
|
@@ -195,7 +190,7 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
195
190
|
if sparse:
|
196
191
|
#Note: complex OK here sometimes, as only linear combos of "other" gens
|
197
192
|
# (like (i,j) + (j,i) terms) need to be real.
|
198
|
-
superops = [
|
193
|
+
superops = [leftTrans @ (mx @ rightTrans) for mx in superops]
|
199
194
|
for mx in superops: mx.sort_indices()
|
200
195
|
else:
|
201
196
|
#superops = _np.einsum("ik,akl,lj->aij", leftTrans, superops, rightTrans)
|
@@ -816,12 +811,19 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
816
811
|
# encodes a lower-triangular matrix "cache_mx" via:
|
817
812
|
# cache_mx[i,i] = params[i,i]
|
818
813
|
# cache_mx[i,j] = params[i,j] + 1j*params[j,i] (i > j)
|
814
|
+
|
819
815
|
cache_mx = self._cache_mx
|
820
|
-
iparams = 1j * params
|
821
|
-
for i in range(num_bels):
|
822
|
-
cache_mx[i, i] = params[i, i]
|
823
|
-
cache_mx[i, :i] = params[i, :i] + iparams[:i, i]
|
824
816
|
|
817
|
+
params_upper_indices = _fc.fast_triu_indices(num_bels)
|
818
|
+
params_upper = 1j*params[params_upper_indices]
|
819
|
+
params_lower = (params.T)[params_upper_indices]
|
820
|
+
|
821
|
+
cache_mx_trans = cache_mx.T
|
822
|
+
cache_mx_trans[params_upper_indices] = params_lower + params_upper
|
823
|
+
|
824
|
+
diag_indices = cached_diag_indices(num_bels)
|
825
|
+
cache_mx[diag_indices] = params[diag_indices]
|
826
|
+
|
825
827
|
#The matrix of (complex) "other"-coefficients is build by assuming
|
826
828
|
# cache_mx is its Cholesky decomp; means otherCoeffs is pos-def.
|
827
829
|
|
@@ -830,27 +832,28 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
830
832
|
# matrix, but we don't care about this uniqueness criteria and so
|
831
833
|
# the diagonal els of cache_mx can be negative and that's fine -
|
832
834
|
# block_data will still be posdef.
|
833
|
-
self.block_data[:, :] =
|
835
|
+
self.block_data[:, :] = cache_mx@cache_mx.T.conj()
|
834
836
|
|
835
|
-
#DEBUG - test for pos-def
|
836
|
-
#evals = _np.linalg.eigvalsh(block_data)
|
837
|
-
#DEBUG_TOL = 1e-16; #print("EVALS DEBUG = ",evals)
|
838
|
-
#assert(all([ev >= -DEBUG_TOL for ev in evals]))
|
839
837
|
|
840
838
|
elif self._param_mode == "elements": # params mx stores block_data (hermitian) directly
|
841
839
|
#params holds block_data real and imaginary parts directly
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
840
|
+
params_upper_indices = _fc.fast_triu_indices(num_bels)
|
841
|
+
params_upper = -1j*params[params_upper_indices]
|
842
|
+
params_lower = (params.T)[params_upper_indices]
|
843
|
+
|
844
|
+
block_data_trans = self.block_data.T
|
845
|
+
self.block_data[params_upper_indices] = params_lower + params_upper
|
846
|
+
block_data_trans[params_upper_indices] = params_lower - params_upper
|
847
|
+
|
848
|
+
diag_indices = cached_diag_indices(num_bels)
|
849
|
+
self.block_data[diag_indices] = params[diag_indices]
|
850
|
+
|
847
851
|
else:
|
848
852
|
raise ValueError("Internal error: invalid parameter mode (%s) for block type %s!"
|
849
853
|
% (self._param_mode, self._block_type))
|
850
854
|
else:
|
851
855
|
raise ValueError("Internal error: invalid block type!")
|
852
856
|
|
853
|
-
#def paramvals_to_coefficients_deriv(self, parameter_values, cache_mx=None):
|
854
857
|
def deriv_wrt_params(self, v=None):
|
855
858
|
"""
|
856
859
|
Construct derivative of Lindblad coefficients (for this block) from a set of parameter values.
|
@@ -1112,11 +1115,11 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
1112
1115
|
if self._param_mode == "depol":
|
1113
1116
|
#d2Odp2 = _np.einsum('alj->lj', self.otherGens)[:,:,None,None] * 2
|
1114
1117
|
d2Odp2 = _np.sum(superops, axis=0)[:, :, None, None] * 2
|
1115
|
-
elif self.
|
1118
|
+
elif self._param_mode == "cholesky":
|
1116
1119
|
assert(nP == num_bels)
|
1117
1120
|
#d2Odp2 = _np.einsum('alj,aq->ljaq', self.otherGens, 2*_np.identity(nP,'d'))
|
1118
1121
|
d2Odp2 = _np.transpose(superops, (1, 2, 0))[:, :, :, None] * 2 * _np.identity(nP, 'd')
|
1119
|
-
else: # param_mode == "
|
1122
|
+
else: # param_mode == "elements" or "reldepol"
|
1120
1123
|
assert(nP == num_bels)
|
1121
1124
|
d2Odp2 = _np.zeros((superops.shape[1], superops.shape[2], nP, nP), 'd')
|
1122
1125
|
|
@@ -1124,7 +1127,10 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
1124
1127
|
if self._param_mode == "cholesky":
|
1125
1128
|
if superops_are_flat: # then un-flatten
|
1126
1129
|
superops = superops.reshape((num_bels, num_bels, superops.shape[1], superops.shape[2]))
|
1127
|
-
|
1130
|
+
sqrt_nP = _np.sqrt(nP)
|
1131
|
+
snP = int(sqrt_nP)
|
1132
|
+
assert snP == sqrt_nP == num_bels
|
1133
|
+
d2Odp2 = _np.zeros([superops.shape[2], superops.shape[3], snP, snP, snP, snP], 'complex')
|
1128
1134
|
# yikes! maybe make this SPARSE in future?
|
1129
1135
|
|
1130
1136
|
#Note: correspondence w/Erik's notes: a=alpha, b=beta, q=gamma, r=delta
|
@@ -1136,11 +1142,11 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
1136
1142
|
parameter indices s.t. ab > base and qr > base. If
|
1137
1143
|
ab_inc_eq == True then the > becomes a >=, and likewise
|
1138
1144
|
for qr_inc_eq. Used for looping over nonzero hessian els. """
|
1139
|
-
for _base in range(
|
1145
|
+
for _base in range(snP):
|
1140
1146
|
start_ab = _base if ab_inc_eq else _base + 1
|
1141
1147
|
start_qr = _base if qr_inc_eq else _base + 1
|
1142
|
-
for _ab in range(start_ab,
|
1143
|
-
for _qr in range(start_qr,
|
1148
|
+
for _ab in range(start_ab, snP):
|
1149
|
+
for _qr in range(start_qr, snP):
|
1144
1150
|
yield (_base, _ab, _qr)
|
1145
1151
|
|
1146
1152
|
for base, a, q in iter_base_ab_qr(True, True): # Case1: base=b=r, ab=a, qr=q
|
@@ -1153,7 +1159,12 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
1153
1159
|
d2Odp2[:, :, base, b, base, r] = superops[b, r] + superops[r, b]
|
1154
1160
|
|
1155
1161
|
elif self._param_mode == 'elements': # unconstrained
|
1156
|
-
|
1162
|
+
if superops_are_flat: # then un-flatten
|
1163
|
+
superops = superops.reshape((num_bels, num_bels, superops.shape[1], superops.shape[2]))
|
1164
|
+
sqrt_nP = _np.sqrt(nP)
|
1165
|
+
snP = int(sqrt_nP)
|
1166
|
+
assert snP == sqrt_nP == num_bels
|
1167
|
+
d2Odp2 = _np.zeros([superops.shape[2], superops.shape[3], snP, snP, snP, snP], 'd') # all params linear
|
1157
1168
|
else:
|
1158
1169
|
raise ValueError("Internal error: invalid parameter mode (%s) for block type %s!"
|
1159
1170
|
% (self._param_mode, self._block_type))
|
@@ -1204,3 +1215,7 @@ class LindbladCoefficientBlock(_NicelySerializable):
|
|
1204
1215
|
if len(self._bel_labels) < 10:
|
1205
1216
|
s += " Coefficients are:\n" + str(_np.round(self.block_data, 4))
|
1206
1217
|
return s
|
1218
|
+
|
1219
|
+
@lru_cache(maxsize=16)
|
1220
|
+
def cached_diag_indices(n):
|
1221
|
+
return _np.diag_indices(n)
|