def __random__(self, index, which=0): if which > 1: sys.exit( 'SparseTensor.__eye__(self,index={0},which={1}): which has be to be 0 or 1.' .format(index, which)) Ds = [copy.deepcopy(self._Ds[index]), copy.deepcopy(self._Ds[index])] if which == 0: qflow = tuple( [utils.flipsigns(self._qflow[index]), self._qflow[index]]) elif which == 1: qflow = tuple( [self._qflow[index], utils.flipsigns(self._qflow[index])]) mergelevel = tuple([self._mergelevel[index], self._mergelevel[index]]) keytoq = tuple([self._ktoq[index], self._ktoq[index]]) iden = SparseTensor(keys=[], values=[], Ds=Ds, qflow=qflow, keytoq=keytoq, mergelevel=mergelevel, dtype=self._dtype) for k in self._Ds[index].keys(): key = tuple([k, k]) temp = self._Ds[index][k] shape = tuple([temp, temp]) size = utils.prod(utils.flatten(temp)) iden.__insertmergedblock__( key, shape, np.random.rand(size, size).astype(self._dtype)) return iden
def __conj__(self, *args, **kwargs): res = self.__unary_operations__(np.conj, *args, **kwargs) res._qflow = utils.flipsigns(res._qflow) return res
def __flippedflow__(self): return utils.flipsigns(self._qflow)
def __flipflow__(self): self._qflow = utils.flipsigns(self._qflow) return self