def identity_wrap(self, operator, subsystem, op_in_eigenbasis=False, evecs=None): """Wrap given operator in subspace `subsystem` in identity operators to form full Hilbert-space operator. Parameters ---------- operator: ndarray or qutip.Qobj or str operator acting in Hilbert space of `subsystem`; if str, then this should be an operator name in the subsystem, typically not in eigenbasis subsystem: object derived from QuantumSystem subsystem where diagonal operator is defined op_in_eigenbasis: bool whether `operator` is given in the `subsystem` eigenbasis; otherwise, the internal QuantumSystem basis is assumed evecs: ndarray, optional internal QuantumSystem eigenstates, used to convert `operator` into eigenbasis Returns ------- qutip.Qobj operator """ subsys_operator = spec_utils.convert_operator_to_qobj( operator, subsystem, op_in_eigenbasis, evecs) operator_identitywrap_list = [ qt.operators.qeye(the_subsys.truncated_dim) for the_subsys in self ] subsystem_index = self.get_subsys_index(subsystem) operator_identitywrap_list[subsystem_index] = subsys_operator return qt.tensor(operator_identitywrap_list)
def identity_wrap(self, operator: Union[str, ndarray, csc_matrix, dia_matrix, Qobj], subsystem: QuantumSys, op_in_eigenbasis: bool = False, evecs: ndarray = None) -> Qobj: """Wrap given operator in subspace `subsystem` in identity operators to form full Hilbert-space operator. Parameters ---------- operator: operator acting in Hilbert space of `subsystem`; if str, then this should be an operator name in the subsystem, typically not in eigenbasis subsystem: subsystem where diagonal operator is defined op_in_eigenbasis: whether `operator` is given in the `subsystem` eigenbasis; otherwise, the internal QuantumSys basis is assumed evecs: internal QuantumSys eigenstates, used to convert `operator` into eigenbasis """ subsys_operator = spec_utils.convert_operator_to_qobj( operator, subsystem, op_in_eigenbasis, evecs) operator_identitywrap_list = [ qt.operators.qeye(the_subsys.truncated_dim) for the_subsys in self ] subsystem_index = self.get_subsys_index(subsystem) operator_identitywrap_list[subsystem_index] = subsys_operator return qt.tensor(operator_identitywrap_list)