Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eig,Eigh for Block UniTensor #372

Merged
merged 5 commits into from
Mar 7, 2024
Merged

Eig,Eigh for Block UniTensor #372

merged 5 commits into from
Mar 7, 2024

Conversation

j9263178
Copy link
Collaborator

@j9263178 j9263178 commented Nov 16, 2023

#345.

Eig and Eigh now support Block UniTensor, for the behavior I just try a basic 2 site problem S^{+}S^{-} + S^{-}S^{+}:

a = cytnx.Bond(cytnx.BD_IN, [[0],[1]], [1,1]) #Bond for site a
b = cytnx.Bond(cytnx.BD_IN, [[0],[1]], [1,1]) #Bond for site b

H = cytnx.UniTensor([a,b,a.redirect(),b.redirect()],rowrank = 2) # 2 site hamiltonian
H.get_block_(2)[0,0] = 1
H.get_block_(3)[0,0] = 1

res = cytnx.linalg.Eigh(A, True, False)
print(res)

Output:

================================ Eigen vals ================================

-------- start of print ---------
Tensor name: 
braket_form : True
is_diag    : True
[OVERALL] contiguous : True
========================
 *is_diag: True
BLOCK [#0]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [0] U1(0)  -->| 1     1 |-->  [0] U1(0)
                 |         |
                 -----------

Total elem: 1
type  : Double (Float64)
cytnx device: CPU
Shape : (1)
[0.00000e+00 ]

========================
 *is_diag: True
BLOCK [#1]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [1] U1(1)  -->| 2     2 |-->  [1] U1(1)
                 |         |
                 -----------

Total elem: 2
type  : Double (Float64)
cytnx device: CPU
Shape : (2)
[-1.00000e+00 1.00000e+00 ]

========================
 *is_diag: True
BLOCK [#2]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [2] U1(2)  -->| 1     1 |-->  [2] U1(2)
                 |         |
                 -----------

Total elem: 1
type  : Double (Float64)
cytnx device: CPU
Shape : (1)
[0.00000e+00 ]



================================ Eigen vectors ================================

-------- start of print ---------
Tensor name: 
braket_form : True
is_diag    : False
[OVERALL] contiguous : True
========================
BLOCK [#0]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [0] U1(0)  -->| 1     1 |-->  [0] U1(0)
                 |         |
   [0] U1(0)  -->| 1       |
                 |         |
                 -----------

Total elem: 1
type  : Double (Float64)
cytnx device: CPU
Shape : (1,1,1)
[[[1.00000e+00 ]]]

========================
BLOCK [#1]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [0] U1(0)  -->| 1     2 |-->  [1] U1(1)
                 |         |
   [1] U1(1)  -->| 1       |
                 |         |
                 -----------

Total elem: 2
type  : Double (Float64)
cytnx device: CPU
Shape : (1,1,2)
[[[-7.07107e-01 7.07107e-01 ]]]

========================
BLOCK [#2]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [1] U1(1)  -->| 1     2 |-->  [1] U1(1)
                 |         |
   [0] U1(0)  -->| 1       |
                 |         |
                 -----------

Total elem: 2
type  : Double (Float64)
cytnx device: CPU
Shape : (1,1,2)
[[[7.07107e-01 7.07107e-01 ]]]

========================
BLOCK [#3]
 |- []   : Qn index 
 |- Sym(): Qnum of correspond symmetry
                 -----------
                 |         |
   [1] U1(1)  -->| 1     1 |-->  [2] U1(2)
                 |         |
   [1] U1(1)  -->| 1       |
                 |         |
                 -----------

Total elem: 1
type  : Double (Float64)
cytnx device: CPU
Shape : (1,1,1)
[[[1.00000e+00 ]]]

@pcchen
Copy link
Collaborator

pcchen commented Feb 26, 2024

Can someone fix the failed tests and then approve/merger this pull request. I have tested the basic function and it works ok.

@j9263178 j9263178 marked this pull request as ready for review March 7, 2024 11:09
Copy link

codecov bot commented Mar 7, 2024

Codecov Report

Attention: Patch coverage is 0.48544% with 205 lines in your changes are missing coverage. Please review.

Project coverage is 17.73%. Comparing base (c93b318) to head (194e558).

Files Patch % Lines
src/linalg/Eigh.cpp 0.96% 103 Missing ⚠️
src/linalg/Eig.cpp 0.00% 102 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff               @@
##           dev-master     #372      +/-   ##
==============================================
- Coverage       17.81%   17.73%   -0.08%     
==============================================
  Files             220      220              
  Lines           48761    48965     +204     
  Branches        19955    20113     +158     
==============================================
  Hits             8686     8686              
- Misses          35871    36075     +204     
  Partials         4204     4204              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jeffry1829 jeffry1829 merged commit dd7aa93 into dev-master Mar 7, 2024
4 checks passed
@jeffry1829 jeffry1829 deleted the bkut_eig branch March 7, 2024 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants