JuliaApproximation / SemiclassicalOrthogonalPolynomials.jl

A Julia repository for semiclassical orthogonal polynomials
MIT License
7 stars 3 forks source link

BigFloat input for t #33

Closed TSGut closed 4 months ago

TSGut commented 3 years ago

BigFloat type input for t with integer a, b, c results in a method error at the moment.

julia> t = BigFloat("1.1")
1.100000000000000000000000000000000000000000000000000000000000000000000000000003

julia> a = 1; b = 2; c = 3;

julia> P = SemiclassicalJacobi(t,a,b,c)
ERROR: LoadError: MethodError: no method matching AbstractQuasiArray{Float64,N} where N(::ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}})
Stacktrace:
 [1] convert(::Type{AbstractQuasiArray{Float64,N} where N}, ::ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}) at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/abstractquasiarray.jl:17
 [2] to_quasi_index(::Type{Float64}, ::ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}) at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/indices.jl:107
 [3] to_quasi_index(::Jacobi{Float64}, ::Type{T} where T, ::ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}) at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/indices.jl:111
 [4] to_indices at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/indices.jl:115 [inlined]
 [5] to_indices at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/multidimensional.jl:412 [inlined]
 [6] _getindex at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/abstractquasiarray.jl:377 [inlined]
 [7] getindex(::Jacobi{Float64}, ::ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}, ::Function) at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/abstractquasiarray.jl:372
 [8] jacobi(::Int64, ::Int64, ::DomainSets.UnitInterval{BigFloat}) at /home/timon/.julia/packages/ClassicalOrthogonalPolynomials/YpJSc/src/jacobi.jl:124
 [9] semiclassical_jacobimatrix(::BigFloat, ::Int64, ::Int64, ::Int64) at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/SemiclassicalOrthogonalPolynomials.jl:183
 [10] SemiclassicalJacobi(::BigFloat, ::Int64, ::Int64, ::Int64) at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/SemiclassicalOrthogonalPolynomials.jl:166
 [11] top-level scope at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/genericJacobilowering.jl:60
in expression starting at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/genericJacobilowering.jl:60

Input of type BigFloat for all four parameters (or BigInt) leads to an issue similar to what is discussed in https://github.com/JuliaApproximation/ClassicalOrthogonalPolynomials.jl/issues/28 and https://github.com/JuliaLang/julia/issues/40108:

julia> t = BigFloat("1.1");

julia> a = BigFloat("1"); b = BigFloat("2"); c = BigFloat("3");

