File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed 
quimb/experimental/operatorbuilder Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -1227,6 +1227,44 @@ def build_local_terms(self, dtype=None):
12271227
12281228        return  Hk 
12291229
1230+     def  build_local_ham (self , dtype = None ):
1231+         """Get a `LocalHamGen` object for this operator. 
1232+ 
1233+         Parameters 
1234+         ---------- 
1235+         dtype : numpy.dtype, optional 
1236+             The data type of the matrix. If not provided, will be 
1237+             automatically determined based on the terms in the operator. 
1238+ 
1239+         Returns 
1240+         ------- 
1241+         H : LocalHamGen 
1242+             The local Hamiltonian representation of this operator. 
1243+         """ 
1244+         from  quimb .tensor .tensor_arbgeom_tebd  import  LocalHamGen 
1245+ 
1246+         terms  =  self .build_local_terms (dtype = dtype )
1247+ 
1248+         H2  =  {}
1249+         H1  =  {}
1250+         for  sites , hk  in  terms .items ():
1251+             if  len (sites ) ==  2 :
1252+                 H2 [sites ] =  hk 
1253+             elif  len (sites ) ==  1 :
1254+                 H1 [sites [0 ]] =  hk 
1255+             else :
1256+                 raise  NotImplementedError (
1257+                     "Only supports 1- and 2-site terms for now." 
1258+                 )
1259+ 
1260+         if  not  H1 :
1261+             H1  =  None 
1262+         if  not  H2 :
1263+             H2  =  None 
1264+ 
1265+         return  LocalHamGen (H2 , H1 )
1266+ 
1267+ 
12301268    def  build_state_machine_greedy (self , atol = 1e-12 ):
12311269        # XXX: also implement optimal method : https://arxiv.org/abs/2006.02056 
12321270
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments