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

Truncating the identity operator loses sparsity #202

Open
putianyi889 opened this issue Aug 13, 2024 · 1 comment
Open

Truncating the identity operator loses sparsity #202

putianyi889 opened this issue Aug 13, 2024 · 1 comment

Comments

@putianyi889
Copy link
Contributor

To avoid type piracy, Jacobi(0,1)\Jacobi(0,1) should return a (0,0)-banded matrix.

julia> Jacobi(0,1)\Jacobi(0,1)
ℵ₀×ℵ₀ Diagonal{Float64, FillArrays.Ones{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}} with indices OneToInf()×OneToInf()

julia> (Jacobi(0,1)\Jacobi(0,1))[1:10,1:10]
10×10 Matrix{Float64}:
 1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0  0.0
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  1.0

julia> (Jacobi(0,1)\Jacobi(0,0))[1:10,1:10]
10×10 BandedMatrix{Float64} with bandwidths (0, 1):
 1.0  0.333333                                                              
     0.666667  0.4                                                         
              0.6  0.428571                                                
                  0.571429  0.444444                                        
                           0.555556  0.454545                              
                                    0.545455  0.461538                     
                                             0.538462  0.466667            
                                                      0.533333  0.470588   
                                                               0.529412  0.473684
                                                                        0.526316
@putianyi889 putianyi889 changed the title Truncating the identity operator Truncating the identity operator loses sparsity Aug 13, 2024
@dlfivefifty
Copy link
Member

Just use layout_getindex for now to avoid this

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

No branches or pull requests

2 participants