def __init__(self, dim, basis=None):
     if basis is None:
         self.dim = dim
         self.basis = sparse.stack(gm.get_basis(dim, sparse=True))
     else:
         self.dim = basis[0].shape[0]
         self.basis = COO.from_numpy(np.array(basis))
     # Diagonal metric (since we're working with what are assumed to be
     # orthogonal but not necessarily normalized basis vectors)
     self.sq_norms = COO.from_numpy(
             sparse.tensordot(
                 self.basis, self.basis,
                 ([1, 2], [2, 1])).to_scipy_sparse().diagonal())
     # Diagonal inverse metric
     sq_norms_inv = COO.from_numpy(1 / self.sq_norms.todense())
     # Dual basis obtained from the original basis by the inverse metric
     self.dual = self.basis * sq_norms_inv[:,None,None]
     # Structure coefficients for the Lie algebra showing how to represent a
     # product of two basis elements as a complex-linear combination of basis
     # elements
     self.struct = sparse.tensordot(sparse.tensordot(self.basis, self.basis,
                                                     ([2], [1])),
                                    self.dual, ([1, 3], [2, 1]))
     if isinstance(self.struct, np.ndarray):
         # Sometimes sparse.tensordot returns numpy arrays. We want to force
         # it to be sparse, since sparse.tensordot fails when passed two
         # numpy arrays.
         self.struct = COO.from_numpy(self.struct)
Exemple #2
0
 def __init__(self, d_sys, n_max):
     self.d_sys = d_sys
     self.n_max = n_max
     self.d_total = (self.n_max + 1) * self.d_sys
     self.basis = gm.get_basis(self.d_total)
     # Only want the parts of common_dict pertaining to the basis setup
     # (which is time-consuming). Suggests I should split the basis part out
     # into a separate function (perhaps a basis object).
     zero_op = np.zeros((self.d_total, self.d_total), dtype=np.complex)
     self.basis_common_dict = sb.op_calc_setup(zero_op, 0, 0, zero_op,
                                               self.basis[:-1])
Exemple #3
0
 def __init__(self, d_sys, n_max):
     self.d_sys = d_sys
     self.n_max = n_max
     self.d_total = (self.n_max + 1) * self.d_sys
     self.basis = gm.get_basis(self.d_total)
     # Only want the parts of common_dict pertaining to the basis setup
     # (which is time-consuming). Suggests I should split the basis part out
     # into a separate function (perhaps a basis object).
     zero_op = np.zeros((self.d_total, self.d_total), dtype=np.complex)
     self.basis_common_dict = sb.op_calc_setup(zero_op, 0, 0, zero_op,
                                               self.basis[:-1])
Exemple #4
0
    def __init__(self, c_op, M_sq, N, H, basis=None, drift_rep=None, **kwargs):
        if basis is None:
            d = c_op.shape[0]
            self.basis = gm.get_basis(d)
        else:
            self.basis = basis

        if drift_rep is None:
            self.Q = sb.construct_Q(c_op, M_sq, N, H, self.basis[:-1])
        else:
            self.Q = drift_rep
Exemple #5
0
    def __init__(self, c_op, M_sq, N, H, basis=None, drift_rep=None, **kwargs):
        if basis is None:
            d = c_op.shape[0]
            self.basis = gm.get_basis(d)
        else:
            self.basis = basis

        if drift_rep is None:
            self.Q = sb.construct_Q(c_op, M_sq, N, H, self.basis[:-1])
        else:
            self.Q = drift_rep
Exemple #6
0
 def __init__(self, dim):
     self.dim = dim
     self.basis = COO.from_numpy(np.array(gm.get_basis(dim)))
     self.sq_norms = COO.from_numpy(np.einsum('jmn,jnm->j',
                                              self.basis.todense(),
                                              self.basis.todense()))
     sq_norms_inv = COO.from_numpy(1 / self.sq_norms.todense())
     self.dual = self.basis * sq_norms_inv[:,None,None]
     self.struct = sparse.tensordot(sparse.tensordot(self.basis, self.basis,
                                                     ([2], [1])),
                                    self.dual, ([1, 3], [2, 1]))
     if type(self.struct) == np.ndarray:
         # Sometimes sparse.tensordot returns numpy arrays. We want to force
         # it to be sparse, since sparse.tensordot fails when passed two
         # numpy arrays.
         self.struct = COO.from_numpy(self.struct)
Exemple #7
0
 def __init__(self, L, H0):
     # The `IntegratorFactory` returns an integrator appropriate for the
     # given modelparams.
     super(HomodyneQubitPrecessionModel, self).__init__()
     basis = gm.get_basis(2)
     precomp_args = {'coupling_op': L,
                     'M_sq': 0,
                     'N': 0,
                     'H0': H0,
                     'partial_basis': basis[:-1]}
     precomp_data = precomp_fn(**precomp_args)
     self.integrator_factory = \
         smeint.IntegratorFactory(smeint.TrDecMilsteinHomodyneIntegrator,
                                  precomp_data, parameter_fn)
     self.traceless_basis = \
             self.integrator_factory.precomp_data['partial_basis']
     self.drifted_particles = {}
Exemple #8
0
 def __init__(self, L, H0):
     # The `IntegratorFactory` returns an integrator appropriate for the
     # given modelparams.
     super(HomodyneQubitPrecessionModel, self).__init__()
     basis = gm.get_basis(2)
     precomp_args = {
         'coupling_op': L,
         'M_sq': 0,
         'N': 0,
         'H0': H0,
         'partial_basis': basis[:-1]
     }
     precomp_data = precomp_fn(**precomp_args)
     self.integrator_factory = \
         smeint.IntegratorFactory(smeint.TrDecMilsteinHomodyneIntegrator,
                                  precomp_data, parameter_fn)
     self.traceless_basis = \
             self.integrator_factory.precomp_data['partial_basis']
     self.drifted_particles = {}