Quanlse/QHamiltonian.py
def buildOperatorCache(self) -> None:
        r"""
        Save the drift/coupling/control terms in a more efficient way for further usage.
        Note that this function will recursively process all the terms added to drift/coupling/control terms and
        save them to cache.

        :return: None
        """
        sysLevel = self.sysLevel
        subSysNum = self.subSysNum

        # Generator the operator for all of the drift terms
        driftMatList = []
        for key in self._driftOperators.keys():
            if isinstance(self._driftOperators[key], list):
                mat = self._driftOperators[key][0].coef * self._generateOperator(self._driftOperators[key])
                driftMatList.append(mat)
            else:
                mat = self._driftOperators[key].coef * self._generateOperator(self._driftOperators[key])
                driftMatList.append(mat)
        # Sum all the drift terms and save to the cache.
        if isinstance(sysLevel, int):
            driftTotal = zeros((sysLevel ** subSysNum, sysLevel ** subSysNum), dtype=complex)
        else:
            dim = 1
            for i in sysLevel:
                dim = dim * i
            driftTotal = zeros((dim, dim), dtype=complex)
        for mat in driftMatList:
            driftTotal = driftTotal + mat
        self._driftCache = driftTotal

        # Generator the pulse sequences for all of the control terms.
        for key in self._waveJob.ctrlOperators.keys():
            ctrlsOp = self._waveJob.ctrlOperators[key]
            self._ctrlCache[key] = self._generateOperator(ctrlsOp)
        for key in self.doNotClearFlagOperators:
            if key not in self._ctrlCache:
                ctrlsOp = self.doNotClearFlagOperators[key]
                self._ctrlCache[key] = self._generateOperator(ctrlsOp)
r"""
        Save the drift/coupling/control terms in a more efficient way for further usage.
        Note that this function will recursively process all the terms added to drift/coupling/control terms and
        save them to cache.

        :return: None
        
r"""
Save the drift/coupling/control terms in a more efficient way for further usage.
Note that this function will recursively process all the terms added to drift/coupling/control terms and
save them to cache.
r " " " Save the drift / coupling / control terms in a more efficient way for further usage . Note that this function will recursively process all the terms added to drift / coupling / control terms and save them to cache .
def buildOperatorCache(self) -> None:
        sysLevel = self.sysLevel
        subSysNum = self.subSysNum
        driftMatList = []
        for key in self._driftOperators.keys():
            if isinstance(self._driftOperators[key], list):
                mat = self._driftOperators[key][0].coef * self._generateOperator(self._driftOperators[key])
                driftMatList.append(mat)
            else:
                mat = self._driftOperators[key].coef * self._generateOperator(self._driftOperators[key])
                driftMatList.append(mat)
        if isinstance(sysLevel, int):
            driftTotal = zeros((sysLevel ** subSysNum, sysLevel ** subSysNum), dtype=complex)
        else:
            dim = 1
            for i in sysLevel:
                dim = dim * i
            driftTotal = zeros((dim, dim), dtype=complex)
        for mat in driftMatList:
            driftTotal = driftTotal + mat
        self._driftCache = driftTotal
        for key in self._waveJob.ctrlOperators.keys():
            ctrlsOp = self._waveJob.ctrlOperators[key]
            self._ctrlCache[key] = self._generateOperator(ctrlsOp)
        for key in self.doNotClearFlagOperators:
            if key not in self._ctrlCache:
                ctrlsOp = self.doNotClearFlagOperators[key]
                self._ctrlCache[key] = self._generateOperator(ctrlsOp)
def buildOperatorCache ( self ) -> None : sysLevel = self . sysLevel subSysNum = self . subSysNum driftMatList = [ ] for key in self . _driftOperators . keys ( ) : if isinstance ( self . _driftOperators [ key ] , list ) : mat = self . _driftOperators [ key ] [ 0 ] . coef * self . _generateOperator ( self . _driftOperators [ key ] ) driftMatList . append ( mat ) else : mat = self . _driftOperators [ key ] . coef * self . _generateOperator ( self . _driftOperators [ key ] ) driftMatList . append ( mat ) if isinstance ( sysLevel , int ) : driftTotal = zeros ( ( sysLevel ** subSysNum , sysLevel ** subSysNum ) , dtype = complex ) else : dim = 1 for i in sysLevel : dim = dim * i driftTotal = zeros ( ( dim , dim ) , dtype = complex ) for mat in driftMatList : driftTotal = driftTotal + mat self . _driftCache = driftTotal for key in self . _waveJob . ctrlOperators . keys ( ) : ctrlsOp = self . _waveJob . ctrlOperators [ key ] self . _ctrlCache [ key ] = self . _generateOperator ( ctrlsOp ) for key in self . doNotClearFlagOperators : if key not in self . _ctrlCache : ctrlsOp = self . doNotClearFlagOperators [ key ] self . _ctrlCache [ key ] = self . _generateOperator ( ctrlsOp )
r"""
Save the drift/coupling/control terms in a more efficient way for further usage.
r " " " Save the drift / coupling / control terms in a more efficient way for further usage .
r"""
        Save the drift/coupling/control terms in a more efficient way for further usage.
        Note that this function will recursively process all the terms added to drift/coupling/control terms and
        save them to cache.

        :return: None
        """ # Generator the operator for all of the drift terms # Sum all the drift terms and save to the cache. # Generator the pulse sequences for all of the control terms.
None
self