julia> P = SemiclassicalJacobi(t,a,b,c)
ERROR: cannot resize array with shared data
Stacktrace:
 [1] _deleteend! at ./array.jl:901 [inlined]
 [2] resize! at ./array.jl:1090 [inlined]
 [3] chop!(::Array{BigFloat,1}, ::BigFloat) at /home/timon/.julia/packages/ClassicalOrthogonalPolynomials/YpJSc/src/ClassicalOrthogonalPolynomials.jl:71
 [4] adaptivetransform_ldiv(::BroadcastQuasiArray{BigFloat,2,typeof(*),Tuple{SubQuasiArray{BigFloat,1,JacobiWeight{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}},false},Normalized{BigFloat,SubQuasiArray{BigFloat,2,Jacobi{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}},Base.Slice{InfiniteArrays.OneToInf{Int64}}},false},Accumulate{BigFloat,1,typeof(*),Array{BigFloat,1},AbstractArray{BigFloat,1}}}}}, ::BroadcastQuasiArray{BigFloat,1,typeof(*),Tuple{BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}}}}) at /home/timon/.julia/packages/ClassicalOrthogonalPolynomials/YpJSc/src/ClassicalOrthogonalPolynomials.jl:104
 [5] transform_ldiv at /home/timon/.julia/packages/ClassicalOrthogonalPolynomials/YpJSc/src/ClassicalOrthogonalPolynomials.jl:64 [inlined]
 [6] transform_ldiv at /home/timon/.julia/packages/ContinuumArrays/D2vwQ/src/bases/bases.jl:178 [inlined]
 [7] copy(::Ldiv{ContinuumArrays.WeightedBasisLayout,ArrayLayouts.UnknownLayout,BroadcastQuasiArray{BigFloat,2,typeof(*),Tuple{SubQuasiArray{BigFloat,1,JacobiWeight{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}},false},Normalized{BigFloat,SubQuasiArray{BigFloat,2,Jacobi{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}},Base.Slice{InfiniteArrays.OneToInf{Int64}}},false},Accumulate{BigFloat,1,typeof(*),Array{BigFloat,1},AbstractArray{BigFloat,1}}}}},BroadcastQuasiArray{BigFloat,1,typeof(*),Tuple{BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}}}}}) at /home/timon/.julia/packages/ContinuumArrays/D2vwQ/src/bases/bases.jl:180
 [8] _broadcast_mul_ldiv(::Tuple{LazyArrays.BroadcastLayout{typeof(^)},LazyArrays.BroadcastLayout{typeof(^)},LazyArrays.BroadcastLayout{typeof(^)}}, ::BroadcastQuasiArray{BigFloat,2,typeof(*),Tuple{SubQuasiArray{BigFloat,1,JacobiWeight{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}},false},Normalized{BigFloat,SubQuasiArray{BigFloat,2,Jacobi{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}},Base.Slice{InfiniteArrays.OneToInf{Int64}}},false},Accumulate{BigFloat,1,typeof(*),Array{BigFloat,1},AbstractArray{BigFloat,1}}}}}, ::BroadcastQuasiArray{BigFloat,1,typeof(*),Tuple{BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}}}}) at /home/timon/.julia/packages/ContinuumArrays/D2vwQ/src/bases/bases.jl:111
 [9] copy at /home/timon/.julia/packages/ContinuumArrays/D2vwQ/src/bases/bases.jl:114 [inlined]
 [10] materialize(::Ldiv{ContinuumArrays.WeightedBasisLayout,LazyArrays.BroadcastLayout{typeof(*)},BroadcastQuasiArray{BigFloat,2,typeof(*),Tuple{SubQuasiArray{BigFloat,1,JacobiWeight{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}}},false},Normalized{BigFloat,SubQuasiArray{BigFloat,2,Jacobi{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}},Base.Slice{InfiniteArrays.OneToInf{Int64}}},false},Accumulate{BigFloat,1,typeof(*),Array{BigFloat,1},AbstractArray{BigFloat,1}}}}},BroadcastQuasiArray{BigFloat,1,typeof(*),Tuple{BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}}}}}) at /home/timon/.julia/packages/ArrayLayouts/7LZ91/src/ldiv.jl:22
 [11] ldiv at /home/timon/.julia/packages/ArrayLayouts/7LZ91/src/ldiv.jl:86 [inlined]
 [12] \ at /home/timon/.julia/packages/QuasiArrays/Kytgm/src/matmul.jl:34 [inlined]
 [13] LanczosPolynomial(::BroadcastQuasiArray{BigFloat,1,typeof(*),Tuple{BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}},BroadcastQuasiArray{BigFloat,1,typeof(^),Tuple{ContinuumArrays.AffineQuasiVector{BigFloat,BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},BigFloat},BigFloat}}}}, ::SubQuasiArray{BigFloat,2,Jacobi{BigFloat},Tuple{ContinuumArrays.AffineMap{BigFloat,Inclusion{BigFloat,DomainSets.UnitInterval{BigFloat}},Inclusion{BigFloat,ChebyshevInterval{BigFloat}}},Base.Slice{InfiniteArrays.OneToInf{Int64}}},false}) at /home/timon/.julia/packages/ClassicalOrthogonalPolynomials/YpJSc/src/lanczos.jl:173
 [14] semiclassical_jacobimatrix(::BigFloat, ::BigFloat, ::BigFloat, ::BigFloat) at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/SemiclassicalOrthogonalPolynomials.jl:186
 [15] SemiclassicalJacobi(::BigFloat, ::BigFloat, ::BigFloat, ::BigFloat) at /home/timon/Documents/Projects/SemiclassicalOrthogonalPolynomials.jl/src/SemiclassicalOrthogonalPolynomials.jl:166
 [16] top-level scope at REPL[464]:1
dlfivefifty commented 3 years ago

The first error is in jacobi(0,0, UnitInterval{BigFloat}()), I'll fix that now

TSGut commented 4 months ago

This behavior appears fixed in the latest versions:

julia> t = BigFloat("1.1")
1.100000000000000000000000000000000000000000000000000000000000000000000000000003

julia> a = 1; b = 2; c = 3;

julia> P = SemiclassicalJacobi(t,a,b,c)
SemiclassicalJacobi with weight x^1.0 * (1-x)^2.0 * (1.100000000000000000000000000000000000000000000000000000000000000000000000000003-x)^3.0 on 0..1

julia> t = BigFloat("1.1");

julia> a = BigFloat("1"); b = BigFloat("2"); c = BigFloat("3");

julia> P = SemiclassicalJacobi(t,a,b,c)
SemiclassicalJacobi with weight x^1.0 * (1-x)^2.0 * (1.100000000000000000000000000000000000000000000000000000000000000000000000000003-x)^3.0 on 0..1