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

Adapt to LazyArrays.jl #1

Open
dlfivefifty opened this issue Oct 24, 2019 · 0 comments
Open

Adapt to LazyArrays.jl #1

dlfivefifty opened this issue Oct 24, 2019 · 0 comments

Comments

@dlfivefifty
Copy link
Collaborator

Sorry for the delay, finally getting into this. Given the new LazyArrays+BandedMatrices+InfiniteArrays framework my view on this has changed, in the sense that we should leverage LazyArrays as much as possible to enable ∞-dimensional usage. For example, the following works and is equivalent to an almost banded matrix:

julia> A = BandedMatrix(1 => Ones(∞), -1 => Fill(2,∞)) # Create Banded Matrix×∞ BandedMatrix{Float64,ApplyArray{Float64,2,typeof(*),Tuple{Array{Float64,2},ApplyArray{Float64,2,typeof(vcat),Tuple{Ones{Float64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}},Fill{Int64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}}}}}},OneToInf{Int64}} with indices OneToInf()×OneToInf():
 0.0  1.0                                                    
 2.0  0.0  1.0                                                 
     2.0  0.0  1.0                                             
         2.0  0.0  1.0                                         
             2.0  0.0  1.0                                     
                 2.0  0.0  1.0                                
                     2.0  0.0  1.0                             
                         2.0  0.0  1.0                         
                             2.0  0.0  1.0                     
                                                                      

julia> B = [[1,2,3]; zeros(∞)] * Ones(1,∞) # Create Low Ranke Matrix×∞ ApplyArray{Float64,2,typeof(*),Tuple{CachedArray{Float64,1,Array{Float64,1},Zeros{Float64,1,Tuple{OneToInf{Int64}}}},Ones{Float64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}}}} with indices OneToInf()×OneToInf():
 1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0    
 2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0     
 3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0    
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0    
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0     
                                                                      

julia> BroadcastArray(+,A,ApplyArray(triu,B,2)) # almost banded matrix×∞ BroadcastArray{Float64,2,typeof(+),Tuple{BandedMatrix{Float64,ApplyArray{Float64,2,typeof(*),Tuple{Array{Float64,2},ApplyArray{Float64,2,typeof(vcat),Tuple{Ones{Float64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}},Fill{Int64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}}}}}},OneToInf{Int64}},ApplyArray{Float64,2,typeof(triu),Tuple{ApplyArray{Float64,2,typeof(*),Tuple{CachedArray{Float64,1,Array{Float64,1},Zeros{Float64,1,Tuple{OneToInf{Int64}}}},Ones{Float64,2,Tuple{Base.OneTo{Int64},OneToInf{Int64}}}}},Int64}}}} with indices OneToInf()×OneToInf():
 0.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0  1.0    
 2.0  0.0  1.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0  2.0     
 0.0  2.0  0.0  1.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0  3.0     
 0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.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  0.0  0.0  2.0  0.0     
 0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  0.0  2.0     
                                                                      

The one issue with the above construction is it doesn't link the bandwidth of A to the number of diagonals taken in B....

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

1 participant