JuliaArrays/LazyArrays.jl

REPL dies to repeat ApplyArray multiplications

TSGut opened this issue · 4 comments

TSGut commented

@dlfivefifty Continuing our discussion in Github:

This is related to fixing the issue in JuliaApproximation/SemiclassicalOrthogonalPolynomials.jl#78
I will use ClassicalOPs.jl for my example instead since it keeps it simpler.

Basically, this kills the REPL:

using ClassicalOrthogonalPolynomials, LinearAlgebra, LazyArrays
P = Legendre()
X = UpperTriangular(I+jacobimatrix(P))

Aj = X
for j = 1:4
    Aj = ApplyArray(*,Aj,Aj)
end
Aj

but it looks to me to be specifically relating to the type display since I can evaluate the entries just fine, e.g.

using ClassicalOrthogonalPolynomials, LinearAlgebra, LazyArrays
P = Legendre()
X = UpperTriangular(I+jacobimatrix(P))

Aj = X
for j = 1:4
    Aj = ApplyArray(*,Aj,Aj)
end
Aj[1:50,1:50]

works just fine.

Since the entries work, one way around this would be for me to just create some new struct HiddenTypeArray{T} or whatever and just have it defer all operations to its data. Is there a more elegant solution?

TSGut commented

Changed the example to be a slightly less degenerate case.

Hit control C and see where it hangs

After #261, REPL outputs

((((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * ((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * (((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * ((ℵ₀×ℵ₀ 
UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * ((((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices 
OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * ((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * (((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, 
FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) * ((ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) * (ℵ₀×ℵ₀ UpperTriangular{Float64, LazyBandedMatrices.Tridiagonal{Float64, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}, FillArrays.Fill{Float64, 1, Tuple{InfiniteArrays.OneToInf{Int64}}}, BroadcastVector{Float64, typeof(/), Tuple{InfiniteArrays.InfStepRange{Float64, Float64}, InfiniteArrays.InfStepRange{Int64, Int64}}}}} with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) with indices OneToInf()×OneToInf()) 
with indices OneToInf()×OneToInf():
 1.0  5.33333  16.0  32.0      46.2222   50.4242   42.6667   28.4444     
     1.0       6.4  20.5714   42.6667   63.0303   69.8182   59.7333
              1.0   6.85714  22.8571   48.4848   72.7273   81.4545
                   1.0       7.11111  24.2424   52.2145   79.1919
                            1.0       7.27273  25.1748   54.8252      
                                     1.0       7.38462  25.8462   
                                              1.0       7.46667
                                                       1.0
                                                                     
TSGut commented

Nice! Once all of the related PRs are merged we can close this then.

EDIT: Maybe they already have been? I will close this since my example runs without issues now.